www.elektor-magazine.com •magazine April 2014 You Crack E-Lock— You Win $25K www.elektor.com/e-lock • E-Lock I Platino-based Experimenters PSU | Motion-Detector Camera Trigger LED's Replace That Fluorescent Tube | Microcontroller BootCamp Current Transformer Calculations Precision Adjustable DC Current Source ATmega on the Internet Raspberry Pi Emulator Elektorize Your Scope Probe US$9.00 - Canada $10.00 DuckDuckGo A 2-value C? Atwater Kent Model 30 Radio Unwrapping RepRap The Nearly Lost World of Elektor 25274 24965 Shop languages: i i 7reichelt electronics » Your competent online partner for Components Shop & soldering technology Power supply systems Home & security technology Measuring technology Network technology PC technology Sat/TV technology Communication No hand freeP No problem! The integrated HF sensor activates this light simply by detecting motion! SMD LED spotlight a. LED motion detection light The triggering microwaves pass through glass, plastic and even thin walls. A'Qr'ffi'O 15, 92 1 LED E27 7W HF 'GU 10 • Replaces 35 W halogen bulb • Power consumption: 4 W • Life: 20,000 hours • 290 Im, warm white DELOCK 46337 4,41 (~£ 3 . 66 ) EEC Tf GU 5,3 ^ Long life Low power consumption ^ Low maintenance • Replaces conventional 40W light bulb • Socket: E27 • Angle of detection 360° • Max. radius of detection 8 m • 7 W, 460 lumens, 3000 K, warm white Accutrace Inc. www.PCB4U.com . . . Cleverscope www. cleverscope. com DLP Design Des far. www.dlpdesign.com Eurocircuits www. elektorpcbservice. com eXfrresspcb Express PCB www. expresspcb. com Labcenter www. labcenter. com. IMgxBgtjxl Maxbotix www. maxbotix. com/elektor .3 41 41 53 73 92 69 p I CO npoioiu ('nljrihi-j & ElrelrCttlCI /Jreichelt ■Ivctra-nlci Pico www.picotech. com/ps241 Pololu www.pololu.com Reichelt www.reichelt.com Saelig www.saelig.com Sensors Expo 2014 www.sensorsexpo.com . . I ** CHI CHRftT«i££ jam bIljiA . WIZnet www. circuitcellar. com/wiznet201 4 91 59 .2 69 15 23 Not a supporting company yet? Contact Peter Wostrel (peter@smmarketing.us, Phone 1 978 281 7708, to reserve your own space in Elektor Magazine, Elektor«POST or Elektor.com www.elektor-magazine.com April 2014 7 •Projects E-Lock, the First Elektor Chip Some Say... E-Lock is unbreakable* If we are to believe all the pre- dictions, 2014 will be the year of the Internet of Things ... All Things! As a consequence all manner of electronic products will start chatting to each other, exchanging information over the Internet, the premise being that commu- nicating with your coffee machine is easier than with your col- leagues or neighbors— but how will the coffee machine know it is you and not Barney from next door? S-e-c-u-r-i-t-y, that's what we're on here. And we challenge You Hacker. By Eduardo Corral (Spain); Developed by Intelligent SoC (info@soclutions.com) That coffee machine might be the least of your concerns, but when 'things' are valuable, you need take some serious precautions. Elektor has given this a good deal of thought and together with Intelligent SoC developed a highly dedicated chip to protect your 'things': meet E-Lock, the first Elektor Chip! The E-Lock chip allows you to connect your con- trol system to the 'Network of Networks' and monitor and control it from anywhere on or around the globe using your computer, tablet or smartphone without having to worry about the security of the connection and in full assurance of protection against intruders. Remarkably, the levels of security we are applying to our computers and mobile devices has not been extended to the millions of webbed embedded systems out there, which represents a serious risk to the healthy expansion of the Internet of Things (IoT). Who in his/her right mind connects an embedded device to the Internet if it is wide open to attacks by hackers attempting to take control or modify its behavior? E-Lock is the answer Enough doom & gloom, let's get back to tech- nology. We got in touch with embedded secu- rity specialists Intelligent SoC [1] and decided to jointly develop E-Lock, a chip— did we mention it's * Courtesy Top Gear. 1/1/e say: Hack E-Lock — > Crack the Code — > Win 61A8hex dollars ($25K). Check www.elektor.com/e-lock for details. 8 April 2014 www.elektor-magazine.com E-Lock the first Elektor chip?— specially designed for the IoT based on two fundamental conditions; 1) to allow the management of a device remotely via Internet and 2) do it in a completely secure way. The E-Lock chip is able to establish a secure connection over the Internet (TCP/IP) using the Transport Layer Security (TLS) encryption proto- col. The chip also offers a 7-line GPIO (general purpose input/output), four 16-bit ADC chan- nels, one 12-bit DAC and one I 2 C bus that allow control and communication with other peripheral devices. Figure 1 shows E-Lock's functional dia- gram. The E-Lock chip (a SoC) also incorporates a real time clock (RTC) that takes the data from an Internet time server as reference, using the Simple Network Time Protocol (SNTP). Evaluation board The E-Lock chip comes in a 100-pin LQFP pack- age, which is not easy to handle for manual assembly. That's why we designed the Evalu- ation (and Application) Board introduced here. The Evaluation Board will allow you to test the E-Lock chip while also serving as a basis for your own secure IoT projects. The board is available from the Elektor Store as number 130280-91. Deeply technical descriptions of the board are available for downloading at [2]. As a get-u-going demo the board will allow you to control up to two relays and monitor the tem- perature of the room in which it is installed in a remote and secure way. Also on board is an expansion connector to host future extensions or simply open the door to developing your own applications. Figure 2 shows the functional dia- gram of the evaluation board. We can distinguish the following sections: E-Lock — The heart of the board. The device manages the communications and the operation of devices connected to it. E-Lock consist of two different communication protocols: • Raw Ethernet configuration protocol; it's used to configure the main network and security parameters, such as IP address, Gateway address, DNS server, SNTP server as well as certificate, key and CA. It is done by using E-Lock unique MAC address. • Secure TCP/IP client-server application pro- tocol. Once E-Lock has been successfully configured, it acts as a secure TCP/IP server following the application protocol explained in detail in datasheet document [2]. VDD VDDA DAC ©lock <=> <=> ACTIVITY GPIO I2C ADC ETHERNET EK1 30280 RESET VSSA GND y Figure 1. E-Lock chip functional diagram. Figure 2. E-Lock Evaluation Board functional diagram. E-Lock Evaluation Board Key Features • Secure bidirectional TCP/IP communication using TLS 1.2 • Software Watchdog • Unique MAC address • Raw Ethernet network configuration • Supply Voltage: 5.0 V • Temperature range: -40 °C to 85 °C • RoHS compliant • Ethernet Controller with RMII interface to PHY • Power on Ethernet (POE) circuit (Option) • 50 MHz System clock • 1 I 2 C Temperature sensor • 2 Relays (one on board) • 7 General Purpose Input/Output lines • 4 Analog-to-Digital Converters, 16-bit • 1 Digital-to-Analog Converter, 12-bit • 1 Inter-Integrated Circuit (I 2 C) bus • External temperature sensor (with connection cable) • Expansion connector • Self configurable • Supplied ready-assembled and tested through Elektor Store • Key component to participation in $25K competition at www.elektor.com/e-lock www.elektor-magazine.com April 2014 9 •Projects If you are designing a dead secure Figure 3. Full schematic of the E-Lock Evaluation Board. +3V3 +3V3 A © © JP1 Always connected in operation ^^On ^00n ^100n ^100n ^100n ^100n ^ 00n VBAT VBAT ri-TsMX-CI 50 R12 T ACTJED \ JP4 r\_ 1 RESET LJ" 2 > \ 50MHz JP3 3 FACTBOOT2 1 FACTBOOT ARR1 rCDr +3V3 ©-■ H \ io «>— I H 1 F factboot' 7 FACTBOOT2' 8x 10k RESET_PHY 26_ 34 35 3 i 3 L 38 / 39_ RMILRXD1 42 ^RMILRXDO 43 ^RMILCRSDV 44 ^RMILTXEN 45 ^RMILTXDO 46 ^RMII_TXD1 47 ^CLK_SYSTEM 50 ^GPI02 51 ^A14 70 ^A13 71 ■T > ro 72 ^FACTBOOT2 73 ^A11 76 ^AIO 77 ^A9 78 OO £ 79 ^A7 80 ^A6 81 ^A5 82 II 83 ^D3 84 ^D2 85 ^D1 86 ^DO 87 ^RELE2 CTRL 90 ^RELE1_RESET 91 ' RELEI SET 92 / 13 _ 14_ 15 ADCO 16 ^ADCI 17 ^DACO 27 21 30 8 40 48 61 75 89 +3V3 © C19 1 1 0On l 22 < m > VREFOUT RESERVED RESERVED RESERVED RESERVED RESET_PHY RESERVED RMILRXD1 RMIIJtXDO RMILCRSDV RMILTXEN RMIIJXDO RMILTXD1 CLK_SYSTEM GPI02 A14 A13 A12 Q Q Q Q Q O Q Q Q Q Q Q >>>>>> < Q Q > VREFH U2 RMIIJ/IDIO RMIIJ/IDC I2C SCL SENSOR I2C SDA SENSOR GPI03 RESERVED A18 A17 A16 A15 OE D7 D6 D5 D4 FACT BOOT2 All A10 A9 A8 A7 A6 A5 WE D3 D2 D1 DO RELE2_CTRL RELE1JTESET RELE1J5ET VREGIN RESERVED RESERVED AD CO ADC1 DACO RESERVED tn to tn tn in io m co > > > > RESET SENSOR ALERT CE Olektor EK130280 A4 A3 A2 A1 AO GPI04 I2C SDA I2C SCL GPI05 GPI06 GPI07 GPI08 ACT JED RESERVED RESERVED VOUT33 FACT BOOT GPIOO GPI01 ADC2 RESERVED ADC3 VREFL XTAL32 EXTAL32 tn tn tn tn > > < tn tn > 41 4— 4 49 60 Cl NM 28 XI I I 29 C4 NM 74 88 • 4— — f— — • 4—i n— -L £ 23 R37 C18 p00n 1 A A0 53 RMII MDIO 54 RMIIJ/IDC 55 SCL SENSOR 56 SDA SENSOR 57 GPI03 _58 59 A18 62 A17 63 A16 64 A15 65 OE 66 D7 67 D6 68 D5 69 D4 52 RESET 93 SENSOR ALERT 94 CE 95 A4 96 A3 97 A2 98 A1 99 AO 100 GPI04 1 I2C1_SDA 2 I2C1 SCL 3 GPI05 4 GPI06 5 GPI07 6 GPI08 7 ACT JED _10 11 _12 31 FACTBOOT 32 GPIOO 33 GPI01 18 ADC2 _19 20 ADC3 24 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 25 XI = CM250C-32.000KAZF-UT / A1 11 / A2 10 / A3 9 / A4 8 / A5 7 / A6 6 / A7 5 / A8 27 / A9 26 ^AIO 23 ^A11 25 ^A12 4 ^A13 28 ^A14 3 ^A15 31 ^A16 2 ^A17 1 30 A18 1 OP 1 1 R38 12 " 1 |c: vcc AO A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 All A12 A13 A14 A15 A16 A17 A18 U4 1/00 1/01 1/02 1/03 1/04 1/05 1/06 1/07 13 DO 14 D1 ' 15 D2 V 17 D3 % 18 D4 V 19 D5 % 20 D6 % 21 D7 ' CY62148DV30 WE CE OE VSS \ \ \ 29 RW 22 CE 24 OE \ 16 + 5V COM © +3V3 dirty © +3V3 a © CN2 I2C1_SDA / / A I2C1 SCL 11 GPI05 13 GPI06 15 RESERVED 17 RESERVED 19 AD CO 21 A 23 ADC2 A DACO /" 25 27 29 31 33_ 35 37 39 10 VBAT 12 14 GPIOO ^ GPI01 ^ 16 18 GPI02 ^ RESET^ 20 GPI03 \ 22 24 GPI04 ^ \ 26 28 30 32 38 40 ADC1 A ADC3 "N DL2 M R13 PoE option 39k HSMX-C150 D1 C5 ± r AV 100n 100 V R30 R29 UVLO VIN UVLORTN PGOOD U3 SD RCLASS SD LM5073 DCCL FAUX RAUX PAD J-X RTN VEE 11 | R27 R25 41 13 5 14 g POEJ5UT- POE NEG SMAJ58A C16 1u 100 V R26 -| 10k |- ? +V IN +VOUT U1 3 CTRL 1 -V IN -V OUT EC3SAW-48S05P lOOu 10 April 2014 www.elektor-magazine.com E-Lock IoT device, E-Lock is the solution. www.elektor-magazine.com April 2014 11 Projects Vou c » nek— Vou \N’ in Crack E ' L m / e -\ock $25K ^.elektor-c The basic commands supported by E-Lock to manage on-board devices are: • Set sensor configuration; • Set relay configuration; • Get sensor configuration; • Read sensor value; • Get relay status; • Set relay status. Output circuit — The board has two output circuits that control two relays: RE1, which is a dual coil latching type, and RE2, which is a non-latching type. Both are configured as SPDT (single-pole, double-throw,) switches and contacts are available on the terminals of CN6 and CN5 connectors respectively, where the cen- tral terminal is Common. On the version made available through the Elektor Store only one of these sections is assembled: RE2 relay and its corresponding connector CN5. The commands to act on devices connected to expansion connector are: • Set Configuration: Initialize GPIOs, ADC channels, DAC channels and I 2 C devices with specific device parameters; • Get Configuration: Used to know current device configuration; • Read: Capture GPIs, ADC and DAC channels and I 2 C devices current values; • Write: Set GPOs, DAC channels and I 2 C devices values. Additional system commands are: • Set system configuration; • Get version; • New Certificate; • New Private Key; • New CA (Certification Authority) Certificate; • EMail notify; • Bootloader (download new firmware). Temperature Sensor — The I 2 C temperature sensor has been separated from the main board to avoid the heat dissipated by the components installed on the motherboard affecting the sensor measurements. Because the TMP275 is an SMD device, it comes assembled on a small PCB and is connected to the main board on CN7 connector using a 7 inch long (approx. 20 cm) patch cable. Expansion Connector — The goal we have pur- sued since the beginning of the design process is for the board to be more than a means of demonstration and eventually serve as a plat- form for our readers' IoT projects and/or your own extension projects. Thus, E-Lock pins not used for on-board peripherals have been routed to expansion connector CN2. It puts +3.3 V and +5 V supply voltages at your disposal, as well as an additional I 2 C bus, four ADCs, one DAC, seven GPIOs and the Reset signal. Power Supply — The board requires 5 volts for operation, conveniently supplied by a power adapter as used on smartphones, through micro USB connector CN1 or directly by connecting a 5-V stabilized power supply on the CN8 termi- nals— paying attention to the polarity indicated on the silkscreen. Ethernet — The board is connected to a 10/100 Base-T Ethernet network through a standard RJ45 connector, which incorporates the corresponding 'Activity' and 'Link' LED indicators. Between the connector and the E-Lock chip we find the usual transformer block and the Physical Layer Trans- ceiver (PHY) chip. PoE — The board is Power over Ethernet (PoE) ready, although the version currently available thought Elektor Store does not include the 48 to 5 V DC/DC converter. The practical implementation of the functional diagram is found in the hefty schematic in Fig- ure 3. Rather than a wall poster showing the Things Embedded Dreams Are Made Of, the sche- matic is printed here in support of all Elektor readers seriously interested in Internet security AND winning $25K in the competition at www. elektor.com/e-lock. Installation and configuring Before applying power to the E-Lock Evaluation Board, download the demo software for PCs, which is available on the project page [2] as archive file 130280-W.zip, and unzip it to a folder on your hard drive. In the ISLEIektor folder, find all the files needed to configure and test your board. The 'doc' folder contains 'network-configuration.pdf', which describes the E-Lock configuration process, and 12 April 2014 www.elektor-magazine.com E-Lock TSLEIektor_130280-applicationnote.pdf', which describes the demonstration application. It is highly recommended to read them before you start using the board. You need to configure the board before test- ing it and to do so the board needs to know some information about your network: router IP address, a free IP address for your board and DNS IP address. After collecting all this information, connect the power supply and Ethernet cable to the board. Then run the application configuration ISLRaw. exe and you hopefully will see the window shown in Figure 4. The application is able to configure various devices attached to the same LAN. The first step is to identify any MAC addresses by clicking on Scan MAC ; doing so, a message will be broad- cast by the application and the chart situated at the bottom of the window will be filled with the information given by the devices that are waiting to be configured. Once all the information has been received select the device you want to configure in the list and the Remote MAC field will be filled automatically. Finally write the desired IP address and press Set Remote IP in order to configure the IP address of the device. If process was successful, the list will be updated with the new IP. A new window shows up to select security param- eters, that is: certificate, key, CA certificate, SNTP server, DNS address and Gateway address. Once all fields mentioned above are filled correctly, press Send to set up the security parameters on E-Lock. You can create your own certificates following the instructions described in the config- uration document but for testing the board you will find sample certificates and key files in the certs folder, select ISLserver-cert.pem for the Cert field, ISLserver-key.pem for Key field and ISLca-cert.pem for the CA field. Demonstration software Once the setup process is completed, proceed to test the operation of the E-Lock board running the demo application ISLEIektor.exe. Figure 5 shows the main window of this application. Before running the application, the temperature sensor board must be plugged into the motherboard. ISLEIektor is an application used to interact with the E-Lock Evaluation Board, exchanging infor- mation through a TCP/IP channel in Secure Mode, based on a communication protocol described in full in the board's datasheet [2]. When ISLEIektor is launched, all the buttons are disabled except Connect. First of all, it is neces- sary to enter the IP address you have assigned to your board in the previous step, then press Connect to establish a TCP/IP connection with the device. When the connection is ready, a new window is shown similar to Figure 6, and you have to set the server certificate and key files. As for the board, you will find the sample certif- ft, ScOutronr P Com Hrmnlir MAC; [ooTbeToeToTTojTi? 1 U . ?K . II .99 Scan MAC Set Remote IP 01 :02:1b ssloiofk Mot cor.ficurea Figure 4. E-Lock Evaluation Board configuration. ft Bl fclektoi IBeto IP Address Of Server Nome Port Connection StaKus Connect | UU«H.MKU ( idto Sonsor Contiquralian Tovnpovaiuro rtumuity Rnmpln rate Sampln mm I -1 — 1 I jjgj I r.rl rimlnj | Ki ilny Configuration Sytilom Conliquration SDCard Operation Mode Mail Notification Reloyl boot state Relay? boot state r r O NO Jit ON OFF j r ON If OFF r Vr ■ r YES Mai No**ca*on Parameters Mai From: Password l@gmail com Mai To: User Name: Sensor end Reloy Moroior Reloy Remote Control I'C tietl«-.Me.e.u.e J h tint Huiimiilr | Ritlsyl _ r on r. off r ON (i OFF Raley? q O ON Enponsion Pins " " I - - I — ' I |Ontr.er fiftfect Key OIC Figure 5. E-Lock Evaluation Board demo application main window. Figure 6. Setting up client certificates on the E-Lock Evaluation Board. www.elektor-magazine.com April 2014 13 •Projects & ft- Heitor (BeUI IP Address or Server Name Port Connection Stanus 1 Chanoe IP Version |1?2 26 0 90 !201* Connected DrecurinmJ Cmt-Vtay —i Sonsor Configuration fimpMbni ~ — — Hurmdity Rnmpln rnfn Sample rati i nnlHjinc j fin Tanfig Rulay Qwifirjurnfiiwi Sysfom Configuration SDCard Operation Mode Mail Notiticalion Relay 1 boot state Relay2 boot state NO row OFF 1 r ON OFF Configure r YES Configure Expansion Pins Mod Nortcaion Poromeiers Mod From: Password: |@rymail com Go to GP10 | Go to I2C I Go to ADC/DAC Mo. To: User Name: li •rnml mSiin •?.*; ft j tytiur rinriu* Sensor end Relay Monitor Relay Remote Control pc i; |h — 1 1 1 Rideryl Ftiiay? Riilayl o Got Holoy Status ® 0FF r ON <- OFF I C ON s OFF Sot rtotov Rfilsy? o • ON Figure 7. E-Lock Evaluation Board successfully connected. The security trap Being secure and feeling secure are different things. Together with millions of others we use the Internet to access and convey information, meet up with family and friends and cheerfully complete transactions with banks and online stores. For peace of mind we look at the https sign in the upper left part of the screen... and feel secure. But are we? Very likely, not. And there are more ways to get to your valuable stuff. Many banks have taken a lot of precautions to secure their ATMs and then some crooks do a ram-raid and run with the money— so much for security. With the IoT taking off at terrific speed, there will be many highways and byways to get into systems and houses. So, what we present here is a solution to secure the connection to your Things, for example the electronics to open your garage door, but you will have to keep checking the windows! About Intelligent Soc IntelligentSoC was founded in Madrid, Spain in 2011 as a spinoff of the R&D department of Datatech SDA, an engineering company which is specialized in the development and design of communication and data processing systems with a strong focus on security. The main goal of the company is to design, develop and manufacture IPs, chips and modules with the latest authentication technologies based on elliptic curve math (ECC), Diffie-Hellman algorithms, and various AES 128/256 encryption techniques. IntelligentSoC's products are currently installed where security is a must-have, such as avionics or military systems, and are currently expanding this technology to other areas like the Internet of Things. icate and key in the cert folder (ISLdient-cert. pem and ISLciient-key.pem). If the connection process is successful, a Con- nected tag will appear in the Connection Status box with a blue background, and all the onboard functionalities will be available (Figure 7). If not, an Error tag will be displayed. If so, no sweat, check the IP address, the Ethernet cable and TCP/IP client Certificate and Private Key and then retry the connection. If you are sure all param- eters are correct but the error persists, use the factory settings recovery jumper JP3 (install it, remove it) to initialize E-Lock and repeat the above configuration process. Click on Disconnect to finish the previous con- nection or modify the IP address field and press Change IP to boot the device with the newly filled IP address. In this last case, it is mandatory to connect again using the new IP address. Now you can test the operation of all available elements on the board, change their initial con- figuration, play with the expansion connector ... detailed information about all the possibilities offered by this demonstration software is found in the 'ISLEIektor_130280-applicationnote.pdf' document found in the doc folder. The folder called source contains the source files of this application and we encourage you to make your changes or use them as a basis for your own applications. We have used Borland C++ Builder6. More info ... We have just skimmed the surface of E-Lock on these pages. Magazine space is at a premium and there is a lot more to describe in terms of what E-Lock has to offer. I highly recommend downloading all documents available on the proj- ect page [2] including the PCB design data, the E-Lock board datasheet and demo and support software. Reading these documents will not just enable you to understand the real power of the first Elektor chip, but also provide essentials to win $25,000 in cash [3]. ( 130280 ) Web Links [1] www.soclutions.com [2] www.elektor.com/130280 [3] www.elektor.com/e-lock 14 April 2014 www.elektor-magazine.com expo & conference www.sensorsexpo.com June 24-26, 2014 Donald E. Stephens Convention Center • Rosemont, IL SPECIAL . Subscriber Discount! Register with code A303C for $50 off Gold and Main Conference Passes * What's Happening in 2014: Tracks 0 (!) V Si M2M MEMS MEASUREMENT & DETECTION POWER MANAGEMENT SENSORS @ WORK WIRELESS Plus+ Full-day Pre-Conference Symposia Technology Pavilions on the Expo Floor • Internet of Things • MEMS • High Performance • Energy Harvesting • Wireless Computing t^ S&Co- location with High Performance Computing Conference • Best of Sensors Expo 2014 Awards Ceremony • Networking Breakfasts • Welcome Reception • Sensors Magazine Live Theater • And More! Featuring Visionary Keynotes: Reimagining Building Sensing and Control Luigi Gentile Polese ' Senior Engineer Department of Energy, National Renewable Energy Lab NREL Sensors, The Heart of Informatics Henry M. Bzeih Head of Infotainment & Telematics Kia Motors America 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. Registration is open for Sensors 2014! Sign up today for the best rates at www.sensorsexpo.com or call 800-496-9877. in h #sensors14 OFFICIAL PUBLICATION: INDUSTRY SPONSOR CO-LOCATED WITH: sensors *Discount is off currently published rates. Cannot be combined with other offers or applied to previous registrations. Platino-based Experimenter's Power Supply A handy supply for the embedded electronics worker By Sunil Malekar / Krishnachandran (Elektor India Labs) Although many benchtop power supplies boast a microcontroller of some sort, the MCU's function is usually limited to controlling the V/A readout. Not so in this proj- ect, which employs Elektor's versatile 'Platino' ATmega powered board to do all of the PSU's control functions, including its internal V and A regulation and fan control. The small power supply described here was inspired by the "Lab PSU for Embedded Develop- ers" published earlier in Elektor [1]. The obvious shortcoming of that design is that the activity of the microcontroller is limited to the display. By contrast, in the Platino-based PSU described here, the MCU rules over output voltage, maximum output current, and a lot more. And a powerful controller it is: Elektor's very own "Platino" [2]. Design considerations Designing an MCU into a benchtop power sup- ply is all about adding a few extra parts in order to reduce the number of potentiometers and switches. The process is fraught with problems but thanks mainly to Platino, some Bascom pro- gramming and a component called Digital Pot, we were successful and managed to minimize component count and board space. The PSU delivers the most common outputs for 'light' lab work— meaning 0 V to 15 V DC in 0.1-V increments, with a 0 mA to 1000 mA selectable current limit. The PSU also provides for fixed 3.3 V and 5 V voltages on a USB connector with 0 to 500 mA adjustable current limit. The instrument display offers two modes of operation: Setup Mode and Normal Mode. Circuit description The Platino Benchtop PSU has a hardware and a software component— both interact strongly to guarantee stability and accuracy of user selec- tions and output values. The heart of the proj- ect is Elektor's Platino MCU board powered by an ATMega328p. Starting with the hardware, let's do some sight- seeing of the schematic in Figure 1 . But before hopping on the tour bus, note that the input volt- age for the unit comes from a standard 18-VDC adapter normally used with a laptop PC, or an equivalent adapter. Main power input and auxiliary supply generator The raw 18 VDC input voltage is connected to cir- cuit on PCB terminal block Kl. Diode D1 protects the circuit form reverse polarity. The raw DC is applied to regulators IC3 and IC4. IC3, an LM7805, supplies the main 5-V power for the Platino board and all other circuitry operating at the same volt- age. IC4, an LM7812, is responsible for the reg- ulated 12 VDC needed by the fan control circuit. Negative auxiliary voltage generator The circuit around IC5 and IC6 converts +5 V, via a -5 V intermediate level, down to -1.27 V (-V E ), which is needed by the positive voltage regula- tor section to Make its output go down to 0 V. The LM337L negative voltage regulator has its output voltage adjusted to -1.27 V by preset P2. Temperature measurement Temperature is measured by an LM335 preci- sion temperature sensor, IC7. The output of the 16 | April 2014 | www.elektor-magazine.com Platino-Based PSU ON/OFF '335 is applied to Platino's PC4 input, enabling the MCU to read and process the sensor voltage and then display the temperature. The measured temperature is used to automatically shut the power supply down when the PSU temperature reaches a predetermined high level. You can set the shutdown level in Setup Mode under "Thresh- old Temperature". Fan control A small fan fitted in the enclosure is used to cool the unit and prevent damage by overheating. The 12-VDC fan is powered by a BS170 MOSFET (Tl) via Platino's PD1 port pin. Connector K8 may be used as a jumper to set the fan operation in Manual Mode by applying a permanent High (no jumper) or Low level (jumper installed) at Pla- tino's PC6 pin. The operation mode of the fan can be set to Auto or Manual by entering the instrument's Setup Mode. In Automatic mode the fan is Platino-con- trolled and is switched on at 20 °C below the user-defined Threshold Temperature value. Below that level, the fan remains off in Auto mode. If Manual mode is selected the software checks the status of K8 to turn the fan on or off. Precision reference generator An LM336 IC in position IC11 generates the 'AREF' reference voltage for Platino, which does all of its calculations related to voltages based Specifications & Features • Output 1: 3.3 V or 5 V / 500 mA max., on USB-A connector • Output 2: 0-15 V / 1 A max., on banana sockets • Both outputs short-circuit resistant • Power supply output capacity: 17.5 watts • DC input: 18 V / 2 A laptop PSU • Readout: 20 x 4 LCD • Single-knob control • High temperature automatic shutdown • Auto or Manual mode for fan & control • Internal temperature sensor • Setup Mode for fan threshold and temperature settings • Normal Mode for V/A adjustment in daily use on that value. The LM336 is a precision reference generator in a space saving TO-92 package style and requiring a minimum of external components. Preset PI adjusts AREF to exactly 5.00 V (use a good voltmeter). This is a onetime setting. Positive voltage regulators The power supply has two outputs, hence two separate positive voltage regulators are used. For the sake of simplicity identical regulators are used. The LM2576 (IC1, IC2) is an adjustable step-down switching regulator used here as a positive voltage regulator on the two sections of power supply. The LM2576 in position IC1 is configured to output 0 V to 15 V at 1 A (max.), www.elektor-magazine.com | April 2014 | 17 Figure 1. Schematic of the Platino- controlled Benchtop Power Supply. Input power is furnished by a common 18 V / 2 A laptop supply. all adjustable. IC2 in the other section provides the 3.3 V (500 mA max.) and 5 V (500 mA max.) selectable output voltages on K7. Both sections are quasi-digitally controlled by Platino. The 0 V to 15 V adjustable output voltage is available on connector K6. The negative auxil- iary voltage -V E is connected to the LM2576's GND pin (3) to make the output voltage start at 0 V instead of +1.23 V as the datasheet says. Both IC1 and IC2 take +18 VDC after diode D1 as their input voltage. Their output filter circuits follow the same layout with differences in current rating for the coils (LI, L2) and buffer capacitors (Cll, C21). Auto-shutdown control Automatic shutdown is implemented for the protection of the power supply and the user. Protection is afforded against short circuits, over temperature and over current. Platino's PB6 pin is used to effectively switch IC1 on and off via MOSFET T2. Since T2 has the -V E voltage at its source terminal, zener diode D8 is necessary to avoid any negative voltage on Platino's PB6 pin. Likewise PB7 is used to switch IC2 off in case of a short circuit, over temperature event, or over current detected at its output. 18 | April 2014 | www.elektor-magazine.com Platino-Based PSU Feedback & error correction This section is responsible for controlling the out- put voltages and currents of both regulators. The main parts in this section are an opamp and a MOSFET. This section generates and controls the feedback of IC1 and IC2 using a control signal supplied by Platino. For IC1, PWO is the 'digital potentiometer' signal to control the feedback voltage. The current mea- surement signal gets fed to the MCU via pin PCI; the voltage measurement signal through PCO. In the case of IC2, PW1 is the 'digital pot' sig- nal; current measurement is by way of PC3, and voltage measurement by way of PC2. The operation of the feedback & error correction section is as follows. Opamps IC9a and IClOa compare the voltage at their non-inverting ter- minals to that at the inverting terminals and then adjust their outputs according to the differences. The outputs determine the impedance seen by the regulator's feedback pins. Consider a voltage between 0 and 5V at the inverting terminal of the opamp; this will cause the opamp output to drop to a level well below the switching threshold of the MOSFET. Consequently the MOSFET's d-s path represents a high impedance. In order to meet the 1.23 V at feedback terminal, the reg- ulator drives the output High but this output is again fed back to the non-inverting terminal. This will ramp up the output of the op amp resulting in a lower impedance. Consequently the overall circuits strive to maintain equal voltages at the opamp's inverting and non-inverting terminals. The current sensing section consists mainly of opamps IC9b and IClOb. The current flowing through the load is converted to voltage by shunt resistors R5 for IC1 and R16 for IC2. The voltage dropped by R5 and R16 is fed to the inverting terminals of the opamps. The voltages cause the opamp outputs to ramp up, resulting in lower MOSFET impedance, resulting in turn in a volt- age drop at the non-inverting terminal. The loop action ideally yields equilibrium between the volt- ages at the non-inverting and inverting terminals. A voltage drop identical to that across the series resistor is developed across 100-ft resistor R9 for IC1 and R23 for IC2. Flence the current flow- ing through the 100-ft resistor is proportional to the load current, which also flows through 2-kft resistor R17 for IC1, and Rll for IC2. The cur- rent-proportional voltage makes the microcon- troller aware of the current demand on the PSU. In order to protect the relevant microcontroller terminals 5.1-V zener diodes D3, D4, D6 and D7 are provided. The 0-15 V regulated output volt- age is scaled to 0 to 5 V which van be handled safely by the microcontroller. Digital potentiometer section The MCP42010 (IC8) is a dual digital 50-kft potentiometer with SIP interference. Flere, it supplies the feedback voltage under control of the Platino MCU. Digital Pot line PWO serves IC1 through IC9a. Dig Pot line PW1 serves IC2 through IClOa. PB3, PB4, PB5 and PDO are SIP interface signals from the MCU to control the dig- ital potentiometer 'wiper' such that it supplies the voltage levels needed in the regulation loop. Output section The output of regulator IC1 is connected to the load via banana type connectors on the front panel (black and red) by way of PCB-mount con- nector K6. The output voltage of IC2 appears on a standard USB type connector also on the enclosure front panel, through PCB-mount con- nector K7. Software The software for the project was written in BAS- COM AVR for ATMEGA328P microcontroller. The Platino board can be used for further development of the project. The software part is divided into a number of sections discussed below. The BASCOM program is available for downloading from [3]. Display section The display section comprises the Platino board and a 20 x 4 LCD. This section of the program initializes the LCD and first outputs the message: "Platino Instrument series 1.0" followed by the name of the project: "Platino Adjustable Bench Power Supply". After the initialization and greet- ings, the display shows the Menu screen with its "Setup Mode" and "Normal Mode" options. Select any option by operating the rotary encoder (R/E) and its integrated pushbutton on the Platino board. At the selected option, press the push- button to view the options given by Normal or Setup Mode. A long press of the button returns you to the Main Menu. Setup Mode In this mode you configure the settings of volt- age, current, fan and temperature threshold by www.elektor-magazine.com | April 2014 | 19 DESIGNSPARK PCB Component List Resistors Figure 2. PCB design for the supply. Default tolerance, wattage: 5%, 0.25 W R1 = 2400. R2, R15, R20 = IkO R3,R7,R12,R14,R19,R24,R25 = lOkO R4 = lOOkft R5, R16 = 50mft shunt precision resistor, 1% 2W R6 = 22kO R8, R18 = lOkO 1% R9, R23 = 100ft 1% RIO, R22 = 30kft 1% Rll, R17, R21 = 2kft 1 % R13 = 4.7kft PI = lOkft trimpot P2 = 50ft trimpot Capacitors C1,C3,C4,C9,C10,C12- C16,C18,C19,C20,C22-C27 = lOOnF C2 = lOOpF 50V, radial C5-C8 = lOpF 25V, radial Cll = lOOOpF 35V, radial C17 = lOOpF 25V, radial C21 = 330pF 35V, radial Inductors LI = lOOpH, 1.4A (2062790) L2 = lOOpH, 2.6A (2215967) Semiconductors D1 = 1N5408 D2 = 1N5822 D3,D4,D6,D7 = 5.1V zener diode, 0.4W D5 = 1N5819 D8 = 3.9V zener diode, 0.4W T1,T2,T4-T6 = BS170 T3 = IRL540NPBF IC1, IC2 = LM2576T-ADJ (Texas Instru- ments) (9488146) IC3 = LM7805 IC4 = LM7812 IC5 = MAX660CPA+ IC6 = LM337LZ IC7 = LM335 IC8 = MCP42010-E/P (Microchip) (1332110) IC9, IC10 = LM358N IC11 = LM336BZ-5.0 Miscellaneous K1 = 2-way PCB terminal block K5,K6,K8 = 2-pin pinheader K2 = 8-pin pinheader K3 = 12-pin pinheader K4 = 6-pin (3x2) pinheader K7 = 5-pin pinheader Miniature fan, 12V, 40x40x15mm 2 pcs. banana socket, 1 red, 1 black, panel mounting (1176431) (1176430) USB-A Socket, panel mounting (1667928) Enclosure, 75xl33x- 110mm, Bopla ref. 26160000 (1217479) Switch, on/off, rocker, pan- el mount, e.g. Schurter ref. 1301.9205 (1162728) PCB, Elektor Store # 130406 Platino board, Elektor Store # 110645 (numbers in round brackets are Farnell/Newark order codes) 20 | April 2014 | www.elektor-magazine.com Platino-Based PSU selecting relevant options. A long press on the R/E button returns you to the Main Menu. Normal Mode In this mode the outputs are switched on for pow- ering the load(s). You can use the rotary encoder to adjust the 0 V to 15 V output as required. A long press of the R/E button returns you to the Main Menu. All outputs are available in normal mode only. Measurement Section The microcontroller obtains information on the output voltage and current feedback from the Feedback & error correction hardware sections. It also measures the voltage and current relative to the reference signal on the AREF pin. Tempera- ture measurement is carried out by the software, and the result appears on the LCD. Measuring signals are scaled to the 0-5 V range by hardware and sent to MCU's ADC. Control section Depending upon the ADC input value the MCU generates the control signals for digital pot IC8 to control the output voltage and current. It also generates the auto shutdown signals for IC1 and IC2 depending upon current and temperature values and the limit value set in Setup Mode. It generates the Fan control signal according to the configuration in Setup Mode. Using suitable software the microcontroller reads the output voltage and increments or decrements the digital pot in order to meet the desired volt- age level. It also monitors the current and limits the output voltage if the load current exceeds the current limit. If a short circuit is detected (exces- sive current) the microcontroller shuts down the particular regulator and resets the digital pot to zero-out. Also the microcontroller shuts down the regulator, if it detects high temperature. The upper current limits and temperature limits can be programmed by the user. A quick overview of microcontroller pins usage jointly by hardware and software is presented in Table 1. Construction First build the Platino with its LCD, rotary encoder with pushbutton, ATMEGA328P MCU and all other components, then 'jumper' it as shown in Table 2. Refer to [2] for the Platino showoff pages. Table 1. Microcontroller Pins Usage Pin designation Function PB0-PB2 Encoder with pushbutton PB3, PB4, PB5, PDO microcontroller <-> digital pot SPI comms. Data in = PB4 Data out = PB3 Chip select = PDO Clock = PB5 PB7, PB6 regulators on/off control PC0-PC3 IC1 and IC2 output voltage and current measurement PC4 temperature measurement PC5 LCD backlight control PC6 fan controls Figure 3. Looking inside the enclosure from the right. The three boards that make up the little supply (LCD, Platino, PSU) are fitted vertically behind the front panel. The add-on board that forms the actual power supply is constructed next, see the PCB layout and Component List in Figure 2. The board is designed to fit exactly to the back of Platino with the help of pinheader connectors. A Bopla enclo- sure accommodates Platino with its 20 x 4 LCD, rotary encoder/pushbutton, the PSU board, a small 12 VDC fan, the power jack, on/off switch, banana connectors, and USB (power-only!) connector. Figures 3 and 4 and various other photographs in this article illustrate the method of construct- Table 2. Jumper settings on Platino JP3 PC5 JP4 PBO JP5 PB1 JP6 PB2 JP10 PB6 JP9 PB7 JP8 RESET JP11 PB7 JP12 PB6 www.elektor-magazine.com | April 2014 | 21 ing the little benchtop supply. The boards sit vertically behind the enclosure front panel, in this order: LCD, Platino, PSU. The front panel requires three rectangular cut- outs: LCD, USB power-out, on/off switch. And three round holes: rotary encoder spindle, banana sockets (2x). Blocking elements like plastic cable feet should be glued to the bottom of the case Figure 4. A close up of the three boards. The assembly is best tested in this state, i.e. prior to building it in the Bopla case. to keep the 3-board assembly securely in place. In the back panel, make round holes for the fan (approx. 37 mm diam.) and the DC input con- nector (approx. 10 mm diam.). To assist ven- tilation, drill 12 2-mm holes in a 40-mm x 40 mm cross shape in the back panel, above the DC input socket. Internal wiring is limited to the fan, the on/off switch, the USB power-out connector, the 18 VDC input and the red and black banana socket. Testing Test your power supply rigorously under full-ca- pacity load conditions, observing all relevant safety precautions. Load the 0-15 V output with 1 amp by connecting a 15-ohm 30-watts power resistor (Figure 5). Load the 5 V output with 500 mA using a 10-ohm 10-watt power resis- tor. Also run a 1-kHz dynamic load test for 15 V (1A); 10 V (1 A) and 5 V (500 mA). Check the short-circuit recovery and auto-shutdown fea- tures by shorting outputs to ground. Check over-current detection and response by setting the limit value, then dropping the out- put voltage a little and check if the set current is maintained. ( 130406 ) Web Links [1] Lab PSU for Embedded Developers, Elektor April 2012 (UK edition), www. elektor-magazine.com/1 10645 [2] Versatile Board for AVR Microcontroller Circuits, Elektor October 2011, www.elektor-magazine.com/100892 [3] Project software: www.elektor-magazine.com/130406 Figure 5. Maximum-output i.e. 15 V @ 1 A test using a 15-ohm 30-watts power resistor. Don't leave it lying on the desk for too long while the test runs (and don't pick it up either). 22 | April 2014 | www.elektor-magazine.com LAUNCH: MARCH 3 / DEADLINE: AUGUST 3 Join the loT revolution by designing an innovative ’Net-enabled electronics system using WlZnci WIZnet’s WIZ550io Ethernet module or W5500 chip Your reward? A share of $15,000 in cash prizes and worldwide recognition from WIZnet Circuit Cellar, and Elektor\ Anyone with a WIZ550io Ethernet module or W5500 smart Ethernet chip is encouraged to participate. WIZnet is providing 2,000 complimentary WIZ550io Ethernet modules for all those who qualify! Requests are served on a first come, first served basis while supplies last. The competition starts on March 3, 2014 at 1 2:00 PM EST and ends on August 3, 201 4 at 1 2:00 PM EST. Get started today! WIZnet’s WIZ550io module is a complete Ethernet solution that includes the W5500 smart Ethernet chip (1 0/1 00 MAC/PHY, hardware TCP/IR 32KB RAM buffer) and network interface (transformer and RJ-45) along with built-in MAC and default IP addresses. For technical support: wizwiki.net/forum To purchase: shopwiznet.com or shop.wiznet.eu circuit cellar Sign up for CC.Post to receive announcements and notifications! •Projects Motion-Detector A night light that flashes on when someone walks past, an IR-LED, a few resistors, a capacitor and an Arduino with a bit of software: that's all you need to take pictures using motion detection. By Rolf Blijleven (Netherlands) I consider the Arduino to be very similar to Lego: you can make all manner of things with it. This is useful and instructive to do, and it results in something useful. You can then use it for a while, and whenever you feel like it, you can take it apart again and use it to make something else. A while ago, I made an infrared remote control for my Nikon D80 using an Arduino. Not because such a remote control is that expensive, but because making one yourself is much more fun and using an Arduino it offers many more possibilities. More- over, it turned out to be child's play: An IR-LED, a resistor and a piece of software that I found on the internet, nothing else is required. A con- siderable advantage of the Arduino, compared to other embedded platforms, is that there is a tremendous wealth of firmware to be found, just free from the Internet. After this, I wanted to trigger the remote control using a motion detector. There are many nice solutions to be found for this on the DIY market and on the internet, but these usually require an AC power adapter. I didn't want that, it had to work without any wires. By chance, I spotted at the supermarket a night light powered from batteries, with a motion sensor, for a couple of dollars (Figure 1). That won't break the bank. It just went with the weekly groceries. 24 April 2014 www.elektor-magazine.com Motion-Detector Camera Trigger Night light hacking The first thing you do, naturally, is look what is inside it. This tuned out to be much better than expected. No difficult SMD parts or— worse— COBs, but instead an IC with legs, normal resistors and capacitors, a PIR-sensor and a photo diode. The part number printed on the IC was TL0001. A quick Internet search and sure enough there appears to exist a datasheet [1]. In Chinese, but that is not a problem: just copy the text and paste into Google Translate. This results in an horrendous translation but is still good enough so that you can get the gist of it. There was even an Application Note in there, that although it was not exactly the same is my night light, it was nevertheless very close. The night light did three things that I didn't want: it only operated in the dark; it gave a pulse that was several minutes long, while I needed a much shorter pulse and a turned on three bright LEDs when you walked past. The latter was easily solved. The three LEDs shared one series resistor. I removed two and replaced the series resistor with one that has a higher value (2.2 kft, A in Figure 2), so that the remaining LED would still switch on with each trigger, but not as bright. Then the inhibit- function during daylight. In the example schematic (Figure 3), R3 is an LDR. This I couldn't find anywhere, but I did find a photo diode, also a device that exhibits a lower resis- tance as the amount of light on it increases. So I replaced that with a reasonably large resistor (220 kft, B in Figure 2). That worked too: Even in bright light the lamp turned on when motion was detected. Figure 1. Available from your Walmart or discount store: a super cheap night light with motion detector. Figure 2. The same night light after a few modifications. +5V +12V Figure 3. A sample schematic from the datasheet for the TL0001 made by the Chinese company Treasure Link Technology. Although it looks very similar, it does not correspond completely with the actual circuit in the night light. www.elektor-magazine.com April 2014 25 •Projects IR-LEP +3 c Ik GN p digital pin 13 ft - IH-»0B3bu 3 3 2 1 • 9 • 74513219 ■ x 'll £»"%,, L i IIIIIMMIII (*L a a a aa a Arduino'";^ 1% ’.ili'TiiiUu! □uemilanove •' 21 fl itliui • RX Duemilanove JJS S* fiZTZ) -> Tr? i s ,* HU • r - www. 4 irOuino.ee 22 POUER «»«COC( «N 0 • v fttyu Ood u»r* 0 12 3 4 5 1,S V (3 X AA) PIR-board IC1 pin 2 Analog in pin O Gnd SV Figure 4. The complete circuit with Arduino, IR LED and PIR-board (formerly a night light). Now the pulse duration. The light turns on for about 5 seconds. That will be an RC-time con- stant somewhere, but which R and which C? I had already observed that it was not possible to turn the light back on immediately after it had turned off. So there had to be another RC-time constant to suppress new triggers for a while ( trigger-in - hibit). Now I really had to resort to reading the datasheet. And sure, it was all there. Machine translated from the Chinese: "Output delay time Tx R9 and C7 by an external sizing, value Tx ~ 24576xR9C7; triggered by an external blocking time Ti RIO and C6 resizing is Ti ~ 24xR10C6." That's clear, isn't it? Time for some reverse engineering : not design- ing a printed circuit board from a schematic, but the other way around: drawing a schematic based on the circuit board. This is a little easier when you can see both sides of the circuit board side by side. A photocopy of the copper side is very helpful. After a little drawing, calculating and soldering I had identified R9/C7 and R10/C6 and replaced them with 'improved' values. That's what I thought. However, it wasn't right. At any rate, the light had completely lost the plot. While I was checking everything again, my eye caught some text in the datasheet: "BISS0001 chip it is fully compatible with". And sure enough, the datasheet for the BISS0001 had the correct formulas: Tx ~ 24576xR10C6 and Ti ~ 24xR9C7. In the Chinese datasheet RIO and C6 where swapped with R9 and C7! With R10C6 = 1 kQ x 100 nF and R9C7 = 270 kQ x 1 nF resulted in Tx ~ 24 ms and Ti ~ 0.5 s (C in Figure 2). Right on the money. C7 could have remained unchanged. An attempt to increase the gain of the PIR-sensor somewhat resulted in a modest improvement. The gain stage comprises two steps. 1IN+, 1IN- and 10UT in the IC are an opamp (see datasheet), the gain of which is about equal to R7/R8. Using 1 MQ/12 kQ this became 84 (was 40 with the original 2 MQ/47 kQ). The makes the PIR-sensor not more sensitive, of course, but it does amplify small signal more. A consequence was that larger signals would hit the power supply rails. The sec- ond stage is also an opamp with a gain equal to R6/R5, originally 100, but with 15 kQ for R6 this became 67. This solved the clipping problem. The result is that the sensor is able to detect movement indoors over a somewhat larger dis- tance than before, but that doesn't mean much by itself. PIR-sensors are especially sensitive at seeing heat differentials. A cat walking past on a frosty day is detected from many meters fur- ther away compared to the same cat on a warm summer's day. The output of the IC is on pin 2, which is soldered to a wide copper track. It is therefore very easy to attach a wire to it. With another two wires for +5 V (after the switch) and ground the night light had become a PIR-board. Not bad for an invest- ment of € 2.65 and some time figuring it all out. I fully expect that in your part of the world the type of motion detector or night light that you can buy will be entirely different. But the above story has at least shown a method you can use to figure out how it operates and adapt some of the features of the circuit to your needs. Work horse Arduino It turned out that connecting the PIR-board to an analog input of the Arduino was more convenient than using a digital input. One digital output of the Arduino is used for the IR-LED with a series resistor, which is used to operate the camera. The three AA-batteries for the night light also serve as the power supply for the Arduino. The circuit is otherwise simplicity itself (see Figure 4). The timing for the IR-pattern for the camera trigger is borrowed from [3] and [4]. Movement a few meters from the PIR-sensor generates a trigger for the camera, which, in turn, could also be a few meters away from the IR LED. This also works through glass, so you can keep your cam- era inside and the sensor/remote control outside. I have mounted the IR-LED on a piece of thick electrical wire, so that the LED can be bent into a different direction compared to the direction of the PIR sensor. 26 April 2014 www.elektor-magazine.com Motion-Detector Camera Trigger My camera, a Nikon D80, turned out to have some unexpected characteristics. When you switch this camera into IR Remote mode it waits a while for an IR-command. If that does not happen it will switch out of IR-mode by itself. Any command after that interval is ignored. For my application (nature photography) this was undesirable. The waiting time can be adjusted in the camera up to a maximum of 15 minutes. That is why the firmware will give the IR-com- mand 'stay awake' if there has been no motion detected for 14 minutes. In this way you can leave the camera for days, waiting for that one rare animal to go by. This interval can also be made shorter. Without the PIR-board you can then also use it to make time-lapse movies of, for example, flowers that grow and open. To allow this interval to be changed in the code in a more obvious way, requires a little bit of com- putation. We are using Timerl, this is a 16-bit timer, so counts from 0 to 65536. If we let the timer start from a timerPreload of 3036 it will count 65536 - 3036 = 62500 clocks and give an interrupt. The Duemillenove runs at 16 MHz; with a prescaler at 1024 this becomes 15625 Hz, so we will have a Timerl-interrupt exactly every 62500/15625 =4 seconds (ignoring any inac- curacies of the clock). In the code this is imple- mented as follows: #define four_sec 1 #define twelve_sec 3 * four_sec #define minute 5 * twelve_sec #define quarter 14 * minute if (val > 200 | | timeCounter == quarter ) { timeCounter = 0; takePi cture ( ) ; delay (500) ; } The source code for the firmware for this project is a free download from the Elektor website [5]. The binary file is only 4 KB, so with an Arduino with 32 KB flash memory there is plenty of spare space for to add your won features. A trigger based on sound would be another possibility. ( 130265 ) Internet Links [1] www.treaslink.com/Upload- Files/20 1053 11 5272 1141. pdf [2] www.e-ele.net/DataSheet/BISS0001.pdf [3] www.bigmike.it/ircontrol [4] http://luckylarry.co.uk/arduino-projects/ arduino-ir-remote [5] www.elektor.com/130265 Figure 5. Arduino and PIR-board with battery housing, mounted back-to-back on a piece of L bracket. This is a quarter of an hour that lasts only 14 minutes, because at 15 my camera would just leave IR-mode. With timeCounter we keep track of the time. In the interrupt service routine we give the intial value timerPreload (=3036) and incerment ti meCounter. The counter value times four is the time elapsed in seconds. ISR (TIMERl_OVF_vect) { TCNT1 = ti merPreload ; timeCounter +=1; } In the main loop we take a picture when there is a trigger from the PIR-sensor or when a quarter of an hour has gone by. Figure 6. The entire circuit housed in a splash-proof enclosure. www.elektor-magazine.com April 2014 27 •Projects By Dr. Thomas Scherer (Germany) Figure 1. Internal wiring of a conventional fluorescent fitting showing the ballast, starter and tube showing the heating filaments. Figure 2. Internal wiring of the LED tube replacement. The two connections on the right are shorted. LED's Replace That Fluorescent Tube The devil is in the detail What's an engineer to do when out on the weekly shop they pass by the Bargain Bin filled with a stash of LED tubes which replace conventional fluorescent tubes? Take a closer look of course. Picking up the long thin box I scrutinize the label- ing to check the tech specs. There never seems to be enough information— I finally submit to my hunter-gather instincts and place one in the shop- ping cart alongside my other finds. They really are a good price. A few minutes later I'm back at the Bargain Bin putting another one in the cart. Who was it that said a bargain is something you don't need at a price you can't resist? Attempt #1 Back at home I plan to fit one LED tube to our bathroom cabinet which I know uses an 18-watt fluorescent tube. According to the label the 10-watt LED replacement tube uses less energy and will produce more light. When all was said and done and the tube was finally up and run- ning I measured (at the same distance) a 30 % L N LED FLT replacement short circuit — ► increase in light output compared to the old flu- orescent tube. I have changed this tube and others like it before. It shouldn't be difficult— take off the diffuser, rotate the tube through 90°, pull it out, insert the LED replacement tube rotate it back through 90°, refit diffuser, job done... Not so fast! It can be that easy, but not necessarily— it depends on the type of light fitting you have. Older fittings use a coil or ballast together with a pre-heat starter device, if yours is like this then you should have no problems. Figure 1 shows the wiring in this type of fitting. The tube has a heating filament at each end— when AC power is applied the voltage across the starter unit pro- duces a glow discharge which heats up a normally open set of bimetal contacts. The contacts close, supplying current to the heating filaments at each end of the tube and through the inductive ballast. With the starter contacts closed, glow discharge in the starter unit stops and the contacts cool down. After a second or so they open, producing a voltage spike between the filaments, initiating the main discharge in the fluorescent tube. With this type of fitting it's normal to hear it click and see the light flash two or three times when you switch on before the tube strikes. Figure 2 shows the internal wiring of the LED replacement tube; on the left is the LED driver module instead of a heating filament. On the right is just a short circuit instead of the sec- ond heating filament. Just fitting this in place of a standard fluorescent tube would most likely cause the lamp to flash until the induced voltage spikes eventually kill the LED driver primary side. It would probably not last too long and any case it wouldn't make a good restful light to shave by. To get round this, the LED tube comes with its own starter unit (Figure 3) consisting of nothing more than a wire link. Using this instead of the standard starter unit solves the problem: The AC input now connects to the LED driver input irre- 28 April 2014 www.elektor-magazine.com Fluorescent Tube Replacement spective of which way round the tube is fitted. So problem solved. Just one tiny complication: my modern bathroom cabinet fitting doesn't have a starter... My first attempt at replacing the lamp ends in failure. All good things come in twos When I originally bought the lamp fitting I chose the latest technology with an electronic ballast. These light up in a few milliseconds without all that clicking and flashing associated with a bal- last and starter. What was an advantage has now turned out to be something of a problem; there isn't a starter device to replace. I wasn't brave or foolhardy enough to just fit the new tube and fire it up. As a last resort I turned to the instruction sheet that came with it. There I read a warning that the tube should not be used in fittings with an electronic ballast. Indeed it states that any electronic ballast must be taken out of the circuit before the LED lamp can be used. Armed with this knowledge and a screwdriver I set to work (Figure 4). The 'Electronic Ballast' module has two wires connecting to the AC input and two lengths of twin cable connecting to the filaments at either end of the fluorescent tube. Figure 5 shows it in circuit with the tube. You can see why it would not have been a good idea to just plug in the LED tube. The LED lamp in Figure 2 would short one side of the ballast and probably generate smoke signals. So it now looks obvious (to me) that I should take out the electronic ballast and wire the AC input to the input side of the LED tube which connects to the internal LED driver... wait a minute, what if the tube gets taken out and put back the other way round? Not only would there be no light, the built-in short circuit at the other end of the LED tube would now be across the AC input, tripping the lighting circuit breaker for sure. Not good. With the ballast now removed, wire the fitting as shown in Figure 6. The LED tube can now be inserted either way round without any prob- lem. The circuit wiring looks like a conventional fitting with a short circuited pseudo-starter and no ballast. Success at the second attempt! With the help of a screwdriver and a couple of termi- nal blocks the rewiring was complete, the lamp shone forth and the engineer was happy (and clean shaven). A cautionary note It is possible that sometime in the future some- one may want to replace the tube. The modified fitting is now no longer suitable for a fluorescent tube. It's important to make this clear otherwise it will be a safety hazard. Without a ballast or starter in circuit the filaments will glow continu- ously bright orange (probably for not very long). Before you fit the LED tube, use a permanent marker and write a cautionary note on the fit- ting: 'Only Suitable for LED Tubes!'. Choose somewhere that will be hidden by the tube but can be seen when the tube is taken out. ( 130403 ) L N L N Figure 3. The starter supplied with the LED lamp is just a wire link. Figure 4. The electronic ballast unit in the fitting. Figure 5. The electronic ballast (Figure 4) wiring to the fluorescent tube. Figure 6. Final wiring for the LED tube. www.elektor-magazine.com April 2014 29 •Projects Microcontroller BootCamp (1) Arduino and Bascom By Burkhard Kainka (Germany) BASCOM-AVRIDE [2.0.7.5] - [C:\Arbeit_neu\Elektor\Uno\Progl\UNO_LEDl.bas] lx lift M £ie Edit View Erogram Iools Qptions Window Help 5 DVM.bas noname2 UNO_LEDl.bas $3 , . v; V S 'U - : • ■ ] , n , o ? , ili ▼ _ 6> X , Sub ▼ Label • UNOJLED1 . BAS i Sregfile = "m328pdef dat" ' AT»ega328p *16 MHz Scrystal * 16000000 Config PORTB = Output Do PORTB. 5 » 1 ' LED on Oaitms SCO PORTB. S - 0 Vaitis SCO Loop '500 ms ' LED of f '500 ms - In the Editorial Office we receive a fair number of requests from electronics enthusiasts who are looking for an easy way to get started with microcontrollers. It's been a good while since we last ran a large series of articles on this subject in Elektor, and the associated hardware is vintage, so it's high time to run a new series. This series is aimed at our readers who already have some experience with analog electronics and now want to start using microcontrollers in their own circuits. You might ask why you should use a microcon- troller when it's possible to do so much with ordinary analog electronics. At first glance, this looks like a good question. New microcontrollers with more features, higher performance, higher clock rates and even more memory are appear- ing all the time, but the first demo program for every one of them invariably makes a LED blink. This leads to the justified criticism that you could get the same result by simply taking an NE555 timer IC and adding a couple of resistors and a capacitor. That's absolutely right, and the com- parison is better than you might think because a lot of the elements of an NE555 timer IC can also be found in a microcontroller. For comparison: the NE555 timer IC First of all there's the output. When you look at the internal block diagram of the NE555 on the data sheet (Figure 1), you can see that it has a push-pull output stage that can actively switch high and low. Microcontrollers have exactly the same kind of outputs. They are called ports, where the name "port" can stand for a set of outputs or for pins that can be configured either as inputs or as outputs. The circuitry connected to the output for a LED blinker application is also the same: a LED with a series resistor, connected either to ground (GND) or to the supply voltage (Vcc). The NE555 also has a second output driven by an open-collector transistor, which can only 30 April 2014 www.elektor-magazine.com Microcontroller Bootcamp switch something to ground. Many microcontrol- lers can also emulate this function. Actually the only difference is that microcontrollers usually have several outputs but the NE555 has only one, since the push-pull output and the open-collector output are not independent. Next we have the inputs of the NE555, which consist two inputs to a comparator that controls an internal flip-flop. Atypical application for this is an astable multivibrator, which hobbyists often call a blinker circuit. You can put all this together in almost no time. You just plug the numbers into a couple of formulas to determine the right component values, and then the NE555 does exactly what you want. Determining the compo- nent values for an NE555 circuit and program- ming a microcontroller are actually comparable tasks. There's another thing that's very similar: both devices (NE555 and microcontroller) have a Reset input that you can use to set everything back to the starting point. And with both devices the Reset input is usually high in the quiescent state and must be actively pulled to ground. Figure 2 shows a simple square-wave genera- tor in the form typically used as an LED blinker. The NE555 data sheet also shows several other basic circuits, including a monostable and a pulse- width modulator— all of which are typical tasks for microcontrollers. If you further consider the countless NE555 applications you can find some- where on the Internet, you certainly have to agree that in many cases all you need is a 555 timer IC and a microcontroller is overkill. For everything from light curtains to servo controls or processing analog sensor signals, there are many things that can be done with this IC and similar devices. And you can be sure that there are still lots of potential applications that haven't been worked out yet. Reducing development time The similarities between the NE555 and a micro- controller are summarized in Table 1. You could formulate the result of a fair comparison as fol- lows: The microcontroller has a bit more of everything and is therefore generally the better choice for complex tasks. For example, a single microcontroller could probably handle a task that would take ten NE555s. Above a certain level of complexity, the microcontroller solution is also smaller and cheaper than the analog solution. On the other hand, an analog electronics solution is a better and more economical choice for quite a few simple tasks. Anyone with a bit of experience in microcon- troller development can also mention another advantage of microcontrollers: once the circuit is complete, you don't need to touch the solder- ing iron again. From that point on, all you do is write and test code. Changes to device functions can be implemented and tested very quickly. Microcontrollers are general-purpose and versatile computation workhorses. The learning curve is worth the effort, since you ultimately save time. Your first exposure to a microcontroller data sheet may put you off, since it can easily amount to 300 pages or more. Fortunately, there are vcc DIS- CHARGE OUT Figure 1. Block diagram of the NE555. Figure 2. Blinker circuit with the NE555 www.elektor-magazine.com April 2014 31 •Projects Table 1. Comparison of NE555 and microcontroller. NE555 chip ATmega microcontroller Switching output Port outputs Inputs Port inputs Timing control by RC networks Internal timer driven by crystal-controlled clock Reset input Reset input Comparator inputs Comparator; analog inputs PWM function PWM outputs Analog signal processing Analog to digital converter Flip-flop Memory cells approaches to the world of microcontrollers that do not require you to understand everything right up front. In many programming languages the first steps are very easy. You just need to have enough confidence to try something even when you don't entirely understand how it works. The main thing is to have a couple of positive expe- riences at the beginning, and after that it just goes automatically. That's doubtless the reason why the first demo task for every microcontroller is a LED blinker. Here as well we remain true to this tradition, if only to maintain the comparison with the NE555. Arduino and Bascom Microcontrollers actually come in all sorts and sizes. At the start of a series such as this we are faced with the choice of which system to use, and there are many different options. We spent a long time talking about which microcontroller, which circuit board (existing or new), and which programming language we could specifically rec- ommend for beginners. Our discussions led to the following proposal: hardware: Arduino Uno; software: Bascom. Figure 3. The Arduino Uno board. Table 2. Arduino Uno at a glance. Microcontroller ATmega328 Supply voltage 5 V USB port 5 V supply and device programming External power supply 7-12 V Digital I/O pins 14 (of which 6 can be used for PWM output) PWM channels 6 Analog inputs 6 Current per I/O pin 40 mA (max.) 3.3-V output 50 mA (max.) Flash memory 32 KB (with 0.5 KB occupied by the boot loader) SRAM 2 KB (ATmega328) EEPROM 1 KB (ATmega328) Clock speed 16 MHz Price (for Elektor Members) $39.70 / £24.75 (check [1]) Arduino has become the most popular system in the hobby environment. The programs are developed on a PC using a simple programming language, and they can be downloaded directly to the microcontroller over a USB connection. A large variety of boards and extension boards (Arduino shields) are also available at amaz- ingly low prices. The entire system is based on the open-source concept, so the software and the hardware are fully documented. The low- cost Arduino Uno board [1] is a good choice for our course because it is equipped with a widely used microcontroller. The ATmega328 is an AVR microcontroller made by Atmel. Programming this device is quick and quite easy. The microcontrol- ler has enough memory to allow relatively large programs to be executed later on (see Table 2). There is a dedicated development environment available for the Arduino. A development envi- ronment in this context, also called an integrated development environment (IDE), is a PC pro- gram that is used to develop programs for a microcontroller. In the development environment, the microcontroller programs are typed in using an editor and then converted into bytes by the compiler, after which they are downloaded to the microcontroller. To ensure that the compiler understands what the microcontroller is supposed to do, you must adhere to the syntax rules of a particular pro- gramming language when you write the pro- 32 April 2014 www.elektor-magazine.com Microcontroller Bootcamp gram. The Arduino IDE uses a simple version of the C programming language, which is the lan- guage used by most professional programmers. It also has several special commands that make program development easier. Many users have become familiar with this programming language and have no trouble working with it. Neverthe- less, for this course we chose the Basic program- ming language. There are many reasons for this choice. One is the Bascom Basic compiler for AVR microcontrollers, which is widely used and popular. The learning curve is especially easy, in part because Bascom includes many special com- mands for sending characters from a microcon- troller to a PC, for showing letters and numbers on a display, and much more. However, perhaps the most important reason for using Bascom is that it makes you fit for all AVR controllers. The selected Arduino board (Figure 3) is used here as a learning platform, but in the end you can use any desired AVR microcontroller on other commercially available boards or on your own boards. You also don't have to limit yourself to ATmega devices. For example, you may be able to manage with the compact ATtinyl3, which has only eight pins. A special feature of the Arduino board is the USB port. In addition to downloading programs to the microcontroller as described below, you can use it to send characters back and forth between the PC and the ATmega328. Among other things, you can use this to control the microcontroller remotely from a PC program or to send mea- surement values captured from sensors by the microcontroller to the PC and display them on the PC. Another thing is that the board can be powered over USB if you so wish. All you need is a USB cable, and you're ready to go. Your first program One option for putting together a blinker circuit with an ATmega328 is shown in Figure 4. To make it easier to see what matters here, the cir- cuit diagram shows the microcontroller without all the peripheral circuitry of the Arduino board. The LED is already present on the Arduino board, so you don't have to put anything together. Similar simplified circuit diagrams are also used for the other example applications described later on. The idea behind this is that you can also try out all of these examples using a bare micro- controller, for example on a breadboard or on +5V a piece of prototyping board. This means that if you wish, you can follow the entire course without the Arduino board. However, it's more convenient and easier for beginners to use the Arduino Uno board. Listing 1 shows the Bascom program for the LED blinker. It starts off with two directives for the compiler, which define what is called the envi Listing 1. LED blinker ' Uno_LEDl . BAS i $regfile = "m328pdef.dat" ' ATmega328p $crystal = 16000000 i '16 MHz Config Portb = Output Do Portb. 5 = 1 ' LED on Waitms 500 '500 ms Portb. 5 = 0 1 LED off Waitms 500 '500 ms Loop Figure 4. linker circuit with a microcontroller. www.elektor-magazine.com April 2014 33 •Projects ronment. This is necessary because the Bascom compiler needs to know the target microcontroller for compiling the program. The Arduino Uno is equipped with an ATmega328P, so the directive is: Portb.5 = 1 Waitms 500 Portb.5 = 0 Waitms 500 $regfile = "m328pdef.dat" You also have to tell the compiler what clock speed the microcontroller runs at. The higher the clock speed, the faster the microcontroller executes the instructions. This can be important when dealing with things that require exact tim- ing. An example is sending characters to the PC at a particular data rate. The board has a 16-MHz crystal that sets the clock speed of the controller. Fjgure 5 The corresponding directive for the compiler is: The first program in the Bascom editor. $crystal = 16000000 Before you get to the actual program, there's another important configuration issue: the port pins of the microcontroller can be used as inputs or as outputs. All port pins are initially config- ured as inputs after a restart. Here we need an output, so the corresponding port must be con- figured accordingly: Config Portb = Output This instruction configures all six pins belonging to port B as outputs. The program actually only uses port pin PB5; all of the other pins remain unused. Why did we choose PB5 in particular? Because a yellow LED is already connected to this pin on the Arduino Uno board. The individual line to the LED is switched to the "high" voltage level (close to the supply volt- age of the microcontroller) by the instruction Portb.5 = 1 . This causes a current to flow through the LED. The port pin is switched back to the "low" voltage level (close to the ground level) by the instruction Portb.5 = 0. There is also a wait instruction to delay program execution. Waitms 500 is self-explanatory; it causes a time delay of 500 ms. All of this is built into a loop struc- ture. Everything between "Do" and "Loop" will be repeated indefinitely. The only way to stop the program is to switch off the supply voltage or press the Reset button. Software: the compiler So far, so good. But how is the program con- verted into an executable form, and how do you get it into the microcontroller? The Bascom Basic compiler was developed by Mark Alberts for the 8051 family and for AVR microcontrollers. First you have to get a copy of this PC software. It is available from the website of MSC Electronics [2]. You can opt for the paid full version or the free demo version. The demo version is fully adequate for trying out the software and for get- ting starting with programming. It is limited to programs that occupy up to 4 KB (4,096 bytes) after compilation. By comparison, the Arduino has room for up to 32 KB. However, 4 KB is not peanuts; it takes a fair amount of programming effort to fill it up. Most of the examples in this series will be much smaller. Installing Bascom is very easy. After you launch the program, the first thing you see is an empty Editor window where you can type in your own program. Of course, you can also import an exist- ing program into the Editor (see Figure 5). These program files (with the suffix .bas) are plain text files that can also be viewed with Windows Note- pad or another editor program. This is called "source code" because the compiler uses the con- tents of these text files as the source for compila- tion. The compiled program is called "hex code" because the bytes are often shown in hexadecimal notation, always with two hex characters in the range 0-9 and A-F per byte. Numbers in the form of bits and bytes and the various notations used 34 April 2014 www.elektor-magazine.com Microcontroller Bootcamp for them will be a frequent topic in this series on microcontroller programming. You can type in the program in Listing 1 yourself or download it from the Elektor page. The file UNO_LEDl.bas is located in the zip folder [3]. Compiling the program is very easy: simply click Program/Compile, click the corresponding icon on the toolbar (a black IC), or press the F7 key. If there is any sort of error in the source text, an error message will be displayed. If there are no problems, a pop-up window shows what per- centage of the memory is occupied. In this case it is less than 1%, which is rounded down to 0%. What matters is the resulting hex file UN0_LED1. hex or the binary file UNO_LEDl.bin, which are two different file formats with the same con- tent. They contain the executable code for the microcontroller. Now you have to load this code into the microcontroller's flash memory. There are many ways to do this, and for now we only describe the simplest way. Other options will be described in subsequent instalments. The simplest way: use the boot loader This program must be located in the microcon- troller's flash ROM in order to run on the micro- controller. Flash ROM is a special type of memory, similar to EEPROM, in which electrical charges ensure that the memory contents are retained reliably for many decades. Flash ROM can be rewritten repeatedly ("flash" refers to very fast writing), so programs stored in flash memory can always be altered at a later date. Special pro- gramming devices are available for programming flash memory. They are connected to specific pins of the microcontroller, and the program bytes are received from the development environment on the PC via the USB link. However, this can also be done without a pro- gramming device. When the Arduino board has a USB connection to the PC as mentioned above, the program bytes can be sent to the micro- controller over the USB link as long as there is a small program running in the microcontroller that receives the data and writes it to the micro- controller's flash memory. This small program is called a boot loader, which is related to the expression "booting up" for start- ing up a computer. This term originates from the word "bootstrap" in the saying "pull yourself up by your bootstraps". Of course, pulling yourself out of the mud by tugging on your bootstraps doesn't work in practice, and likewise a micro- controller with nothing in its program memory cannot program itself. However, this is possible if a boot loader is already present in memory, and the Arduino comes with a built-in boot loader. The development environment on the PC also has to be able to download program code using the Arduino boot loader. Fortunately, Bascom devel- oper Mark Alberts already guessed that some- one would want to program an Arduino board in Bascom at some point in time, so this capabil- ity is already incorporated. After you configure the right settings, everything is quite easy. Here we describe how this works with the demo ver- sion, since there is a small difference with the full version. First you have to install the original Arduino soft- ware available from [4], which includes the USB driver for the Arduino Uno board. Then you con- nect the Arduino Uno over a USB cable. The driver is loaded automatically, after which the Arduino Uno should be visible in the Windows Device Man- ager window. There you can see which COM port number (e.g. COM2 or COM3) has been assigned to the Arduino Uno. If you wish you can change the COM port number in Device Manager, but this is usually not necessary. However, you should note or write down the COM number. If you wish, you can also open the Arduino IDE and try out a couple of sample programs. However, here we want continue straightaway with Bascom. In Bascom you can choose from a large variety of programming devices and boot loaders under the menu item Options/Programmer. The right setting is "ARDUINO" (not "Arduino STK500/2"), as shown in Figure 6. It's also important to con- Figure 6. The settings for the Arduino boot loader. www.elektor-magazine.com April 2014 35 •Projects Figure 7. figure the right COM port (in this example COM2), The compiled program in and it's essential to configure the right baud rate the form of hex numbers. (115,200). This is because both parties must agree on the data transmission rate in bits per second (baud). We'll come back to this subject later on in the course when we talk about send- ing messages and measurement data to the PC. If you only go by the Bascom help and the exam- ples included with Bascom, some of your settings will be wrong here because the Arduino Uno is relatively new and the Arduino camp has only recently changed to the highest standard trans- mission rate of 115,200 baud. All in the interest of fast data transfer and correspondingly super- fast device programming. Time is scarce in our fast-paced era. In Figure 6 you can see that the option "Auto Flash" has also been ticked. This saves a mouse click later on, and it reduces the risk of doing something wrong. The "Terminal Emulator" option is also very helpful if you want to have programs send messages and data to the PC later on. Once the right settings have been selected, close the window with ESC. That's the previously mentioned difference between the demo version and the full version, which has an "OK" button. If you don't know about using the ESC key, it looks like the program is stuck. Incidentally, ESC also works with the full version. Now you're done, and it's time for action. As pre- viously mentioned, press F7 to compile the source code. Then press F4 to start the programmer. Alternatively you can click the small green PCB symbol "Program Chip"; the result is the same. In any case, a new Programmer window opens. There the compiled program ( UNO_LEDl.bin ) is already nicely loaded and displayed in the form of hexadecimal numbers (Figure 7). Good job: it works! After this you can sit back and relax; the rest is automatic. Flowever, you can also do everything yourself. If you opt for this, you must be very careful because there is a function here that can completely erase the microcontroller memory, which means that the Arduino boot loader is also gone. Stay well clear of anything with the word "erase" in it. The only right option is "Chip/Write Buffer into Chip". Now you will see a long chain of messages in the programmer window, with the lovely word "Started" at the end. During the programming process you can see from the activity of the Tx and Rx LEDs on the Uno board that a lot of data traffic is going on. At the end the window closes again. The downloaded program starts running imme- diately after the end of programming, and the yellow LED blinks. It may be a tiny program, but it's a big step for you as the programmer. If you're not quite sure about all this, try making some small changes to the program. For example, you can change the blinking rate. For really fast blinking, change Waitms 500 to Waitms 100, or for very slow blinking change it to Waitms 2000. After editing the code, recompile it and repro- gram the microcontroller, and then check the result. If the LED does exactly what you pro- grammed it to do, there's no room for doubt: it really works! In the next instalment we turn our attention to inputs. ( 120574 - 1 ) Web Links [1] www.elektor.com/arduino [2] www.mcselec.com [3] www.elektor-magazine.com/120574 [4] http://arduino.cc/en/Main/Software 36 April 2014 www.elektor-magazine.com MasaooSaHa elektor post The Beginning ot a BeauilM frlenashlg " 3T r ' 5 ■StfElfilwii*? The latest on electronics and information technology Videos, hints, tips, offers and more Exclusive bi-weekly project for GREEN and GOLD members only Elektor behind the scenes In your email inbox each Friday S'ii-CDn based rife forms of the World. uniter EJeVsr.POSr M-e pTOffeh- , Shaw rj < .va ao c%. 1 ' n-auaarK, m ' J ***** D-#™ itmtrt* WlPl Ilf M »- n*l nnn ■ _ — . . ^ i«ir r*i &UT PWjrltf Ijr, lf L '*“* rflrrjmiTO tlTM ^ V/N tup» EPJ1I Rlifeio.-pOST Ml frtf 1 M **" | J ivsfc aivta aj FiAcipwiri pmtluj lektor if ***** H<,n «3» bwrtaTftMj 0«aw EleKtw.TV goes Linux c * Mc * *5fln Jm BiMf btMiMnn nt WMGH IT ON ELEKTOft.TV »» Register today at www.elektor.com/newsletter i i Benefit now: Elektor PCB Service offers a permanent 90-day launch discount on new Elektor PCBs! •Projects By Martin Ossmann (Germany) Current Transformer Calculations Understanding in-circuit current measurement To calculate current we normally use a shunt to turn it into a voltage and measure the latter instead. But if we wish to measure the current in isolation, then a current transformer is the thing to use. How you actually do this is what we shall now describe. This method has the disadvantage that direct currents (DC) cannot be measured. Nevertheless there are numerous applications, for example in switch-mode power supplies, where the curve shape is the item of interest and we can dispense with the DC component. Circular cores are often employed in current transformers. The current being measured is taken through a ring core (Figure 1). A sec- ondary winding is added to the ring core and 'short-circuited' using a shunt resistor. The volt- age across this shunt is measured with the oscil- loscope. Figure 2 illustrates the result of this kind of measurement. Our pulse voltage source covered in the January/ February issue [1] provides the 10 V impulses used here (blue trace). Using a 20 Q resistor produces 500 mA current impulses, arising from which we get shunt measurement impulses of 50 mV (red trace). The current transformer pro- duces pulses of 5 mV. The frequency is 250 kHz. In fact the result looks very promising, with the current transformer doing a good job of reproduc- ing the shape of the square-wave signal pulses. A problem arises if we drop the frequency to 50 Hz (Figure 3); the current transformer no longer reproduces the square-wave signal cor- rectly (green trace). Equivalent circuit for a transformer Constructing a rent probe with cur- a ring core calls for a good con- cept model of the current transformer that will result from it. That's what we will now discuss. A transformer consists of a primary winding (Index 1) and a secondary winding (Index 2). The number of turns in each coil is n 1 and n 2 . We can measure the so-called no-load inductances L l0 and L 2o (Figure 4). If the primary and sec- ondary windings are fitted to the core in the same way, we can also calculate these with the help of the value A L . That is to say: Z_ io = r? x 2 x A l and L 2o = n 2 2 x A L The ratio of the number of turns is then N = n 2 / n 1 . For instance, with a core made of Vit- roperm with A L = 80 pH / turns 2 the following arises: The reason for this will be discussed in a moment. Using circuit modeling we can establish how to dimension a current transformer of the kind required. n 1 = 1 L l0 = 80 pH n 2 = 25 L 2o = 50 mH N = n 2 / n 1 = 25 Another characteristic of interest with transform- 38 April 2014 www.elektor-magazine.com Current Transformers ers is the coupling factor k. We can determine k by measuring the short-circuit inductance. If we short out the secondary, in our example we find Z_ lk = 0.2 pH. On the other hand, if we short out the primary we measure L 2 k . However, this value is not independent of the other three and is in fact: ^-2k x ^-lo “ ^-lk x ^-2o = ^ This relationship enables us to calculate, for example, L 2 k . In our example this turns out L 2k = Ll '\ Ll ° =125 nH L lo The coupling factor arising from this is: 0.9987492178 In this case it turns out to be very close to unity (1), meaning that a current transformer using a ring core is virtually ideal. The three characteristics L l0f L 2o and L lk complete the description of the transformer. To define the relationship of transformer we use an equivalent circuit. The generic form of this is shown on the left-hand side of Figure 5. It consists of an ideal transfer device (trans- former) with a transfer ratio of 1:M. We then have a main (or magnetization) inductance L m , the primary stray inductance L ls and the secondary stray inductance L 2s . Since the equivalent circuit contains four characteristics, we cannot specify it unambiguously but can select certain charac- teristics freely. Consequently the elements do not have direct physical counterparts. From now on we will use the equivalent circuit shown on the right-hand side of Figure 5. This has the primary stray inductance Z_ s , arising directly from the short circuit measurement L s = L lk . The main inductance L m results from the no-load measurement / turns formula: ^-m ^-2o ^2 2 X A\_. The transfer ratio M is worked out as: M = N / k = 25.0313... * N. As the coupling factor is virtually 1, M is almost Figure 1. Ferrite ring used as a current transformer. Figure 2. Current measurement of a 250 kHz square-wave signal using a current transformer. Figure 3. Measuring a 50 Hz square- wave signal with a ferrite ring. Figure 4. No-load and short circuit measurement in a transformer. www.elektor-magazine.com April 2014 39 •Projects Figure 5. Equivalent circuit of the transformer. Figure 6. Equivalent circuit of the current transformer. Figure 7. Current measurement set- up using transformer. R 2 n-L m R ' K N 2-n ■ A L - N 2 Dimensioning With these insights we can next assess how to dimension a current transformer. If we make R larger, the voltage signal increases, but so does the lower cut-off frequency, meaning we can no longer measure low frequencies (simultaneously the voltage drop on the primary side increases). The choice of R is therefore a compromise. Since oscilloscopes often display voltages in the mV range poorly, we should make R sufficiently large that moderate currents produce a voltage of sev- eral tens of mV. Now we come to the number of turns. Raising N reduces the transfer impedance and with this, the voltage produced. At the same time, however, L m gets larger and that reduces the lower cut-off frequency. Here too we must accept a compro- mise. Additionally we note that a higher value of A L helps, because it lowers the boundary fre- quency, without affecting the transfer impedance. exactly the same as the ratio of the number of turns. We have now defined all the elements of the equivalent circuit (Figure 6). Using these elements we can now carry out simulations in SPICE for example. Ferrite ring core By way of example we will calculate the param- eters (using a ferrite ring core) with a value for A l of around 3 pH / turns 2 . If R = 0.5 ft and N = 25 we get: We now allow the current being measured (/) to flow through the primary. On the secondary side we connect a (small) resistor R and measure the voltage on it. Since the stray inductance lies in series, it has no influence on the current flowing through the transformer. The transformed cur- rent I/M on the secondary side passes through the parallel circuit of Z_ m and R to produce the voltage measured U. For current transformers we normally have n 1 = 1, producing N = M = n 2 , which we shall now take as a given. When the frequency of current I is sufficiently high that the coil impedance is significantly greater than R, we can ignore L m and simply say U = R x I / N. The transfer impedance is thus R tr = U / I = R / N. Using a complex AC calculation we can now recalculate that a sys- tem of this kind constitutes a high-pass with the cut-off frequency R 2N 0.5Q 50 0.01Q R 2-7t-A L 'N 2 = 42 Hz The factor of 2 in the denominator for the trans- fer impedance arises from the two 50 ft resistors R1 and R2. These match the signal to a 50-ft cable, creating a voltage divider that reduces the signal by half (Figure 7). At a current of 1 A we obtain 10 mV on the oscil- loscope, which is not a lot. The lower cut-off frequency is around 50 Hz, so with a ring core of this kind 50 Hz signals can be measured only with significant error. Vitroperm, a magic material A German company called Vacuumschmelze GmbH manufactures a material called Vitroperm, 40 April 2014 | www.elektor-magazine.com Current Transformers which possesses very high permeability (at low frequencies). Below 1 kHz their ring core (type T60006 L2025-W380) has the A L value of around 80 pH/turns 2 . This reduces, with other param- eters, the boundary frequency to around 2 Hz. With this kind of core we can now construct a current probe that can be deployed without prob- lem below 50 Hz (Figure 8). A few words still need to be said on the 'inter- nal' resistance of the current probe. Shunt R on the secondary is transformed on the primary side by a factor of 1/A/ 2 . So if we use R = 0.5 Q. and N = 25, the effective resistance on the primary side amounts to precisely 0.0008 Q, which can be ignored in normal situations. Admittedly there is still a stray inductance L lk = 0.2 pH in series with this, representing an impedance of 1.2 ft at 1 MHz. The viability of the current transformer for higher frequencies is restricted by parasitic capacity and so on, but our simple example will make measure- ments into the MHz region without any problem. (130410) Web Links [1] www.elektor-magazine.com/130005 [2] www.elektor-magazine.com/130410 Figure 8. Vitroperm core. Advertisement 3 ■ ■ ^ Q Add USB to your next project, w O D It's easier than you might think! DLP-USB1232H: USB 2.0 UART/FIFO HIGH-SPEED 480Mb/s • Multipurpose: 7 interfaces • Royalty-free, robust USB drivers • No in-depth knowledge of USB required • Standard 18-pin DIP interface; 0.6x1 .26-inch footprint DLP-I08-G 8-Channel Data Acquisition Only $29.95/ • 8 I/Os: Digital I/O Analog In Temperature • USB Port Powered • Single-Byte Commands DLP-IOR4 4-Channel Relay Cable DLP-THIb Temp/Humidity Cable DLP-RFID1 HF RFID Reader/Writer DLP-FPGA USB-to-Xilinx FPGA Module www.dlpdesign.com LCR + Stability Measurement Use the Cleverscope FRA panel to easily auto plot Gain/Phase, Impedance, Capacitance or Inductance vs Frequency. Display the Gain and Phase Margin. Check for instability. Easy As, with Cleverscope. — A ~ ii i - chM ■ h i . a ; f / ■ . ■ - ■* . wfa. : ■j. znaiid- > SHHOtflt* JUsd kv Mir- | ■ l: W OO'Ji JtM'l: 1.0M 4^- Mq: -«r -T- W V T See our FRA tutorial video to show you how to verify your operating power supply or amplifier design. Check the impedance of your DC buses. Verify magnetics you have wound. 80 dB dynamic range! 0 - 65 MHz isolated Sig Gen. 9 *Sli aai- > 3TOi- mu - ■ -Ltt ‘’rt «] lOOuH toroid Streaming 100 G samples to disk ♦ ♦ Protocol Analysis • Symbolic Math • Matlab Interface • 80 dB dynamic range *100 MHz Bandwidth • Tracking Zoom • 0-65MHz isolated sig gen • Video Tutorials CS328A-FRA rr 1 4 Bit MSO 14 www.cleverscope.com www.elektor-magazine.com April 2014 41 •Projects Precision Adjustable DC Current Source With integrated hi-Z voltmeter By Henry Morizot (France) Parroting the Science Class teacher an adjustable current source consist of any old voltage source, a variable resistor and applying Ohm's law, right? In Elektor Class, the project described here is the next dimension after/ equals V-over-R, offering precision and versatility rivaled There are numerous ways to build direct-current (DC) sources, mainly depending on the required characteris- tics: current strength, fixed or adjustable, single or dual polarity, floating or grounded load, precision, anything else? The lowliest of schematics is no more than a voltage source and a resistor. But as soon as you want some precision regardless of load current, you have to resort to a voltage-to-current con- verter using one or more operational amplifiers. The reference paper from Jerald Graeme [1] is recommended reading on the subject. In principle For our needs— which includes sourcing very low current reliably— the topology should take into account measuring the voltage across the load without stealing current from it. A theoreti- cal configuration as shown in Figure 1 is based on two operational amplifiers. The first one (Ul) generates the current and the second one (U2) isolates the measuring circuit from the load. Both amplifiers are unity-gain (xl) connected, hence do not require any precision resistors. The principle of operation: a secondary current source J x feeds reference diode D1 connected to amplifier Ul's input with the diode return con- 42 April 2014 | www.elektor-magazine.com Precision Adjustable DC Current Source nected to amplifier U2's output, whose input is connected to the load. A resistor Rs is connected between amplifier Ul's output and the load. Disre- garding errors in the amplifier, the output voltage on each of them is the image of their respective input voltage. So the voltage across R s becomes equal to the reference voltage V ref from Dl. This constant voltage developed across R s induces a constant current Rs sourced by amplifier U1 and flowing exclusively through load Z Ld , provided the bias current with amplifier U2 is insignificant. Manual switching of different values for R s affords outputting any current across a very large range. The reference voltage selection is all but triv- ial. Appearing like a wasted voltage, you could attempt to make it as small as possible, but this is defeated by multiple error sources. First of all, the amplifiers "suffer from" initial offset voltage and common mode rejection ratio (CMRR). Actu- ally, the voltage developed across R s resistor is not exactly the same as that present at the ref- erence. More precisely, this voltage could even deviate up to the following value: Main Specifications • Low Ranges (10): lOnA - lOpA • High Ranges: (10) lOpA - 20mA • 3.5 Digit LCD Readout • Battery Powered (4x AAA) • Extendable as a High Impedance Voltmeter (optional) • Microcontroller Free value of 20 mA, again using the 100-mV refer- ence will require a resistance R s of 5 ft. If the rotary switch represents a contact resistance of 100 mft, this yields an additional 2% error, to which we should add the error induced by intrin- sic printed circuit track resistance. Conversely, if we choose a higher reference voltage, say 10 V, added to some wasted energy, we will be faced with the difficulties inherent to tiny currents. First there is the value of R s \ to obtain, say, 10 nA (nanoamps) we'll need a 1-Gft resistor— expen- sive and not easy to find with a tight tolerance. Next, at the resistor switching level, the finite insulation resistance of the rotary switch will be in parallel with this very large resistance and affect the required value. And still here, do not forget that the printed circuit itself is not a per- fect dielectric. Vn,^=V^+V. + VL (Rs) v ref v os(U 1 ) y os (U 2 ) + V, ex CMRR + V. ex (C/1) CMRR, (U 2 ) where V os = initial offset voltage; l/ ex = common-mode voltage; CMRR= common-mode rejection ratio. Finally, we should reject any "exotic" value for the reference voltage (for example 1.235 V) because this value inevitably leads to "exotic" values for the R s resistors themselves. In this project, the reference voltage was chosen at 1.00 V, a satisfactory compromise. For example, if both amplifiers are specified for an offset voltage of 2 mV and a common mode rejection ratio of 78 dB; and if voltage extension is 20 V, we could obtain in the worst case: l/ (Rs) = V ref + 9 mV, and if we choose V ref = 100 mV, we can have an error up to 9%! Fortunately, because all terms of the sum are polarized and may compensate themselves, this worst-case deviation is statistically unlikely, but it gives a good idea about a possible loss of precision. Secondly, it is important to take into account the mechanical switching of the resistors defining the output current. For example, to obtain a current Figure 1. Theoretical model of a near perfect current source. www.elektor-magazine.com April 2014 43 •Projects Into the schematic Fig ure 2 shows the schematic of the instru- ment. Its design is Analog Electronics Paradise and deserves a thorough discussion. Not a micro- controller in sight. References The current needed by the floating source ref- erence is obtained from a current mirror com- prising transistors T2 and T4. The master cur- rent of 215 pA through T2 comes from resistor 44 April 2014 | www.elektor-magazine.com Precision Adjustable DC Current Source This circuit contains a FETish diode chain R55, R67 shunted with P4, and R68. R67 minimizes impact from the large tolerance of pot P4, which delivers the output limiter adjustment voltage typically spanning 0.8 V - 20.4 V. The 1 : 1 ratio of the current mirror output at T4's collector supplies the bias current for reference diode D4. T2 and T4 not being matched, emit- ter resistors R50 and R51 counteract a possible unbalance. The resistor divider made up of R56, P3 and R60 allows precise adjusting of the source reference to 1.000 V. We've chosen an LT1004CZ voltage reference from Linear Technology, but it is also possible to use a slightly less temperature com- pensated type like the LM385BZ-1.2 from National Semiconductor. Measuring amplifier The bias current of measuring amplifier IC8 being an error term algebraically added to the source current, it is important to keep it insignificant relative to the minimum output current of 10 nA. For this reason, the amplifier is an AD820AN from Analog Devices which has JFET inputs having an extremely low bias current. It's quite a vintage device (20-year old), but possibly the only one to accept a single supply up to 30 V with rail- to-rail output and rather high precision. Very likely, it's still available because of that, even in a DIP package. Neglecting the offset voltage, the output voltage of the unity-gain connected amplifier is the image of its input voltage. This output sinks the return current from the voltage reference. It sources some current for the voltmeter input attenuator and also for the negative branch of voltage lim- iter indicator's differential amplifier. In the measuring circuit, diode D5 inserted between load return and Ground plays an import- ant role, assuming in fact a triple function. Its main object is to raise the load return potential of a few hundreds millivolts, allowing the mea- Figure 2. Schematic of the Precision Adjustable Current Source. The circuit has a lot of clever analog design aspects to it. The light lines indicate wiring in the air. suring amplifier IC8 to always work in a linear region. Everyone knows that operational ampli- fiers exhibit a lot of defects when approaching supply rail levels, especially the open-loop gain which collapses drastically. This causes an output offset voltage of a few up to hundreds of mil- livolts, depending on amplifier design and load conditions, mainly if the output has to source or sink current, the latter being the worst case around ground rail potential. The sourced current— even the tiniest— always flows through D5, except when using the instru- ment as a voltmeter only. In that case, there is nothing except the current caused by the voltme- ter's input attenuator, unfortunately proportional to measured voltage. In order to get a significant voltage drop across the diode, a tiny current is added, made up of two components: the collector current from T8, defined by the input resistance R58 + R63 with differential amplifier IC7B (and inversely proportional to the clamping voltage), and on the other hand the current sourced by amplifier IC7A through R66 (and proportional to the clamping voltage). The sum of these currents is nearly constant and about 20 microamps, caus- ing a minimum voltage drop of approximately 420 millivolts. Secondly, the voltage drop across D5 compen- sates for the voltage drop across 'clamping diode' (FET) T9 of the voltage limiter, thus making the clamping voltage across the load independent of the current sourced. Actually, this is not per- fect because this compensation is only effective for currents above the smallest current forced through D5 as previously described. Also, the characteristics of diodes T9 and D5 are slightly different. That's why D5 is a type 1N4001, its voltage vs current slope resembling that of clamp- ing diode T9 closer than a small signal diode like a 1N4148. Ideally, D5 would be identical to T9, but considering the cost of the latter, this is not essential because that compensation is only a secondary parameter. Finally, in the case the instrument used as a voltmeter only, D5 together with resistors R61 and R64 protects the components against exter- nal voltages up to about 30 V, irrespective if the instrument is powered or not. www.elektor-magazine.com April 2014 45 •Projects Normally, a high-impedance voltmeter is only used with high-impedance sources themselves and having such a low short-circuit current sug- gests inability to cause damage, but one never knows... Current generator Output current is obtained from amplifier IC6, the same type as that used for the measuring amplifier (AD820AN), the characteristics needed being nearly the same. It is unity-gain connected and buffered by transistor T6, the amplifier itself being unable to source the maximum required current of 20 mA. Neglecting the amplifier offset voltage, the out- put voltage on T6's emitter is the image of the reference voltage at the wiper of P3, and this output is connected to the high-end common point of current selection resistors. On the other hand, through unity-gain measuring amplifier IC8, the low-end of the reference voltage is itself the image of the voltage present at the low end of the current selection resistor. Thus, the voltage across the current selection resistor is the image of the reference voltage, and this very voltage is applied to that resistor which in turn generates the required current. Base-emitter resistor R59 with T6 implements a selection according to the output current. For currents up to 100 pA, the amplifier alone sources the current through this resistor, and then starting from 200 pA, the transistor operates as a buffer. Moreover, R59 sinks the leakage current of tran- sistor T6 if it is greater than the required output current. This phenomenon may appear under exceptional circumstances, like if the instrument outputs the maximum current of 20 mA for some time into a zero or almost-zero load— the tran- sistor dissipates about 460 mW, which raises its junction temperature of nearly 115°C, caus- ing significant leakage current. If immediately afterwards you want the instrument to output the minimum current of 10 nA, the leakage cur- rent may be temporarily greater than this value, requiring the amplifier not to source current, but rather to sink the excess. Surge current limiter When the ratio between 'open-circuit' and 'load-applied' voltages is significant, the result- ing surge current may vastly exceed the final value during the few microseconds needed for the amplifiers to stabilize. Despite more than 10 years experience on the previous instrument ver- sion without any damage on checked components, a surge limiter is included here in the form of a JFET transistor which acts by momentarily cut- ting off the load from the current generator. JFET transistors are subject to large tolerance in terms of electrical characteristics. Consequently users have to check that the transistor to be mounted is able to fulfill its function. This can be done easily with the test circuit described further on. As with measuring amplifier IC8, the gate current of transistor T5 is an error term added to the sourced current. Flowever, with the type of transistor men- tioned, this current is extremely low because of the small reverse voltage applied (1.7 V max.). Another simple and efficient but more constrain- ing way to eliminate the surge current consists of adjusting the voltage limiter to the minimum 46 April 2014 | www.elektor-magazine.com Precision Adjustable DC Current Source before applying the load, and then increase it until the clamping indicator turns off. Current selectors Output current selection is obtained by manual switching of resistors. Because of the large num- ber of current values (20), this selection is split into two ranges: high and low, allocated to rotary switches S3 and SI with 12 positions. An "OFF" position outputting no current allows the instrument to be used as a simple high-imped- ance voltmeter, but with some limitations (see the section on the voltmeter). In that mode, there is also a voltage limiter disconnect option consisting of a microswitch actuated in the "OFF" position. As you can see, the spread of the current selec- tion resistor values applied is rather low, thanks to some series and parallel combinations, even if it means slightly more resistors. The precision of these resistors directly affects the output current precision. For such an instrument, a 1% tolerance is enough and moreover easy to get. Voltage limiter Voltage limitation is done by the unity-gain con- nected amplifier IC7A buffered by complementary transistors T7 and T8, the output being connected to the load through T9 acting as a clamping diode. Voltage limiting is adjustable with the front panel mounted potentiometer P4 from approximately 1 V up to 20 V. Transistor T8 begins to sink the output current as soon as the voltage across the load is greater than that present at T8's emitter, the clamping diode T9 getting forward biased. Transistor T7 is only useful during the reverse recovery period of T9 to extract the charges previously accumulated. This time, the chosen amplifier is an LT1490A from Linear Technology (everyone has to live), a micropower dual version with rail-to-rail input and output, operating off a single supply up to 44 V and still available in a DIP package. Like the measuring amplifier input, the leakage current of FET-ish diode T9 is an error term which must be insignificant up to a reverse voltage of 20 V. In the previous instrument version, this diode was an ultra-low leakage type BAV45, but unfortunately it is today quite impossible to find. A good alternative is to use the gate- source diode from JFETs like 2N4391..4393 or J201...203 (source connected to drain being the cathode). Caution! Unless having them selected, do not use the plastic case series PN4391...4393, which are specified with a gate reverse current up to 10 times higher. Voltage limit visual indicator The voltage limit indicator is comprised of dif- ferential amplifier IC7B, transistor T3 and LED D3. By way of unity-gain connected amplifier IC8, the differential amplifier measures the volt- age across "diode" T9. This amplified voltage appears between amplifier output and the pos- itive supply rail, and not ground as you might expect. The arrangement saves energy, the LED current being drawn from the supply current of amplifiers IC7 and IC8 (about 1 mA total), these amplifiers suitable for powering with a voltage slightly smaller than that required for current source amplifier IC6. The only requirement is to use a high efficiency red LED with an intrinsic low www.elektor-magazine.com April 2014 47 •Projects Figure 3. The printed board is populated at two sides. See also the notes and photographs covering components "in the air" forward voltage (about 1.6 V at 1 mA). By means of resistors R52 and R54 this configu- ration referenced to the positive supply rail also provides one of the components needed for the minimum current required through D3. If T9 is reverse biased (limiter off), the output of IC7B swings high, switching T3 into conduction, effectively shorting out the LED. Conversely, as soon as T9 becomes forward biased at about 250 mV, the amplifier output voltage drops low, switching the transistor off and causing the LED to light. This 250-mV threshold across the diode corresponds to a current of about 10 pA, equal to 0.1% of the minimum output current. Conse- quently the LED lights as soon as there is a hint of voltage limiting going on. It's fair to ask why have gain on the differen- tial amplifier IC7b and then kill it by a resistor divider to drive T3. Why not have the compos- ite gain and a direct drive of the transistor? It's merely because the output of the amplifier cannot go beyond the supply rail and so cannot drive the base of the transistor more positive than its emitter, meaning the LED would remain on all the time. Another reason for the presence of the resistor divider is to not approach the ava- lanche voltage of T3's base-emitter junction if the amplifier output drops low. When the instrument is used as a voltmeter only, this could occur if the voltage limiter disconnect option is installed and the limiter not adjusted to the maximum value. Exactly in that case the LED indicator could even be used as a voltage threshold indicator by adjusting the limiter accordingly. Component List Resistors R1,R55 = 12kft 5% 400mW R2,R40 = 180kft 5% 400mW R3,R10 = 50Mft 1% 1W R4,R15 = lOMft 1% 600mW R5,R6,R7,R11,R12,R13,R16,R21,R22,R57,R58 ,R66 = lMft 1% 500mW R17 = lMft 0.1% 250mW R8,R14,R26,R27,R67 = lOOkft 1% 500mW R19 = lOOkft 0.1% 250mW R9,R54 = 56.2kft 1% 600mW R18,R53,R56 = 4.64kft 0.5% 250mW R20,R25,R44,R47,R48,R65 = 680kft 5% 500mW R23 = l.lkft 1% 250mW R24 = lOkft 0.1% 250mW R28,R29,R30,R37 = lOkft 1% 500mW R31,R32,R33,R38 = lkft 1% 500mW R34,R35,R36,R39 = 100ft 1% 400mW R41,R42,R43 = 220kft 5% 500mW R45 = 0.47ft 5% 1W R46,R49 = llkft 1% 500mW R50,R51 = 330ft 5% 500mW R52,R60 = 21.5kft 1% 600mW R59,R68 = 3.6kft 1% 500mW R61,R64 = 5.6kft 5% 500mW R62,R63 = 68.1kft 1% 600mW R69 = 0.1ft 5% 1W P1,P3 = lkft multiturn preset P2 = 50kft multiturn preset P4 = lMft miniature cermet potentiometer Inductors LI = 680pH 980mA 0.46ft L2 = lOOpH 580mA Capacitors Cl = 47pF 5% C2,C14,C17,C19,C20 = lOOnF 20% C3 = lOnF 10% C4 = 470nF 5% C5 = 47nF 1% 160V polypropylene C6,C9 = lOOpF 35V radial 20% C7,C10,C11 = lpF 63V 10% C8 = 2.2nF 100V 10% C12 = 22pF 200V 5% 48 April 2014 | www.elektor-magazine.com Precision Adjustable DC Current Source Power supplies The instrument is runs off 6 volts nominal sup- plied by four alkaline 1.5-volt AAA cells. Three internal voltages are generated : +23.8 V for the current source, +4.2 V and - 4.2 V for the voltmeter. The 23.8 V voltage is the minimum value required to ensure correct operation in the worst case. This voltage is obtained by a classic switching regulator type LM3578A from National Semiconductor, and it is adjustable with trimpot P2. Additional output filtering by L2 and Cll reduces the ripple on the supply rail. The +4.2 V supply is obtained from an LP2951 micropower adjustable linear regulator from National Semiconductor. The output voltage is fixed by resistors R49 and R53. This regulator also includes a comparator, switching whenever the output falls out of regulation by about 5%. The comparator output is used to activate the Low Battery indicator on the voltmeter display. The 4.2 V level causes the LO BATT indicator to be turned on when the battery voltage falls below 4 V, which leaves a comfortable time margin, the instrument remaining fully functional down to approximately 3.5 V. The -4.2 V rail also needed for the voltmeter supply is obtained from the +4.2 V section by means of an ICL7660 charge pump converter from Intersil. Integrated voltmeter The integrated voltmeter is a very classic 2-Kcounts type. It is based on an ICL7136 A/D converter from Intersil, directly driving a V 2 -inch C13 = InF 100V 5% C15,C16,C18 = 2.2|jF 25V radial tantalum Semiconductors D1,D4 = LT1004CZ-1.2 D2 = 1N5818 D3 = LED, red, low current, 3mm D5 = 1N4001 T1,T2,T4,T8 = BC557 T3,T6,T7 = BC547 T5,T9 = 2N4392 IC1 = ICL7136 IC2 = CD4070 IC3 = LM3578AM IC4 = ICL7660 IC5 = LP2951ACM IC6,IC8 = AD820AN IC7 = LT1490CN8 Miscellaneous SI, S3 = 1x12 rotary switch, Grayhill 56SD30- 01-1-AJN (Digikey # 440-7657) S2 = 3x4 rotary switch, TE Connectivity Al- coswitch (1186546) S5 = PCB mount slide switch, Knitter Switch MFP201N (134-0113) LCD1 = LCD module 3.5 digit, transflective, Varitronix VI302-DPRC (Digikey # 1183159) TP 1 ,TP2 ,TP3 ,TP4,TP5 ,TP6,TP7 ,TP8 ,TP9 ,TP 1 0 ,T- P11,TP12,TP13 = test pin, 1mm diameter, Stelvio Kontek 3110014000540 (Digikey # 305-0913) K2 = test terminal PTFE, ITT Canon 011-1004- 040FB9 (1347796) Insulated terminal 30A, black (2112490) Insulated terminal 30A, red (2112491) Black cap knob, 1/4" shaft (1209791) Black cap knob, 11.6mm for 1/8" shaft (Digikey # 259-6812) 2x holder for 2 AAA batteries Enclosure: Teko Coffer A/7, dim. 160x95x45mm 4 x Hexagonal PCB spacers (see text) PCB # 130287-1 from Elektor Store (Numbers only in round brackets are Newark/ Farnell order codes) www.elektor-magazine.com April 2014 49 •Projects Figure 4. Not a PCB design error, this: To avoid stray leakage currents, components and a wire are soldered directly to the pins of the range selector switch. PCB tracks simply are not up to this task. Figure 5. The + input of the instrument is a star junction with components connected in the air rather than to lossy PCB tracks. Figure 6. A microswitch attached to the PCB and wired into the circuit creates a high- impedance voltmeter option on the instrument. high 372-digit LCD. The measuring reference volt- age is obtained from an LT1004CZ reference diode, the same as that used for the current source. The resistor divider made up of R9, PI and R18 allows precise adjustment to 100.0 mV. The front panel accessible trimpot permits voltmeter calibration without opening the case. Quadruple XOR gate IC2 is required for the dis- play to drive both the decimal points and the Low Battery indicator. The latter is driven by the com- parator in IC5, via T1 doing the level conversion. Voltage measurements at the instrument ter- minals capitalizes on the intrinsic capability of differential inputs on the A/D converter, the load return not being grounded, but instead connected to the anode of diode D5. The 4-position rotary switch coupled with an input attenuator allows selection of either the 2 V or 20 V range for output/input voltage, and the 20 V range for limiter voltage and battery voltage. Thanks to its current source disconnection capa- bility, the instrument can be used as a voltmeter only with a very high input impedance. However, this function comes with the following restrictions: • the current selector must be in the "OFF" position; • the voltage limiter must be adjusted to the maximum value of 20 V (except if the volt- age limiter automatic disconnect option is installed); • the voltage to be measured must respect the instrument polarity (however, it is still possible to measure a reverse voltage up to approximately 400 mV); • the input voltage must not exceed 20 V (nev- ertheless, the instrument powered or not is protected against voltages up to about 30 V). Construction The care and precision used in designing this instrument should be reflected fully by your con- struction on board # 130287-1 of which the two overlays (front side and rear side) are pictured in Figure 3, together with the Parts List. For obvious reasons the range selector section should not exhibit high contact resistance, jit- ter, leakage resistance or stray capacitances. Figure 7. The board and the front panel are secured with hex PCB spacers to make up a solid assembly. 50 April 2014 www.elektor-magazine.com Precision Adjustable DC Current Source Hence the switches high-end types you should not attempt to replace by cheap devices. Basi- cally for the same reason the 10-Mft and 50-Mft resistors are directly wired on the rotary switch contacts. What you see in Figure 4 is a not a quick & dirty fix but a necessity. A star point is available at K2, the + measure- ment terminal of this circuit. Look at Figure 5. A red, insulated banana socket is mounted on the front panel. There is a hole in the PCB close to that for the red socket. A PTFE (Teflon™) test terminal is press fitted into this hole and the fol- lowing connections are soldered to it: • the gates of T5 and T9; • R64, which is 'mounted in the air' between this terminal and IC8. Note that pin 3 of IC8 is bent out of its socket terminal to solder straight to R64; • a wire to the common contact of S3; • a wire to the red terminal on the front panel. Components are mounted on both sides of the PCB— check the PCB overlays and the pictures in the photographs at various places here to see which component goes where. The LCD is mounted on top of IC1 using two stacked socket strips to get it at the correct height. Some remarks on S4— this switch can be used to use the circuit as a high-impedance voltme- ter. Note: S4 is drawn in 'current source' posi- tion in the schematic. The most elegant solution (also mechanically most complicated) is to use a microswitch that registers position 1 of rotary switch S3. This microswitch is attached to the PCB or mounted to the back of the front panel. An extender attached to the shaft of S3 (discussed below) actuates the lever on the microswitch. Luc Lemmens at Elektor Labs glued two M2 bolts to the PCB— it's a bit tricky to get the microswitch to register in the correct position, but it can be done, see Figure 6. Another, slightly less com- Advertisement Create Complex Electronic Systems in Minutes Using Flowcode 6 Flowcode is one of the World’s most advanced graphical programming languages tor micro- controllers (PIC, AVR, ARM and dsPIC/PIC24). The great advantage of Flowcode is that it allows those with little experience to create complex elec- tronic systems in minutes. Flowcode’s graphical development interface allows users to construct a complete electronic system on-screen, develop a program based on standard flow charts, simulate the system and then produce hex code for PIC AVR, ARM and dsPIC/PIC24 microcontrollers. Design Simulate Download New in Version 6: • Component Library Expansion; • Improved Simulation; • New Test Features; • 3D Design Environment; • Third Party Instrument Support; • Dashboard HMI Components; • And More! Further Information and Ordering at www.elektor.com/flowcode www.elektor-magazine.com April 2014 51 •Projects plicated option is to add an extra SPDT (slide) switch for S4 to the front or side of the case. If the voltmeter feature is not wanted or needed, a simple jumper wire on the PCB can short S4 to permanently set current source mode. The shafts of rotary switches SI and S3 are too short to protrude through the front panel. Exten- Figure 8. sions for 1/8" shafts are difficult to find, although Suggested front panel layout suitable ones may be found in RC model shops, printed here at actual size. Diameters of 1/8" are commonly used there for shafts and spindles— Luc found some couplings there but these were too high to fit between the switch and front panel. Therefore we used an old, simple trick by removing the plastic from a small screw terminal block and using its metal parts as a coupling between the shaft of the switches and a 3.2-mm diameter metal shaft (a decapi- tated M3 bolt will do too). Space between PCB and front panel is tight; you may need to file the ends to make the coupling fit there. On S3, the shaft extender coupling can be used to actuate microswitch S4. The PCB is mounted to the front panel using four hex studs (12 mm height). We glued them to the backside of the panel with 2-component glue (for aesthetics' sake on the pictures). Sure, coun- tersunk bolts through the panel present a more durable solution. We used some washers between the studs and the PCB to be able to mount the LCD flush with the backside of the front panel. The finished board and front panel assembly is pictured in Figure 7. The arrangement of con- trols on the front panel is shown in Figure 8. Slide switch S5 (power) is originally a DPDT type, but we cut off three pins of the second switch to save space on the PCB. Two battery holders in series for two AAA cells each power the current source. One is mounted on the bottom of the case to the left and one to the right of the capacitors underneath the LCD. In a taller enclosure one holder for four batteries (even AA types) may do the job too. ( 130287 ) Reference [1] Precision DC Current Sources, Jerald Graeme, Burr-Brown Corp., EDN April 26 and May 10, 1990. 52 April 2014 www.elektor-magazine.com Professional Quality Trusted Service Secure Ordering ■o'* I! 'Jlektor PCB Sirvltf Md.fl KWd StlV*£«i M 4 f Hi f J pee n 4 * Goo:J f no* Elektor PCB Service at a glance: O 4 Targeted pooling services and 1 non-pooling service o Free online PCB data verification service o Online price calculator available O No minimum order value o No film charges or start-up charges service wo. isers havr ui: ±r rf to extend tieir ser ■ i" - V S tfllTKE. ir r~i ii-W -1 ] Jrt ■■■wj; . ^ ,aky i» & M taivwn KW'v «n i :tor ar mi Delivery from 2 workina days •Projects ATmega on the Internet (2) Using Raspberry Pi as a network gateway By Dieter Holzhauser (Germany) All you need for remote control of an ATmega32 microcontroller from your home LAN or the Internet is a second computer connected to the ATmega32 microcontrol- ler over a serial link. Here the second computer is a bare-bones design in the form of a Raspberry Pi. In this instalment we show you how to integrate the hardware described in the first part of this series into your home LAN and into the Internet. At the end of last month's instalment we had a microcontroller connected to a Raspberry Pi board over a serial link, and we used it to blink an LED under the control of a terminal. Controlling the demo program on the ATmega microcontroller using a keyboard and monitor connected to the Raspberry Pi is pretty close to remote control. However, if you really want to control your own electronic devices remotely your best option is to use your home LAN, or the Internet if you want access from anywhere in the world. Here we tell you how it works. Secure shell / SSH The terminal remote control arrangement described in the previous part can be extended to a LAN and to the Internet by using a secure shell (SSH). In the simplest case, SSH allows command lines from one computer to be trans- ferred over a network and appear on another computer. Data exchange with SSH is encrypted and is relatively secure. The term SSH stands for a network protocol and for the programs that use this protocol. The SSH program running in the background on the Rasp- berry Pi is the SSH server. It provides the SSH service. The service offered by the server is used by an SSH client. The computer hosting the client may be located in the same LAN as the Raspberry Pi or somewhere else, linked over the Internet. If you do not have Linux on your remote control computer, you can simply boot with a Linux Live CD. These CDs are often included with popular computer magazines. With the usual distributions you can open a console without any special instal- lation and run the SSH client as described below. The Linux system on the Raspberry Pi has a built-in SSH server. It can be activated under raspi-config (see Part 1). SSH on the LAN Naturally, a Raspberry Pi does not offer all the features of a full-fledged desktop PC. Neverthe- less, for some applications it makes sense to operate devices on the LAN under remote control via SSH without a monitor or keyboard. A LAN is a private local network, typically with Internet access, in which a network router such as the FRITZ! Box looks after all the details. The same protocols are used on LANs as on the Internet: TCP and IP. Devices on a LAN (called nodes) typically have their own private IP addresses. The router separates the LAN from the WAN, which means the Internet. In this way it screens the LAN and protects it against access from the Internet. Only the router appears on the Internet as a node with a public IP address (host). Although we focus on the German FRITZ! Box in this article, it is certainly possible to use other Internet routers with similar capabilities for the purpose described here. The detailed settings for the Raspberry Pi can be configured in the user interface of the FRITZ!- Box. Its IP address can also be seen there. You should configure the router so that the Raspberry Pi is always assigned the same local IP address. If the settings are configured as shown in Fig- ure 1 , the SSH client can be called from a Linux computer on the LAN by typing the following 54 April 2014 www.elektor-magazine.com ATmega on the Net command line: ssh pi@192. 168. 178.28 Another option is: ssh pi@raspberrypi The command line prompt of the Raspberry Pi appears after the user enters the password pi. Next you should launch picocom on the Raspberry Pi. If the demo program suidemol.c is running on the ATMega32, the lines with three blinking asterisks shown in part 1 will appear on the mon- itor. After closing picocom, you can type exit to close the ssh program. SSH on the Internet Establishing a SSH link over the Internet is basi- cally the same as on a LAN. However, the settings for this are considerably more complex because you have to connect a SSH client on the Internet to the SSH server on the LAN. This works the opposite way as the usual situation in which a browser on the LAN, acting as a client, requests pages from a web server and these pages are sent to the client over the Internet. The Inter- net router is prepared to receive incoming data because it comes in response to a request from the LAN. By contrast, unknown data arriving from the Internet, such as data from a SSH client some- where else in the world, represents a security risk. For this data to be received, it must pass through ports that are normally blocked on LANs. As components of complete internet addresses, ports correspond to numbers that are assigned to services on networks. For example, the stan- dard port for SSH is 22. To allow "unexpected" incoming SSH data to be forwarded to port 22 on the Raspberry PI, the router must be explic- itly configured to enable forwarding for this port. The SSH server of the Raspberry Pi then listens to this port. Figure 2 shows the FRITZ! Box port forwarding enable page for the SSH server on the Raspberry Pi. Remember to disable port forwarding when you no longer need it. Along with the number of ports for which for- warding has been enabled, the public IP address of the FRITZ! Box is shown on the overview page Details fur raspberrypi Auf dieser 3eite werden Detailinformationen zum Netzwerfcgerat bzw. Denutzer angezeigt. Name raspberrypi Zurucksetzen IPv4-Adre3se 192.168.178.28 0 Diesem Netzwerkgerat immer die gleiche IPv4 Anschluss uber LAN 1 Figure 1. Setting the IP address in the FRITZ! Box. Zuruckzetzen = Clear. Anschluss uber = Connect Via. Portfreigabe Portfreigabe bearbelten & Portrreigabe aKtiv rar Andete Anwendungen ; Bezeicnnung ssh-server Protokoii tcp von Port 22 cm Computet id^pbenypi an IP-Adresse an Port 22 Figure 2. Enabling port forwarding in the FRITZiBoxforthe SSH server of the Raspberry Pi. Andere Anwendungen = Other Applications. Bezeichnung = Label, an = to. Freigaben Portfrcigobcn Spcichcr FRITZBox-Dicnste Dynamic DNS VPN Uber Dynamic DNS kdnnen Anwendungen und Dienste. fur die in der FRITZ! Box-Firewall Portfreic elnem festen Domainnamen aus dem Internet erreicht werden, obwohl sich die bffentliche IP Adre Intcmctcinwahl andcrt. S? Dynamic DNS benulzen Geben Sie die Anmeldedateii fur llireti Dynamic DNS-Anbieter an. Dynamic DNS-Antxeter Benutzerdefiniert Z Neuen Duinainiiamen update-uRL: | http://dynup.de/dyn.php7username-f ritzbox&p Domainname: fritzbox50.p7.de Benutzemame: fritzbox Kennwort: **+* Figure 3. DDNS configuration settings in the FRITZIBox. Benutzemame = User Name. Kennwort = Password. of the router configuration. When an SSH server on the Internet issues a call with this IP address (with the remainder of the address as previously described), it gains access to the SSH server of the Raspberry Pi, The same call also works on the LAN to which the Raspberry Pi belongs because the FRITZIBox sends it to the Internet and then receives it as the addressee. The fly in the ointment here is that with a dial-up Internet connection, the IP address of the FRITZI- Box changes almost every time a link is estab- lished (depending on the provider). Even a per- manent connection does not prevent this, since the connection is normally broken every day by the provider and this results in the assignment of a new address. Unfortunately, the IP addresses of routers are not recorded in the public Domain Name System www.elektor-magazine.com April 2014 55 •Projects (DNS). The only remedy here is to use Dynamic DNS (DDNS). With this option the FRITZIBox is assigned a fixed domain name. This name is first used to contact a DDNS server, which sub- sequently calls the FRITZIBox with its current IP address. This is possible because the FRITZIBox (assuming it is suitably configured) notifies the server for the DDNS service of every change to its IP address. Here's how this works in practice: DDNS providers (such as the German dyndns:free ) offer a por- tion of their services free of charge at a specific time. First you have to register. The DDNS access data is sent by e-mail. After this, configuring the FRITZIBox is relatively easy (see Figure 3). First you have to enter the desired domain name for accessing the FRITZIBox. This consists of the name you chose followed by the predefined part of the domain name. You also have to create a DDNS user account in the FRITZIBox and enter the associated user name and password. Finally, you have to enable DDNS in the FRITZIBox and enter the data necessary for logging in to the DDNS server. Right after the data is accepted, the FRITZI- Box tries to log in to the DDNS server. This can also be done under software control. The URL of dyndns:free is: specially configured or retrofitted. For example, the Android app vSSH comes with an extended keyboard. Final remarks Naturally, there's no reason for going to the trou- ble of setting up remote access to an ATmega32 program from the Internet unless it runs a pro- gram that does something genuinely useful, instead of the simple demo program. The program mmdemol.c (which can be down- loaded free of charge from [1]) implements a serial user interface with four sample communi- cation scenarios. It needs roughly 300 lines of code for this. It can also be extended to do other things if you maintain the structure of the pro- gram. One of its features is support for commu- nication between a terminal and several micro- controllers over a low-impedance wired-AND bus, which also makes large distance between the bus nodes possible. This program is described in detail in the comments at the end of the code section. Another important note: If you want to use this approach for remote control of real devices instead of just a couple of LEDs, you can increase the security by requiring a second password entry before allowing remote access to the hardware, in addition to the password required for SSH http : //dynup . de/dyn . php?username=xxx&password=xxx&hostname=xxx . xxx . de where the xxx terms are placeholders for the actual names. To see whether the login was successful, check the Online Monitor page or the overview page. Now you can establish a connection from the Internet to the SSH server of the Raspberry Pi with the agreed name by entering the following command: ssh pi@xxx.xxx.de Here again the xxx terms are placeholders. There are also SSH apps for smartphones. The program on the ATMega32, the shell and picocom expect to be served by a terminal. This means that the arrow keys as well as the Ctrl key, the Esc key and so on must be available. Hardly any alphanumeric keyboards on smartphones have these keys by default, so they must be access to the Raspberry Pi. You shouldn't ignore security, as otherwise it's entirely possible for jokers and people with dubious intentions to do unpleasant things while remaining anonymous. ( 130481 - 1 ) Web Link [1] Elektor web page for this project: www.elektor-magazine.com/130481 56 April 2014 www.elektor-magazine.com Elektor and National Instruments Present: ^^lusively for Students! Professional Hard & Software at a Special Discounted Price! As the new sales partner of National Instruments, Elektor offers products from the Nl platform for the education of students and enrichment of educational institutions. This educational platform brings together hardware, software and teaching materials to allow students an attractive and inspiring learning environment. Do Engineering - Real-World Solutions for Hands-On Learning LabVIEW With the LabVIEW system design software, students can gain hands-on learning through projects and systems in a single environment and thus acquire skills and procedures that are invaluable to any future career they might wish to pursue. Circuit Design Suite The Nl Circuit Design Suite combines Nl Multisim and Ultiboard software for a complete circuit design, simulation, validation, and layout platform. The Suite has features that are specifically tailored to the needs of students, which are useful in the development of electronic concepts. myDAQ myDAQ is a low-cost data acquisition device that allows for measurement and analysis of physical signals in any place, at any time. myDAQ is compact and portable, guaranteeing students practical experience outside of the laboratory and use of industry standard tools and methods. Connect with us! www.facebook.com/elektorim www.twitter.com/elektor •Projects Raspberry Pi Emulator By Bert van Dam (Netherlands) You don't have a Raspberry Pi, but you are nevertheless curious how this popular platform works? With the aid of the open-source processor-emulator Qemu it is possible to emulate this wildly popular single-board-computer on a Windows PC. Many Elektor readers will have become acquainted by now with the Raspberry Pi through the vari- ous Elektor.Post-articles distributed to Members every 14 days [1] or the Elektor book 'Explore the RPi in 45 Electronics Projects' [2]. For those of you who have not yet acquired an RPi but are nevertheless keen to play with this multifaceted system, we describe here the possibility of emu- lating the Raspberry Pi on a Windows-PC. Of course, this emulation will not be 100% correct because some hardware is not physically present, but this method will still give you a very good impression of the possibilities. To make it easy for you, all the necessary soft- ware can be downloaded from the Elektor website. In the instructions described below, we assume you are using the SD card which is available with the Raspberry Pi book (also on [2]) as the Linux operating system that normally runs in the RPi. But you can also use any other Debian-based distribution for the RPi. • Go to the Elektor website [3] and download the Qemu software package and the pro- gram Disklmager. Both programs are suit- able for Microsoft Windows (tested with Win7 64-bit). • Make a new folder, for example c : \qemu and unzip both software packages into this folder. You do not need to install the programs. • Use the Disklmager program to make a copy of the SD card from the book. (When start- ing the program it is possible that Windows will ask whether you agree to allow this pro- gram to make changes to your computer. Answer with 'yes'. After that it is possible that a nasty error message appears, you can ignore that one; in spite of this the program will operate correctly.) Name the copy rpi- bookbertvandam . i mg and store this in the qemu folder. • Start the program fix. bat in the qemu folder by double-clicking it. The emulation will now begin and stops with the final line reading: root@(none) : /# This is the Linux prompt. • Enter the following command: nano /etc/ld . so . preload This starts the text editor, which contains the following line (or something very similar): /usr/li b/arm-li nux-gnueabi hf/li bcofi_ rpi . so Insert the hash (or pound) symbol (#) in front of this line and subsequently press Ctrl-X. The press Y followed by the Enter key. • The editor will now close again and you are back at the prompt: root@(none) :/# Now enter the command halt, press Enter and wait until the prompt reappears (ignore the error message). Close the window using the small red cross at top right. • Start the program run. bat in the qemu folder by double-clicking it. The program will now automatically load the copy of the SD card 58 April 2014 www.elektor-magazine.com CD cn -i—* i_ CU > “O < and after a short time the famous Raspberry Pi screen will appear. The message Tailed' when loading the file sys- tem and error messages when loading libmod are normal. These are caused by certain hardware that is not available but is expected by the software (and which of course is present on a real RPi). You can now experiment to your heart's content in the emu- lation window. It is even possible to go through the first few chapters of the 'Raspberry Pi' book. Of course you cannot make any of the electronics projects from the book, because Qemu only emulates the Raspberry Pi and not the electron- ics from the book. When you use the mouse in the emulation window all its commands are used for the Raspberry Pi emulation. You can return the mouse to Windows by pressing the key-combi- nation Ctrl-Alt. The emulation program requires quite a bit of computing power from your PC, so it is possible that everything is running and reacting somewhat slower compared to a real Raspberry Pi. From now on you can start the emulation using run . bat and stop it using the command sudo shutdown -h now in a ter- minal window or via the task bar (the red power symbol on the far right) and then 'Shutdown'. Wait until the message system halted appears before closing the window. ( 130539 - 1 ) With thanks to xecdesign for the preload information. Web Links [1] www.elektor-magazine.com/post [2] www.elektor.com/rpibook [4] www.elektor.com/130419 Raspberry Pi I ©eKtor nPoioiu Robotics & Electronics Zumo Robot for Arduino (Assembled with 75:1 HP Motors) ITEM #2506 $9995 Arduino-controllable tracked robot small enough for mini-sumo (less than 10 cm x 10 cm) and flexible enough for you to make it your own. Individual parts and kit version also available — build your own configuration! Baby Orangutan B-328 Robot Controller • Integrated dual motor drivers • User-programmable ATmega328P AVR • Small 24-pin DIP form factor (1.2" x 0.7") Wixel USB Wireless Module ITEM #1337 Programmable MCU module featuring a 2.4 GHz radio and USB: write your own software or load precompiled, open-source apps. Both boards include: • 3-axis accelerometer, 3-axis gyro, and 3-axis magnetometer • Voltage regulator and level shifters for 2.5 V to 5.5 V operation MinlMU-9 v2 ITEM #1268 $4995 • Small size: 0.8" x 0.5 • Small size: 1.0" x 0.5" • Pressure sensor for altitude measurements Inertial Measurement Units (IMUs) AltlMU-10 ITEM #1269 Mini Maestro 12-Channel USB Servo Controller ITEM #1352 $29 95 • USB, serial, and internal scripting control • 6-, 1 8-, and 24-channel versions also available 3.7 g Specs at 6 V: • 6 oz-in • 0.07 sec/60° Sub-Micro Servo ITEM #1053 $495 Optical Encoder Pair Kit for Micro Metal Gearmotors ITEM #2590 $095 9 Add quadrature encoding to your micro metal gearmotors! • 3- and 5-tooth wheels included • 3.3 V and 5 V versions available • Works with our growing assortment of gearmotors with extended back shaft (gearmotors sold separately) Take your design from idea to reality. Find out more at: www.pololu.com www.elektor-magazine.com April 2014 59 •Projects By Alfred Rosenkranzer (Germany) Figure 1. 10-MHz square wave signal using coax and 50-Q termination at the scope input (A); The same signal measured with a standard probe and a flying Earth lead (B). Figure 2. An Agilent probe with the Earth lead removed, using a ground spring. Elektorize Your Scope Probe Measuring high-speed digital signals with probes is prone to produce errors. The ground connection of the probe has special significance. If the standard flying- lead-and-croc-clip is used, the scope images often show wild overshoots definitely not present in the signal. More expensive probes have a "ground spring" to es- tablish a ground connection that's as short as possible. Such a ground spring is eligible for Elektorizing! Measuring signals with an oscilloscope is daily bread and butter to an engineer either at work on in their spare time. The output from a signal generator can gener- t- — ft . -L \ 1 i 'p* . JV. n r V | j T I y'-vv-j — ■‘V-v:.;;* imw ■?. m:ocL3. -w km*) I 5 07 DH ire ?o-w HAMEI3 ImnwiMiii 4 III Sg fWffrUl ally be directly connected to a scope input using a coax cable with a BNC plug at either end. For low-frequency signals such as audio is isn't neces- sary to terminate the cable with its characteristic load. Higher frequency signals such as video or digital signals generally need a load termination at the end of the cable— ideally the scope will have a switchable load option built into its input stage or else use a 50-Q feed-thru terminator. In most cases for circuit debugging, a high imped- ance scope probe is used to trace a signal path through a circuit. Any part the circuit will 'see' the probe tip as a 10-MQ impedance to ground. This is made up of a 9-MQ series resistor in the probe body (in parallel with a capacitor of around 10 pF) and the 1-MQ scope input impedance. Altogether these two impedances form a 10:1 voltage divider network so that the signal at the scope input is only one tenth of its actual value. The signal is sampled with the tip of the probe and the Earth connection is a flying lead, usually around 10 cm (4 inches) long terminated in a crocodile clip. It is assumed that the scope probe has already been tweaked for optimal response using the scope test output signal. When measuring fast digital pulses you notice that the signal shown on the scope changes depending on where you attach the Earth lead, particularly noticeable on overshoot at the signal edges. The suspicion is that the displayed wave- form is not a true picture of what is happening in the circuit (Figure 1). More expensive probes such as those made by Agilent or Tektronix provide a tip ground or ground spring option. This removes the long Earth lead and improves the waveform by allowing a 60 April 2014 www.elektor-magazine.com Scope Probe shorter Earth connection nearer to the point of measurement (Figure 2). The resulting wave- form is shown in Figure 3. The author hasn't seen this type of earthing fea- ture on any of the standard low-cost probes, but luckily they do have an Earth collar just back from the probe tip which can be used for this purpose. Wind a length of bare copper wire around the collar a few times and twist the ends to make it grip the collar (Figure 4). For convenience this Earth connection can be temporarily soldered into the circuit under test. It costs practically nothing and if it falls off it only takes a minute to replace. Bandwidth These improvements will not alter the fact that the scope probe bandwidth usually limits high frequency measurements. To check this out use a square wave generator and measure the rise or fall time on the scope display first using a BNC to BNC coax with a ter- minator load and then with the scope probe. If the rise time is slower with the probe then you can be sure the probe bandwidth is having an effect. Professional solutions include probes with an input impedance of 500 or 1000 ft. These at first seem very low compared to standard 10 Mft probes, but at high frequency the probe's input capacitance has a greater influence on signal loading. Also signals in this range tend to be in the 1 Vp p range and the ICs can easily drive the extra load. The cost of such a probe is in the region of $100 Euro, which is rather a lot if it only gets occa- sional use. You can build a test probe with similar characteristics quite cheaply. First take a length of 50-ft coax fitted with a BNC connector at one end (alternatively cut a 2 m (7 ft.) BNC to BNC cable in half to make two probes). Trim back the insulation from the cut end and solder a resistor to the center conductor. A small length of heat shrink sleeving will cover the joint and resistor. Tease out the shielding wire strands and sol- der to a short length of wire to make the Earth connection on the PCB. Another length of heat shrink over all the bare wires will finish the job (Figure 5). The value of resistor used here can be either 450 or 950 ft. Together with the 50 ft termination resistor at the scope input these resistor values produce a 10:1 and 20:1 volt- age division of the measured signal. The non standard resistor values are available from com- ponent stockists. Failing that you can use values of 470 and 1000 ft and accept that the voltage division ratios will be slightly out. If something breaks, it's a simple job to trim the cable back and make another. Figure 6 shows a low-impedance scope probe from HP. In the white plastic shell is a swappable resis- tor. Connection to the scope is via an SMA con- nector and a length of SMA cable (the cost of this probe puts it in the 'Professional Use only' camp). Using an SMA connector, cable, a resistor, wire and some heat shrink sleeving it should be simple to produce something similar (providing you have some SMA-diameter cable and a BNC adapter). ( 130112 ) Figure 3. The 10-MHz signal measured with a short Earth lead on the probe collar. Figure 4. A standard Flameg probe with DIY tip-ground modification. The Earth lead is removed. Figure 5. The DIY low-impedance probe. Figure 6. An old HP low-impedance probe. www.elektor-magazine.com April 2014 61 SS;s VOl electronics senga . networ data „ ai medial information ' | ■m product news ( embedded design tips tutorial software Q) neering tools system au d i o business n inq media ° COMMUNITY .. ^Jat\4'4x) -Uk4r> iAouy ir\4tiy^s4s opirtiorts! Ov&cjv. omtI" ovy Nje^i Social stadia 0«He4s f or J&Yick- ertgage*vei4j CIRCUIT CELLAR / AUDIOXPRESS / ELEKTOR Take Out a GOLD Membership Now! ALSO AVAILABLE: The all-paperless GREEN Membership, which delivers all products and services, including Elektor magazine, online only. 0[ektor membership 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; our virtual, online laboratory • 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 projects • Exclusive GOLD Membership card cr^-- — - ©ektor membership Connect with us! www.twitter.com/elektor www.facebook.com/elektorim •Labs Big Brother Be Gone By Clemens Valens (Elektor.Labs) The search function on Elektor.Labs has switched to DuckDuckGo, an Internet search engine claimed to provide real anonymous search. Our first impressions are very positive: fast, accurate and clean results without tracking. No more Big Brother following you around the Internet. Why don't you give it a try? Collecting information is easy; making it accessible is difficult. Since its launch Elektor.Labs has collected quite a lot of useful information about electronics and projects, and obviously good tools are needed to exploit this data. Since Elektor.Labs is a laboratory we can experiment with search engines to find out which solution suits us best. The Elektor.Labs website started out with the default were impressed with the quality of the pages returned. OK, Goo- gle added some commer- cial links to the results, but the precision of the results outweighed this inconvenience. However, as we were soon to discover, Google Site Search turned out to be too much of a good thing— it even presented pages we didn't know the existence of, like site-wide lists of new posts. At first DuckDuckGo search engine integrated in the website's 'Drupal' content management system. This search engine works fine as long as you know exactly what you are looking for. Punch in the search phrase and you will be rewarded with all the articles contain- ing that exact phrase. Typo? Nothing found. Wild- cards? Not allowed. While investigating the rationale behind the absence of wildcards we discovered that there are (at least) two schools of thought for search engines: few accurate results versus many less-ac- curate results. Our website adhered to the first school whereas we preferred the second, which we felt would be more suited for people not too sure about the exact term they are looking for. So we replaced the default search engine by Google's Site Search. Initially we got spectac- ularly precise results; we found everything we wanted and even some fans of the first school we thought that that was all right, but quickly these listings started to outnumber the useful results. Deactivating these listings did not solve anything because Google had memorized them all and so we pulled the plug on Google Site Search. Enter DuckDuckGo. This is a rather recent search engine that boasts anonymous search while try- ing to limit spam to a minimum. They offer a site search function as well, although not as neatly integrated as Google. When you click the Elektor. Labs search button you are taken to our Duck- DuckGo site search page. Try it and be amazed by its lightning speed. There is still a trifling incon- venience though: make sure you do not delete "site: www.elektor-labs.com" from the search box. ( 130461 - 1 ) www.elektor-labs.com/node/3795 64 April 2014 www.elektor-magazine.com Elektor Labs What's up with this cap? By Thijs Beckers (Elektor Labs) Loyal readers will be aware that Elektor have been offering printed circuit boards, programmed microcontrollers, kits and modules et cetera for some considerable time as a complementary (not: complimentary) service to Elektor Magazine. This service we hope increases the chances of success when assembling your own circuit at home or in your workspace. While we cannot fly over and assist with your soldering, at least our semi-kits ensure that the correct components are available to those interested. One of my duties at Elektor Labs is to randomly check these semi-kits for completeness and make sure everything is in agreement with the published BOM when they arrive from our suppliers. For our recent ADAU1701 Universal Audio DSP Board ([1]) we had one of our trusted suppliers do the parts picking for the semi-kit. When the kits arrived at our warehouse I randomly checked a couple for correctness and completeness. I then stumbled upon something very odd with the 100- nF (0.1 pF) capacitors. The picture shows two of them, each from a different side. Now I'd like to believe I'm not a complete knucklehead on elec- tronic components, but this capacitor included in the kit had me flabbergasted. It was supposed to be a 100-nF capacitor, but as you can see in the photo, it has a "105" marking on one side and cheerfully "104" on the other side. Every 100-nF capacitor in every sample kit I checked showed the same 104 / 105 print as shown here, so it was not just a misprint on one of them, and it's a long time to April 1. Trawling the net for a possible explanation didn't result in an answer, nor did any of my colleagues at here at Labs know what was going on here. According to our LCR meter (the fancy one we published about in the March, April and May 2013 editions [2]), the capacitor is indeed 100 nF. Your DSP kit should be okay. So here's my call out to you, our well-informed reader and/or omniscient professional, to explain what's going on with this component. Is it just an ex-factory misprint? Or is there a method to the madness? Send your insights to editor@elektor.com, sub- ject: madcap. ( 130460 ) Web Links [1] www.elektor-magazine.com/130232 [2] www. elektor-magazine. com/1 30093 www.elektor-magazine.com April 2014 65 •Labs Unwrapping RepRap By Patrick Wielders (Elektor Labs) A couple of weeks ago Labs took delivery of RepRap 3D printing machine [1] from RS Com- ponents / Allied Electronics [2] to experiment with. Here were cover the unpacking and assem- bling of the mini manufacturing machine. The first thing you come across after opening the box is a packing list, which should be checked thoroughly to make sure all items listed are pres- ent and intact. All parts that make up the kit are packed in transparent bags, and on every bag there's a content list, which is very useful. The letter of introduction that comes with the kit includes a link to the online Assembly Manual [3]. Initially we looked for clues to a printable version of the manual, but it soon dawned upon us that disadvantage of this approach is that you need to have a computer with Inter- net access up and running while assembling the printer. But it didn't take long for us to see the benefits of the online-only manual: for example, the images are displayed at a higher resolution after you click on them, offering more detailed visual support. The manual provides all the details needed for an easy step-by-step assembly procedure. It features lots of pictures, loads of useful tips and in general is well structured. We reckon anyone who ever played with Lego or built something from Ikea drawings can assemble this 3D printer. Check our time-lapse video of the steps to assembly at [4]. A nice touch of the RepRap concept is that all the parts printed by a 3D printer are available as open-source 3D designs and the links to their locations on the web are included. So, if you feel up to it, you can download the files and print (spare) parts yourself. This can be useful in case a part is worn out or when an improved version of the part becomes available. Imagine, downloading upgrades and (3D-)printing them yourself for the purpose of improving your own 3D-printer... ain't that a blast? ( 130562 ) Web Links [1] www.reprap.org [2] www.rs-components.com [3] http://reprappro.com/documentation [4] http://youtu.be/eLEMP8VmtM8 66 April 2014 www.elektor-magazine.com 25% OFF CIRCUIT CELLAR Whether it’s programming advice or design applications, you can rely on Circuit Cellar for solutions to all your electronics challenges. Raspberry Pi, embedded Linux, low-power design, memory footprint reduction and more! Become a member, and see how the hottest new technologies are put to the test. RiwtwT-r t\ I/O hert [Pwl 3 ) !*■ MffW i n " i IMiTi: tlltw Mu ll B circuit cellar MCU-BASED COLOR DATA ACQUISITION MfL fjfrjrM , rif artiwin .^nsi.r » ms mar ■ Wertt* Clide | 04* Pm tHstrnnlcj: fn^reiXTPeur m wn Cdbe-SoMoO RokUt H-f* I/O kund | Robot* «urJH trtrtrft 0*Sk* for [ IE0 CbJirWWriKJlofi | CWfoG Se^pi-rs ^ Tl((5. tut th-nfl fIM? ri*5 is DtfWl SNft* JOIN TODAY! www.circuitcellar.com/sepN1 3 DESIGNSPARK PCB By Neil Gruending (Canada) DesignSpark Tips & Tricks Day #9: Custom Outlines Continued Let's finish our board outline that we started last time. Figure 1. Failed DesignSpark PCB Import. Figure 2. Deleting the plane covering the mounting holes. Last time we started a PCB board outline for a Hammond 1551N enclosure. We started by importing the enclosed STEP model into DesignSpark Mechanical and then we modeled the circuit board to make sure it would fit. Today we are going to finish importing the board into DesignSpark PCB so that we can the board ready for components. Fixing the import Figure 1 shows where we left off last time. The PCB outline is correct but the mounting holes are obviously wrong. I tried some other pack- ages and they correctly imported the DXF file we created last time. Exporting the DXF from those packages would also import properly into DesignSpark PCB so something in our DXF file must be confusing it. After some experimentation I found that there are a couple of errors with the model I had created in DesignSpark Mechanical. The first problem is that the mounting holes weren't really holes in the board model because they are covered by a thin plane. It was hard to see until I rotated the model a bit and saw that the bottom of the holes were shaded instead of being white. The second problem is that DesignSpark PCB doesn't think the board shape is a closed shape since it raises a warning after the import. Moving the corners showed that two of them aren't con- nected properly because the unconnected lines won't resize properly. So let's start by fixing the mounting holes in the DesignSpark Mechanical PCB model. The first step is to use the pull tool to pull the PCB outline 1.6 mm upwards from the sketch plane which creates a solid PCB object. Then select the circles from the original sketch plane and delete them like in Figure 2. The trick is make sure that you select the circle covering the mounting hole has a solid and not just circle outline otherwise you won't be able to 68 | April 2014 | www.elektor-magazine.com delete it properly. You will know when hole is clear because you will see the white background show through the hole. Once you've cleared both holes right click on "Curves" head- ing in the PCB outline structure and select delete to remove the extra lines that we don't need anymore. Before you export the new DXF you have to select the top view of the PCB (Design->Orient->Top). Otherwise DesignSpark Mechanical will export the DXF as a 3D per- spective of the PCB which won't work. Figure 3 shows what the corrected board looks like in DesignSpark PCB with the new DXF. It still raises the same import warning but that's due to the mounting holes— not a problem since we'll be deleting them later anyways. Figure 3. Fixed board import. Adding the mounting holes I usually like to set up my mounting holes so that they're unplated and without any copper pads under the screw head to avoid tearing the copper off of the board when tighten- ing the screw. These types of holes are usually made as a library component because they require copper keep- outs on the outer layers. DesignSpark PCB can do this but it's difficult because you can't add keepout elements to a DesignSpark PCB library component. Instead you would have to manually add them to every hole you make. Today we'll just use a plated hole since they're much easier to use in DesignSpark. You can make them unplated as well but be careful that the copper pads don't tear off the PCB. Start by creating a new PCB symbol for our mounting hole. We're going to use ANSI #2 screws so add a pad with a 2.5-mm hole and a 5.5-mm pad which corresponds to the recommended size [1] for a pan head screw and nut. For all practical purposes these sizes suit the metric M2 screw also. Once you finished editing the pad save it your library. Next CD IT = 2.10.8.1 PicoScope includes drivers for all current scopes from the Pico- Scope 2000 Series to the 6000 Series and we are working on adding support for some older devices. The drivers can also be used on their own to create custom applications. A number of customers are already using the new beta and contributing to a lively discussion on the Pico forum at http://www.picotech.com/support/. www.picotech.com/linux.html (130458-1) J www.elektor-magazine.com | April 2014 | 73 •Industry Philips LUXEON Lime LEDs break 200 Im/W Barrier Lime, the newest addition to the widely renowned LUXEON color portfolio of LEDs from Philips Lumileds, enables lighting designers to take the next step in delivering the highest quality, tunable white light in bulbs and fixtures. LUXEON Rebel ES Lime is the proprietary LED technology in the revolutionary Philips hue bulb, where it combines with LUXEON Rebel Red-Orange and Rebel Royal Blue emitters to deliver over 16 million color options— all controlled from an iOS device. Philips hue can use color tunable Light Recipes to help set mood and energy level in the home, office, retail, classroom and hospital environments. Lime is the highest efficacy LUXEON LED manufactured to date. Therefore it enables highly efficient color mixing by providing a convenient above-blackbody color point with optimal standalone efficiency of 200 Im/W at 350 mA and 85°C. The spectral output of Lime is closely aligned with the wavelength that human eye cones are most sensitive to, 555 nm. In addition to LUXEON Rebel ES, the Lime technology is offered in the LUXEON Z format, an undomed, 2.2 mm 2 LED that is 75% smaller than most high power LEDs. In spotlight and downlight applications, the LUXEON Z enables tighter packing density and better color mixing control. The LUXEON Z Lime can be combined with Red and Blue LEDs to achieve a broad spectrum of saturated colors. Alternatively, tunable white light with high efficacy can be achieved from 1800-6500K along the blackbody curve. www.philipslumileds.com/LUXEONRebelColors www.philipslumileds.com/LUXEONZ (130458-III) 6 & 8-Channel Energy Measurement . .. __ 4 Microchip Analog Front Ends Offer High Accuracy for 3-Phase Smart Meters Microchip Technology Inc. Announce their next-generation family of energy- measurement Analog Front Ends (AFEs) with industry-leading accuracy. The MCP3913 and MCP3914 integrate six and eight 24-bit, delta-sigma Analog-to- Digital Converters (ADCs), respectively, with 94.5 dB SINAD, -106.5 dB THD and 112 dB SFDR for high-accuracy signal acquisition and higher-performing end products. The MCP3914's two extra ADCs enable the monitoring of more sen- sors with one chip, lowering cost and size. Additionally, the programmable data rate of up to 125 ksps with low-power modes allows designers to scale down for better power consumption or to use higher data rates for advanced signal analysis, such as calculating harmonic content. These AFEs also feature a CRC- 16 checksum and register-map lock, for increased robustness. As the energy-metering infrastructure is being upgraded worldwide, designers are demanding increased AFE accuracy, performance and flexibility to develop the latest generation of smart meters. These features are also required by the designers of advanced power-monitoring systems for applications such as server power supplies and power distribution units, uninterruptible power supplies, smart power strips and data-acquisition products in the industrial and commercial markets. Microchip's new AFEs improve application perfor- mance with their industry-leading accuracy, while providing the flexibility to adjust the data rate to optimize each application's rate of performance ver- sus power consumption. Microchip also announced two new tools to aid in the development of energy systems using these AFEs. The MCP3913 Evaluation Board (part # ADM00522) and MCP3914 Evaluation Board (part # ADM00523) can each be purchased today for $99.99. www.microchip.com/get/EUJ9 (130458-IV) 74 | April 2014 | www.elektor-magazine.com news & new products New Items from Parallax ActivityBot (# 32500) (rrp: $199.00) Learn real-world engineering skills with the friendly, capable, and peppy ActivityBot. It's a great option for first-time robot-builders, as well as for an intro to technology and engineering courses in high schools and colleges. Step-by-step web tutorials take you through programming its multicore Propeller chip in C, wiring circuits on a breadboard, and building sensor systems so your robot can navigate on its own. Follow- ing the checkmarks gets you to the fun fast, with optional links for added learning. Key Features: • Easy to program in C on Windows, Mac, or Linux with the SimplelDE software and custom Sim- ple Libraries • Multicore Propeller control board makes it quick to integrate sensors, motors, and more • High-speed servo motors with optical encoders provide fast, consistent maneuvering • Breadboard and 3-pin headers let you experiment with common electronics parts, no soldering or proprietary connectors required • Component kit makes navigation systems that use touch, visible light, infrared light and ultrasonic sensors • Built-in SD card slot and microSD card are ready for data-logging and file storage Y-6 Multicopter (# 80100) (rrp: $799.00) The Elev-8 Y-6 Multicopter is a flying robotics platform that is lifted and propelled by six fixed pitch rotors. Unlike other 'Tri-copter' platforms, the Y-6 has a motor mounted on the top and bottom of each boom. This 'double-stack' of the motors gives you added payload capabilities, and makes your system redundant in case of a sudden motor loss, making the platform safer to fly. Aircraft stabilization is electronically controlled by the HoverFly board with Parallax's Propeller multicore microprocessor. The benefit to this system is a stable platform with no mechanical linkages, for a small, maneuverable, and agile aircraft. Key Features: • Open underbody for accessory and camera mounting • Redundant flight platform enabled by the use of two motors per boom arm • 4 lbs. payload capacity • Open source design files available for you to download and use • LED strips wrap horizontally around the motor booms giving you precise orientation markers • Uses common 4-40 hardware that can be found in most local hardware stores • Modular frame allows you to repair and modify your platform quickly and easily Gimbal Joystick ( # 27808) (rrp $24.99) The Quad-Bearing Gimbal Joystick is a high-quality, two-axis human input device. It is useful for send- ing continuously-variable settings, such as position, direction, or throttle values to a connected micro- controller. The joystick interfaces readily with analog-to-digital converters as well as simple RC timing circuits. It is mechanically adjustable for a customized action and feel. The included adapter kit provides a connection option to breadboards or thru-hole boards with 0.1" spacing (simple soldering required). Key Features: • 5 k-ohm linear-taper potentiometer on each axis provides even resistance transitions without skips • Ball-bearing action on both axes make for silky-smooth, jitter-free operation • Selectable spring return-to-center on vertical axis for rudder-type or throttle-type inputs • Selectable detents and/or friction on vertical axis to hold joystick in place when not being manu- ally held www.parallax.com /[item #] (130448-11) www.elektor-magazine.com | April 2014 | 75 •Regulars Atwater Kent Model 30 Radio (1926) By Gerard Fonte (USA) In the mid 1960's I was a teenager and getting interested in electronics. I had just read about rebuilding old radio receivers (Popular Electronics May 1964) when I saw a mammoth Silvertone console radio on the curb, just waiting to be collected by the "sanitation engineers". Unfortunately I couldn't ask the school-bus driver to stop. I probably couldn't have gotten it on the bus anyway. It was about four feet tall (1.3 m), two feet wide (0.6 m) and weighed at least 50 pounds (20 kg). But, being a resourceful student, I called my parents from school and begged and pleaded for them to pick it up for me before someone else did or it got trashed. I was well rewarded for my histrionics. Buying Blind Some time later I went to my first auction and there was a large console radio that was in very sad shape. It had been stored in the barn for many years and the wood was falling apart and the back was closed up. I couldn't see any of the electronics. The bidding started at two dollars. Not knowing any better, I bid two dollars. Nobody else said anything. So, I got it for two dollars. One bid and one auction win! Pretty good for my first time. The thing was nearly as big as me and as I was dragging it to the car, I realized that something was loose inside. When I got it to the car I pulled off the backing. Inside was a pristine Atwater Kent Model 30 radio. I don't know what it would have auctioned for, but I am pretty sure it would have been a lot more than two dollars— which was about all I could afford. With some help from a friend, I was able to replace the shorted filter capacitor that was mak- ing the regulator tube's plates get red hot. (For those unfamiliar with vacuum tubes, or "valves", only the filaments were supposed to glow.) The radio had fantastic tone and volume. But better still, it had several shortwave bands— very import- ant for a budding engineer in those times. With such a fantastically successful start, I continued collecting old radios and suchlike. AK-30 Basics The Atwater Kent model 30 was built around 1926. It's a six-tube, Tuned Radio Frequency (TRF) type of receiver. What that means is that is pretty much an amplified crystal radio. Looking at the redrawn schematic, Figure 1 [1] (origi- nal also available, Ed.), there are three stages of tuned RF amplifiers, followed by a "grid-leak" detector, followed by two Audio Frequency (AF) amplifiers. This makes six stages with one tube for each stage. 76 | April 2014 | www.elektor-magazine.com fftebtanic* XXL The tuning of the three RF amplifiers is noth- ing more than a parallel L-C (inductor/capaci- tor) network (exactly like a crystal radio). The three air-variable capacitors were adjusted for tuning. Putting three identical tuned amplifiers in series increases gain (obviously) and selectivity (i.e. the ability to separate signals close in fre- quency). Each tuning stage narrows the passband considerably. With three stages, the selectivity is pretty good. Of course, there weren't all that many broadcasters to interfere with each other at that time. This also meant that each capacitor had to be properly adjusted to tune in a station. The Model 30 was the first Atwater Kent to use only one dial to adjust all three simultaneously. The capacitors were connected with pulleys and a metal band to accomplish this (more on this later). There was an RF gain control that varied the filament voltage to the three RF amplifiers. The grid leak detector (inset) was a very simple and cheap way to demodulate the RF signal. The procedure was to place a small bias on the grid by connecting a high value resistor to ground. The resistor in the model 30 was about 2 megohms. The effect is to change the operating point of the tube to only amplify the negative half of the signal. In this way there was detection as well as amplification. And while this did work, there were many things that affected the performance. This included signal strength, tube degeneration and I ESP 20041 Retronics is a monthly section covering vintage electronics including legendary Elektor designs. Contributions, suggestions and requests are welcome; please telegraph editor@elektor.com Leakage! Drip-drip! The real grid leak resistor lead directly to the development of the fictitious "grid leak (drip) pan" that was used to collect all of these electrons and keep them from falling on the floor and creating a mess. Like the left-handed monkey wrench and the board-stretcher, great enjoyment was had by all (except the victim) in the futile search by the new-hire in the radio repair shop. There are rumors that these pans did exist and that some unscrupulous souls would actually sell these grid leak pans to the unsuspecting public. There are currently "audiophile" AC power cords that sell for $1699.99. Perhaps, more reasonably, parts vendors and distributors may have given pans away as humorous promotional items. -•-4 T - ••* i . -err <■> IT ' **r! m , ^.sTS&Sjs 1 ***** **»*#* » „ G*d Ptra« Brown Origin*! p** nvmtm-i-t CrdLw«<-re» Grid - 79 M PfyjTr* Ot OdtWH 1 ■ Btpawrorwrw ■ 7AM i*pHrirtl* 789 L 3 JkF TfltfrtJiXiWM HI - 7S5D Pari numbdfl ilwm on Lfrt riming »rc from Ihc 19 JZ juris ll»l. Brown H/M* R*d PFELffvINAHV EJ BVTW, -d-s;. bb^imv 14 AwH) ABdriMy GBril#rv ■u.'Kdte) M >!■ » ■, ti» iwFwi, — W3NLB u&TbZS AtvJClT Kt nr McKlti M BWM Hag r-tfn ft.- waaaooqo) * 51 Urn- .TC-fe | |«*l tOPI Figure 1. Redrawn AK-30 schematic, reproduced with permission from Leigh, W3NLB and Atwaterkent. info. www.elektor-magazine.com | April 2014 | 77 •Regulars Tubes Figure 2. View of my AK-30, hinged lid opened. Figure 3. View of the AK-30, radio chassis pulled out. grid-resistor variation (these resistors changed with temperature and humidity). After the leaky-grid stage came two stages of audio amplification. The final result was a signal that could drive headphones well or a loud-speaker poorly. Of course the loud- speakers of that era were really not much more than a headphone attached to an acous- tic horn. The volume control varied the voltage on the filament of the detector rather than the input voltage to the AF amplifier stages (as is normally done today). My AK-30 As you can see from the pictures in Figures 2 and 3, the case was nearly perfect and all the You can't really understand the radios of the era without understanding a bit about the critically important vacuum tubes. First, they were expensive. In the early 1920's they could cost as much as $9.00 each which is about $120.00 today. By 1930 the cost dropped to about $1.50 ($20.00 today). An early radio could rival a Model T Ford in price. A mid- 20's radio like the Model 30 was a significant financial investment. There were variations in tube manufacturing but eventually most producers settled on the four-long-pin base. And any tube that had the same last two digits was generally interchangeable. For example the UX-201, UX- 201A, UX-301, UX-301A, etc. were reasonably similar. I say "reasonably" because the filament current was substantially less in the later tubes. This was very important since these radios operated from batteries. The early five-volt filaments used a full amp of current. The later versions reduced this to a quarter amp. With six tubes, tubes were in place. However, there were some problems. The most significant was that the metal pulleys connecting the variable capacitors were crumbling (Figure 4; thanks Allen [2]). I had never seen (and still haven't) anything like this before. I suspect that it was due to metal fatigue. Especially since the metal appeared to be sintered rather than cast or machined. (Sintered metal starts as a powder that is pressed and heated into its final shape.) Cycling between a hundred degrees in the summer and zero degrees in the winter (40 °C to -20 °C) could certainly do that. The second problem was that one of the tubes had an open filament. This is not a major prob- lem today. It's easy to go to eBay or to one of the many antique radio sites on the internet to find a replacement. However, when I got this the internet didn't exist. Trying to locate a tube 78 | April 2014 | www.elektor-magazine.com fRefrtanicA XXL power for the filaments usually came from a 6-volt automobile battery. Filaments were wired in parallel, so there was no problem with substituting different tubes which had different filament ratings. Tubes had to be devoid of oxygen. Otherwise the filament would oxidize (burn!) and fail. There were two general methods for accomplishing this. The first was to put a vacuum into the tube. Unfortunately, vacuums of the day weren't all that good. So, in order to eliminate the remaining oxygen a "getter" was inserted into the envelope. The getter was a chemical that reacted and bound up all the free oxygen. Getters caused the discoloration on the inside of the tube envelope. Different getters created different colors. Generally the color was silver-black. But some were bright blue and others were iridescent. The second method was to place an inert gas into the tube— typically argon. This eliminated the getter and the glass envelope is perfectly clear. Of course, the problem with argon is that it breaks down at high voltage and glows a nice blue (very similar to the classic neon lamp). For some reason, detector tubes (UX- 200A) usually used argon and RF (UX-201A) tubes used getters. Perhaps because detectors used lower voltages and there was less chance of breakdown/ionization. that hadn't been manufactured for decades was not a trivial task. The last problem wasn't really a problem. The two AF tubes were not the ones specified. They were apparently substitutes. All of the tubes of that time were simple triodes and many were interchangeable. They could amplify by a factor of about 8. (The minimum gain of a 2N2222 tran- sistor is 50.) Instead of the two UX-201A tubes, there was a UX-200A and an SX-112A tube (Fig- ure 5). The SX-112A was a newer tube designed for audio output. It could provide a whopping 200 milliwatts of power. Batteries The Model 30 needs five direct voltages: 90, 67.5, 22.5, 6 and -4.5. These are supplied by batteries. The 90 volts is used to drive the head- phones. The 67.5 volts goes to the plates of the RF amplifiers and the first AF amplifier. The detector tube uses the 22.5 volts. The 6 volts powers the filaments. The -4.5 volts biases the final AF amplifier. (It draws no appreciable cur- rent and can last for years.) Figure 4. Disintegrated pulleys: photograph reproduced with permission of Allen Wooten, WD4EUI. Obviously, batteries had to be replaced on a reg- ular basis. So, the operating costs of an early radio were significant. It wasn't until a few years later that AC powered sets became widely avail- able. And that was because of the development of rectifier tubes that could handle the power requirements. Construction Details There are some interesting construction details surrounding the RF coils. The back of the case is routed out in three places by about a quar- Figure 5. Tube complement ter of an inch to provide clearance space for the in my AK-30. www.elektor-magazine.com | April 2014 | 79 •Regulars m — - ™ QCo Jpf F rft** #F1 000 pad l r 'litp Wii 1? ( ~Frti* twjr A W AW T ^'> aw ^ rr« WWp W I r M 1 t++*M \ r=x -vf-M LOW ORItN-TIU^V tbacim -m BRDWN WHit* ^fW/lK #ri-.(WTW( fmmr smetapm r w/n; coils. Figure 6 shows the chassis removed from the case. This seems like a design error. I would think that the case would normally be designed to accommodate the coils to begin with. The second detail is that the three coils are Figure 6. Clearly visible here are the tuning coils sticking out from the "chassis". mounted at right angles to each other (Fig- ure 7). This is done to reduce inductive cou- pling between them. Without this, there would probably be leakage that would feedback and initiate oscillation. Oscillation was a significant problem in early radios. Lastly, the RF coils are actually transformers. There is another winding inside of the coil. I do not know if this was the standard method at the time or if this is associated with Atwater Kent. It is certainly an unusual technique. Turning the Page The battery-operated TRF radios were pretty much gone by 1930. They were replaced with regenerative circuits that provided high gain and selectivity with fewer tubes, or with superhet- erodynes that were similar to today's radios. AC operation became standard and the prices for radios plummeted. Unfortunately, my collection of huge radios didn't survive my going to college and living in a small apartment. Of the three special pieces I had (the Silvertone, the AK-30 and the Ediphone) I was only able to keep the AK-30 and Ediphone. I gave the colossal Silvertone to my older sister. However, I don't think she appreciated the gift. It was gone in a year or so. Too bad. Currently the going price for that in near perfect physical and electrical condition is about $1000. ( 130426 ) Web Links [1] www.atwaterkent.info [2] www.wd4eui.com Figure 7. Detail of tuning coils mounted at right angles to each other. 80 | April 2014 | www.elektor-magazine.com Ordering Information ORDERING INFORMATION To order, contact customer service for your region: USA / CANADA Elektor US 111 Founders Plaza, Suite 300 East Hartford, CT 06108 USA Phone: 860.289.0800 E-mail: service@elektor.com Customer service hours: Monday-Friday 8:30 AM-4:30 PM EST. UK / ROW Elektor International Media 78 York Street London W1H 1DP United Kingdom Phone: (+44) (0)20 7692 8344 E-mail: service@elektor.com Customer service hours: Monday-Thursday 9:00 AM-5: 00 PM CET. 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 for your region. COMPONENTS Components for projects appearing in Elektor are usually available from certain advertisers in the magazine. If difficulties 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. TERMS OF BUSINESS Shipping Note: All orders will be shipped from Europe. Please allow 2-4 weeks for delivery. Returns Damaged or miss-shipped goods may be returned for replacement 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, magazines, online publications and presentations. Elektor accepts no responsibility or liability for failing to identify such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, discs, and software carriers 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 educational 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 Membership renewals and change of address should be sent to the Elektor Membership Department for your region: USA / CANADA Elektor USA P.O. Box 462228 Escondido, CA 92046 Phone: 800-269-6301 E-mail: elektor@pcspublink.com UK / ROW Elektor International Media 78 York Street London W1H 1DP United Kingdom Phone: (+44) (0)20 7692 8344 E-mail: service@elektor.com O Do you want to become an Elektor GREEN or GOLD Member or does your current Membership expire soon? Go to www.elektor.com/member. www.elektor-magazine.com | April 2014 | 81 Community Elektor World Elektor's Nearly Lost World By Wisse Hettinga During Elektor's 60+ years' existence the lab and editorial teams must have built, handled and demoed hundreds of prototypes for the projects that made their magazine famous. A lot of hard- ware built in the old days got junked in 2007 during a move to new offices A few items escaped our cleansing frenzy though, mainly thanks to a few headstrong and proud guys from the lab aided and abetted by a zealous Retronics Editor. In the huge attic here at Elektor House we still cherish a small collection of Elektor hardware and projects and related stuff that defined the his- www.elektor-magazine.com All Around the World ... tory of the lab, the magazine and the publishing the shelves from the comfort of your chair .... company as a whole. only look, don't touch! We hope you recognize some of the old stuff here: we have the Formant, the Elektor Junior Computer, the 'Mondrian' Plotter, items from high-end audio series, the Edwin amplifier, the Filmnet Decoder, The ElektorScope, a whole pile of vintage measurement equipment and more. The picture is available at high resolution on www.elektor-labs.com/attic so you can browse We love e-stories. Under the topic specially created for this article at www.elektor-labs. com, please post a comment, story or whatever you feel fitting as a tribute to any old Elektor project you recognize in the picture (it's free for all Elektor Members). The posting, comment and/ or story we like best wins a totally contemporary piece of hardware, the J2B board. ( 130459 ) □ www.efektor-magazine.com April 2014 83 •Regulars Hexadoku The Original Elektorized Sudoku Hexadoku participants are diehards. Every month a large number of them succeed in solving this mentally grueling puzzle. Join the crowd, find the solution in the gray boxes, submit it to us by email, and you automatically enter the prize draw for one of five Elektor book 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 five Elektor Book Vouchers worth $70.00 (£40.00 / €50.00) each, which should encourage all Elektor readers to participate. Participate! Before May 1, 2014, supply your name, street address and the solution (the numbers in the gray boxes) by email to: hexadoku@elektor.com Prize winners The solution of the January & February 2014 Hexadoku is: 1F734. The €50 / £40 / $70 book vouchers have been awarded to: Arun Annaji (India), Per Troelsen (Denmark), Arwin Vosselman (Netherlands), Brian Unitt (UK) and Udo Altmann (Germany). Congratulations everyone! 2 7 F c C D B 2 0 E F 3 4 2 6 0 1 7 8 6 8 E C 3 4 5 2 E 9 3 F 8 c B C 3 1 F 5 8 0 7 4 0 A 2 3 C 6 9 7 5 D E 3 F 4 B C 6 D 2 1 E A 0 3 1 E 0 8 4 5 D 9 2 4 0 3 6 8 1 E D 6 8 1 3 7 2 F E D C 0 1 E 8 8 3 5 4 9 1 0 4 E 8 F 3 9 6 E A 3 B D F 7 5 C 2 1 8 4 0 F 5 B D 4 E i 6 8 3 0 9 2 7 c A 3 2 7 0 8 A c 9 1 4 D F 5 6 E B 1 4 C 8 0 2 5 7 E 6 A B D 9 F 3 5 7 A 3 D 0 2 B 9 E 8 c F 1 6 4 4 8 F 9 E 3 6 A 0 i B D c 2 5 7 c B i E F 7 9 4 5 A 2 6 8 3 0 D D 0 6 2 c 5 8 1 F 7 3 4 9 A B E 2 9 8 B 1 4 7 0 3 F 5 A 6 E D c 6 3 D F 2 C A E 4 8 9 0 7 B i 5 7 A 0 c 5 6 3 8 B D E 1 4 F 2 9 E i 4 5 9 F B D 2 c 6 7 3 0 A 8 A D 3 7 6 i E 5 C 0 F 8 B 4 9 2 8 E 2 4 7 9 0 C 6 B i 5 A D 3 F B c 9 i A 8 F 3 D 2 4 E 0 5 7 6 0 F 5 6 B D 4 2 A 9 7 3 E C 8 1 The competition is not open to employees of Elektor International Media, its business partners and/or associated publishing houses. 84 | April 2014 | www.elektor-magazine.com Gerard's Columns So you've decided that your ePod is going to make money for you. You're going to manufacture them and sell them yourself. And with a little luck and a lot of perspiration, you're hoping to retire early. Look out Bill Gates! You know that poor management is the root cause of 80% of the failures in new companies. But, you're not going to make that mistake because you've taken finance courses and read all about business management. Let's look at the failures not caused by bad management. Product Quality A good product for a good price is the hallmark of success. But an inferior product, at any price, will have a difficult time. It cannot be overstated that the quality of a new product must be exceptional. You're challenging existing products so your ePod must stand out in some way. It must clearly superior in performance or else sell for considerably less than similar products. Customers must get more bang for their buck or else they will not change their buying habits. Examine your own buying habits. What will it take for you to change your grocery store? A product that has bugs or performs poorly is devastating in two major ways. The first is that it immediately clobbers your sales volume. You'll get few sales and a lot of returns. (Which you can't re-sell as a new unit. But many start-ups do anyway. Can you say bad manage- ment?) The second is that it gives your business a poor reputation. So even if you correct the product, you've alienated your customer base. Never forget— your customers give you money! Cherish them and cultivate them. People expect and deserve a professional quality product. By going into production you've said to the world that you're a professional and that your product is just as good, or better, than competing products. If you can't deliver that, don't try. All that will do is frustrate you and give your company a bad name. Pricing Start-ups often have difficulty in pricing their product. For example suppose your product costs $25 in parts and takes you an hour to assemble. Should your minimum selling price be $50 or $100? If you said $50 you'll be out of business very quickly. Here's why. Suppose you get an order for 1000 ePods. That's 1000 hours of Production assembly time or 25 weeks of full-time effort. Very few customers are willing to wait half a year for delivery. So you will have to hire and train assemblers. Setting up your own company with employ- ees, offices, insurance, equipment, taxes, etc. is not fast or cheap. An hour of technical labor plus overhead will be at least $25 an hour. So, right out of the gate, all your mark-up is gone. Even if you raise your price for other customers, you will have no profit from sales for at least six months. That's a huge financial hurdle to overcome. Alternatively, you could contract out the assembly, locally. This will save you the set-up time, labor and overhead costs. However, the contractor is now paying for salaries and overhead. He expects to see a profit, so he will charge you more than what he is paying. Again you will see no profits for half a year. It's very possible that you will actually lose money. Finally, you could contract with an overseas assembly house. Their labor costs are very low and nowadays they are fairly easy to work with and no longer require huge volumes (10 Kunits or more). Of course, there are the problems of language, import/export rules, contract negotiation, shipping costs, etc. Then there is the concern of intellectual property protection. It is not unheard of for these contracting houses to manufacture your product and sell it for themselves. With their name on it! It's no fun competing with your assembler. Initiating an international lawsuit is ridiculously expensive and time-consuming. Lastly, these cheap assemblers are notorious for poor workmanship. The bottom line on pricing is to assume a minimum cost of $25/hr for labor (which is still quite low). Your MINIMUM selling price should be twice the parts and labor costs. If this means that your selling price is not competitive, then you have a problem. Design for Production and Test Probably the single most important factor in reducing labor costs is to design your product to be easy to assemble and test right from the start. Labor costs usually have the biggest influence in product pricing. So, if you can significantly reduce the labor, you can sig- nificantly reduce your assembly costs and make your product more financially attractive to consumers. Obviously, there is way too much information about this to discuss here. But there are plenty of books on the subject. If you are seri- ous about producing your ePod, then you should be willing to spend a few dollars for the books and a few weekends reading them. You may have to re-design your product. But, a few up-front hours spent in improving the ePod can save you thousands, or tens of thousands of dollars, in the long term. And then there's the engineer's mantra: "After you built it the first time, you know how to build it right." Look around your home or office. Examine how the products are put together and learn from them. These are successful products. They have to be successful products or you wouldn't have bought them. ( 130570 ) www.elektor-magazine.com | April 2014 | 85 •Store SPECIAL OFFER for GREEN and GOLD Members! www.elektor.com/zeroes 110 Elektor Editions, Over 2500 Articles . DVD Elektor 2000 through 2009 This DVD-ROM contains all circuits and projects pub- lished in Elektor magazine's year volumes 2000 through 2009. The 2500+ articles are ordered chronologically by release date (month/year), and arranged in alphabetical order. A global index allows you to search specific content across the whole DVD. Every article is printable using a simple print function. This DVD is packed with ideas, circuits and projects that are ideal for any electronics enthusiast, student or professional, regardless of whether they are at home or elsewhere. ISBN 978-1-907920-28-8 £77.95 • € 89.00 • US $121.00 Explore the RPi in 45 Electronics Projects E Raspberry Pi This book addresses one of the strongest aspects of the Raspberry Pi: the ability to combine hands-on electronics and programming. No fewer than 45 excit- ing and compelling projects are discussed and elab- orated in detail. From a flashing lights to driving an electromotor; from processing and generating ana- log signals to a lux meter and a temperature control. We also move to more complex projects like a motor speed controller, a Webserver with CGI, client-server applications and Xwindows programs. Each project has details of the way it got designed that way. The process of reading, building and programming not only provides insight into the Raspberry Pi, Python, and the electronic parts used, but also enables you to modify or extend the projects any way you like. 288 pages • ISBN 978-1-907920-27-1 £34.95 • € 39.95 • US $56.40 Lots of power with low distortion ■ Q-Watt Audio Power Amplifier Elektor has a long history with audio power amplifi- ers. We are proud to present yet another fully analog circuit developed entirely in house. Despite the sim- ple design of this audio power amp with just one pair of transistors in the output stage, Q-Watt can deliver over 200 quality (Q!) watts into 4 ohms with excep- tionally low distortion thanks to the use of a special audio driver IC. Due to popular demand, this project is now supported by a semi-kit containing everything you need to build a stereo amplifier. 2 PCBs and all electronic parts Art.#110656-72 £151.25 • € 169.95 • US $244.00 The luxury of precision within everyone's reach B 500 ppm LCR Meter The remarkable precision of this device and its amazing ease of use are the result of careful design. It works so well behind its uncluttered front panel that one could almost forget the subtleties of the measurement tech- niques employed. A dream opportunity for our readers who are passionate about measurement to enjoy them- selves. If, like us, you wonder at the marvels modern techniques bring within our reach, come along and feel the tiny fraction of a volt. Set: main board and LCD board, assembled and tested Art.# 110758-93 See www.elektor.com/lcrmeter All articles in Elektor Volume 2013 E3 DVD Elektor 2013 This DVD-ROM contains all editorial articles published in Volume 2013 of the English, American, Spanish, Dutch, French and German editions of Elektor. Using the supplied Adobe Reader program, articles are pre- sented 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 86 | April 2014 | www.elektor-magazine.com Books, CD-ROMs, DVDs, Kits & Modules graphics program, zoom in / out on selected PCB areas and export circuit diagrams and illustrations to other programs. ISBN 978-90-5381-277-8 £23.50 • € 27.50 • US $37.90 Display, SD card, Ethernet, RS-485, buttons and LEDs 03 XMEGA Web Server Board This microcontroller board is particularly well suited to monitoring and control applications. The plug-in TCP/IP module allows you to implement a web server and other network-oriented applications and a microSD card provides mass storage. Four LEDs, four buttons, and a removable display provide the user interface options. And of course the board comes with a wide range of external interfaces. Controller Module Art.# 120126-91 See www.elektor.com/xmega Programming step-by-step E Android Apps 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, aim- ing to show how personal applications can be pro- grammed. A wide variety of applications is presented based on a solid number of hands-on examples, cov- ering anything from simple math programs, read- ing 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. 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! 244 pages • ISBN 978-1-907920-15-8 £34.95 • € 39.95 • US $56.40 MIFARE and Contactless Cards in Application E RFID MIFARE is the most widely used RFID technology, and this book provides a practical and comprehensive introduc- tion to it. Among other things, the initial chapters cover physical fundamentals, relevant standards, RFID antenna design, security considerations and cryptography. The complete design of a reader's hardware and software is described in detail. The reader's firmware and the asso- ciated PC software support programming using any .NET language. The specially developed PC program, "Smart Card Magic.NET", is a simple development environment that supports sending commands to a card at the click of a mouse, as well as the ability to create C# scripts. Alter- natively, one may follow all of the examples using Visual Studio 2010 Express Edition. Finally, the major smart card reader API standards are introduced. The focus is on pro- gramming contactless smartcards using standard PC/SC readers using C/C++, Java and C#. 484 pages • ISBN 978-1-907920-14-1 £44.90 • € 49.90 • US $72.50 A Small Basic approach E PC Programming There are many different PC programming languages available on the market. They all assume that you have, or want to have, a knack for technology and difficult to read commands. In this book we take a practical approach to programming. We assume that you simply want to write a PC program, and write it guickly. Not in a professional environment, not in order to start a new career, but for plain and simple fun... or just to get a task done. There- fore we use Small Basic. You will have an application up and running in a matter of minutes. You will understand exactly how it works and be able to write text programs, graphical user interfaces, and advanced drivers. 194 pages • ISBN 978-1-1-907920-26-4 £29.50 • € 34.50 • US $47.60 www.elektor-magazine.com | April 2014 | 87 •Store Drag 'n Drop ADAU1701 Universal 1 Audio DSP Board Always wanted to start out with DSPs, but afraid of the SMD? Here's the answer: Elektor's all-DIY Univer- sal Audio DSP Board! Based on the Analog Devices ADAU1701 DSP chip and drag-and-drop software, this board will ease your way to becoming a sound crafts- man, guaranteed maths-free. Semi-kit: all TH components, PCB with DSP preassembled Art.# 130232-71 £64.95 • € 169.95 • US $104.80 140 Minutes video presentation and more . DVD Feedback in Audio Amplifiers In this Masterclass we address several aspects of feed- back in audio amplifiers. The focus of this Master- class, although not entirely math-free, is on providing insight and understanding of the issues involved. Presenter Jan Didden provides a clear overview of the benefits that can be obtained by feedback and its sib- ling, error correction; but also of its limitations and disadvantages. Recommended to audio designers and serious audio hobbyists! ISBN 978-907920-16-5 £24.90 • € 29.95 • US $40.20 An essential source of reference material . Process Measurements with C# Applications Measurement is vital to the successful control of any process. This book introduces PC based measurement systems and software tools for those needing to under- stand the underlying principles or apply such technigues. Throughout the book, the C# programming language is used to give the reader immediate practical desktop involvement. C-Sharp has a wide support base and is a popular choice for engineering solutions. The basics of measurement and data capture systems are presented, followed by examples of software post-processing. Application examples are provided from a range of pro- cess industries, with reference to remote monitoring, distributed systems and current industrial practices. 144 pages • ISBN 978-1-907920-24-0 £24.50 • € 27.50 • US $39.50 Helped By Arduino I Mastering Microcontrollers The aim of this book is not only to let you enter the World of Arduino, but also to help you emerge victori- ous and continue your microcontroller programming learning experience by yourself. In this book theory is put into practice on an Arduino board using the Arduino programming environment. Having completed this fun and playful course, you will be able to program any microcontroller, tackling and mastering I/O, memory, interrupts, communication (serial, I 2 C, SPI, 1-wire, SMBus), A/D converter, and more. This book will be your first book about micro- controllers with a happy ending! 348 pages • ISBN 978-1-907920-23-3 £34.95 • € 39.95 • US $56.40 Circuits & Projects Guide E Arduino The Arduino user is supported by an array of software libraries. In many cases, detailed descriptions are missing, and poorly described projects tend to confuse rather than elucidate. This book represents a different approach. All projects are presented in a systematical manner, guiding into various theme areas. 88 | April 2014 | www.elektor-magazine.com Books, CD-ROMs, DVDs, Kits & Modules ; Fractal | I Digita5 s, g"al Processing \ UFl PAiVjccnlrcil t :s \t 1 , //'V * i X ■— 1^ V -iSfj \ A Oqijart Ibralirr 0tektor eificurt CELLMf In the coverage of must-know theory great atten- tion is given to practical directions users can absorb, including essential programming techniques like A/D conversion, timers and interrupts— all contained in the hands-on projects. In this way readers of the book create running lights, a wakeup light, fully func- tional voltmeters, precision digital thermometers, clocks of many varieties, reaction speed meters, or mouse controlled robotic arms. While actively work- ing on these projects the reader gets to truly com- prehend and master the basics of the underlying controller technology. 260 pages • ISBN 978-1-907920-25-7 £34.95 • € 39.95 • US $56.40 Time & Date Floating in the Air E UltiProp Clock Electronics is never so fine as when it skillfully com- bines magic with physics, mechanics with software, imagination with thoroughness and precision, and a taste for beauty with good workmanship. This time- piece was designed to display the time and date in an original way— but we admit we did also design it to draw cries of amazement from the visitors who find it in our laboratory. Well bet many of you will want to do the same in your own homes! Module, ready assembled and tested Art.# 120732-91 See www.elektor.com/ultiprop Ideal reading for students and engineers Practical E Digital Signal Processing using Microcontrollers This book on Digital Signal Processing (DSP) reflects the growing importance of discrete time signals and their use in everyday microcontroller based systems. The author presents the basic theory of DSP with minimum UK /ROW Elektor International Media 78 York Street London - W1H 1DP United Kingdom Phone: +44 20 7692 8344 E-mail: service@elektor.com mathematical treatment and teaches the reader how to design and implement DSP algorithms using popular PIC microcontrollers. The author's approach is practical and the book is backed with many worked examples and tested and working microcontroller programs. The book should be ideal reading for students at all levels and for the practicing engineers who may want to design and develop intelligent DSP based systems. Undergraduate students should find the theory and the practical proj- ects invaluable during their final year projects. Simi- larly, postgraduate students should be able to develop advanced DSP based projects with the aid of the book. 428 pages • ISBN 978-1-907920-21-9 £44.90 • € 49.90 • US $72.50 USA / CANADA Elektor US 111 Founders Plaza, Suite 300 East Hartford, CT 06108 USA Phone: 860.289.0800 E-mail: service@elektor.com Further Information and Ordering: WWW.elektor.COm/store or contact customer service for your region www.elektor-magazine.com | April 2014 | 89 •Regulars NEXT MONTH IN ELEKTOR MAGAZINE Arduino Experimenter's Shield To perform simple experiments, such as those in the newly started Microcontroller BootCamp course, Elektor Labs developed a small experimental PCB for plugging on to practically any Arduino board. The shield contains two buttons, two LEDs, one potentiometer and level shifters for adjusting the logic levels of the Arduino board. In addition, the shield is equipped with a universal ECC connector. Mini RGB Lamp with IR Remote Control Lighting circuits with colored LEDs are all the craze nowadays. There are plenty of such RGB lamps for sale, but an electronics engineer naturally designs and builds such a device himself. This circuit is small and employs four LEDs connected in series and powered at just 5-V thanks to a simple voltage converter. The control is effectively via a standard RC5 remote control that allows, among others, color and brightness to be adjusted. Touchfree Display Control The Ootside Box mentioned in the March 2014 installment of Elektor World is a smart circuit that lets you detect hand movements from a distance by means of a metal frame around a tablet computer. The system allows you to operate programs and games with simple gestures. Next month we present the hardware and software designed for this purpose. We regret that 'Intelligent Cuelight System' and '433 MHz Gateway' could not be published in the current edition as scheduled. Article titles and magazine contents subject to change, please check www.elektor-magazine.com for updates. Elektor May 2014 is processed for mailing to US, UK and ROW Members starting April 22, 2014. See what's brewing @ Elektor Labs 24/7 Check out www.elektor-labs.com and join, share, participate! Project Proposals Create a Project create a new project or enter a proposal This page lists all the new project proposals and project ideas that have not been promoted to In Progress yet. Promotion of a project depends on its popularity, originality or usefulness. Create a new project or submit an idea now! Get help, feedback & votes from other visitors, ard mavbe you will oet Elektorized tool You have to log in to vote, to comment or to create a project. Vote for your Favorite P DDS Function Generator Shield for Elektor FPGA Board Total views; 69 After going through the recent Elektor FPGA Board article scries, I wanted to put my FPGA board to some practical use while gaining more experience... iririririr You want to post a project but you are not a member? ^ojr| fg-mQ Click here to send a description of your project including a circuit diagram and a photograph for evaluation and mayte _£i you will be granted fiY3 Rcbuildablc E-cig cartomiscr. Total views; 9 This is just barely electronic - unless you count the coil of resistance wire in the cartomiser. As a project, its far from finalised - sn far the... HPDisk - An SD- based disk emulator for GRIB instruments and computers Total views; 3,794 Fancy being able to store the data from your old HP163xx analyser? Or your Spectrum Analyzer? Or pretty much any old GPIB-instrument that supports a... iririririr Challenges ★ ★★★★ CC Weekly Code Challenge CIRCUIT CELLAR All challenges, Join a Project! DDS Function Geneiatoi Shield 90 | April 2014 | www.elektor-magazine.com \ \ 7 functions of PicoScope: Technology 1. Oscilloscope 2. Spectrum analyzer 3. Function generator 4. AWG 5. Logic analyzer 6. Serial protocol analyzer 7. Automatic waveform test For just £1395 • High resolution •USB powered • Deep memory B A ± 5Q V ®