July & August 2012 Th ink Measure yo) \JL v^BSI yg,J| * jP Wi ■H f • P ■ 3 |» 1 ’ 1 J_i] X'.^) ' jHHj rvzj Mi * r*i F#r,x *nk Lv ' M. Vk. One platform for 8-, 16- and 32-bit development - with Microchip's MPLAB® X IDE InflntocfrafcB Dote! * „-.cM t^nmenf 8-bit PIC® Microcontrollers 128K Flash 16 MIPS 250+ Options 16-bit PIC® Microcontrollers & dsPIC® Digital Signal Controllers 256K Flash 70 MIPS . 150+ Options 32-bit PIC® Microcontrollers 512K Flash 1.5 DMIPS/MHz . 80 MHz 500 + A Analog & W e**». ■ ■ >+*W.. I . 1Z1 I 'J ■ " '-T.V J ' .'■ ■ ' h *1 -m.1 u.J .1 I.J-.L* ■. .-*■ KTT? Uu*fc. ■Ski iU_' * Slnta i-J- ZB-! I iW kfc‘1 F if il*M ■ '-*» i»f ■■ ■* rW pm 4 in; tups' hmr 'sh ■■-»■■! m p ji f jwi 'jw jiuuiiini Ut. wsr ■ itOL-*'* JmL ilii il VkP-. iE-fc Llu .1 L-rtJP b_* r -AS m ■ > -KriiVi w UR ■ ■ ad -m in n ■!■ ■ uwHn inn pr s ‘ Mw « « imh##' t we s I !r— i ******* wm J*#i *-**»*! l* r j • P ra r- - -■ -1 r ••i.Bh - ■■-t r-»_ J - launched its or Projects. an electronics lektor member. The , vote for project prbpbsdlsi ybu\ like, add pohtribut&xto peer projects. / \\\\\\\ But that’s not all. Elektor Projects is also set up to stage activities for you, like games, design challenges and community projects in which yob too can participate. And it doesn't stop here either, no sir, we go all the way by offering you a chance to make money from your passion! hnwi UfJ! b4CB*i AVR bus co'iaw E=t^ ■ Etttel2rfEUa9ur£HKUf RL7fl 5DR ^_i us6 *r-*» f 7-" fkp C; F* h ■ Hi «n C.t« _ Sharing Lle^tronics Prajecti ‘irrti l I -1 f in^p — n j ymj| Pinjj^ i m- tjug «ILtF * - fc-J -lilfrp ris M W a^ihi^w Challenges pi tif i-'.i *- in Pi ugi uss 1 M LlrrJ rhTiyi mW •Xemesas i im n asm Go with the flow Proposals In Progress ed The work flow on Elektor Projects is simple. It all starts by entering a project or a proposal that's subject to voting y 0 Qr jf gje^tor tech members. If an entry attracts ma y . Dr0D0sa | is promoted to In staffers consider the suh]ect of partial ar in ^ ^ The goal of registered projects E | ek tor's online shop. 5s 14 Elektor 7/8-2012 COMMUNITY Praj*tt lltfi; U«r Loit YWr* And nil . ! ^Jj_G..i *. daU 4fl‘i ri i.i !4 rttfd cninvil ’o [its coirriUita'i FJEqiiit control of 3 g □ wcietl parapento sub«*tfrj si i cmB cn i s i ji - :u l: L 33pn TV* MSra f(I4 In MAT *wr >SbIi fer- a pOwe'efi pjuper.fe :) i fflliAJ dp it dn -jrit two. pi Ehd U*ktar JrfdJCCl: imr In ‘mrlulr ft 1 (MOS-l I ■ s.nSn£Hxl -JflSKS 3 Jpik* JUttl cai^-TrtiE EG (In £niErtt«jEJEn . |'J> C^.'S iLviSK.'il Participate and get noticed You can contribute to projects in all phases: Proposal, In Progress or Finished. Simply click the Create Contribution link at the bottom of a project page. Adding a comment to a contribution is also possible. This way we keep related information nicely grouped together without cluttering the main project page. When you join a project you will receive notification messages whenever the project is updated. Of course you can always unjoin. Elektor Labs will back you up projerth as been pro^- irs F Note that it is u for Vote and get elected ^° yects ^°by W voti : ng a f^^ yP ^' c 'P at:e Vektor try when you think it's a poorTh^ 0 UnV ° te an en ' Can vote or unvote only one. Ever V m ^ber Possible to overrate your r, ^ 50 * is not hundreds of votes on it 0n T T P ° Sal b V Putting sibie to create a buzz on " 1 ° ther band - * is pos Once a time to get going- "»« hea der picture your project. Without one it will never appea aa llery on the Home page. If you run into problems yc »u cap ask otker members o, help, you can even ask th L abs,or sbPPO- . ?££££ -V -ck ,0U UP « "« cle Goodbye Standby By Uwe Reiser (Germany) Energy saving has been a hot topic for some forty years now. In the early years the focus of public, political and specialist attention was on the large- scale users of energy, but now atten- tion is also turning to the much more numerous smaller-scale users, on the principle that 'many a mickle makes a muckle'. After a series of bans im- posed on ordinary incandescent light bulbs and the introduction of energy- saving bulbs in all shapes and sizes, the EU has recently started to take a look at the energy use of appliances in standby mode. Limits have been set that affect even small mains adaptors. However, one appliance, of which there are many millions in use in the coun- try, and which wastes energy round the clock, has surprisingly somehow man- aged so far to avoid proper scrutiny: the humble fixed-line telephone. The author, however, had not failed to notice this needless loss of energy. It had been a source of mild irritation for You will now no doubt be wondering how the author managed to satisfy these requirements. The fundamental question is how a circuit that draws no current can detect when it needs to come into operation. This is indeed the telephone's mains adapter, which then leaps into action to power the tel- ephone. Mains is also applied via this relay to the rest of the energy-saver circuit. The telephone will ring, and the call can be picked up and answered as Telephone without standby current some time that even the most state- of-the-art fixed-line telephone is doing nothing most of the time except wait- ing for an incoming call, and yet needs a mains adaptor drawing power all day. It is perhaps worth knowing that most older telephones [1], [2], such as the type 706, draw no current at all when idle. This would be the ideal to which the author would aspire: a current draw in standby mode of zero. Furthermore, the energy-saving circuit itself should be as efficient as possible, preferably switching itself off completely as well. possible and in fact not as problematic as it might appear. As is well known, the fixed-line network operator feeds an AC voltage of up to about 60 V down the analogue line as a ringing signal; when the receiver is picked up to an- swer or place a call, a DC voltage ap- pears on the line and a current flows. Now to the circuit. The ringing voltage is passed via Cl to the bridge rectifier formed by diodes D1 to D4. The result is smoothed by C2 and pulls in bistable relay RE1. The mains voltage is then passed via the contacts of this relay to usual. If the user wants to place a call, he first presses button SI, which caus- es the DC voltage across the 'a' and 'b' wires to pull in relay RE1. The number can now be dialled. All that remains is to explain how the energy-saver circuit knows when the call is over, or, indeed, has not been picked up in the first place. This job is done by timer IC2 (a device almost as elderly as the type 706 telephone!), connected here as a monostable with a period set by R1 and C3 of 30 s. Af- ter this period has expired the second, 18 Elektor 7/8-2012 opposing, coil of RE1 is energised and the relay drops out. The telephone and energy-saver circuit are now without power. This behaviour is perfect for the case where a call is not answered. However, calls often last longer than half a minute and it is not ideal to have to keep pressing SI to retrigger the monostable. That is where optocoupler I Cl comes in. It, together with an indicator LED, is driven via the bridge rectifier formed by diodes D5 to D8 which are in se- ries with the telephone line. The loop current thus flows also through these LEDs as long as the receiver is lifted. This keeps the top end of C3 at ground potential throughout a call, holding the output of IC2 high. Thirty seconds af- Think Up. r f ? ter the receiver is replaced all the loads are disconnected. The relay and the optocoupler serve to keep the low-voltage electronics and the telephone line isolated from the mains supply. The bistable relay used must be a type where the two coils are completely separate, and hence with a total of four coil connections. A red LED is best for D9, which lights while the receiver is lifted, because of its low forward voltage. The energy-saver circuit itself naturally consumes some power during a call. However, thanks to the 0.5 W transformer used and the simple, efficient electronics, it amounts to only a few milliwatts. This is small compared to the savings that can be expected when the unit is idle. TV 9 I c * JK As you can see from the photograph of the prototype and from the component mounting plan, an Elektor printed cir- cuit board has been designed for this project [3]. No SMDs are involved, and so populating the board should present no difficulties. Four- or six-way RJ11 sockets may be used. The board can be mounted in an enclosure that is fitted between the telephone and the wall plate. Jumpers J1 to J3 determine whether the circuit responds to the line wired to pins 1 and 4 or to pins 2 and 3. All three jumpers must be in the same position (position 1 or position 2). The transformer we have suggested has two 115 V primary windings and so can be configured using J4 for 115 V or 230 V operation. For 115 V operation +12V 2x 6V/ 2x CVA25 091046-11 'X 'X, Elektor 7/8-2012 19 One final word on tel- ephones. There are some models that are not ready for operation for ten to fifteen seconds after be- ing powered up. These are not ideal for use with this circuit, as one or per- haps more rings will be lots when a call is received. Also, some telephones with integrated (non- cassette- based) answering machines two links are fitted in the outer posi- tions; for 230 V operation a single link is fitted in the middle position. The jumper arrangement precludes fit- ting all three links at once, which would have the un- fortunate effect of short-cir- cuiting the mains supply. If a transformer with a single appropriate primary wind- ing is used, these links are not needed. either forget their stored messages or rapidly exhaust their back-up batteries when power is lost, and these also are not ideal. Caution. Modification or home con- struction of circuits connected to the PSTN (public switched telephone net- work) is subject to local regulation and may not be legal. (091046) [1] www.telephonesuk. co.uk/phones_prel960. htm [2] www.telephonesuk. co.uk/phones_1960-80. htm [3] www.elektor. com/091046 20 Elektor 7/8-2012 Think Up, r Noisy LEDs Simple generation of complex sound effects By Ralph Willekes (Belgium) These days there are many types of intelligent LEDs available. These LEDs flash or change their colour, slow- ly or quickly and with dif- ferent colour combinations. Those LEDs that gradually change from colour to colour (so-called rainbow LEDs) were found to be particularly suitable for an alternative application. They happen to produce incredibly complex sounds when they are con- nected as shown in this cir- cuit. Potential divider Rl/Pl lim- its the current through the LEDs and has a significant impact on the sound pro- duced. The value can be set between roughly 100 ft and 100 kft. In this circuit it was achieved using a re- sistor and a preset. If you want to keep things very simple you can get rid of the preset and experiment a bit with series resistor Rl. The circuit works with a single LED, but the addition of For a more LEDs leads to more interesting C2 to Rl 'heavier' sound you can increase about 1 pF or even 10 pF. Cl avoids the presence of any DC voltage at the output. The supply voltage to the circuit can be anywhere be- tween about 4 V and 10 V (depending on the value of Rl and the LEDs used). Make sure that you turn the volume down fully on your amplifier before you connect this circuit, since level of the output signal can vary sig- nificantly. (120261) sounds because the LEDs end up 'fight- ing' each other for the energy. C2 and resistor R2 form a low-pass fil- ter. Start with a value of about 10 nF in order to hear the full range of sounds. Internet Links Demo film: http://youtu. be/z_aOeCGBZIk Version using different LEDs and 4.7 pF for C2: http://youtu.be/ vbITTveORRA COMPONENT LIST Weerstanden: Rl = 100ft R2,R3 = lOkft PI = lOOkft Miscellaneous 'Elex' type experiment- er's board Capacitors Cl = 22pF 16V C2 = see text Semiconductors D1,D2,D3 = rainbow LED, preferably mixed types Elektor 7/8-2012 21 Bicycle Rear Light one super LED and 10 components last 5 minutes By Henri Dutoit (France) tv Fitting a bike with a rear light that stays on even when sta- tionary is both use- ful and interesting - especially when it uses a circuit as simple as this. This project would stand a good chance of winning the prize for the hands on the soldering iron. If they want to, they'll discover here some fun- damental notions like rectification, stabilization, the constant current source... but don't let's scare them away with all that for the moment. The idea is clear, the solution illuminating: in es- sence, we have a rectifier, a very high capacitance buffer capacitor, and a high-bright- ness LED. smallest circuit in this edition. This is, moreover, the reason why it's been chosen here, as Elektor has already published at least two or three The alternating voltage from the dynamo (G1 on the cir- cuit diagram) is rectified by 4 diodes, which works out cheaper than a single bridge- rectifier. Once it has been charged up by a few turns of the pedals, a single 1 farad su- percapacitor, known as a GoldCap, is able to keep the LED D3 lit for a good five minutes when the bike is sta- tionary. Before seeing how this LED works, let's take a look at the supercapacitor, on whose terminals the rectified voltage must not exceed the voltage stated by The idea is clear, the solution illuminating. versions that are more elaborate, but not necessarily any better. This version is stripped right down to the bare es- sentials, but stays on for 5 minutes; it also provides an ex- cellent pretext for trying to get young people interested in electronics, who maybe want nothing more than to get their the manufacturer, i.e. 5.5 V. So we're going to be using a 5V6 zener diode to clip the peaks of the pulsing direct voltage. There's no risk that the current supplied by a bike dynamo is going to harm this device, which is capable of dissipating a power of 3 W. If you are a bit dubious, you can always go 22 Elektor 7/8-2012 Think Up, / r y for a capacitor with a higher voltage rating, for example the DK-6R3D105T from Elna America (available from Digi-Key) which, as its type number suggests, can handle 6.3 V. An- other advantage of this device is its lower series resistance compared with the Panasonic type we tested (30 ft instead of 50 ft), which means that when fully charged, its voltage will be slightly higher. With the GoldCap, using an AC voltage of 6 V @ 50 Hz, we measured a DC voltage of 4.8 V with 0.76 V residual ripple. T1 and the two components associated with it, R2 and the LED Dl, form a constant current source. Even when the su- percapacitor discharges, these ensure that the brightness of the powerful LED D3 remains stable. It needs to be able to handle a continuous current of at least 20 mA. This current is determined by the value of Rl. The table gives an idea of the way the voltage across Rl changes with Stop Uri 0 1 V 2 min 0.5 V 3.5 min 0.25 V 4.5 min 0.1 V 6 min 0.05 V time once the bike has stopped. After six minutes, the volt- age has dropped right off and the current in the LED is now only 5 % of its nominal value. To make the circuit easy to build, we suggest building it on prototyping board or breadboard. Watch out! Don't forget to make the break in the topmost track, otherwise T1 and D3 will receive the alternating voltage! (110473) COMPONENT LIST Resistors Rl = 47Q R2 = 1.2kQ Capacitors Cl = IF 5.5V, e.g. Panasonic EECF5R5H105 Semiconductors Dl = LED, red, standard (V f = 1.7V) D2 = zener 5.6V 3W D3 = LED, red, high brightness, e.g. MCL034URC ( I max — 20 mA) D4-D7 = 1N4004 T 1 = BC547B Elex-1 (UPBS-1) prototyping board Elektor 7/8-2012 23 ATtiny Goes Wireless V ANTI MODI R1 71 R2 hH €> BC547 45V 3 6 7 8 9 n VCC PA2 PB7 PDQ'RXD PB6 PD1 IC1 PB5 PD2 PB4 PD3 PB3 PD4 ATT1NY2313 PB2 PD5 PB1 PD6 PBO PA1/X2 PAtyxi GISD 19 18 17 16 15 14 13 12 R4 110296 - 12 By Jurgen Stannieder (Germany) In many application areas it can be very handy to be able to control some- thing wirelessly. This circuit shows how an ATtiny microcontroller can be used to switch an appliance on and off re- tion we represent the appliance to be controlled by a red LED at the receiver end. At the transmitter end, buttons SI and S2 are responsible for the 'on' and 'off' switching functions (see left-hand circuit diagram). When one of these buttons is pressed it pulls the corre- 'E' to switch the appliance on and 'A' to switch it off. The command message is emitted at output PD1 (TXD) of the AT- tiny, where it is inverted by T1 and then sent to the Conrad transmitter module. The inverter is needed here as the TXD output (as is conventional) returns high Reliable data transmission with a good 12 m range within your house motely with a little help from wireless transmitter and receiver modules avail- able from Conrad Electronic. If needed, it is very easy to extend the project to include additional commands. To demonstrate the principle of opera- sponding input of the microcontroller (PD3 or PD4) to ground. The software running in the microcontroller recognis- es the input and converts it into a com- mand message. In this case the mes- sage consists of the single character when no message is being sent. With- out the inverter this would mean that the transmitter would always be active when no message was being sent: with the arrangement shown the transmit- ter is idle between messages. Crystal Elektor Products & Services • ATtiny2313 microcontroller (programmed) • Transmitter: 110296-41 • Receiver: 110296-42 • ELEX-1 (UPBS-1) prototyping board • Free software download Products and downloads available via www. elektor. com/ 110296 24 Elektor 7/8-2012 Think Up, ' •f COMPONENT LIST Transmitter Resistors R1 = 4.7kft R2 = lOkft R3 = 470ft Capacitors C1,C2 = 33pF C3,C4,C5 = lOOnF MKT, 5mm Semiconductors LED1 = 5mm, red T1 = BC547C, TO-92 IC1 = ATtiny2313 DIP-20, pro- grammed, Elektor # 110296-42) Miscellaneous XI = 3.6864 MHz quartz crystal, HS49/S case S1,S2 = pushbutton, e.g. B3F-1000 TX = Transmitter module from 433 MHz AM transceiver set, Conrad Electronics # 130428 Dl P20 socket ELEX-1 (UPBS-1) board (1/2) XI produces the clock for the micro- controller, the 3.6864 MHz frequency used allowing easy generation of baud rates from 9600 baud to 76800 baud. We configure the microcontroller to run at 9600 baud, which gives reliable operation with the radio modules. LED Dl and its series resistor are present in the circuit to give feedback to the user when the microcontroller registers an input. The LED lights when either of the buttons is pressed. At the receiver end (see right-hand circuit diagram) the signal from the receiver module is passed to another microcontroller which then processes the received information. Because the signal was inverted prior to transmis- sion, it must be returned to its unin- verted form by inverter Tl. The soft- ware in the microcontroller reads the signal in at its PD0 (RXD) input. De- pending on whether its sees the let- ter 'E' or 'A', it turns LED Dl on or off. Again, the microcontroller receives its clock from crystal XI, with a frequency of 3.6864 MHz. The 433 MHz radio transmitter and receiver modules used in this project are available as a set from Conrad [1]. Construction is relatively straightfor- ward. It is worth noting that the an- tennas on the transmitter and receiver modules are tuned appropriately at the factory and should not need further adjustment. The circuit can conveni- ently be built on an Elektor Universal Prototyping Board Size-1 (UPBS-1, a. k.a. ELEX-1) cut into two halves (see photographs and mounting plans). The author managed to achieve reliable communication between the two mod- ules within his house over a distance of 12 m. (110296) [1] www.conrad-uk.com/ce/en/ product/130428/ Elektor 7/8-2012 25 A Zero Current Switch For inductive Loads By Matthias Haselberger (Germany) Relays or contactors are often used to switch mains powered inductive loads such as motors, valves or electro magnets. When the device is switched off an arc can form across the relay contacts as they open. This leads to premature relay failure if measures are not taken to suppress the spark. In addition to relay damage the high voltage spark causes interference and EMC issues. The most common method of suppressing the arc is to connect a snubber in parallel to the contacts. This device is a series resistor and capaci- tor network. Now when the contacts break, energy stored in the inductor has a path to dissipate through the snubber to generate a small amount of heat in the resistor. Typical values of the snubber components are R = 1 to 100 ft und C = 10 to 1000 nF. Relay contacts open at unpredictable times during the mains AC cycle; at the time of maximum current the induced 'back-EMF' and contact arcing prob- lems mentioned above will be most severe. Semiconductor relays using thyristors or triacs will always turn off when the voltage across them passes through zero, for a load with a highly reactive power component the voltage and current will be phase shifted so that this point corresponds to the in- stant of maximum current. A snubber will be an essential component in this situation. Snubbers are however not complete- ly unproblematic; a small current will continually flow through the snubber RC network (and load) when the con- tacts are open. Not only is this wasteful but with a very light load such as a fan, it can of- ten be enough to keep the fan running. Increasing the value of R reduces its effectiveness at suppressing arcs. There is however an alternative so- lution to the problem of switching inductive loads. The method suggested here is really quite simple: make sure that the inductive load can only be switched off when the current waveform (not the voltage) passes through zero. With no current flowing there will be no en- ergy stored in the load inductance to cause problems. Using this approach 26 Elektor 7/8-2012 it's possible to dispense with the snub- ber completely. This was the train of thought that passed through the au- thors mind and set him on the path to design this zero-current switching electronic relay. So to the solution: The parts of the cir- cuit handling the power are the bridge rec- tifier Bl, the DC Think Up T " IS X > * a y base-emitter junction of T3, turning it off and bringing T1 into conduction thereby switching the load on. To turn the load off the TTL input is brought low to turn off the photo tran- sistor. T3 can now only be turned on when T2 turns off. T2 remains con- ducting until the load current passes through zero when the voltage across D1 and D2 drops to zero. So after the TTL input goes low, the load remains switched on until load current sinks to diagrams confirmed the circuit func- tion using inductive loads. CHI shows the voltage at the collector of T1 and CH2 the voltage at the emitter of T1 and the base of T2 which corresponds to the absolute value of current flowing in the load. CH3 shows the control volt- age applied to the gate of Tl. A phase shift of 20 0 between the voltage and current waveform is used in this simu- lation. The author confirmed the simu- lation results with observations of the finished working circuit. Those of you Snubber-free switching path through the IGBT Tl and the shunt made up from D1 and D2 can be short-circuit- ed. This effectively replaces the classic TRIAC. Its gate is controlled by the voltage at the collector of T3. T3 is influenced by the optocoupler out- put and also the zero current detector made up from Dl, D2 and T2. When the load is switched off there is no current flowing and T2 will be off, T3 will be conducting and Tl will be off. A high on the TTL input turns the photo transistor in I Cl on which shorts the (almost) zero. J ust what we wanted. The author simulated the circuit us- ing the Multisimll software from Na- tional Instruments (Nl). The resulting interested in the simulation details can look at the 'Elektor3_10.msll' file as- sociated with this project which can be downloaded from the Elektor website CHI ‘‘V CH2 \ \ s ' ■j X \ / \ f V . .... 5ms/Div CH3 1 'i . i III ' 1 j 1 v.*.-.— ■ • ■ • 1 ■ COMPONENT LIST Resistors R1 = 100 ft R2 = 2.2kft R3,R4 = 47kft R5 = 82kft 1%, 0.6W 350V (Vishay MRS25000C8202FCTOO) R6 = 2200 . R7 = 180ft R8 = 68ft R9 = 22kft Capacitors C1,C3 = 10|jF 100V 20%, pitch 2.5mm, diam. 6.3mm C2 = lOpF 63V, axial, 10 x 4.5mm D3 = 1N4007 D4 = BZX79-C13 (13V 05W) Semiconductors Bl = W06M, 600V 1.5A D1,D2 = 1N4004 Tl = IRG4BC30KDPbF T2..T5 = BC546A IC1 = PC817 (see text) Miscellaneous PCB # 100270 [1] Elektor 7/8-2012 27 [1]. An evaluation version of the Mul- tisim simulation software is available from NI [2]. A few more circuit details: R1 ensures that the voltage at the base of T2 re- ally does go to zero when the current waveform passes through zero. D4 limits the V CE of T2 and T3 and also the V GE of T1 to a safe value. Capacitor Cl together with the jumper position JP1 allows the circuit to be used in situa- tions where the AC load is lightly in- ductive. It allows some adjustment of the turn-off point of T2 (and Tl) to the actual zero crossing point of current in the cycle. An IGBT type device has been used for Tl because the higher switching threshold of the gate voltage is more suited to this application than a high voltage MOSFET. Practically any optocoupler can be used for I Cl, its switching speed is not critical. A PCB is available for the project. The layout doesn't use any SMD's so as- sembly is very easy. The PCB can be obtained from the Elektor shop or the layout files in Eagle format can be downloaded free of charge [1] allow- ing you to produce your own. Be aware that the circuit is directly connected to the mains, some parts of the circuitry and PCB tracks carry lethal voltage levels. It is therefore vital to observe all the appropriate health and safety precautions. The use of 1N4004 diodes allows load currents up to 1 A, corre- sponding to a power rating of 230 VA. Transistor Tl does not need a heat sink at this power level. To make the design suitable to handle a higher current is not just a simple matter of swapping D1 and D2 for higher current versions. It will also be necessary to beef- up the PCB tracks handling the load current, B1 must also be replaced and Tl will require a heat sink. (100270) I nternet Links [1] www.elektor.com/100270 [2] http://www.ni.com/multisim LED-LDR Ring Oscillator By Burkhard Kainka (Germany) Can high-bright- ness white LEDs and light- dependent resistors (LDRs) be used to make an oscillator? I decided to have a go. For the experi- ment I chose type PGM5516 LDRs which have a rel- atively low resistance (5 k ft to 10 kft at 10 lux). A ring oscillator configuration was used, with each LED placed directly next to its neighbouring LDR (see circuit). The first test, without the capacitors, was unsuccessful. I had hoped that the natural slow re- 3 V and 9 V. The oscillation frequency rises with supply voltage. At 3 V the 120321 - 11 sponse of the LDRs would be enough to start oscillation, but the oscilloscope proved me wrong. Only by adding the 220 pF electrolytic capacitors could I get the oscillation to start, using a power supply of between circuit must be kept in darkness (and the result is a very low-energy run- ning light!). At 2.7 V the circuit draws 0.9 mA and is disturbed by even the smallest amount of ambient light. (120321) 28 Elektor 7/8-2012 green energy energy efficient ow P° wer hydri solar pmnennpn Renesas RL78 MCU ology lr\z. Ah 20 /? ' high pi win big prizes The RL78 Green Energy Challenge Do you want to influence how the world experiences green energy? loin the RL78 Green Energy Challenge today and show how your energy-efficient design solution can contribute to a "greener" world. Use an RL78 MCU to develop a low-power, green-energy design solution and you could win share of a $17,500 cash grand prize. Plus, keep following Renesas on Twitter and Facebook for a chance to win additional prizes through weekly challenges. For complete details, visit www.circuitcellar.com/RenesasRL78Challenge f @Renesas_Europe www.facebook.com/renesaseurope Participation in Weekly Challenges and receipt of partner prizes is not a factor in selecting winners for the Cash Grand Prize from Renesas. See website for complete rules and details. Void where prohibited by law. t In association with Elektor and Circuit Cellar Soft AC Line Start By Jurgen Kruger (Germany) This circuit clearly falls under the head ing "Why didn't I think of that earlier?" Virtually everyone who works with elec- that is triggered by a de- layed gate signal from an RC network with an upstream series triggers at a gate current of 60 pA. This allows resistors R1 and R1 to have relatively high values. These resistors in combination with Cl determine the ° I? D3 TH1 R 3 W it §i * t • — T nc < ► m 106S D4 - 71 tromcs has been faced with the need or desire to limit the inrush current of a large load. In the distant past this was achieved by placing a hefty resistor in series with the supply line and using a contactor (or a relay with a bit of additional elec- tronics) to short out the resistor shortly T(150k) 35V 4 4- — —4 4 Di... ra= UM4004 K2 -o C J the zero crossing point and become saturated due to inadequate core mag- netisation. With the specified components and component values, the circuit can be used for loads up to 230 VA. Higher currents require heavier-duty diodes and an SCR with a higher current rat- ing, as well as a heat sink for the SCR. With such modifications you should bear in mind that high-current SCRs require higher trigger currents, so the values of R1 and R2 should be re- duced and the value of Cl should be increased. Another option would be to use separate drive logic, but that would detract from the elegant simplicity of the circuit. The value or R3 should be adapted to the intended use or desired inrush current level. (110339-1) Knitting Counter Knitting always involves a lot of count- ing as you have to keep track how many rows you've knitted and how many should follow. This can of course be done with pen and paper, but it's more fun with an electronic variant us- ing a microcontroller. This counter has the following func- tions: • Switch SI increases the counter by one. • Switch S2 saves the current count in the EPROM memory of the micro- controller. • Switch S3 resets both the counter and internal memory to zero. • Switch S4 turns the device on and off. When it is turned on the display will show the value stored in the internal memory. Elektor 7/8-2012 31 1 The display and counter function are turned off after about 5-10 seconds in order to improve the battery life. Press- ing SI turns the display and functions back on again. An LED shows when the circuit is switched on, even with the display blanked. A low dropout voltage regulator (LP2950) is used the get the maximum usage from a 9 V battery. At the heart of the circuit is a PIC 16F628A. The three digits of the LED display (a common cathode type) are multiplexed via the PIC. The software is written in PICbasic from Proton and can easily be modified if required. Since the author has only recently started with programming microcon- trollers, the software has not made use of timers or interrupts. Despite that, the display is still turned off after some time, but this is achieved solely by the software. IC2 The circuit is built on a standard ex- perimenter's board and the component layout was developed using the pro- gram Lochmaster from Abacom [1]. The basic, asm and hex files can be freely downloaded from [2]. (120253) I nternet Links [1] www.abacom-online.de/uk/html/ lochmaster.html [2] www.elektor.com/120253 32 Elektor 7/8-2012 OHM'S LAW Three famous people brought together in one equation... do you see any similarities? V R.I— -KJ-*! 'Green' Solar Lamp By Burkhard Kainka (Germany) Energy saving is all the rage, and here is our small con- tribution: how much (or rather how lit- tle) cur- rent do we need to light an LED? Experi- ments with super-bright 1 W green LED showed that even one microamp was enough to get some visible light from the device. D1 R1 Rootling in the junk box produced a 0.47 F memory back-up capacitor with a maximum working voltage of 5.5 V. How long could this power the green LED? In other words, if discharged at one microamp, how long would the voltage take to drop by 1 V? A quick calculation gave the answer as 470 000 seconds, or about five days. Not too bad: if we use the capacitor for energy storage in a solar- powered lamp we can probably allow a couple more microamps of current and still have the lamp on throughout the night and day. All we need to add is a suit- able solar panel. The figure shows the circuit diagram of our (in every sense) green solar lamp. (120323) Power LED Driver By Michael Holzl (Germany) I f you want to operate power LEDS with a truly constant current - which signifi- cantly prolongs the lifetime of the lamp - and avoid the power loss resulting from using a constant voltage supply with a series resistor, you need a suit- able constant current source. However, the only way to achieve really good ef- ficiency is to use a switching regulator. Altogether, this means that you need a switching regulator designed to gen- erate a constant current instead of a constant voltage. With this in mind, the author started working on the development of a LED pocket torch with especially high effi- ciency. Along with using high-capacity rechargeable batteries to maximise operating life, it's worthwhile to be able to reduce the brightness, and therefore the operating current of the LEDs, when you don't need full power. Accordingly, the author incorporated a dimming function in the design, based on operation in PWM mode in to reduce power losses to an absolute minimum. As you can see from the circuit dia- gram, the author chose an LT3518 switching regulator IC, which is a buck/boost converter optimised for LED operation. Here it is used as a down converter (buck mode). This IC can achieve better than 90% efficiency in this mode, depending on the input voltage. According to the typical appli- cation circuit on the data sheet [1], its switching frequency can be set to ap- proximately 170 kHz by selecting a val- ue of 82 kft for Rl. To maximise overall efficiency with this type of IC, the volt- age drop over the sense resistor used to measure the current flowing through the LED should be as low as possible. This particular device operates with a voltage drop of 100 mV, corresponding to a current of just under 1.5 A with the specified value of 68 mQ for R2. This value proved to be suitable for the Cree LED used by the author. At this current level, a diode with a power rating of at least 6 W should be used for Dl. IC1 has an additional property that is ideal for this application: the connect- ed LED can be dimmed by applying 34 Elektor 7/8-2012 Design ~£zz f *+ ^ LEDS rated at over 5 W. These devices require a correspondingly higher supply voltage, which means more cells con- nected in series. This is only possible if the supply voltage for IC2 is reduced by a 5 V voltage regula- tor or other means, and of course R4 a PWM signal to pin 7 of the IC, with the brightness depending on the duty cycle. Obviously, the PWM frequency must be lower than the switching fre- quency. The PWM signal is provided by IC2, a special voltage-controlled PWM generator (type LTC6992 [2]). The duty cycle is controlled by the volt- age applied to the MOD input on pin 1 (range 0-1 V). The resistor connected to pin 3 determines the internal clock frequency of the IC according to the formula f = 1 MHz x (50 kft/R3). This yields a frequency of approximately 73.5 kHz with R3 set to 680 kft, which is much too high for controlling IC1. However, the PWM IC has an internal frequency divider with a division fac- tor controlled by the voltage applied to pin 4, which in this circuit is taken from voltage divider R4/R5. The division fac- tor can be adjusted over the range of 1 to 16,384. The division factor with the specified component values is 64, re- sulting in a PWM frequency of around 1,150 Hz. If you want to be able to generate a PWM signal with an adjust- able duty cycle over the full range of 0 to 100%, you must use the LTC6992-1 option. The -4 option, which provides a range from 5 to 100%, might be an acceptable alternative. To prevent the duty cycle (and thus the brightness of the LED) from depending on the battery voltage, which gradually drops as the battery discharges, IC3 generates a stabilised 1.24 V control voltage for potentiometer PI. Series resistor R7 reduces the voltage over PI to 1 V, which exactly matches the input voltage range of the LTC6992. All capacitors should preferably be ce- ramic types, in particular due to their low effective series resistance (ESR) as well as other favourable character- istics. However, only capacitors with X5R or X7R dielectric should be used; capacitors with type Y dielectric have very poor temperature characteristics. The supply voltage is limited to 5.5 V by the maximum rated supply voltage of IC2. The author used four NiMH re- chargeable cells connected in series, which yields a voltage that is j ust within spec. With an operating voltage in the range of 4.5 V to 5.5 V, you must use an LED that can operate at less than 4 V. This eliminates devices with several chips connected in series on a carrier, which is very often the case with power must also be connected to this lower supply voltage. Finally, a few words about soldering. An exposed thermal pad must be provided on the PCB for the LT3518, and the rear face of the IC must be soldered to this pad. The author obtained good results by dimensioning the exposed pad large enough to extend beyond the outline of the IC. When assembling the board, first tin the pad and the rear face of the IC. Then heat the pad with a soldering iron. When the solder melts, withdraw the tip of the soldering iron to the edge of the pad and simultaneously place the IC on the pad and align it. After this the pins can be soldered. The author produced a two-sided PCB, and the CAD layout data (Target) can be downloaded from the Elektor web- site [4]. (120201-1) [1] www.linear.com/product/LT3518 [2] www.linear.com/product/LTC6992 [3] www.ti.com/product/tlv431 [4] www.elektor.com/120201 Elektor 7/8-2012 35 M I , I DC Protection for Speakers By Andre Aguila (Burkina Faso) I'm in the process of building myself a single-ended class A MOSFET ampli- fier consisting of two mono blocks, and I don't want to use a coupling capacitor between amplifier and the speaker. So I needed a cir- cuit that would protect the speaker against DC voltages; I have given it a dual role: • DC protection in the form of a device to discon- nect the speaker in the presence of a DC voltage greater than ±1 V, using an LM358; • speaker connection de- layed by around 5 s after powering the amplifier, using a 555. H I've drawn inspiration from various ideas gleaned from the I nternet, but I don't think this circuit actually exists anywhere in quite this form. Obviously, for a stereo sys- j tern, you'll need a protection circuit for each channel. The output signal from the audio amplifier without an output capacitor is applied to the normally-open con- tacts of relay Rel, and also to the input of the DC volt- age detects formed by an * RC integrating network and comparators, whose output drives the relay control stage and an LED indicator. The network R6/C4 is a low-pass fil- ter that heavily attenuates the audio w signal but will allow any positive or negative DC component through to the inputs of dual comparators IC2a and IC2b, which are protected from exces- sive voltage by diodes D1 and D2. IC2a output goes from + 12 V to -12 V when the voltage on its negative input is higher than that on the positive input, while IC2b output goes from +12 V to -12 V when the voltage on its positive input is lower than that on the negative input. The values of resis- tors R7, R8, and R9 in the potential divider set the DC voltage detection thresholds to around +1 V for IC2a and -1 Vfor IC2b. To disable the relay if a posi- tive or negative DC voltage is detected, all that remains to be done is to combine the LM358 outputs. As these are not open-collector out- puts, diodes D4 and D6 form a wired-OR gate to avoid short-circuiting them. If there is a positive DC volt- age on the amplifier output, IC2a output will go from +12 V to -12 V and disable the relay by turning off T2, while IC2b output remains at +12 V. If a negative DC voltage is present at the in- put to our protection circuit, the roles of IC2a and IC2b outputs are reversed. 36 Elektor 7/8-2012 Design ■ N A-V- - Transistor T1 inverts the output from the 555, wired as a monostable, which is high (here that means ground) for around 5 s after power is applied. T1 is then turned off, as its base is at the same voltage as its emitter, and thus holds T2 off: the relay remains de-en- ergized. At the end of the time delay, the 555 output falls (-12 V), T1 con- ducts and the relay is energized via T2. I 've carried out a lot of testing and tried several types of relay, finally choosing a high-quality 24 V type designed for speakers, and I'm very pleased with the circuit. Preset PI makes it possible to adjust the operating threshold of the relay chosen according to its coil resist- ance. The choice of a 2N1711 for T2 is justified by both its availability and its gain, higher than a BD139, for exam- ple. Don't worry if it gets hot, its junc- tion can withstand up to 175 °C. The protection circuit is mains powered via two symmetrical regulator (IC3 and IC4) which will need to be fitted with small heatsinks of the transformer sec- ondary voltage is high. It should theo- retically be between 12 and 25 V, but given the fluctuation in AC line voltage, it's wiser to limit it to a range of 15 to 22 V. As the power drawn from the trans- former is modest — around 3 VA is more than enough — it would be feasi- ble to use quite a small transformer to allow the protection circuit to be fitted within the speaker being protected. You will note that the 555 is powered between the centre zero rail (which is its positive rail) and the -12 V rail. Choosing a low-current LED for D8 will let you save a few tens of milliamps, at least when the diode is lit. In this case, the value of RIO will increase from 680 ft to 4.7k so as to reduce the cur- rent to 2 mA instead of 15 mA! When testing, bear in mind that when the protection circuit input is open- circuit, the two opamps receive no bias voltage. So to test their opera- tion, you'll need to apply a DC voltage source. (120263) I've drawn inspiration from various ideas gleaned from the Internet, but I don't think this circuit actually exists anywhere in quite this form. IC3 B80C1500 ®" — I K1 0 Q 0 2x 15...22VAC cn 100u 40V C12 WOu 40V C9 220n CIO 220n 1 T 8 Csl rsi 7 i T >12 +12V O C7 lOOn C8 lOOn IC4 6 -12V 0^ amplifier output 120263-11 Elektor 7/8-2012 37 Bulb-2-LED Bicycle Light Conversion By Anders Gustafsson (Finland) Elektor is all over the globe, starting out from Holland. The same with bicy- cles, which are even older. All the way from Aland I slands N60 E20 (check that out), Anders Gustafsson wrote 2 us: "I just got so fed up with my bicycle light. I ride the bike to and from work every morning and with fresh batter- ies the light was acceptable. Problem was that the batteries wore down real fast so I was wondering what a LED could do. The original bulb, an Osram PR2 2.4 V 0.5 A should produce 10 Im. A Cree XP-E should produce 114 Im at 350 mA. I opted for a slightly lower current, or 320 mA, powering the LED from a constant-current switcher which will produce a constant current down to a battery voltage of 1.5 V. To get the output where I wanted, I used a Khatod KLCP 20CR lens with a 6-degree angle." Besides a circuit diagram of a simple voltage step-up converter based on a Linear Technology LT1618 chip [1]. Anders kindly included a few photo- graphs of his reworked bicycle light, which are reproduced here mainly as food for thought. The great thing about the LT1618 is that it can operate as a constant-current, constant-voltage source. The fixed- frequency, current mode switcher is rated to operate from an input voltage between 1.6 V to 18 V. Its high switch- ing frequency of 1.4 MHz permits the use of small inductors and capacitors. Here we use constant-current mode and power the converter from two (thick!) 1.5 V batteries to obtain a LED current that's remarkably steady around 320 mA. The values of R2 and R3 in the volt- age at the output are set up for (/out = 4.64 V using R2 = R3 V out U.263 A -1 ) which is fairly arbitrary but bearing in mind that some absolute maximum has to be set. For sure the desired con- tuaxeii llr-IXR 38 Elektor 7/8-2012 (V{out)*l(D2))/(V(in)*-l(V1 )) 1 - -200m-| 0.0ms 0.1ms 0.2ms 0.3 ms (V(out)*l(D2))/(V(in)*-l(V1)): (499.895ms, 685.036m) stant current of about 320 mA has pri- ority as we aim to power an LED 'to the max'. With the IADJ pin (4) of the chip tied to ground the nominal current sensing voltage is 50 mV (appearing between the ISP and ISN pins). Here we have a constant current like Measured performance Source [V] Source [A] l^out [V] lout [mA] Efficiency (O/o) 1.3 0 1.3 - II 1.7 0.45 2.89 - 1.8 0.71 2.95 329 75.9 II 2.3 0.62 3.03 323 68.9 || 2.8 0.45 3.03 320 76.9 || 3.2 0.38 3.03 321 80.0 0.05V 0.15Q 0.33A which is just right to push that Cree LED into producing a very bright light beam in darkest Aland Islands and be- yond, even if the batteries are juiced. Theoretically! So, Elektor Labs grilled the converter, measured its perfor- mance and drew up a table with se- lected results. I n conclusion, the circuit does a good job both when powered from two dry cells (source = 3.0 V) or from two rechargeables (source = 2.4 V). The more mAh's proudly print- Elektor 7/8-2012 39 COMPONENT LIST Resistors R1 = 0.15ft size 1206 R2 = 332kft size 0805 R3 = 124kft size 0805 Capacitors C1,C3 = lpF X5R, size 0805 C2 = lOOnF X5R, size 0805 Inductor LI = 10pH, 7.3x5mm, e.g. TT Electronics HM7610100LFJTR ed on the batteries, the longer your LED headlight shines. Next we decided to put the start-up response of the converter through an LTSpice simulation, specifically at the Semiconductors D1 = MBR050 IC1 = LT1618EMS (Linear Technology) Miscellaneous PCB # 100879-1 from www.elektorpcbservice.com lower end of l/ in (1.8 V) and the nomi- nal value (3.0 V) as it is often found that these converters fail to start when the batteries are flat. The run-in be- haviour of the 1.4 MHz oscillator in the LT1618 can be seen in both images. Space being at a premium in the bicy- cle headlight the choice of SMD parts rather than through hole should be obvious. Hence a very small circuit board was designed and printed here. If you experiment with the circuit on your workbench, do not forget to at- tach a heatsink to the LED as it is like- ly to die without one. Even a U-style finned heatsink for T03 devices does a good job. (100879) I nternet Link http://cds.linear.com/docs/ Datasheet/1618fas.pdf EZ-SMD OpAmp Tweaker Board By Dietmar Schroder (Germany) When working on electronics projects containing one or more operational amplifiers (opamps), the associated resistors and capacitors often have to be exchanged in order to change, op- timize or generally adjust the circuit's behaviour. Doing so is remarkably easy when using SMDs (surface mount devices) so these tiny components may be preferred over the 'good old' through-hole versions. Mini-MELF re- sistors are especially easy-going in this respect. 40 Elektor 7/8-2012 To be able to quickly assemble a circuit containing an opamp, a truly versa- tile and universal PCB was developed that's suitable for '1206' components. 1 1 was designed to be suited for a SOI C- 14 quad opamp, like the ubiquitous TL074. It is laid out as a single-sided board and quite small, so it can easily be etched on a piece of circuit board idling somewhere in your workshop. A pdf file representing the track layout of the board can be downloaded free of charge from the Elektor website [1]. The board routing was designed such that hookup wire is rarely called for to complete the circuit you are putting together. There are some extra uni- versal pads though for the more de- manding cases. There are also several solder jumpers which can be conveni- ently shorted using a blob of solder, if necessary. Looking at the PCB design, one half of the left side got copied and appears mirrored on the right with only a few alterations, hence the result is almost symmetrical, except for the supply volt- age decoupling capacitor (marked 'C'). This is connected between the positive and negative supply rails ( not from sup- ply to ground, since this could inject supply ripple into the ground rail). Putting it all to work, fill in the neces- sary components in the schematic and — using the colours in the illustrations printed here — populate the PCB ac- cordingly using whatever components ues as many times as you like, keep- ing your documentation up to date as you proceed to Fame & Glory with your project. There's nothing tricky with, or difficult about, this universal 'prototyping tool', so feel free to give it a try and person- There's nothing tricky with, or difficult about, this universal 'prototyping tool'. you need for your design. Note that the schematic printed here shows just two opamps, i.e. half the actual circuit. The schematic is also available for down- loading at [1], so you can conveniently print it and fill in the component val- ally verify that it works a treat when developing circuits hands-on. (110737) Internet Link [1] www.elektor.com/110737. ABCDEFGH I K ^ ttfftftttf Elektor 7/8-2012 41 Room for a Small One? By Stefan Hoffmann (Germany) As practically every Elektor reader will attest, electronics can be a lot of fun. The circuit described here, a small elec- tronic game for two or more players, proves the point. The game takes the form of a balance, with weights be- ing represented by resistors. The players take turns to place resistors (whose val- ues they do not know) on one 'pan' of the electronic balance, which is formed by two bent wires. The 'coun- terweight' is another resis- tor, whose value is also not known to the players. The state of the balance is indi- cated by three LEDs of differ- ent colours: yellow, indicat- ing that the pan is too light; green, indicating balance; and red, indicating that the pan is too heavy. The object of the game is to place as many resistors as possible on the electronic balance without lighting the red 'too heavy' LED. Bonus points are awarded to a player who can get into the relatively narrow central zone corresponding to perfect balance. The circuit is based around a number of voltage dividers and three operational ampli- fiers, used as comparators. When switch SI is closed the 9 V supply is provided to the circuit and the game is started. The first voltage divider is formed by resis- tors R4 and R5. The two wires that play the role of the balance pan are at either end of R4. If resistor R x is absent, as at the beginning of the game, the voltage U x will be around 2.88 V. As the game progresses, more and more resistors are added at R x between the two wires. These resistors are all in parallel with R4. The more resistors are added to the electronic balance, the lower the total resistance between the ends of resistor R4 and so the higher the voltage U x . The voltage divider formed by the three resistors Rl, R2 and R3 is responsible for de- termining the voltages that are the thresholds for the comparators to which they are connected, and hence for the boundaries between the different states in which the balance can be. With the values given in the circuit diagram we obtain a value for Ux of about 4.4 V and for U 2 of about 4.6 V. If U x is lower than 4.4 V the out- put of IC1.B will swing to the positive supply rail. This will in turn light the yellow LED to indicate that the balance pan is too light. If U x is great- er than 4.6 V the output of IC1.A will swing to the posi- tive supply rail and the red LED will light to indicate that the balance pan is too heavy. If U x lies between 4.4 V and 4.6 V then the system is bal- anced. In this situation the 42 Elektor 7/8-2012 Design voltages at both the output of I Cl. A and the output of IC1.B will be at 0 V and therefore the voltage at the invert- ing input of IC1.C will also be 0 V. The voltage divider formed by resistors RIO and Rll set the voltage at the non-inverting input of IC1.C at about 2.81 V, and as a result when the sys- tem is balanced the output of I Cl. C will be at the positive supply voltage and the green LED will light. The voltage divider formed by resistors R8 and R9 produces a voltage half-way between the output voltages of I Cl. A and IC1.B and feeds this into the inverting input of IC1.C. The consequence of this is that the green LED only lights when the system is balanced. There are various ways that the game could be played: the author's sugges- tion is as follows. At the beginning of the game each player receives ten resistors, whose coloured bands have been made unreadable using a black felt-tip pen (see photograph). Players then take it in turns to add one of their resistors to the electronic balance. If the yellow LED remains lit he receives ten points and play passes to the next player. If the red LED lights the player loses his points and the round is over. If the green LED lights, the player re- ceives ten points for his resistor and then doubles his score. In this case also the round ends. I nstead of playing a resistor a player can 'fold' and leave the round, halving his current score. Play then passes to the next player, who must choose whether to add an- other resistor or also fold, again halv- ing his score. If the next player choos- es to play and the yellow light remains on, he receives ten bonus points, and, if the green LED lights, he receives the ten bonus points and doubles his score. However, if the red LED lights, the player loses his points as before. At the end of each round each player adds his points to his running total. It is best to play as many rounds as there are players, so that each has one turn to start the game. For the 'weights' the author recom- mends using fifty 100 kft resistors, five 47 kft resistors, three 33 kft resistors and three 22 kft resistors. The more low-value resistors there are the quick- er each round will tend to be. (120239) LC Oscillator with Pot Tuning By Burkhard Kainka (Germany) An LC oscillator is usually adjusted us- ing a variable capacitor. However, for frequencies below around 100 kHz this calls for a variable capacitor with a value in the nanofarad range, which is somewhat impractical. In many situa- tions, however, a potentiometer can be used instead. We start by looking at an oscillator us- ing a 2.9 mH inductor salvaged from a low-energy lightbulb and a 2.7 nF ca- pacitor (see upper circuit). The theo- retical resonant frequency of this com- bination is 56.9 kHz. The circuit operates from a supply voltage as low as 1 V, as the resonant circuit has a high Q factor. If an extra 10 nF capacitor is wired in parallel the resonant frequency falls to 26.2 kHz. The Q factor is reduced and so the gain in the circuit must be increased, and a supply voltage of at least 2 V is needed. Elektor 7/8-2012 43 Using a switch it is possible to select between the two frequencies (see mid- dle circuit). And now the subtle bit: instead of the switch we use a 1 kft potentiom- eter (see lower circuit). In this form the frequency of the oscillator can be smoothly adjusted using the potenti- ometer, almost as if we were using a 10 nF variable capacitor. Experience shows that using a linear potentiome- ter gives a rather non-linear frequency adjustment, and so it is preferable to use a logarithmic potentiometer. A fur- ther problem is the high level of damp- ing: the energy loss needs to be made up for with higher gain, and so with a higher emitter current. This can be achieved either by reducing the emit- ter resistor or by increasing the supply voltage. Experiments show that the maximum frequency coverage possible is around a 2:1 range. If the two capacitors are very different in value the damping in the middle of the frequency range is so great that oscillation stops. With the values shown in the circuit diagram the frequency can be adjusted between 34.2 kHz and 55.1 kHz. (120320) FET Radiation Meter By Burkhard Kainka (Germany) What must be the simplest possi- ble radiation meter consists of just a BF245 JFET and an ohmmeter. Ions produced as a result of the radiation charge up the gate of the FET and thus change its resistance. The FET needs to be enclosed in a metal tin to screen it from electric fields and from ions that might normally be present in the atmosphere. After taking a calibration measurement we can experiment by placing various samples inside the tin. The device was tested using a small sample of pitchblende (a uranium ore), a 241 Am source taken from a smoke alarm, and a gas mantle, still in its paper sleeve. The results were as follows. Reference (no sample) 160.2 ft Pitchblende 156.3 ft (-3.9 ft) 241 Am source 155.9 ft (-4.3 ft) Gas mantle 159.0 ft (-1.2 ft) The results are clear: when a sample is placed near the FET it tively charged, reducing its drain-source resistance. The experiments above were repeated several times and showed good reproducibility. In practice it takes around half a minute for the FET's resistance to settle. (120319) a (3 Alpha, Beta At/* _ J1 © BF245B ML 0 Q 120319 - 11 44 Elektor 7/8-2012 Whatever you're measuring, we have the solution. From simple to complex applications, nothing can handle your measurements more effectively than the National Instruments data acquisition platform. Whatever your budget, channel count, or performance requirements, its unparalleled high-performance I/O and ability to increase productivity through software measures up to the challenge. This combination can help you balance performance and investment to deliver precision accuracy that is scalable and always trustworthy. Designed for Performance. 01635 517300 » Download The Complete Guide to Building a Measurement System at ni.com/daq uk.ni.COm info.uk@ni.com Browse our webcast library of measurement & control topics at uk.ni.com/webcasts JOIN THE CONVERSATION: Follow us on v Search niukie national ^INSTRUMENTS ©2012 National Instruments. All rights reserved. CompactRIO, LabVIEW, National Instruments, Nl, and ni.com are trademarks of National Instruments. Other product and company names listed are trademarks or trade names of their respective companies. 1684 Gee Whiz, a GPIB-to USB Converter $50 interface circuit brings 80s/90s edebris to life If the acronym GPIB is new to you, you are either Young, Innocent, Unelektorized or even Delektorized. Everyone else: here's a low cost converter that connects legacy GPIB equipment to your PC via contemporary USB. By Anders Gustafsson (Finland) GPIB (General Purpose Interface Bus) refers to an IEEE 488 standard parallel interface originally defined in 1984 for at- taching sensors and programmable instruments to a com- puter. Using a 24-pin connector, up to 15 devices can be daisy chained together and addressed individually. Hewlett Packard's version of the GPIB is unsurprisingly called HPIB. GPI B equipment being horribly expensive in its heydays, and the comms protocol over intricate, it never entered the hob- byist's realms. GPI B equipment at the time was for high brow professionals and rocket scientists — everyone else on a pa- per round just dreamt of it. To what purpose? So what's the point in building a converter to bring that old 1980/90s grot to life? The answer: 30+ years on, you buy quality and ruggedness at a fraction of the original price. GPI B was widely used for high-end measurement equipment and today there is a flourishing market for second-hand in- struments. Several vendors sell reconditioned and calibrated instru- ments and if you look on places like eBay, good instruments from the likes of HP, Tektronix and Marconi can be had for less than 100 pounds, or even cheaper if you want to take a gamble and buy an instrument that's "beyond / in need of repair". Avoid the "FU" variety though. 46 Elektor 7/8-2012 Make / I \ H5V © H5V © R6 MCLR C4 R1 7 1R1 1 / 1R2 2 / 1R3 3 ''iRS b ^1R6 6 / 1R7 ']R8 8 16 lb 4 14 5 6 12 7 11 11 12 9 B 8x 100R 14 I 20 VDD MCLR/VPP/RE3 RB7/BKI3/PGD IC1 RB6KBI2/PGC RB5/KBI1/PGM RAQANO RB4/ANll/KBI(yCSSPP RA1/AN1 RB3WJ9CCP2/VPO RA2/AN2A/REF-/CVREF RB2/AN8/IMT2/VMO RA3/AN3A/REF+ RB1/AN1CVINT1/SCK/SCL RA4TOCKI/CIOUT/RCV RB(yAN12/IMnyLFTtySDI/SDA RA5/AN4/SS/HLVDWC20UT RCOmOSO/TBCKI RC7/RX/DT/SDO RC1/TSOSI/CCP2/UOE RCGfTX/CK RC2/CCP1/P1A PIC 18F 2550 RC5/OWP VUSB RC4/D-/VM VSS OSC1 OSC2 VSS C7 470n C5 22p XI h[h 20 MHz 10 X C6 22p 28 7" 2 2 27 7" 26 R2 24 23 22 16 2R16 15 2R15 S 14 2R14 S> 13 2R13 S 12 2R12 ^ H 2R1I ^ 10 2R10 S \ 9 2R9 18 SxlOOR SER RX A 17 ■\ 16 15 SER TX USB CH- ^ USB D- ^ 19 +5V ll R3 1R1 1R2 +5V © 1R3 1R4 1R5 1R6 1R7 1R8 8x10k 18 17 16 15 14 B 12 11 ^C2 Cl □ 20 lOOu 16V +5V © VC :c B1 A1 B2 A2 IC2 B3 A3 B4 A4 B5 A5 B6 A6 74LS245N B7 A7 B8 A8 DIR Gl HD G 1 10 +5V © K3 +5V C> D- O- CHO- GIOQ 2 USB D- / 3 USBCH-y 1 - 1 +5V © SER TX \ SERRX USB-B K2 +5V © K1 mclr y _PGD/ _rccy V2R16 R5 v 2R15 v 2R14 4 ^ 2RB b v 2R12 v 2R11 / v 2R10 8 v 2R9 H5V K4 V 2R9 1 \2R10 2 \2R11 3 \2R12 4 \ 1R4 5 \1R6 6 \ 1R7 7 \ 1R8 8 \1R1 9 \1R2 10 \lR3 11 12 8x10k O O O O O o o o o o o B 2R13 / 14 2R14 y 15 2R15 y 16 2R16 / jrs/Lj 17 18 19 20 22 23 24 8x 270R 100592 - 11 While most modern Chinasian instruments are almost im- possible to repair, old instruments are built from standard components mostly. In good US engineering tradition they are also built like tanks, and service manuals can often be downloaded for free from places like the Boat Anchor Manual Archive [1]. Thus fixing small and not so small faults should be feasible and may serve as an excellent exercise in Elec- tronics. In fact, gurus like Jim Williams claim that fixing bro- ken instruments is the best way to learn electronics [2]. Lots of formerly up-market, now 2 nd , 3 rd , ...10 n -hand instru- ments you may stumble upon are equipped with a 24-pin GPI B connector. 1 1 has a 'Centronics look' as you can see from the picture. You rarely see it on present-day instruments, but for several decades, the GPIB bus reigned supreme in the field of sampling &data collection and was occasionally used for other things as well like Commodore's printers and floppy disk drives. GPIB-USB Converter Features • Low-cost external adapter • Full GPIB / IEEE488 functionality by USB • PIC18F2550 @ 20MHz with on-chip USB interface • Emulation and enumeration of PC COM port • Software developed in C and MCF1PFSUSB Framework A thorough description of GPIB is beyond the scope of this article, but suffice it to say that you can hook up all your GPIB compatible instruments to a USB-equipped computer and then address and configure them at will from that com- Elektor Products & Services • PIC18F2550 source code files: free download from www.elektor.com/100592 • PCB # 100591-1: from www.elektorpcbservice.com Elektor 7/8-2012 47 CDC -> . * — * , _ GPIB <-> USB Adapter 11 1 — — Elektor 7/8-2012 49 COMPONENT LIST Resistors R1,R2 = 100ft, DIL16 array R4 = 270ft, DIL16 array R3,R5 = lOkft, SIL9 array R6 = lOkft Capacitors Cl = 100 |jF 16V, radial C2,C3,C4 = lOOnF C5,C6 = 22pF, ceramic, lead pitch 2.5mm C7 = 470nF Semiconductors D1-D8 = LED, 3mm, red IC1 =PIC18F2550-I/SP, programmed, Elektor # 100592-41 IC2 =74LS245 Miscellaneous XI = 20MHz quartz crystal K1 = 4-pin pinheader, pitch 0.1” (2.54mm) K2 = 6-pin pinheader, pitch 0.1” (2.54mm) K3 = USB socket, Type B, PCB mount K4 = 24-way I EEE488/Centronics connector, male, PCB mount. Alternatively, IDC version wired to board (Farnell # 1099278). PCB # 100592 from www.elektorpcbservice.com Basic Demo. Under that, you will find a direc- tory called CDC -> Basic Demo -> Firmware. Make a copy of that and call it something like "CDC - Basic Demo - Firmware GPI B". Copy the files provided to the same dir and do the modi- fications described in 'pic2550.txt' (also printed here) and in readme.txt. Then open the project USB Device -> CDC -> Basic Demo -> C18 -> PICDEM FSUSB.mcp and build! The build should complete without errors. Then just program the PIC18F2550 from MPLAB. tions\USB Device -> CDC -> Basic Demo\inf. If all is well you should now see a new COM port. Assuming this is COM4, you should be able to talk to it with, say, HyperTerminal. Connect your GPI B instrument(s), making sure they all have unique addresses. To set an instrument to address 22 deci- mal, set the switches (5,4 ... 1) as 10110. The instrument can now be addressed as '6' for Listener and 'V' for Talker. To make the instrument talk, send 2?UV Ctrl-Enter; Building, connecting up, examples The converter (some say: "adapter") is easy to build on the printed circuit board shown here. The 24-way I EEE/Centronics style male con- nector for board mounting proved hard to get and as you can see from the photograph it may be substi- tuted by a plug part (salvaged from a cable connector) and 24 discrete wires. A neater solution might be to obtain an I DC version of the 24-way plug. Assuming the build was as successful as the software's, con- nect the converter to the computer using a USB cable. The computer should report New Hardware Detected and ask for information. Point it to mchpcdc.inf in C:\Microchip Solu- 50 Elektor 7/8-2012 Make By your GPIB Command The software receives data on GPIB and passes it on as is to USB. When sending, data is passed as packets where the first is a command and the second is blank (reserved for future use). Valid commands are: ' ' - Send string as is (ATN de-asserted) '2' - Send string as GPIB command with ATN asserted '4' - Interface clear (resets all instruments) '6' - Assert GPIB REN (puts instrument in remote mode) '8' - De-assert REN 'V' - Verbose mode, echoes typed commands 'Q' - Verbose off Command strings are terminated by either a line feed (AS- CI I 0A h ) which will trigger an EOI on the bus or an ETX (AS- CII 0x03) which will not. The latter is useful when you need to switch between Command and Data modes in the middle of a message. you should now see the instrument outputting its readings on HyperTerminal. It's life Jim but not as we know it! Since the original HPIB/GPIB standard does not define what commands an instrument can accept, it is best to refer to the instrument manual for actual examples. For instance, to set an HP3456A to AC Volts from GPIB, you need to first address the instrument in Command mode (ATN asserted) with ?U6, then send the actual command F2 in Data mode (ATN de- asserted). The actual string to do so becomes: 2 F2 where is a space, is Ctrl-C and is Carriage Return and Line Feed. The spreadsheet example included in the software down- load for the project assumes two instruments, one HP 3456A DMM addressed as 22 and one HP 5328A Counter addressed as 23. The macro will loop 20 times, taking two readings, one from each instrument, and put them in spreadsheet columns B and C respectively. It is hoped that the circuit described here is helpful in some way to prevent a few GPIB equipped instruments from end- ing up in dumpsters, skips, landfills, incinerators or other places unworthy of their heritage status. (100592) I nternet Links [1] http://bama.edebris.com/manuals/ [2] The Art and Science of Analog Circuit Design, page 3. [3] www.microchip.com/stellent/idcplg?IdcService=SS_ GET_PAGE&nodeId = 2651¶m=en534494 [4] www.elektor.com/100592 Also worth seeing & reading Short GPIB tutorial: www. hit. bme. hu/ ~papay/edu/GPI B/tutor. htm Tutorial from HP: http://bitsavers.org/pdf/hp/hpib/TutorialDescrOfHPIB.pdf Author's project site: www.dalton.ax/gpib WHAT vintage GPIB equipment 4 me Pen/X-Y plotter Multiplexer Oscilloscope Function Generator Power Supply Network Analyzer Data Logger Sample & Hold Unit Keywords: Telemetry Unit Agilent, Advantest, Fluke, Hewlett Packard, Marconi, National Spectrum Analyzer instruments, Tektronix, IEE 488. Elektor 7/8-2012 51 ns \ r\ L>o 16 Ways to Switch your AC Power On By Vladimir Mitrovic (Croatia) Connect this microcontroller controlled switch between an ordinary AC Power On/Off switch and the load, and you have 2 4 (say, sixteen) ways available for managing how and when the load actually gets powered. Your options are listed in the table! As soon after the AC outlet voltage (230 VAC or 115 VAC) is applied to the Live (L) and Neutral (N) input terminals (USA: G; Ground), the voltage across C2 will rise above 2.7 V and the AT- tinyl3 microcontroller (I Cl) will start to execute the program held in its flash memory. The program controls the log- ical state of output pin PB4 in order to switch the power supply to the load on and off. In detail: if PB4 is at T, the current through the LED inside optoisolator IC2 is inter- rupted causing the internal triac driver and triac Trl to be held Off; conse- quently no current flows through the load connected to the AC Power output terminals; if PB4 is at 'O', current flows through the LED inside IC2, the internal triac driver and Trl are switched On; consequently AC current flows through the load con- nected to the output terminals. The circuit, in particular, the ATtinyl3 firmware, has full control of the power distribution to the load as long as the AC Power On/ Off switch (not shown here) is on. For example, the program can switch on the load with a delay, keep the load switched on for a prede- termined time period, switch the load on and off according to some pattern... you name it! An example Bascom-AVR program called "EE_prog_switch.bas" is writ- ten to illustrate the possibilities. The program is a free download from [1]. 'Bascom-AVR is supplied by MCS Elec- tronics — a free Demo version limited to 4 KB source code size is available [2]. I nitially the program checks the state of configuration switches S1-S4 and calls the relevant pre-programmed routine from a set of 16 — see the table. 'One-shot' routines will execute only once; to repeat them you should switch the AC Power switch ahead of the cir- cuit Off and On again. Routines with a repeating pattern ('once every...') will execute in a loop as long as the AC Power is on. If you want to select a different pattern, you should switch AC Power off and flip to another setting on S1-S4. The new setting will be rec- ognised the next time your AC Power switch is switched to On. 100443 - 11 52 Elektor 7/8-2012 Make dimension the following components: 115 VAC/60 Hz AC: Cl = 0.68pF; R1 = 750 Q; R2,R3 = 470 kft 230 VAC/50 Hz AC: Cl = 0.33pF; R1 = 1.5kft; R2,R3 = 1 Mft pies, and you are en- couraged to define and implement oth- er patterns that suit your applications. I f there is only one On/ Off pattern that the switch should follow, you can omit switches S1-S4 and thus make the cir- cuit even simpler. I I should be noted that the design does not accommodate for precise timing. The overall accuracy primarily depends on the accuracy of the ATtiny's internal RC oscillator (<10%; <3% if calibrat- ed), while the Wait routines in Bascom- AVR are accurate to within 1%. Depending on your local power grid, Cl should be an X2 class capacitor with a minimum specified operating voltage of 250 VAC; for ex- ample, WIMA MKP-X2, WIMA MP3-X2, Epcos MKP X2 or similar, rated for 250, 275 or 305 VAC voltages. As these ca- pacitors are normally available with ±20% tolerance, the value is calcu- lated to ensure 10 mA of current even in a worst-case, i.e. when the capaci- tance is significantly out of tolerance. As a matter of fact, the total AC cur- rent flow through Cl exceeds 20 mA, but half the current is lost' because of the half-wave rectification. Most of the current flows through the LED inside IC2: some 5-6 mA when switched on (if necessary, adjust the value of R4 to keep this current within range). The ATtinyl3 runs on its internally calibrat- ed 9.6 MHz oscillator, but the clock fre- quency is lowered to 600 kHz to keep power consumption under 1 mA. The rest of the current flows through zener diode D1 which acts as a shunt regu- lator and provides a reasonably sta- bilised voltage for the circuit. You can expect about 4.4 V across C2 when I C2 is switched off, which will drop to some 3.4 V when IC2 is switched on. The ac- tual values depend primarily on Dl. Resistor R1 limits the inrush cur- rent during power-on, but sadly also causes some unwanted losses during operation. You may use a 1 watt non- flammable resistor in place of Rl, but a better solution would be to use a NTC resistor. Unfortunately, we were unable to find an appropriate NTC for limiting the inrush current to 200 mA. There- fore, two series connected Epcos NTC thermistors may be considered with a Description of the pre-programmed routines (example program) S4 S3 S2 SI switch on switch off off off off off as soon as AC power is switched on never off off off on as soon as AC power is switched on 10 minutes after switch-on off off on off as soon as AC power is switched on 30 minutes after switch-on off off on on as soon as AC power is switched on 60 minutes after switch-on off on off off 10 minutes after AC power is switched on never off on off on 30 minutes after AC power is switched on never off on on off 60 minutes after AC power is switched on never off on on on 10 minutes after AC power is switched on 10 minutes after switch-on on off off off 10 minutes after AC power is switched on 30 minutes after switch-on on off off on 10 minutes after AC power is switched on 60 minutes after switch-on on off on off once every 20 minutes 10 minutes after switch-on on off on on once every 30 minutes 10 minutes after switch-on on on off off once every 60 minutes 10 minutes after switch-on on on off on once every 12 hours 1 hour after switch-on on on on off once every 24 hours 1 hour after switch-on on on on on never never Elektor 7/8-2012 53 resistance of 680 ft (at 25°C). These thermistors are intended for tempera- ture measurement and compensation, but work well as inrush current limiter, too. For 115 VAC, it is safe to use just one 680 ft NTC thermistor. The BT136 triac is rated for 4 A RMS on- state current. Consider replacing it with a stronger device if the load current can be expected to exceed 3 A. Com- ponents R7-C4 form a snubber network and may not be necessary depending on the particular triac and load used. A 1-second delay is provided at the beginning of the example program. Therefore, the expression “as soon as the power is switched on" from the ta- ble should be read as “1 second after the power is switched on". This was found necessary as the voltage across C2 rises slowly at power-up and there is not enough power to switch on IC2 and Trl until the voltage across C2 reaches more than 3.5 V. A 1-second delay will allow the voltage across C2 to reach at least 4 V before the pro- gram actually starts to run, which will ensure that IC2 and Trl can be reliably switched on at the very beginning of the program. The ATtinyl3's fuse bits should be set during programming to enable the On- chip Brown-out detection (BOD) circuit to monitor the VCC level with a trigger level fixed to 2.7 V, and to configure the micro to run on the calibrated in- ternal RC oscillator at 9.6 MHz clock frequency. It is the programmer's (i.e. your!) responsibility to set a divide- by-16 prescale factor at the beginning of the program to lower the clock fre- quency to 600 kHz. If you are not into programming microcontrollers, order your ATtinyl3 ready programmed from Elektor (# 100443-41) [1]. Caution. The circuit is at Live AC po- tential and potentially hazardous to touch. Never work on the circuit while it is connected to the AC power out- let. The circuit must be enclosed in an approved enclosure preventing any part of it from being touched. When in doubt, ask for the assistance of a quali- fied electrical engineer. (100443) I nternet Links www. elektor. com/ 100443 www.mcselec.com Elektor Products & Services • Bascom-AVR source code file: # 10044-ll.zip, free download • Printed circuit board # 100443-1: www.elektorpcbservice.com from www.elektor.com/100443 • Ready programmed ATtinyl3: #100443-41, www. elektor. com/100443 54 Elektor 7/8-2012 Make A snippet of the BascomAVR source program. Dim S 1 _ s 4 As Byte , Mi nut e As Byte , Hour As Byte Control pin Alias Por t b. 4 Sw on Alias 0 S w_ of f Alias 1 Config Clockdiv = 16 / clock = 600kHz nop Config Pi nb. 4 = Out put Control_pin = Sw_off / s wi t c h off the 1 oad Config Pinb.O = Input Config Pinb.l = Input Config Pinb.2 = Input Config Pinb.3 = Input Port b = Port b Or &B 0 0 0 0 1 1 1 1 enable pull-up r es i s t o r s Wai t 1 S 1 _ s 4 = Pi nb And &B 0 0 0 0 1 1 1 1 read S1-S4... Select Case SI s4 / and execute corresponding routine Case &B0000illl Control pin = Sw on Case &B 0 0 0 0 1 1 1 0 Control pin = Sw on mi n u t e = 10 : Gosub Wait minute Control pin = S w off Case &B 0 0 0 0 1 1 0 1 Co nt r o 1 _ p i n = S w_ o n mi n u t e = 3 0 : Gosub Wait minute Control pin = S w off Case &B 0 0 0 0 1 1 0 0 Control pin = Sw on mi n u t e = 6 0 : Gosub Wait minute Control pin = S w off Case &B 0 0 0 0 1 0 1 1 mi n u t e = 10 : Gosub Wait minute Control pin = Sw on Case &B 0 0 0 0 1 0 1 0 mi n u t e = 3 0 : Gosub Wait minute Control pin = Sw on Case &B 0 0 0 0 1 0 0 1 mi n u t e = 6 0 : Gosub Wait minute Control pin = Sw on Case &B00001000 mi n u t e = 10 : Gosub Wait minute Control pin = Sw on mi n u t e = 10 : Gosub Wait minute Control pin = S w off Case &B 0 0 0 0 0 1 1 1 mi n u t e = 10 : Gosub Wait minute Co nt r o 1 _ p i n = S w_ o n mi n u t e = 3 0 : Gosub Wait minute Control pin = S w off Case &B 0 0 0 0 0 1 1 0 mi n u t e = 10 : Gosub Wait minute Control pin = Sw on mi n u t e = 6 0 : Gosub Wait minute Co nt r o 1 _ p i n = S w_ of f Elektor 7/8-2012 55 Arduino LC'Deed Control a display using a (virtual) serial port By Michael Gaus (Germany) The Arduino platform provides an easy way to get started in the world of microcontrollers, and is enjoying ever-increasing popularity. What's more, there is a wide range of compatible hardware and software available. In many projects it is LCDl LCD DISPLAY 16x2 9 u E 3 % 8 & pi / 10k 6 ID 11 12 13 14 1 15 1 16 | 0 Q Q Q Q ARDUINO Duemilanova Diecimilia UJ (N rl i § a ! § I § a a a 3 a| i i i i i r i i i i i r 120192 - 11 desirable or necessary to display information on an alphanumeric LCD panel: in the Arduino world this would normally be accomplished using a 'shield' (daughter board) carrying the LCD. However, there is a much simpler way, as we shall see. Dot-matrix alphanumeric LCD panels by and large conform to a 'standard' in that most types are compatible with one another in terms of their supply voltage, pinout and control interface, and in the command set supported by the LCD's controller. If we examine the pinout of one of these LCDs we see immediately that in principle it could be connected directly to the sockets on a Uno, Diecimila or Duemilanove Arduino board. It is therefore not necessary to go to the trouble of building a shield. The LCD's controller must be an HD44780 or compatible device, and the pinout of the module must adhere to the 'standard' mentioned above (see table). It is important that the display supports four-bit interface mode, since when we fit the module directly not all of the LCD's data lines will be connected. The display must also be able to run from a 5 V power supply. And one final requirement: the pins on the LCD must have a pitch of 2.54 mm so that a corresponding header can be soldered directly to it. Table: Pinout of a 'standard' LCD Pin Signal l GND 2 VCC 3 VO (contrast) 4 RS 5 RW 6 E 7 to 14 DO to D7 Finding a display meeting all of the above conditions might sound like quite a task, but in fact there are surprisingly many suitable modules, the Elektor 'standard LCD' [1] included. First solder a 14-way header to the LCD (or several shorter headers: see below). The display can now be fitted to the Arduino's sockets so that pin 1 of the LCD mates with the GND pin of the Arduino board, the adjacent pins connect to 'Digital 8' to 'Digital 13', and pin 14 of the LCD mates with Arduino pin 'Digital 2'. Arduino pins 'Digital O', 'Digital 1' and 'AREF' remain unconnected: see the circuit diagram. 56 Elektor 7/8-2012 Make Unfortunately the two socket rows that include the digital pins on the Arduino board are not spaced a multiple of 2.54 mm apart: in fact, the distance is somewhat less than this. With a little judicious bending of the header pins on the LCD module they can nevertheless be made to fit into the sockets. Pin 8 of the LCD module will then find itself dangling in free space between the Arduino's two rows of sockets. It is not absolutely essential to solder a full 14-way header to the LCD. It is sufficient to use shorter lengths of header strip to connect just pins 1, 2, 4, 5, 6, and 11 to 14. This arrangement leaves Arduino pins D12, D8, D7 and D6 free for use as / i\ ROWS and LCD_COLUMNS respectively: the default values provided are suitable for a two-row, 16-column display. When the system is reset the greeting 'Arduino LCD' should appear: if it does not, it may be that the contrast voltage is not correctly set. The icing on the firmware cake is that the display can also be controlled from a PC over the Arduino's USB connection, using a virtual COM port and either a terminal emulator program or more specialised software. By default the interface runs at 9600 baud, but this can be changed in the setupO function with a suitable call to Serial. begin(). Commands and text to be displayed can be sent over the serial interface. Commands always begin with a backslash character ('V, ASCII value 0x5C), followed by a sequence of bytes whose length depends on the command. To set the cursor position a total of four bytes is required. The command starts with the backslash, followed by a single ASCII decimal digit representing the desired row (for example, '1' for row 1 or '2' for row 2) . Next come two ASCI I decimal digits giving the desired column (for example, '01' for the leftmost column or '16' for column 16). A complete The icing on the firmware cake is that the display can also be controlled from a PC over the Arduino's USB connection. inputs or outputs for other purposes. The power supply for the LCD module is provided by Arduino pin D13. The firmware running in the device must configure this line as an output and set it to a high level to turn on the LCD. Since LCDs of this type generally have a current consumption of less than 10 mA, the output pin has no difficulty in handling the load. A trimmer is required to allow the contrast voltage of the LCD to be set: this can easily be soldered directly to the pins on the LCD. Most LCD modules need a contrast voltage of between 0 V and 1 V. For greater mechanical stability the LCD module can be mounted on nylon spacers. To demonstrate how to drive the LCD from the Arduino the author has written an example program (called a 'sketch' in Arduinoese), which can be downloaded for free from the web pages accompanying this article [1]. In the sketch file 'arduinojcd.pde' two lines must be adjusted to reflect the number of lines in the LCD module and the number of characters per line. These are defined as the constants LCD_ example might be '\ 105', which would move the cursor to row 1, column 5. To erase all the text on the display, send '\c' (the 'c' standing for 'clear'). Commands and text can be intermingled in a compact fashion. For example, sending '\201Hello World!' will cause the string 'Hello World!' to appear on the second line of the LCD. To display a backslash character it must be doubled in the transmitted string: '\\'. The 'Serial Monitor' in the Arduino I DE can be used fortesting. (120192) [ 1] http://www.elektor.com/120192 Elektor Products & Services • Software (free download): 120192-11. zip • Suitable LCD module (2 by 16): 120061-71 Products and downloads available through www. elektor.com/ 120192 Elektor 7/8-2012 57 Mini-Mute Kill noisy TV commercials with one stroke You must know the feeling: you're watching a great movie and all of a sudden a commercial comes blasting into the room. Your instinctive response is to turn down the sound or press the mute button - but where's the zapper? By Peter de Bruijn (Netherlands) This handy circuit does the job for you. It converts your coffee table into one big button: if you rap on the table, the TV sound is muted right away. When the film resumes, you can restore the sound by rapping on the table again. The circuit uses a piezoelectric trans- ducer fitted in the bottom of an enclo- sure. The transducer acts as a shock sensor. The transducer is fitted at the rear of the enclosure touching a screw that rests on the table, and two feet are fitted at the front to improve the operation of the transducer. A yoke made from a length of solid electrical wire provides a mount for an I R trans- mitter that sends the mute command to the television set. This gives the IR transmitter a clear view of the televi- sion set, even if cups and the like are standing on the table. J ust a PIC The circuit is very simple and essential- ly consists of an 8-pin PIC microcon- troller. The piezoelectric transducer is connected to the GPO input, and zener diode D1 limits the maximum voltage applied to the input. The GP5 output drives an IR LED via transistor T1 to send IR commands to the television set. Pushbutton SI allows the circuit to learn the right mute command. If it is pressed and held for a while, indicator LED D2 lights up and the mute code transmitted by the original remote TSOP34836 K4 fp p p p cp U ih +3VO + K2 4® R2_ 10k 43V O R1 IC1 pH I GPtyCINH/ICSPDAT GP1/CIN-/ICSPCLK GP2/TDCKI/INT7COUr GP3/MCLRA/PP GP4mG/OSC2/CLKOUT GP5mCKI/OSd/CLKIN U) !S R6 R7 T1 R4 PIC12F1822-I/SN BC847 D2 i K1 a#:® Vb 120227-11 control unit can be read in using an IR receiver module (type TSOP34836) connected to K3. This code is stored in the PIC. Connector K4 is used for programming the PIC. The pinning is compatible with the Microchip PICkit programmer, among others. The circuit can be powered by a 3 V button cell or two 1.5 V cells in a bat- 58 Elektor 7/8-2012 Make / I \ tery holder. The circuit draws less than 100 nA in the quiescent state (ultra low sleep mode), so a power switch is not necessary. The PCB for the advert killer has been kept very small by using predominate- ly SMDs. Note: the prototype version shown in the photo does not have a programming connector, but this con- nector is present in the final version. Construction The circuit board and a pair of 1.5 V cells can easily be fitted in a stand- ard box measuring 5 x 2.5 x 7 cm. Of course, a much smaller box can be used with a button cell. Remember to program the PIC before closing the box (the source and hex code are available at [1]). Drill a hole the bottom of the box at the rear so that the middle of the pi- ezoelectric transducer is accessible from outside when the box is resting on its base. Then secure the piezoelec- tric transducer in the bottom of the box with hot-melt glue or silicone adhesive. Thread a screw into the hole until it touches the transducer. Glue the screw firmly in place (see the accompany- ing construction drawing: (1) screw, (2) piezoelectric transducer, (3) PCB). At the front of the box, fit two feet to enhance the operation of the vibration sensor. Fit a bracket (made from 2.5 mm 2 / AWG13 electrical wire, for example) on the box for mounting the IR LED. This gives it a free view of the television set. With a bit of imagination, you can transform the box into something that looks nice on the table. For instance, the author 'dressed up' the prototype with a toy dragon. Use Start by learning the right mute code. Press and hold the button until the indicator lamp (D2) lights up (longer than 3 seconds). Hold the original re- mote control a few centimetres in front of the IR receiver and press the Mute button twice. If the code is received properly, it will be saved and the circuit will return to normal mode. If no code is received within 10 seconds or a bad code is received 6 times, the program automatically returns to normal mode. The learning function works with virtu- ally every remote control unit. Now you can place the advert killer on your coffee table or the like. Tap the ta- (SMD0805) C1,C2 = lOOnF Semiconductors D1 = 3V 0.375W zener diode (SOD123F) D2 = LED, low current, red, 3mm D3 = IR-LED, 5mm (e.g. Vishay TSUS5202) ble or the box when you want to switch the TV sound on or off. The sensitivity can be optimised by choosing the right location on the table. The advert killer also responds to cups set down hard on the table, but every- one quickly learns not to do this, and it has the advantage that the table is less likely to be damaged. (120277-1) I nternet Link [1] www.elektor.com/120277 COMPONENT LIST Resistors (SMD0805) R1,R2 = lOkft R3 = lMft R4 = lkft R5 = 470ft R6 = 22ft 0.25W R7 = 330ft 0.25W Capacitors T1 = BC847 (SOT23) IC1 = PI C12F1822-I/SN (SOI C8) I R receiver module, 36kHz (e.g. TSOP34836) Miscellaneous K1,K2,S1 = 2-pin pin- header, pitch 0.1 in. (2.5mm) K3 = 3- pin pinheader, pitch 0.1 in. (2.5mm) K4 = 6- pin pinheader, pitch 0.1 in. (2.5mm) Piezo buzzer (e.g. Kingstate KPEG165) Pushbutton with make contact, panel mount 2 AA or AAA batteries with holder, or 3-V button cell PCB # 120277-1 Elektor 7/8-2012 59 Battery Maintainer By Burkhard Kainka (Germany) The author found that a long-neglect- ed gel battery in a hand-held vacuum cleaner had gone high-resistance. It took some effort to make it usable again, by alternately applying voltages of opposite polarities to it. A reverse voltage can help to break down the internal non-conducting layers which can form when the battery is left idle. The battery is now back in action and charging and discharging as normal. Unfortunately, however, the battery will probably start to fail again if we once more leave the appliance lying around unused for a while. To prevent this happening the author applied a well- known technique: the battery is inter- mittently presented with a very brief high-current load. The circuit shown here does the j ob: every two seconds it draws a current of about 1 A for 2 ms. This corresponds to an average current of about 1 mA, which is of compara- ble magnitude to the self-discharge of the battery. Although the circuit does not consume much energy, it can keep the battery fresh. PE ©" BC548,t R2 L© If 2N3CS5 €) ■ BC548 BT1 12V s 120318 - 11 ■ilj * \v;* side, you can add an ex- tra load resistor to the circuit. The circuit is based on the NPN relaxa- tion oscillator from the 2011 Project Generator Edition of Elektor (www.ele- ktor.com/110195), here delivering the base current for the power transistor. I n the prototype the current was meas- ured at around 1 A: to be on the safe The LED indicates when each current pulse occurs, which also serves as an indication of the battery's charge state: the less frequently the LED flashes, the lower the battery voltage. (120318) One-transistor Voltage Converter By Burkhard Kainka (Germany) Taking apart a solar-powered lamp revealed a single-transistor voltage converter circuit that allowed an LED to be driven from a 1.2 V cell. The l/h diagram shows the circuit (with slight modifications). The circuit oscillates at about 500 kHz and, at a cell voltage of 1.4 V, draws 11 mA with a respectably bright LED. The circuit works down to a supply voltage of 0.8 V. The oscilloscope shows 3 V pp at the LED, as expected. The left-hand coil and the capacitor form a series reso- nant circuit, excited by the collector of the transistor which alternates periodi- cally between conducting and blocking. When the transistor is off the upper coil dumps its stored energy so that the voltage on the collector rises to about double the cell voltage. A sinewave voltage of 35 V pp (!) was measured across the capacitor in the resonant circuit. Using a two-channel 60 Elektor 7/8-2012 i BTl LI 470uH L2 470uH H I 1V2...1V5 R1 yfTv © Cl BC547B ^150p D1 o 120324 - 11 Make oscilloscope showed the phase rela- tionships: the resonant circuit shifts the phase by about 90 degrees. The base resistor coupled with the base capacitance and the Miller capacitance (http://en.wikipedia.org/wiki/Miller_ effect) of the transistor add a further phase shift. The voltage increase obtained using the series resonant circuit can be used to make a bipolar voltage converter, for example to power operational amplifi- ers (see r/h diagram). Two electrolytic capacitors and two diodes rectify the voltage. The circuit can deliver a volt- age difference of 9 Vat 0.2 mA, which is enough for a low-power opamp. (120324) Advertisement LAYOUT c IQ -pool II Free Ftione UK: 0800 389 8560 sales@pcb-pool.com All registered brands remain the registered trademarks of the respective manufacturer ! p-cvusoos . . ^ \ (id trice QropriiCfK)Ql f*A110*AI ‘lUblRUMlMTS RS-274X taJ Emv-pc l www.beta-layout.com Elektor 7/8-2012 61 Elex Board Layout in Loch Master By Luc Lemmens (Elektor Labs) For the construction of (small) through- hole prototype boards use is often made of stripboard (Veroboard), a fast and easy way to build relatively tidy and usable circuits in conjunction with wire- wrap or tinned copper wire. Stripboards come in many types and sizes and Elektor has its own variant: the prototyping boards that were de- signed for Elex projects and which are still available from our shop. These an affordable and simple aid for the design of the layout of components and wire links onto stripboards, using a computer boards which also go under the type name of 'UPBS-1', -2 (Universal Proto- typing Board Size-1 or -2) come with a thoughtfully laid out set of tracks, so that a small circuit can be created us- ing a minimum number of wire links. J ust as with 'real' PCBs the success or failure of the board and the simplicity of the layout depend on the amount of thought put into the placement of the components. The PC program Loch- Master from Abacom [1] is an afforda- ble and simple aid for the design of the layout of components and wire links When you click on a track whilst in test-mode you can see which other tracks and links are connected together. I^\ |“ -- [j 4? B 3 ft F! " - i* : n s y Ml i=H 1 1\ A 1 9 r " JfHCpT WQPvm, WWP UBPV/Mi 1 D2 lWtffl? lDOGV/lA. lM«0y lDOOV/L* I W IhMWT UW?r'/LJ, jhHWJ WWWJi a t>* JJ+W07 10MW/L4, JM40Q7 UCKOV^IA ( ds lHWfrf hyl* 1 W JW4QQI? lOflf.v/L/- SU4«n? IQPW/IA 1 . E-iwr tip ■S^-bto 1 M for*" 5 k mivjl. I w t3rmr*l i dQt*ls 1 ptertfe 1 X»V r LM317T fempor wlrm: I ip/?j iWh 1 rWU tom: "wji 1 (1S*> Wrt; n-r>l 1 ¥ 1 ! c.^ s Urn a PAntfvf Lochmaster can also generate a parts list, including an overview of any wire links. 62 Elektor 7/8-2012 Make / l\ onto stripboards, using a computer. The program comes with extensive li- braries with standard components that can be placed with just a few mouse clicks. Wire links can be easily added and everything can still be moved about or modified. Before you build the ac- Lochmaster also comes with a set of templates of the layout for various prototyping stripboards. We have add- ed the track layouts of our own Elex boards to these. The templates are available as a free download from the Elektor website [2]. You can add these templates by saving them in the 'Board sional PCB design package and there are several areas in which there is room for improvement. However, it is still a very useful development tool, which we gladly make use of at Elektor Labs! (120301) tual circuit you can carry out a simple connection check so you can find short circuits or open connections and cor- rect them before doing any soldering. The end result is a fairly realistic rep- resentation of the board, which can be printed out and be used as a template for the soldering. Layouts' folder of the Lochmaster folder. When you start a new design in Lochmaster (from menu, File -> New), this folder opens automatically and you simply select the required layout. You can't really compare the facilities of Lochmaster with those of a profes- I nternet Links [ 1] www.abacom-online.de/uk/html/ lochmaster.html [2] www.elektor.com/120301 Elektor 7/8-2012 63 LED Garland Controller All the colours of the rainbow By Koen Beckers (Netherlands) These days you can buy various types of LED garlands at a reasonable price. With these you can illuminate various objects indoors or outdoors with inter- esting lighting effects. When you use a garland with RGB LEDs you can even create a range of colours or continuously cycle through the colour spectrum. In this case the author wanted to en- The program in the ATtiny varies the brightness of the R, G and B LEDs using an internal pulsewidth con- troller. The program was writ- ten such that the col- our of the LED garland changes continuously. At the start of the code are several items that can be modified to suit your preference before programming the microcontroller. For example, the speed and the number hance several kitchen cabinets with a novel lighting system. To this end a waterproof LED garland with built-in resistors was chosen. This type of gar- land can be obtained from e.g. [1]. The strip is available in lengths up to 5 m and it comes with double-sided sticky tape so it can be mounted onto any clean, flat surface. The supply voltage required by the LEDs is 12 V and the power requirements for the strip used by the author is 7.2 watts per metre. Various types of controller can be bought to drive such RGB LED garlands, but as an electronics hobbyist you 'j ust' design one yourself of course, so that it does exactly what you want it to do. The design for this circuit turns out to be very simple: an ATtiny2313 micro- controller surrounded by a 5 V voltage regulator and three power transistors. The latter are driven via base resistors from port pins PDO to PD2 of the micro- controller. I n the circuit you'll also see a 6-way ISP connector for programming the microcontroller. +I2V © K1 IC1 78L05Z Cl lOOn C2 C3 □ lOOn KXj K3 vrc 2 MOSI 4 GND 6 o a o o o o 1 MSO 3 SCK 5 RST 19 18 17 AVRISP 16 15 14 13 12 20 VC :c IC2 (SCK)PB7 RESET (MSO)PB6 PD60CP) (MOSDPB5 PD501) PB4 PD4CTO) (OCI)PB3 PD3(INT1) PB2 PD2(ll\rTO) (AINDPBl PDlfTxD) (AINO)PBO PD0(RxD) ATTiny2313 XTALl GM> XTAL2 <5 10 ‘4 +5V © R1 T ii K2 LED bar O 0 Q 0 J R4 R3 H^h © 71 HBD139 Cr Tl BD139 €)" T2 BD139 120217 - 11 64 Elektor 7/8-2012 Make of colour changes can be modi- fied, or a self test can be activated. If this is selected then just after the cir- cuit is switched on, it will show the col- ours red, green and blue sequentially, followed by white. This way it is easy to verify that all LEDs in the strip are still working. The current consumption of the LED garland is in practice very close to that stated by the manufacturer. Each LED colour takes a current of just over 200 mA/m. When the transistors specified in the circuit are used (BD139, J Cmax 1.5 A) you could in theory drive a strip with a length of 1.5/0. 2 = 7.5 m. In practice it's best to limit this to about 5 m. For higher currents you can change the BD139 to a Tl P122. This can handle 5 A so that it should be able to cope with LED garlands up to a length of 20 m. Remember that in that case you'll need a power supply that is rated at least at 12 A at 12 V. If you decide to use the TIP122 there is no need to modify the printed circuit board. Although the pinout is differ- ent, it is the mirror image of that on the BD139. The TIP122 can simply be mounted the other way round, with the heatsink tab facing the outside, which makes it possible to mount the transis- tors on a common heatsink next to the PCB. Note that the PCB tracks are not designed to cope with currents of 10 A or higher. / l\ It can happen that the R, G and B la- belling is incorrect on some LED gar- lands, so it's best if you check that they correspond to the correct LEDs before connecting the LED garland to the PCB. The source and hex code for the pro- gram can be downloaded from the Elektor website [2]. (120217) I nternet Links [1] www.ledlightdepot. co.uk/9-led-waterproof-flex-strip [2] www.elektor.com/120217 Advertisement W§! PCBs ww Muuuuch Cheape No-frills policy 17,22 EURO" 5 pcbs, 1 00 mm x 1 00 mm *per piece, incl. UflT (23%) + shipping costs e. g. Germany 1 0,89 EURO * Ja&altac iuiuLU.jackaltac.com Elektor 7/8-2012 65 Flowcode 5 is one of the world’s most advanced graphical programming languages for microcontrollers (PIC, AVR, ARM and dsPIC/PIC24). The great advantage of Flowcode is that it allows those with little to no programming experience to create complex electronic systems in minutes. www.elektor.com/flowcode MIAC (Matrix Industrial Automotive Controller) is an industrial grade control unit which can be used to control a wide range of different electronic systems including sensing, monitoring and automotive. Internally the MIAC is powered by a powerful 18 series PICmicro device which connects directly to the USB port and can be programmed with Flowcode, C or assembly. Flowcode is supplied with the unit. MIAC is supplied with an industrial standard CAN bus interface which allows MIACs to be networked together. for electronics E-Blocks are small circuit boards each of which contains a block of electronics that you would typically find in an electronic or embedded system. There are more than 40 separate circuit boards in the range; from simple LED boards to more complex boards like device program- mers, Bluetooth and TCP/IP. E-blocks can be snapped together to form a wide variety of systems that can be used for teaching/learning electronics and for the rapid prototyping of complex electronic systems. Separate ranges of complementary software, curriculum, sensors and applications information are available. dia - ...for industrial control Flowkit provides In Circuit Debugging for a range of Flowcode applications for PIC and AVR projects: • Start, stop, pause and step your Flowcode programs in real time • Monitor state of variables in your program •Alter variable values • In circuit debug your Formula Flowcode, ECIO and MIAC projects r — - • r —z* k’ W ng with Flowcode New features in Flowcode 5 Flowcode 5 is packed with new features easier including: • New C code views and customization • Simulation improvements • Search and replace function • New variable types and features, constants and port variables • Automatic project documentation • New project explorer makes coding easier • Implementation of code bookmarks for program navigation that make development • Complete redesign of interrupts system allows developers access to more chip features • Compilation errors and warnings navigate to icons • Disable icons feature • Improved annotations • Improved links to support media • Support for MIAC expansion modules and MIACbus T I U JiJSSi i- Mown 1 1 Hi -J dJ ■ IH JF*' c™ — * M 1 + EPH r|£l *9+ for robotics Formula Flowcode is a low cost robot vehicle which is used to teach and learn robotics, and to provide a platform for competing in robotics events. The specification of the Formula Flowcode buggy is high with direct USB program- ming, line following sensors, distance sensors, 8 onboard LEDs, sound sensor, speaker and an E-blocks expansion port. The buggy is suitable for a wide range of robotics exercises from simple line following through to complete maze solving. E-blocks expansion allows you to add displays, connection with Bluetooth orZigbee, and GPS. for USB projects ECIO devices are powerful USB programmable microcontrollers with either 28 or 40 pin standard DIL (0.6”) footprints. They are based on the PIC 18 series and ARM 7 series microcontrollers. ECIO is perfect for student use at home, project work and building fully integrated embedded systems. ECIO can be programmed with Flowcode, C or Assembly and new USB routines in Flowcode allow ultra rapid development of USB projects inclu- ding USB HID, USB slave, and USB serial bus (PIC only). ECIO can be incorporated into your own circuit boards to give your projects USB reprogrammability. More information and products at: www.elektor.com/eblocks I There's no lack of distance counters for walkers or cycling; but swimmers are reduced to mentally totting up how many lengths of the pool have been complete, for want of a counter suitabli for their favourite sport. The project described on ( these"pages got designed to build an electronic solution that takes care & of this tedious counting. The result is a device that's reliable. handy, light, discreet - and inexpensive. We're happy to be able to share with you here. *3f** , *t# 1 mm r# Elektor 7/8-2012 LENGTHS COUNTER FOR SWIMMERS Main technical specifications • small unit worn on the back of the swimmer's head, under the goggles strap • vocal announcement of distance without waterproof earpieces • error rate < 5 % • powered by two AAA cells • compact: 96 x 47 x 24 mm • system open to lots of other applications Figure 1. For my first tests, I had started with an MEMS gyroscope system and Morse code. Unfortunately, the accuracy left a lot to be desired (just like my knowledge of Morse code). If I'm always getting lost when count- ing my lengths, it's because I'm think- ing of how to get a microcontroller to do it for me! As a result, I end up do- ing too many lengths, and the more I swim, the more I think. So the project took form in the water and ideas jostled with one another in my head: because of the need for the case to be watertight, I didn't want any buttons, displays, orindicators; itwould have to go into standby automatically at the end of the session, after a vocal announcement of the lengths swum, audible underwater without any special device or earpieces. The device would be self-contained and require no ex- ternal action for counting the distance. The error rate would be less than 5 % and the maximum dimensions 100 x 50 x 30 mm. 'Only' three details then remained to be solved: • What physical principle and what type of detector to use to measure the distance swum in a pool? • How to produce vocal announce- ments audible in the water without waterproof earpieces? • What techniques to use to obtain a compact device, with low power consumption, using cheap and rea- dily available components? I may as well tell you that for months I thought of nothing but this during my twice-weekly swims. Here are the results of some of my aquatic cogita- tions. Detecting the turns When a sport swimmer turns in a pool, their body performs one or more co- ordinated rotations So it's reasonable to imagine that, in order to detect the turns and add up the lengths, all we need do is to capture these rotations by means of MEMS-type gyroscopes. I built an operational prototype fitted with IDG-500 triple-axis gyroscopes [2]. To keep it simple, the total lengths were announced in Morse code by a small sounder (Figure 1). After a great many tests in the work- shop and in the pool on all styles of swimming, the results were encourag- ing, but the error rate of around 15 % exceeded my target of 5 %. It proved impossible to optimize the counting algorithm using just gyroscopes: if I increased the sensitivity, the swim- mer's spurious movements caused false counting. Conversely, an overly- selective algorithm would miss turns that were rather too gentle. So I had to base my counting on a common el- ement that is relevant for all types of turns in a swimming pool: the thrust against the side of the pool just after the turn. For a sportsperson, it ought to be possible to detect these vigorous thrusts using an accelerometer. So that set me on the road to a prototype us- ing an accelerometer (see box), which did give better results. However, my system was still sensitive to the swim- mer's style, so, undaunted, I decided to pursue my research. A friend suggested using a GPS to lo- cate the swimmer, but I raised the objection that GPSs don't work inside buildings. However, his idea of using the swimmer's physical position, rath- er than their movements, was inter- esting: let's determine the swimmer's heading, at some given moment; if just afterwards the heading has changed by 180°, we can deduce from this that they have turned, and thus swum one length of the pool. QED. Elektor 7/8-2012 69 HOBBY The accelerometer prototype During the tests with the gyroscope, I wasted a lot of time because I was modifying the software blind, without knowing exactly what the detectors were giving during the swimming pool tests. In order to optimize the software, I needed to have been able to record the detector data during the swim and then analyse them quietly back in the workshop. Not wanting to make the same mistake in the new testing phase, I decided to work more methodically: • build a prototype that would let me record the data from the detector during the swim • develop a program for displaying and analysing the data on a PC • deduce from this a counting strategy • develop, then test a counting algorithm off-line on a PC • transfer the algorithm onto the target circuit • test the algorithm in the swimming pool The accelerometer prototype comprises three active devices: an accelerometer, an 8-bit microcontroller, and an l 2 C EEPROM. In the role of the accelerometer, I used the MMA7361L component from Freescale, as its sensitivity of ±1.5 g on each axis seemed well suited to the values I expected to find during my tests. The pC is a PIC18F2685, a classic that I am very familiar with. A 24C512 EEPROM, with a ca- pacity of 64 kB, available in an 8-pin DIP package, is tasked with storing the data supplied by the detector. The acquisition frequency of 50 Hz is chosen so as to be able to reproduce the swimmer's movements faithfully. The data are offloaded to the PC using a simple serial link. On the PC side, the programs were developed in the LabVIEW 2009 environment from National Instruments, an essential tool when you need to analyse data and evaluate processing algorithms. In the end, there were no less than four different pieces of software to develop: • the acquisition program carried by the swimmer • the LabVIEW program for offloading the data and storing them in a file • the LabVIEW program for analysing and processing the data • the final counting program, carried by the swimmer Keeping on track, in lane To determine the heading, there's nothing better than an electronic com- pass using a magnetometer, like the MAG3110 [4] from Freescale. This obliging device comes with an l 2 C link and is quite happy with the unregulat- ed voltage supplied by two batteries. The price is reasonable, even in one- off quantities. The only downside is the tiny 2x2 mm SMD package with ten connections, impossible to solder by hand. Luckily, on the Internet [9] we can find a little board fitted with this device and a 0.1 inch pitch connector, so it's possible to build an evaluation model. To produce an electronic compass, it's not enough just to scale the raw data supplied by the MAG3110: determining the heading requires some trigonomet- ric calculations, and we must compen- sate for the permanent stray magnetic field in the unit we build. What's more, I learnt from the application notes [4] that the heading provided by a mag- netometer will suffer from major er- rors if it is not horizontal, which is very likely to be the case for a detector worn by a swimmer. To eliminate this error, the magnetometer inclination has to be compensated using data provided by an accelerometer [3]. Fortunately, the document also offers the solution: an algorithm to do just that (with source code), which lets us convert the three pieces of raw field data provided by the magnetometer and the three compo- nents of the gravitational field given by the accelerometer into three an- gles called pitch, roll, and yaw (Fig- ure 2). The heading we're after cor- responds to the yaw. With the accelerometer already built in to my second model, and armed with the code (in passing, it's well written and documented) provided by Freescale, after a few hours of manipu- lations and development I arrived at an honourable electronic compass. Sound reproduction The second challenge to be addressed was the reproduction of the vocal an- nouncements in the water. I had suc- cessfully evaluated a voice compres- sion/reproduction algorithm rather poetically named Adaptive Differential Pulse Code Modulation (ADPCM) de- scribed in the AN643 application note from Microchip. This technique is ide- ally suited to an 8-bit microcontroller and gives a quality of reproduction that is satisfactory for my application. Several other projects that have ap- peared in Elektor have also used this principle [7]. The sound signals synthesized by the pC will have to be amplified and repro- duced using a small loudspeaker, but how can we ensure that the swimmer is going to be able to hear them prop- erly with their ears under the water? So I built another model to test the sound reproduction: the pC chosen is a PIC18F27J13 with 128 kB of flash memory (for the sound samples), able to operate at a voltage of less than 3 V. The initial tests using a small water- tight loudspeaker, whose membrane was in direct contact with the water were disappointing, and in any case the speaker was too big. In the end, the best results were obtained using a mini speaker just 20 mm in diameter, 70 Elektor 7/8-2012 LENGTHS COUNTER FOR SWIMMERS fitted inside the watertight case — as long as I drove it with several hundred milliwatts so that the voice announce- ments could be heard under water. To do this, I chose an integrated Class- D amplifier developed by Analog Devices (SSM2301). Eureka! The block diagram (Figure 3) brings together my four main active compo- nents: the accelerometer, the mag- netometer, the audio amplifier, and the microcontroller. The PI C18F27J 13 re- ceives the information provided by the accelerometer directly on three ana- logue inputs AN1, 2, and 9. Port RCO enables or disables this device so as to minimize power consumption. The magnetometer supplies its data via a private l 2 C bus, operating in 'bit bang' mode and using ports RC5 and RC6. The pulsewidth modulated audio sig- nals are supplied by the pC on wire CCP10. The passive low-pass filter eliminates most of the 16 kHz compo- nents arising from the sampling. The amplifier, which is capable of supplying up to 1.5 watts, drives the loudspeaker directly without any output filtering. Connector K4 allows communication with the pC via the 1 2 C bus. Although it is not used here, this 'secret door' will allow this board to be used for other purposes in the future. The 'RUN' LED and connector K3 are key allies while the software is being perfected. K2 is the programming con- nector to which we will connect a PIC programmer (ICD3, PICkit, etc.) in or- der to flash and debug the software. Jumper CNF lets us configure the length of the user's usual pool: 25 m (82 ft.) without the jumper, 50 m (164 ft.) with the jumper. The impact-sensitive switch K1 is con- nected to an Ultra Low- Power Wake-up input. As the name ULPWU indicates, this takes the pC out of its deep sleep Figure 2. Illustration of the notions of pitch, roll, and yaw. Vbat 110760-12 Figure 3. Block diagram of the solution adopted. Elektor 7/8-2012 71 HOBBY Vbat © BAT 3V Supply — + (2xAAA) TP2 o- 1 i ( i < ES1AL > • < 6V3 > VSENSORS © C5 10 1 8 11 12 14 B Accelerometer VDD G-SEL XOUT NC U3 YOUT NC ZCXJT ^ MWV736IL NC SLEEP NC SELF-TEST OG-DET VSS C8 lOu 6V3 C9 lOu 6V3 Vbat © R7 Acceleration switch _ Microcontroller ~ ^C2 U^^/3 SSI 1 I a □ K3 17 VDDCORE/VCAP MCLR U1 VDD RB(yAN12/C3IMyiMnyRP3 RB1/AN1QONC/RTCC/RP4 RB7/CCP7/KBI3/PGCVRP10 RB2/AN8ONC/CTED1/REF0/RP5 RB6/CCP6/KBI2/PGC/RP9 RB3AN9C3INA/C7ED2/RP6 RB4/CCP4/KBIQ5CL2/RP7 RB5/CCP5/KBI1/SDA2/RP8 PIC18FZ7) 13-l/NL RA7/OSC1/CLKI RA6/OSC2/CLKO RAQ'ANQ'C U NA/ULPV\AJ/RPO RC3/SCK1/SCL1/RP14 RC1/CCP8T10SI/RP12 RC4/SDI 1/SDA1/RP15 RCQTlOSCynCKI/RPll RA1/AN1/C2INA/VBG/CTDIWRP1 RC 2/ANU/C 21 HD/CTPLS/RP13 RA2/AN2/CUMD/C3IBA/REF-/CVREF RC5/SD01/RP16 RA3/AN3/CUhB/VREF+ RC67CCP97TX1/CK1/RP17 RA5/AN4/CUNC/SS1/H.VDIWP2 RC7/CCPUCmXl/DnyRP18 VSS1 VSS2 18 RX2 19 TX2 20 21 G X 22 SCL S 23 SDA S Rll 390R | - 8 G SLEEP 10 B 14 15 Ifi X"* AUDIO PCM G SLEEP G X Debug Port UART K4 \ 2 C TrI T VSENSORS ICS © Magnetometer SCL SDA Jl CNF C7 lOOn Si Si — • — 8 2 VDDIO VDD U2 SCL SDA CAP-A INTI NC CAP-R IWG3LL0FCR1 GMD GM3 10 ^T]c: HlOOnHlI C6 lOOn AUDIO ON “ Vbat © R8 WAKE UP Clfi lOOn R9 RIO H 39GR H H 390R \-f C17 CIS lOOn < lOOn > n C14 lOOn C19 lOOn C15 lOOn GAIN VDD SD OUT+ U5 IN+ SSM2301RMZ -R2 in- our- GND HP Audio Amplifier 110760 - 11 Figure 4. J ust like the block diagram, but this time with actual devices. mode when the switch is closed by a (small) impact given by the user. This is how we will be able to dispense with an on/ off switch and avoid any problem of watertightness. All the devices chosen offer the possi- bility of being taken out of service at any time, in order to reduce their pow- er consumption both in operation and during periods of stand-by. The micro- controller and amplifier are powered directly from the batteries (V bat ), while the detectors are powered via ports RC3 and RC4 (V detectors ). Be sure to also read the box 'Limiting the pow- er consumption in stand-by mode'. In order to monitor the battery volt- age, a divider connected to the V detec . tors voltage, which is very close to the battery voltage and changes with it, is connected to analogue input AN4. When the detectors are disabled, the consumption of this divider itself also drops to zero. When the voltage is be- ing measured, the reference is taken from the V ddcore voltage, which is regu- lated and close to 2.5 V. It's only a small step from the block diagram to the outline circuit (Fig- ure 4): once again, we find the four active devices that have already been described in some detail. Diode Dl, in inverse parallel with the power input, will save the life of your distance counter if you accidentally fit the batteries the wrong way round; in this event, the residual voltage of the 72 Elektor 7/8-2012 LENGTHS COUNTER FOR SWIMMERS Figure 5. Marking the axes for the device. batteries short-circuited by the diode will be of the order of 1 V and hence harmless to the circuit. You'll real- ize your mistake straightaway, as you won't hear the usual welcome mes- sage. Refit the batteries the right way round at once, and everything will be OK again. You'll notice a lot of decoupling and filtering capacitors, including C2. The unusual value of 10 pF is recommend- ed by Microchip, as the V ddcore /V cap pin is internally connected to the output of the 2.5 V regulator that powers the pC core. According to the manufacturer, it is essential to decouple this point using a high-value capacitor with low internal resistance (low ESR). The accelerometer's three analogue outputs, labelled G_X, G_Y, and G_Z are connected to C8, C9, and CIO. To- gether with the device's 32 kft output impedance, these three 10 pF capaci- tors form a first-order low-pass filter. The cut-off frequency obtained, around 0.5 Hz, makes it possible to sample at a low frequency (a minimum of 1 Hz, according to the Shannon criterion), without having to worry about very low frequency phantom signals caused by spectral aliasing. The amplifier input has a simple 3 rd - order passive low-pass filter. The (free) LTspice simulator [8] shows us that the attenuation of this filter is 2 dB @ 600 Hz and 38 dB @ 16 kHz (cut off frequency). The in-band attenuation is not a problem, as the pC provides a high amplitude signal (3 V pp ) and the amplitude has a gain of 12 dB. Diving right on in... Although my initial tests had certainly confirmed the feasibility of the project, I had not been bothering very much about its final size. So it now remained for me choose the housing for the main active components, and above all a case that would meet the requirements of being as compact as possible, but still able to hold two AAA cells; if possi- ble watertight; and available in one-off quantities at a reasonable price. I found the perfect case in the Smart Case M from OKW, which met all my specifications... except for the water- tightness. My solution is simple but effective: a couple of turns of electri- cal insulating tape, and think no more about it for months. The battery life is such that you hardly have occasion to open the case more often than that. Unfortunately, several of our devices only exist in tiny packages that are im- possible to solder by hand. The pC was chosen in a 6 x 6 mm QFN28 pack- age, the magnetometer in a 2 x 2 mm Limiting the power consumption in stand-by mode Microchip guarantees a consumption in 'deep sleep' mode of ten or so nanoamps for its PIC18F27J13 microcontroller. Similarly, Analog Devices claims 20 nA in stand- by for its SSM2301 amplifier. So these two devices are going to have virtually zero consumption while asleep. The consumption claimed by Freescale for the magnetometer and the accelerometer in operation is 1 mA and 400 pA, while their consumption in sleep is 2 pA and 3 pA respectively. Although it is very low, this stand-by consumption is still around 100 times greater than that of the microcontroller and amplifier combined. An elegant solution consists in powering the low-consumption detectors directly from the micro- controller ports. In this way, we can be certain that by sending a 0 to these ports, the consumption of the detectors is going to drop to 0 nA in stand-by. Elektor 7/8-2012 73 HOBBY Figure 6. The rules for orientation of the axes must be transferred to the PCB and the detector it carries. A little bit of software takes care of the rest. Figure 7. My prototype. The magnetometer is extremely sensitive and is affected by the speaker's permanent magnet. I kept them as far apart as possible, otherwise the total saturation of the magnetometer would have prevented any valid measurements. In spite of everything, the permanent magnetic field from the L/S magnet received by the detector is relatively high, but the compensation algorithm makes it possible to cancel out the effects. DFN10 package, the accelerometer in a 3 x 5 mm LGA14 package, and the amplifier in a 3.25 x 3.25 mm MSOP8 package. The first three packages don't have pins, so manual soldering is out of the question. For practical reasons, I chose not to use packages smaller than 0805 for the passive components. It's now pos- sible to find 10 pF / 6.3 V ceramic ca- pacitors in an 0805 package at reason- able prices. The track layout for the double-sided PCB didn't cause any special problems, other than that the pitch of the ac- tive components and the diameter of the vias obliged me to employ Class 6 routing. The detector signal processing algo- rithms in this device provide angles with respect to a system of co-ordi- nates called NED (North, East, Down). Figure 5 shows this system of co-ordi- nates applied to our project. In order for the software to be able to make use of the information supplied by the accelerometer and magnetom- eter, we need to make sure that the ori- entation of these detectors inside the device is consistent with the NED co- ordinate system of the unit as a whole. Figure 6 shows the detector sensitivity axes and those of the device. It can be seen that the detectors have been ori- ented (turned) in such a way that their sensitivity X axes are inline (or parallel) with the unit's X axis, and in the same sense. Perfect! For the Y axis, we are still in line, but the sense of the vec- tors is reversed for both detectors. The directions with arrows tell us that the values returned by the detector vary in the opposite sense to what the NED system expects. So to get back on an even keel, the software will have to in- vert these data, which can be achieved simply by just multiplying them by -1. And to conclude, the Z axis needs to be inverted for the accelerometer but not for the magnetometer. Casing up It is inadvisable to attempt to solder the components for this project by hand. If you are interested in an as- sembled, tested, ready- to- use module, we invite you to let us know by e-mail to editor@elektor.com. If there is suffi- cient demand, Elektor will have a mod- ule produced. Casing up (Figure 7) will then take only a few minutes: Fit fine, insulated wires to the two bat- tery clips which will be located at the bottom of the unit; Connect two more clips to the board's 74 Elektor 7/8-2012 LENGTHS COUNTER FOR SWIMMERS power input, taking care to maintain the polarity; Fit the four clips, using flat-nosed pli- ers; Solder two fine wires approx. 6 cm long to the speaker output and twist them together; Solder them onto the speaker; Fix the PCB into the case using a 2.7 mm self tapping screw; Stick the back of the speaker to the cover, close to the well where the case fixing screw goes, using either a spot of hot-melt glue or a small piece of dou- ble-sided tape; Insert two new AAA cells into the unit, taking care to observe polarity; The speaker, that's Kenneth, should announce "Welcome!" then the length of the pool (25 m or 50 m, depending whether the configuration jumper is fit- ted or not); Close the case and tighten the screws; Seal the case using two turns of insu- lating tape. Don't forget to put a small square of insulating tape over the screw. Software The software functions are summed up in the block diagram (Figure 8); the most interesting part involves the calculation of the compensated head- ing, in the middle of the diagram. The compensated heading and pitch angle are used by the turn detection and dis- tance totalling algorithms. Logically enough, these functions call upon the speech synthesis module, based on the famous ADPCM modulator, to make the announcements to the swimmer. The 'sleep and wake management' module recovers the swimmer's physical posi- tion. If the swimmer has not done any lengths for the last 10 minutes, this module puts the pC and its peripher- als into 'deep sleep' mode. Only the detection of a knock or re-applying power to the unit will awaken the pC from its slumber. Battery monitoring is managed by a separate routine which, when the time comes, will cause a dry "Low battery" to be announced. All the processing described above is carried out by five asynchronous tasks (Table 1). During the testing phase that led to the final version of the project, I was care- ful to write drivers that could be used for the strategic functions and devices employed. By going about it like this, I Figure 8. The software block diagram and its position in the real world. Elektor 7/8-2012 75 HOBBY Table 1. The application breaks down into 6 tasks Task name Function ac qui r e_ at t i t ude Reads the data from the accelerometer and magnetometer, scales the data, compensates for the permanent field, calculates the pitch, roll, and heading angles. Task executed every 400 ms swi mmer_ posi t i on If the swimmer stays standing up for more than 10 s, the unit goes into pause. If the swimmer is horizontal for more than 5 s, counting starts again. Task executed every 500 ms countturns If a change of heading of more than 60° is detected for 10 s consecutively, the length count variable is incremented. Task executed every 500 ms manage battery If the battery voltage is too low for 20 s consecutively, the "Low battery" announcement is given and repeated every 5 min. Task executed every 2,000 ms ma n a g e _ s 1 eep If the swimmer does not swim any length for 10 min, the unit goes into stand-by. heartbeat Manages the flashing of the LED knew I'd save a lot of time and effort when I came to incorporate the mod- ules into the final project. As I already had drivers for the basic peripherals (analogue/digital converter, l 2 C bus, serial link, dynamic memory) as well a robust multitasking core, it made writ- ing and integrating the main applica- tion easier. In its final form, the project includes no less than 14 source files in C (Table 2). As usual, the whole of this software is available from the Elektor website [1]. Using it in practice Fitting the batteries into the unit is greeted with a polite "Welcome!" This kind little word will reassure you that Table 2. Software source files Module Function COLO.c Application main file COLOutil.c Application utilities COLOspeech_samples.c Speech samples YASKpic.c Co-operative multitasking core CMPAdev.c Attitude compensated compass M310dev.c Manager for MAG3110 magnetometer ADPpl8.c Manager for ADPCM modulation for speech reproduction MFSpl8.c Single file system manager MEMpl8.c Dynamic memory manager ADCpl8.c Analogue/digital converter manager 1 2Cpl8_sw.c Manager for l 2 C in bit bang mode TTYpl8.c Serial link (UART) manager 1 OSpl8.c Input/output manager SYSpl8.c Centralization of interrupts and system timers the batteries have been fitted correctly and the unit is working properly. The unit will then announce the pool length selected via the configuration jumper (25 m or 50 m). Before you leap into the water with your new toy (and Beyonce in Bikini), re-tighten the case fixing screw and check that the two turns of insulating tape are watertight. Fit the counter be- hind your head, the widest part at the top, held in place by your goggles strap, and head off to the shower. After a few seconds, the unit will say "Pause" - it has detected that you are standing up. In pause, the distance is not counted. In the meantime, the device has dis- creetly calibrated itself. Once you're in the water, start your first length. After 5 s, a chime will tell you that counting has begun, then, a few seconds later, a sonar 'ping' will tell you that one length has been counted. When you reach the other end of the pool, turn as usual (this version of the software does not yet take into account the quality of your turn!) After a few seconds, a new 'ping' will sound and Kenneth will an- nounce "Two laps", i.e. two lengths of the pool. After the 'ping' for the fourth length, the voice will announce "Four laps", i.e. four lengths, and so on. As the device's counting capacity is 299 lengths, i.e. around 7.5 km in a 25 m pool, you'll have to put in quite some effort before you can go right round the clock in a single session. Once out of the pool, rinse and dry the unit before you put it away in your sports bag. After 10 min of inactivity, the counter will say "Goodbye" and go into stand-by automatically. There's no point removing the batteries when it is not in use. You can also stop it imme- diately by giving it a flick on the side, it won't mind and will answer "Goodbye" before going to sleep. At the start of 76 Elektor 7/8-2012 LENGTHS COUNTER FOR SWIMMERS your next session, give the case an- other flick on the side before you fit it under your goggles strap. 1 1 will reward you with “Welcome!" to tell you it has woken up. If you hear "Low battery" every five minutes during your train- ing, replace the batteries. Unfortu- nately, the device does not memorize the total of all the lengths swum during successive training sessions. It could do it, it's only a question of software — over to you! Other possible uses If you're more interested in robotics or modelling than swimming, this lit- tle board with its open-source software forms an excellent basis for a central inertial base with six degrees of free- dom. Connector K4, connected to the microcontroller's l 2 C port, will give you the best communication interface there is. It's up to you to let us know if you'd like us to come back to this in a OKW Smart Case M A9066109 + A9166001 : recommended housing ADS02008MR-R Projects unlimited : mini LSP 8 ft, 020 mm C8 C3 Main components used in project PIC18F27J 13-1 , Micirchip, MCU, 8 bit, 128 KB Flash, 3 KB RAM (QFN28) MAG3110FCR1, Freescale, 3-axis magnetometer w. I2C interface I2C (DFN10) MMA7361LCR1, Freescale, 3-axis acceler- ometer w. analogue outputs (LGA14) SSM2301RMZ-R2, Analog Devices, 1,5 W classe D audio amplifier (MSOP8) ASLS-2, Assemtech, Acceleration sensi- tive switch (2G), C6 C7 C4 C20 R1 C17C18 R2 R8 R9 cc CvJ t— CD ^ LO O o DC CC CC 8 5 C12 Cl C15 C14 Figure 9. The author's double-sided PCB design. future issue. Do tell us if you're inter- ested in this project and the develop- ments it might lead to. (110760-1) Internet Links [1] www.elektor.com/110760 [2] Gyroscope http://invensense.com/mems/gyro/idg500.html [3] Accelerometer www.freescale.com/ - search keyword: MMA7361 [4] Magnetometer www.freescale.com/ - search keywords: MAG3110, AN4246, AN4247, AN4248, AN4249 [5] LabVIEW www.ni.eom/labview/f/ [6] MPFS file system www.microchip.com - search keyword under 'Search Microchip': AN833 (the search will return the application note about the TCP/IP stack, which MPFS is part of) [7] ADPCM modulation www.microchip.com - search keyword: AN643 www.elektor.fr/nouvelles/explorer-16-i-creating-and- adding-sound-files-to.l55918.lynkx www.elektor.nl/Uploads/Files/ CreateYourOwnSoundFiles.pdf [8] LTspice simulator www.linear.com/designtools/software/ [9] Sparkfun www.sparkfun.com Acknowledgements I'd like to thank Messrs Antoine Authier, Denis Meyer > and Clemens Valens who were always forthcoming with good ideas and ad- vice throughout the construction of this project , as shown by the abundant e-mail correspondence exchanged over a few months (around 400 messages). Thank also to Kenneth Cox , one of Eiektor's freelance translators , who kindly provided the voice for the speech samples. Elektor 7/8-2012 11 INFOTAINMENT The Maze of the Lost Electronic —£>(— Diode: V F =0.6V — pj— Zener: V z = 36 V f — ^ Resistor: R - 10 ft — j j — Capacitor: C = 1 pF VTA- I nductor: L = 10 pH Push-button By Sadettin Commert (France) Ariadne, Theseus and the Minotaur, Chartres, ’ The Name of the Rose', to name but a few - there's no shortage of mazes in our imagination. What's more, to please the calculator wizards, Elektor has already published a number of labyrinthine puzzles that have proved pretty tough. Now this time we have a variant in the form of a circuit diagram, which we've kept deliberately simple so everyone can have a go. The grid contains only passive components, whose DC behaviour is easy to understand. Enter the maze and leave it with a prize worth over £ 800 . Have fun and learn Let's leave it to its inventor, Sadettin Commert, to explain: “Like any trainer or teacher, when I prepare my lessons or when I'm at the blackboard, I'm always on the lookout for methods that will encourage assimilation. I fine-tune my teaching, adapting to the students' level, since levels and abilities vary a lot. I try to use analogies with physical phenomena that are familiar in everyday life (mechanics, hydraulics, thermal, optics, acoustics, and so on). In electricity and electronics, these sorts of analogies allow us to perceive the currents and voltages that are otherwise intangible and invisible on our human scale. Now what sort of fun can we have with j ust four components (R, L, C, and D) ? In wondering about that, I came up with the 78 Elektor 7/8-2012 THE MAZE OF THE LOST ELECTRONICS TECHNICIAN 5 Technician idea for this game. Everyone likes a maze, they encourage perseverance, and it's rare for anyone to give up before finding the way out!" And now you too can go and play with it, and get other people to play as well, whether they're electronics technicians or not. To play, all you need is to have a rudimentary idea of the way these components behave at DC. Put yourself in the place of an electron — or an electronics technician — lost in this electronic labyrinth, and feel the excitement of getting lost, and the relief when you find the way out. Before setting off, you just need to bear in mind that the diode is a one-way device — it works in the direction of the arrow. There's no question of current flowing in the opposite direction, just like in a one-way street. With the capacitor, which would let AC current pass in both directions, here we have a complete block, as we're in DC — the current can't pass in either direction. The inductor lets the DC current pass in both directions, j ust like the resistor and the switch (as long as it is closed). Now it's over to you! Find the path the current will take if we apply a DC voltage of 20 V to one or other of the inputs. To which of the three inputs 1, 2, or 3 must we apply this voltage for the current to arrive at the output? If several of you want to have a try, don't forget to make a number of photocopies of this page before you start. A superb prize offered by Matrix Multimedia Send in your answer by e-mail only before 15 th August 2012 to: labyrinth@elektor.com. The body of the messages won't be read. Only the 'Subject' line will count, it will be analysed automatically, and it must contain the right answer in the form of a number ( 1, 2, or 3) followed by a number in answer to the following subsidiary question: How many correct answers to the maze question will we have received by 15 th August 2012? Thanks to the generous sponsorship by Matrix Multimedia, the winner of this competition will win the following two-part prize: Electronic Workstation - Desktop Approx, value £800.00 With its small benchtop footprint and a high specification, this self- contained, easily portable Electronic Workstation is the perfect tool for electronics education and prototyping. The Workstation includes a number of PC-based virtual instruments: a two-channel oscilloscope, spectrum analyser, signal generator, 8-channel logic analyser, digital signal generator, and serial communications analyser. The Workstation also includes a power supply and an 8-channel PC interface that is compatible with Flowcode, Visual Basic, C# and LabView. Other characteristics are described here: www.matrixmultimedia.com/product.php? Prod=HP886EU&PHPSESSI D= The free workstation will be accompanied by the Protostation Advanced Breadboard, normally available as an optional extra and approximately £120.00. The unit includes not only a large prototyping area, but also a whole array of switches, potentiometers, LEDs and sensors that are easily connected to the prototype area. An on-board function generator provides sine or square waves (10 Hz - 10 kHz). Two connectors are provided for easy connection to E-blocks or the Electronic Workstation. www.matrixmultimedia.com/ product. php?Prod=HP512&PH PS ESS I D= Now it's your turn! The solution will be published in the October 2012 edition, which will be out in mid September. Elektor 7/8-2012 79 MICROCONTROLLERS Arduino on Course (la) Part la: Welcome & Arduino! fso.und generation By David Cuartielles (Spain) Practice makes perfect and in this the first of a series of arti- cles I will focus in presenting all the bits and pieces you need to understand in order to play 1-bit sound from a digital pin on your Arduino board. We will start by looking at the easiest way to create sound by means of a simple piezo buzzer or a speaker. I will then introduce the Arduino Tone Library, as a simplified way to achieve the same functionality. And I will close by introducing an advanced technique that allows play- ing short sounds stored in the form of .wav files. When it comes to the theory, you will be introduced to a technique known as 1-bit Delta Sigma Digital to Analog con- version, but don't be scared by the name, the methods and technologies are presented along with examples you can easily reproduce with a minimal set of parts. Get out your materials I f you aim at reproducing all the examples in this article you need to have: • an Arduino Uno board, though some of the other boards in the Arduino line using ATmega328, ATmegal68, ATme- gal28 or ATmega256 will work as well; • a USB cable to connect your Arduino to a computer; • a piezo buzzer to play tones; • alternatively a mini loudspeaker or headphones and a socket to connect them to the Arduino board; • a computer running the Arduino IDE and a tool called SoundData for the IDE (check the download links in the references section). Sound machines When talking about interactive music instruments, I like to refer to them as Sound Machines. They consist of three blocks: the data used to generate the sound, the user interface, and the actual sound engine. The data refers to the way the sound is used. It could be generated, we could play back sounds from a sample collec- ts o w> c • i^m N a; "D TO Figure 1. Arduino UNO hooked up to a piezoelectric buzzer. 80 Elektor 7/8-2012 ARDUINO ON COURSE This article is going to lay the foundations for creating Interactive Sound Machines using a standard Arduino Uno board. However, all the knowledge described here as well as the code can be easily ported to Arduino Mega, Arduino Mini or any other member of the Arduino 8-bit family. Jump the Arduino bandwagon, this stuff comes straight from a creator of the platform! tion, or just perform real-time sound alteration. Data is the actual sound, the tones in a piano, or the bytes stored inside the channels in a sampler. The user interface defines the way the sound structures will be manipulated, or the mechanisms to modify the sound characteristics. The easiest example is the volume control usually implemented as potentiometer or rotary encoder. The Ul is what the user manipulating the instrument has his/ her hands (or mind) on to alter the sound engine's behaviour. Finally, the engine defines the way data is displayed. It takes the data and renders it as sound according to the control par- ameters introduced by the user through the Ul . I n our case, the engine is the Digital to Analog converter we are going to implement via software. From blink to bee The "Hello World" example to start using Arduino is making the LED on pin 13 blink. The code looks like this: /* Blink Get the LED on pin 13 to go on/off http : / /arduino . cc */ int ledPin = 13; // define the LEDs pin void { } setup ( ) pinMode ( ledPin, OUTPUT ) ; // configure the pin as output void loop ( ) { digitalWrite ( ledPin, HIGH ) ; / / turn the pin on delay( 1000 ); // wait lsec digitalWrite ( ledPin, LOW ) ; // turn the pin off delay ( 1000 ); // wait lsec } The example is self explanatory. With little changes we can use the same example to start playing sound out of our Ar- duino. We will be using a piezoelectric buzzer and later on we will move into using a proper loudspeaker to increase the quality of the sound output. The piezoelectric buzzer The contact microphone, also known as piezo buzzer is an electronic component made of a combination of two discs of different materials. One of them is metallic and the other one is usually ceramic, having the piezoelectric properties. When applying a voltage to the component, the materials will repel each other, producing an audible click. Making the volt- age difference zero will cause the materials to return to their original position, again producing a click sound. By applying a voltage of a sufficiently high frequency, the click produced by the piezoelectric will modulate into an au- dible tone. You can test this by connecting a piezoelectric buzzer to Ar- duino by wring its positive pin to, say, Arduino's pin 8 and the negative pin to Arduino ground (GND), see Figure 1 . Take the previous code and modify the line that determines the pin the LED is connected to: int ledPin = 8; // define the pin for // your Speaker or Piezoelectric When running this program you will hear the piezoelectric clicking once per second, which is the times when the voltage changes at its pins. You can modify the code to make the delay between clicks. The smaller the delay, the more the clicks will merge into a modulated tone. Try to change both lines in your program affecting the time between clicks to be: delay ( 1 ) ; Now you will be hearing a sound with a frequency of 500 Hz. You will also notice the sound to be louder due to a property of the piezoelectric components. They resonate in the kilo- hertz range, at least the ones we find commercially available, as they are designed to be buzzers or contact microphones. If you want to experiment further in sound production with this technique, I would encourage you to not use the de- lay ( ) function from Arduino. The reason for this is that you Elektor 7/8-2012 81 MICROCONTROLLERS will need a better time- resolution to produce a richer selec- tion of tones. The function delayMicroseconds () is much more suitable to sound production, as it is three orders of magnitude more accurate. Adding all these changes to the original Blink program, will give us the Bee program: /* Bee Make a piezoelectric oscillate on pin 8 http : / /arduino . cc */ int piezoPin = 8; // define where the // piezoelectric is connected void setup ( ) { pinMode ( piezoPin, OUTPUT) ; } void loop ( ) { digitalWrite ( piezoPin, HIGH ) ; delayMicroseconds ( 1000 ) ; digitalWrite ( piezoPin, LOW ) ; delayMicroseconds ( 1000 ) ; } Playing tones According to Fourier's Law every sound is the result of adding a series of sinusoidal sound sources having different phases and amplitudes. We could say that sine and cosine waves are the fundamental components of sound. Unfortunately microcontrollers, and the one on the Arduino Uno is not an exception, cannot imitate the sinusoidal shape perfectly. We can anyway produce square waves by repeat- edly switching a pin HIGH and LOW. The tones produced in this way have the same frequency, but are not clean as they add components to the pure sinewave. In musical terms, the instrument making square waves has a different tonal char- acteristic than the one making sinusoidal ones, although the tones proper are the same. The only issue we find here is that sound is expressed in frequency (hertz or Hz) while microcontrollers work with time. The total amount of time a HIGH-LOW oscillation lasts is what we call the period (seconds). There is a relationship between period p and frequency f as expressed in the follow- ing formula: , i i /= — > p=- p f In other words, period is the inverse of frequency and vice- versa. In this way, if we want to know the delay needed to play say, the A 4 tone using Arduino, we need to do a bit of maths again like: p — — - 0.002272 s = 2.272 ms = 2272 us 440 If we want the program "Bee" to play A 4 , we need to modify it so that the total time in both calls to delayMicrosec- onds ( ) adds up to 2272 microseconds. digitalWrite ( piezoPin, HIGH ) ; delayMicroseconds ( 1136 ) ; digitalWrite ( piezoPin, LOW ) ; delayMicroseconds ( 1136 ) ; The different tones within a scale can be mapped to time- delays so that they can be played using Arduino. Table 1 shows a full octave. Table 1. Available musical notes / tone frequencies Tone Frequency [Hz] Period [|js] Delay [|js] Q 261.63 3822 1911 d 4 293.66 3405 1703 Ea 329.63 3024 1517 Fa 349.23 2863 1432 g 4 392.00 2551 1276 A A 440.00 2272 1136 Ba 493.88 2025 1012 Cs 523.25 1911 956 Arduino's tone library There is more to sound playing than just the tone. Musical scores are expressed in notes, which are the tones played for just a certain amount of time. In order to simplify the possibility of playing basic melodies using Arduino, we added a library to the system that handles all the math explained so far in this article, as well as note durations. Now that you understand how to play a tone at a relatively low level, I think it is convenient to introduce this abstraction to make easier for you to create programs playing sound. This library is called tone and brings in a function allowing playing a tone. In the background this is done by controlling some of the internal timers in the processor. One timer takes care of the tone itself, while the other monitors its duration. There are two functions to play sound, called the same, but 82 Elektor 7/8-2012 ARDUINO ON COURSE with a different amount of parameters. tone ( pin, frequency ) ; / / play a tone tone ( pin, frequency, duration ) ; // play a note, duration in milliseconds You should note how time is measured. The function's argu- ment 'duration' will play the note for a certain number of milliseconds (ms). If you want to have a function counting the time in a way that is closer to how it is made in musical scores, you will have to decide how long the different notes /* we define durations as numbers / between 1 and 7 : 1 - whole note - 1 unit 2 - half note - 0.5 units 3 - crotchet - 0.25 units 4 - quaver - 0.125 units 5 - semi quaver - 0.0625 units 6 - demi semi quaver - 0.03125 units 7 - hemi demi semi quaver - 0.015625 units */ void playNote ( int speaker, int theTone, int duration ) { // we give for granted that the half // note lasts 0.5 seconds long time = 500 / pow ( 2, duration-1 ); // assign the note to the speaker tone ( speaker, theTone, time ); } will be. The following code assigns durations to the different notes considering that the basic note lasts 0.5 seconds. The function above could also be written in a way that would make use of the more common variable of the beats per minute (bpm) . In that way we could make the instrument play at dif- ferent speeds depending on the desired tempo for the melody. /* we define durations as numbers / between 1 and 7 : [. . .] */ void playNote ( int speaker, int theTone, int duration, int bpm ) { // menmotecnic: 120 bpm - - > // 1000 milliseconds for half note // source http://bradthemad.org/guitar/ // tempo_calculator . php long time = ( 1000 * bpm / 120 ) / pow ( 2, duration ); // assign the note to the speaker tone ( speaker, theTone, time ); } Chained melodies It's "awesome and stuff" to play a short melody at some point during the execution of a program. A melody consists of notes and silences. Here we are going to see how to play a melody stored as an array of numbers. Inside the Arduino IDE there is an example dealing exactly with this. Open the program under File ->• Examples ->• 2. Digital -► toneMelody: /* Melody Plays a melody [. . .] */ finclude "pitches. h" // notes in the melody: int melody [] = { NOTE_C4 , NOTE_G3 , NOTE_G3 , NOTE_A3 , NOTE_G3 , 0, NOTE_B3, NOTE_C4 } ; // note durations: 4 = quarter note, // 8 = eighth note, etc.: int noteDurations [ ] = { 4, 8, 8, 4, 4, 4, 4, 4 } ; void setup ( ) { // iterate over the notes //of the melody: for ( int thisNote = 0; thisNote < 8; thisNote++ ) { // to calculate the note duration, / / take one second divided by the // note type. e.g. quarter note = // 1000 / 4, eighth note = 1000/8, / / etc . int noteDuration = 1000 / noteDurations [thisNote] ; tone ( 8, melody [ thisNote ] , noteDuration ) ; // to distinguish the notes, set a // minimum time between them. // the note's duration + 30% seems to / / work well : int pauseBetweenNotes = noteDuration * 1.30; delay ( pauseBetweenNotes ); // stop the tone of playing: noTone ( 8 ) ; } Elektor 7/8-2012 83 MICROCONTROLLERS } } void loop ( ) { // no need to repeat the melody. } int duration, int bpm ) // menmotecnic: 120 bpm - - > // 1000 milliseconds for half note // source http://bradthemad.org/guitar/ // tempo calculator . php long time = ( 1000 pow ( 2, duration / bpm * 120 ) / ) ; // assign the note to the speaker tone ( speaker, theTone, time ); delay ( time*1.30 ); // add 30% for the // silence between notes } void setup ( ) { for ( int thisNote = 0; thisNote < 8; thisNote++ ) { playNote ( 8, melody [ thisNote ] , noteDurations [ thisNote ] , bpm } } void loop ( ) } { // // let' s to it listen just once You will notice that the melody is stored in two arrays: the notes are in one, while the note durations are in a different one. Durations are expressed differently from what we saw earlier. Our previous example was using durations expressed in the way it is done in music. The first command in the program includes a file called pitches . h that comes as part of the code into a different tab within the example. The file sadly is too large for printing here. It includes a series of constants representing the frequencies for each tone. In that way, the constant note_a4 represents the numeric value 440, or 440 Hz for the note A a . /-k*-k-k-k*-k*-k*-k*-k*-k-k-k*-k*-k*-k-k-k*-k-k-k*-k-k-k-k-k*-k*-k-k-k * Public Constants -k-k-k-k-k-k-k*-k-k-k-k-k-k-k*-k*-k-k-k-k-k*-k-k-k-k-k*-k*-k*-k-k-k-k-k*/ #def ine NOTE B0 31 #def ine NOTE Cl 33 #def ine note" _CS1 35 [. . .] #def ine NOTE G4 392 #def ine NOTE GS4 415 #def ine note" A4 440 #def ine note" AS4 4 6 6 [. . .] #def ine NOTE CS8 4435 #def ine note" D8 4 6 9 9 #def ine NOTE DS8 4978 The above example can be modified to make use of the beats-per-minute (BPM), what will allow changing the speed at which the melody plays. We just need to include the playNote function we made earlier and modify the way we express the durations to be expressed in the same terms as in our new function: #include "pitches. h" int melody []= { NOTE_C4 , NOTE_G3 , NOTE_G3 , NOTE_A3 , NOTE_G3 , 0, NOTE_B3, NOTE_C4 } ; int noteDurations [ ] = { 2, 3, 3, 2, 2, 2, 2 , 2 }; int bpm = 120; void playNote ( int speaker, int theTone, Now try including a potentiometer or any other analog sen- sor to modify the BPM rate and in that way play the melody at different speeds. Our next instalment begins with playing 1-bit notes and culminates in a method to make Arduino play a sound with barely more than a single line of code. The files for this month's instalment may be found at: www. elektor.com/120366 (120366) The Author David Cuartielles (1974, Zaragoza, Spain) is currently Head of the Prototyping Laboratory at K3, Malmo University, Sweden, and owns a Research Fellow position in Interaction Design at the Medea Research Studio. In 2005 he co-authored the Arduino prototyping platform. David has a permanent interest in embedded electronics and education, having taught and given lectures at several institutions around the world including: UCLA, NYU, Samsung Art and Design Institute, Copenhagen Institute for Interaction Design, Tecnologico de Monterrey, and others. 84 Elektor 7/8-2012 Share Component Tips By Raymond Vermeulen (Elektor Labs) OPA660: Diamonds are not forever simple amplifiers. Others may be inclined to do something with analogue video, and people with a digital bent will be pleased with the steep signal edges, If you do find a use for it, please tell us about the results. I'm keen to know what you discover. [1] 400 MHz differential amplifier with an OPA660: www.ti.com/lit/an/sboa049/ sboa049.pdf [2] OPA660 data sheet: www.ti.com/lit/ds/symlink/opa660.pdf ( 120389 -I) The OPA66O is no more. It has been obsolete for many years, although a few distributors like Rochester Electronics still have some in stock. The successor is the OPA86O, but it is not entirely the same. The integrated buffer has a greater gain bandwidth and a higher slew rate, but the original open-loop amplifier has been changed to a closed-loop version. This eliminates the option of using it as a differential amplifier, despite the fact that this was one of the most attractive features of the OPA66O (see the application note [ 1 ]). A few words about the heading of this item: the OPA66O was not made from diamond, but it was often called a 'diamond transistor'. This nickname comes from the symbol for a transconductance amplifier. The operating principle of a transconductance amplifier is very similar to that of a normal transistor, and the pins even have the same names: base, emitter and collector. However, no external bias is necessary and if you apply an AC voltage with no DC offset to the base, you get an AC voltage with no DC component on the collector. This can be handy because it reduces the external component count. The transconductance can be adjusted by varying the current into pin 1 [ 2 ]. You may be wondering what this is good for. Well, audiophiles will probably use it to make Parameter Condition Value OTA and buffer input impedance 1 MQ || 2.1 pF Buffer slew rate 5 V step 3000 V/ps Buffer output bandwidth V 0 = ±1.4 V 800 MHz Elektor 7/8-2012 85 Chateau Rising Damp An ATM 18 hygrometer By Gregory Ester (France) The elasticity and condition of the corks in your best bottled wines vary according to the humidity in the ambient air. So to avoid unpleasant surprises, you need to monitor the humidity and correct the value, which must be neither too high nor too low. The relative humidity varies according to the temperature of the ambient air, hence our ATM18 hygrometer is going to display both humidity and temperature. 70 i %8G And even if you're not a wine connoisseur, you'll be able to use this application to monitor the ambient air quality. Extreme levels are bad for your health and comfort in the home. Air that is too PB2 DATA PB1 CLK Figure 1. Wiring block diagram. 86 Elektor 7/8-2012 Component Side +5V GND Figure 2. Soldering the single-pin sockets. .A. 1 F 2.54±Q.2 ►| | H e:: o, 4 ±o i 'f Figure 3. Air humidity detecting surface. dry weakens the skin and respiratory system, while excessive air humidity can lead to moulds, allergic reactions, and stimulate the proliferation of dust mites. We'd be foolish to forego the benefits of electronics. For this application, I chose the DigiPic- co digital detector [1]; its characteris- tics are given in Table 1. It is supplied calibrated, which makes it easy to use. The signals connections are made via large tinned copper pads. Once all the ingredients for the hy- grometer have been brought together, it takes only a few minutes to connect up the hardware as per the block dia- gram (Figure 1): the data process- ing and display are going to be han- dled here by two circuits published by Elektor in 2008 - the ATM18 board [2] and a 2-wire display [3]. Preparation and implementation Four single-pin sockets (Figure 2) are used to simplify feeding the power to the DigiPicco module and accessing the clock signal (SCL/Serial CLock) and data line (SDA/Serial DAta) that are needed for synchronous communica- tion via the l 2 C bus. So it just takes a few wires simply plugged in to provide the electrical link between the DigiPicco module and the ATM18. Thanks to the extremely simple instructions offered by the famous Bascom-AVR, we can Figure 4. Close-up of the detectors. access, at clock rate, the temperature and humidity image bytes supplied by our DigiPicco module. DigiPicco, MaxiService! The DigiPicco module from 1ST [4] has everything you need to be able to talk to it easily thanks to 1 2 C communica- tion and conveniently read the ambient temperature and relative humidity of the air you are breathing. The P14 capacitive humidity detector [5] is formed by a porous electrode soldered directly to the base board. In Figure 3, we can see that the detec- tor has a large exchange area, giving it improved sensitivity. An SMD version PT1000 detector is used to measure the temperature. In Figure 4, we can clearly see the two detectors that convert the two physical quantities to be measured into electri- cal values. Table 1. Characteristics of the humidity / temperature detector temperature measured from -25 °C to +85 °C relative humidity from 0 to 100 % communication serial via l 2 C bus accuracy < ±3 % RH (15 to 85 % RH @ 23 °C) < ±0.5 °C (-25 to +85 °C) temperature detector PT1000 humidity detector P14 current consumption < 3 mA supply voltage 5 V Elektor 7/8-2012 87 Di9iPitco not found! Check the connection Figure 5. You'll need to check everything again... J ust four bytes! The address is factory-preconfigured to $F0 during manufacture. If the module is missing on the bus, the error message in Figure 5 will be displayed. I n this event, you'll need to check eve- rything again. Because this project is firmly intended to be instructive, I've made it display certain elements of the collected or cal- culated data (Figure 6). On the first line, the address visible is scanned au- tomatically at start-up. The second line displays the most significant and least significant bytes corresponding to the humidity of the air; there then follow the most and least significant bytes of the temperature measured. A little calculation lets us display the two results: the relative humidity for the first value on line 3, followed by Di9iPicco!$F0 64 51 50 4@ 16435 12840 IVT : 50. 2?i/24 . ? a C Figure 6. Isn't it nice when everything works?! the temperature. In point of fact, for the two quantities detected, the bytes are received in the order 'most signifi- cant byte' followed by 'least significant byte'. As a result, we need to offset the most significant byte eight bits to the left by multiplying it by 256, after having masked its MSB (01111111 = 0x7F) by means of a logical AND. Add to this the least significant byte and the result is a binary word coded in 15 bits. A quick glance at the source code file will enable you to link the above expla- nations to the instructions. The detector transfer functions are lin- ear (0x0 - 0x7FFF (0 - 100 % RH), 0x0 - 0x7FFF (-40 to +125 °C). The pro- portional relationship lets us deduce the final values — here a relative hu- midity of 50.2 % for a measured tem- perature of 24.7 °C. The display is updated every second; the 3 mm yellow LED indicates the ac- tivity on the 1 2 C bus. Note that in the current situation, it takes around 5 s to go from 100 % relative humidity to around 50 %. You can test this yourself by blowing close to the P14 detector. It will take around 5 s to return to the initial value. 110488 Links [1] http://uk.farnell.com/ist/ digipicco-tm- basic- i2c-g/ sensor- humidity- module/ dp/1778051?Ntt=digipicco [2] www.elektor.com/atml8 [3] www.elektor.com/071035 [4] http://www.ist-ag.com/ [5] http://www.ist-usadivision.com/ resources/datasheets.php lektor Brought to you by Eurocircuits R - ESJ* The European reference for PCB prototypes and small series Speed up your design cycle and keep costs down using our fast, easy-access online PCB pooling services. We deliver: • Top quality PCBs at low pooling prices • Fast deliveries to suit your requirements • Comprehensive technology support • No set-up or tooling charges • No minimum order charge - order from 1 PCB • Online ordering without pre-payment • Stencil service PCB proto - dedicated engineering prototype service , fast and low-cost • 1 or 2 PCBs in 2, 3, 5 or 7 working days • DRC-checked and fully finished with 2 soldermasks and 1 legend, 150pm technology • 1 x 100 x 80mm in 7WD - 2 layer 47,02 € - 4 layer 95,52 € • 2 x 100 x 80mm in 7WD - 2 layer 36,89 € each - 4 layer 74,76 € each Prices quoted include 2 1 % Belgian VAT but exclude transport costs iff A / T * W mj STANDARD pool - widest choice of Eurocircuits pooling options • 1-8 layers 150pm technology PCBs • from 2 working days TECH pool - all the benefits of pooling for high-density PCBs • 2-8 layers 100pm technology PCBs • from 4 working days IMS pool - aluminium-backed PCBs for high heat-dissipation (LED) applications • Single layer Insulated Metal Substrate PCBs • 1 .5mm aluminium base with 75pm thermally conductive dielectric and 35pm Cu foil • from 3 working days On demand - multi-option non-pooling service for specialist needs • 1-16 layers down to 90pm technology • RF and high Tg materials • from 2 working days www.elektorPCBservice.com Economical 7-segment Display By J org Trautmann (Germany) Current consumption is always an im- portant consideration when designing battery-powered devices. This circuit shows how a seven-segment display can be driven by a microcontroller in a way ideally suited for such applica- tions. Furthermore, we even econo- mise on component count! I n a conventional circuit where a single digit is displayed each individual seg- ment is provided with its own current- limiting resistor through which it can be continuously driven. If the current consumption is 5 mA per segment then the total current draw when displaying an '8' will be 35 mA. If multiple digits are to be displayed, they are normally multiplexed in a sequential fashion so that only one digit is driven at a time. I n this case the total maximum current draw remains at 35 mA per digit. The circuit described here uses only one series current-limiting resistor per seven-segment display, and it is pos- sible to reduce the total current con- sumption to 5 mA per displayed digit. The trick is to use multiplexing at the segment level, realised in software in a microcontroller (in this example an ATtiny24). In the software each digit to be dis- played is represented by a seven- bit string. Each position in the string cor- responds to a segment to be driven and can take on the value 0 (for 'off') or 1 (for 'on'). For example, the dig- it 6 could be represented by the string '0111111', with all segments except the first being illuminated. The soft- ware examines the elements in the string one by one in sequence and turns the corresponding segment on or off (see listing). The time period allot- ted to each segment is about 2 ms and so the digit is refreshed at about 70 Hz, giving a flicker-free display. As an example application of this tech- nique the author has designed a digital die (see the circuit diagram). As long as input pin PB2 is held low by the user holding down button SI, a counter counts through the digits from 1 to 6 at a 1 kHz rate. When SI is released the counter's current value is shown on the seven-segment display. There are only a few components in the circuit and so the whole thing can easily be constructed on a piece of prototyping board or on the ELEX-1 (UPBS-1) ex- perimental printed circuit board. The Elektor Products & Services • Free software download • Prototyping board: ELEX-1 (UPBS-1) • Ready-programmed microcontroller: Seewww.elektor.com/120264 120264-41 90 Elektor 7/8-2012 Test microcontroller is available ready-pro- grammed from Elektor. A type CR2032 battery provides the circuit with a 3 V power supply, which is smoothed by capacitor Cl. The output ports of the ATtiny24 are capable of switching cur- rents of 5 mA without difficulty and so they can be connected directly to the corresponding inputs of the seven-seg- ment display module. Only one seg- ment is ever active at any one time and so R1 acts as a current-limiting resistor for the entire display. Be careful when selecting a display that it only includes one LED in each segment, as otherwise the supply voltage of 3 V will not be high enough. In the interests of reducing power consumption button SI has a further function: if it is held for more than two seconds, a minus sign flashes on the display for a few seconds and then the microcontroller switches into sleep mode. Current consumption in this mode is less than 1 pA. A further press of SI will wake the microcontroller up again. If the user forgets to put the Listing Sub Show_number( byval Number As Byte) For J = 1 To 7 'display segments in multiplexed fashion digit = Mi d( a( number) , J, 1) 'extract segment value as digit Port_value = Val(digit) 'state to be written to output port ( 0 or 1) " Select Case J Case 1 , ue Case 2 Case 3 Case 4 Case 5 Case 6 Case 7 Porta. 0 = P o r t _ v a Porta. 1 = P o r t _ v a Porta. 2 = P o r t _ v a Porta. 3 = P o r t _ v a Porta. 4 = P o r t _ v a Porta. 5 = P o r t _ v a Porta. 6 = Port v a u e u e u e u e u e u e End Sel ect Waitms 2 'shine segment for 2 milliseconds Porta = &B00000000 'clear all segments to zero ext J End Sub microcontroller to sleep, it will auto- matically switch to this mode two min- utes after the last roll of the die. These functions obviate the need for an extra switch to interrupt the power supply. (120264) MOSFET Circuit Breaker By Georges Treels (France) Cutting the power rapidly in the event of an overload implies monitoring the current through the load. This is usually done either by measuring the voltage difference across a series resistor, or by using a Hall-effect current sensor. This second solution is certainly appealing, but the cost of these sensors is still quite high, and they're not all that easy to implement. The disadvantage with the first solution is the voltage drop across the series resistor. Having come to this conclusion, I had the idea of combining both methods by using a P-channel MOSFET as both disconnecting device and series resistor. To achieve this, I turn a (minor) drawback of MOSFETs to advantage: their drain/source resistance. Opamp I Cl is wired as a comparator monitoring the voltage difference between the drain and source of the MOSFET T2, which is wired in series with the power rail to be monitored. This voltage drop is a function of the current flowing into the load, and hence through T2, and the latter's drain/source resistance. NowT2 will be turned on as long as its gate is kept at 0 (by R6). The trigger threshold for I Cl is adjusted by preset PI (in conjunction with R5). If this threshold is exceeded, 1 Cl's output goes high, which turns off T2 via R3. At the same time, T1 turns on and LED D1 lights to show there is a fault. The circuit- breaker has tripped, and everything is safe again. Elektor 7/8-2012 91 K2 R5 PI T2 nr LM741AH/883 / 10k R6 IRF9520 R2_ 47k 1 SI H K1 R4 BC547 110566-11 gig - t* ~ |* c,V,v.ir i ill [ULimr.nnbjn^ .V.ottrj - Macratolr fieri SH 0 K3 It? u Pjup l i-roul fuijEJUlu ■ n ■ ■ m m LI- A" a’ B 3i ® -Ji - On RqIpia S?i£P Q & ff 1 CS “ LUI 4 MUM -J- U/ i l if nrii‘ ■ j-lww * X ■ ? j* Dciek ’ S] T ■W" mi T jJ “ if ift Jirf 2 . l.ndJ. r / H ■ V A- IPS W 4 S {Itpliaa d r a Pnrri f + Aligrararn-j i * j CtM- 1 'Miflifli { 1 en 3 A 9 c n E f a h r T 2 Calcu I jlipn of fine pan-ainuLm i G Tr-el* DWHl i t, c 7 B 9 ID 11 12 i: « [ 1 15 15 IT M * «■ FimjKI fouU f euti j 4 ►G aSQilfl IBC* - + i IIA1 Uln Pd* R5 PI : Vi 1 9 02 100 4JQQQ0 IRF9520 I u ^ds U ds R5 PI : theoretical value 10 9 0.5 5 220 176 10 12 0.5 5 220 308 10 24 0.5 5 220 836 5 5 0.5 2.5 220 220 5 12 0.5 2.5 220 836 5 24 0.5 2.5 220 1892 1 5 0.5 0.5 220 1980 1 12 0.5 0.5 220 5060 1 24 0.5 0.5 220 10340 0.1 5 0.5 0.05 100 9900 0.1 12 0.5 0.05 100 23900 0.1 24 0.5 0.05 100 47900 Once the cause of the overload has been corrected, all we have to do to turn T2 back on is to force its gate to 0 by briefly pressing SI. The function of R3 is to protect I Cl output from excess current while SI is pressed. In order to make this circuit- breaker function, we just need to determine a few parameters for it: • choice of MOSFET • maximum current • working voltage then all we have to do is calculate the values for R5 and PI accordingly. Let's call the voltage on I Cl's non- inverting input l/ ref , the circuit- breaker input voltage U, the drain/source current /, and lastly, the MOSFET's internal resistance R ds . Wecan write that L/ ref = 1/jXPl/ (R5+P1) The voltage on pin 2 of I Cl is: U- (JxK ds ) So PI = [R5x(l/-lxK ds )] / (lxfl ds ) Example: U\ 9 V MOSFET R 6s \ 0.5 ft I\ 1 A R5: 100 ft We will get: PI = 1,700 ft, i.e. 2 kft in a practice. If these little calculations bother you, don't worry, you can use a spreadsheet to do them for you (screen shot). Depending on the (P-channel) MOSFET used, this system turns out to be very flexible. By skilfully combining R ds , and I max drain/source, it is possible to monitor currents from 1 to 100 A, or even more. Of course there's a downside to everything, and this circuit isn't perfect either. To detect weak over-currents, you'll need to choose a MOSFET with quite a high drain/source resistance. You'll also need to recalculate the trigger threshold if the input voltage 92 Elektor 7/8-2012 changes. By way of an example, the table gives practical values for a circuit- breaker from 5-24 V and 0.1-10 A, based on the common, cheap IRF9520 MOSFET. In general terms, for this sort of circuit to be reproducible, you need to make allowance for the component tolerances, in particular the MOSFET's R 6s resistance, which is quite sensitive to device temperature. I n my view, the advantages more than outweigh the disadvantages, as this electronic circuit- breaker is compact, works every time and without fine tuning, while PI lets you cover a wide current range. (110566) Voltage Inverter using a 555 C2 C5 TzffluTz 220u 25V By Peter Krueger (Germany) In many circuits we need to generate an internal adjustable voltage. This circuit shows how it is possible to use a trusty old NE555 timer 1C and a bit of external circuitry to create a voltage inverter and doubler. The input voltage to be doubled is fed in at connector Kl. To generate the stepped-up output at connector K2 the timer 1C drives a two-stage inverting charge pump circuit. The NE555 is configured as an astable multivibrator and pro- duces a rectangular wave at its output, with variable mark- space ratio and variable frequency. This results in timing ca- pacitor C3 (see circuit diagram) being alternately charged and discharged; the voltage at pin 2 (THR) of the NE555 swings between one-third of the supply voltage and two- thirds of the supply voltage. The output of the NE555 is connected to two voltage invert- ers. The first inverter comprises Cl, C2, D1 and D2. These components convert the rectangular wave signal into a nega- tive DC level at the upper pin of K2. The second inverter, comprising C4, C5, D3 and D4, is also driven from the output of I Cl, but uses the negative output voltage present on diode D3 as its reference potential. The consequence is that at the lower pin of output connector K2 we obtain a negative volt- age double that on the upper pin. Elektor 7/8-2012 93 JL M Pos: 0.000s & i 1 .. .« MEASURE CHI Max 3.12 V CHI Pos Width 1 73J8ju» CH3 Max 10.5 V j CH2 — Mean -12.1V CH4 Mean -5.37 V CHI I A,m ii 2.0( CH: 2,00V MSOLOjis CHS 2.0GV cm 2.00V 16-Apr-12 10^00 Now let us look at the voltage feedback arrangement, which lets us adjust this doubled negative output voltage down to the level we want. The NE555 has a control voltage input on pin 5 (CV). Normally the voltage level on this pin is main- tained at two-thirds of the supply voltage by internal circuit- ry. The voltage provides a reference for one of the compara- tors inside the device. If the reference voltage on the CV pin is raised towards the supply voltage by an external circuit, the timing capacitor C3 in the astable multivibrator will take longer to charge and to discharge. As a result the frequency of the rectangle wave output from I Cl will fall, and its mark- space ratio will also fall. The source for the CV reference voltage in this circuit is the base-emitter junction of PNP transistor Tl. If the base volt- age of Tl is approximately 500 mV lower than its emitter voltage, Tl will start to conduct and thus pull the voltage on the CV pin towards the positive supply. I n the feedback path NPN transistor T2 has the function of a voltage level shifter, being wired in common-base configura- tion. The threshold is set by the resistance of the feedback chain comprising resistor R3 and potentiometer PI. When the emitter voltage of transistor T2 is more than approxi- mately 500 mV lower than its base voltage it will start to conduct. Its collector then acts as a current sink. Potentiom- eter PI can be used to adjust the sensitivity of the negative feedback circuit and hence the final output voltage level. Using Tl as a voltage reference means that the circuit will adjust itself to compensate not only for changes in load at K2, but also for changes in the input supply voltage. If K2 is disconnected from the load the desired output voltage will be maintained, with the oscillation frequency falling to around 150 Hz. A particular feature of this circuit is the somewhat uncon- ventional way that the NE555's discharge pin (pin 7) is con- nected to its output (pin 3). To understand how this trick works we need to inspect the innards of the 1C. Both pins are outputs, driven by internal transistors with bases both connected (via separate base resistors) to the emitter of a further transistor. The collectors of the output transistors are thus isolated from one another [1]. The external wiring connecting pins 3 and 7 together means that the two transistors are operating in parallel: this roughly doubles the current that can be switched to ground. The two oscilloscope traces show how the output voltage behaves under different circumstances. The left-hand figure shows the behaviour of the circuit with an input voltage of 9 V and a resistive load of 470 ft connected to the lower pin of output connector K2. The figure on the right shows the situation with an input voltage of 10 V and a load of 1 kft on the lower pin of output connector K2. The pulse width and frequency of the rectangle wave at the output of I Cl are automatically adjusted to compensate for the differing con- ditions by the feedback mechanism built around Tl and T2. Because of the voltage drops across the Darlington out- put stage in the 1C (2.5 V maximum) and the four diodes (700 mV each) the circuit achieves an efficiency at full load (470 ft between the output and ground) of approximately 50 %; at lower loads (1 kft) the efficiency is about 65 %. (120141) [1] http://en.wikipedia.org/wiki/555_timer_l C 94 Elektor 7/8-2012 HACK THE TRACK Weird PCB design Epping ( 3 ) High Barnet Chalfont & . Latimer =^= =^= Watford Junction t Theydon Bois i Totterldge & Whetstone Watford High Street 1 Busheyl ■ Watford Southgate > Amershar Loughton Woodside Park ' Croxley Rickmansworth ' West Finchley Moor Park Roding Valley Chigwell Buckhurst Hill' Hatch End 1 Bounds Green i Northwood ^ West Ruislip I Finchley Central Northwood Hills Wood Green ' Canons Park =i= Harrow & . Wealdstone Hillingdon Ruislip East Finchley Ruislip Manor Harringay South Green Lanes Tottenham Colindale* ! Woodford Turnpike Lane i „ _ uueensDui ■ Kenton Preston r"> Kingsbury Highgate Crouch Hendon Central ' Uxbridge Ickenham i South Woodford Blackhorse Road Seven Sisters =%= i Archway Manor House 1 1 Barkingside Newbury Park Brent Cross' Rayners Lane Northwick Park Tottenham Hale^ Walthamstow v Central West Harrow Golders Green Hampstead Heath ' Upper Holloway Redbridge Wembley Park Finsbury South Kenton i North Wembley ■ ^ Wembley Central Stonebridge Park ■ Harlesden ■ Willesden Junction Oollis HiU South Harrow • =t= Upminster Upminster Bridge Walthamstow Queen's Road Wanstead Gants Hill Leytonstone High Road ^ South Ruislip I Kentish Town Holloway Road Kentish ' Town West Willesden Green Finchley Road & Frognal Highbury & Islington^ Midland Road Caledonian Road, Sudbury Hill' Hornchurch Dalston Kingsland Brondesbury Park Northolt- Camden ' Caledonian Road & Barnsbury ^Stratford International Hackney Central Sudbury Town ! Finchley Road ' Swiss Cottage Camden Town ' Canonbury Kensal Rise Brondesbury Kensal Green ^ _ _ , _ . Kilburn South \ Queen s Park H |gh Road Hampstead Dagenham East OSl Dagenham Heath way Becontree =*= Greenford I Dalston Junction i Mornington | 'Stratford^ Woodgrange Park Stratford © High f Street ...X : Wood Homerton Hackney Wick Alperton i Haggerston ' Great Portland Street Perivale' Paddington Road Marylebone^ Barking^ Baker Street Warwick Avern Royal Oak_ sWest bourne Park Pudding Mill Lane Hoxton i Hanger Lane' Edgware =^= Farringdon ^ Liverpool Street Regent's Park Bow Road Ladbroke Grove Latimer Road Russell Barbican' Square Shoreditch High Street 1 Bayswater Bromley- by-Bow Goodge Street 1 North Ealing ■ Shepherd's , Bush=*= Chancery Notting Stepney Green Whitechapel I Devons Road Ealing Broadway i Aldgate East Tottenham North Acton Queensway Marble West Acton Langdon Park Court Road Aldgate ' I All Saints Canning -Town Royal } Victoria High Street Kensington Cannon Mansion Shadwell Westferry Shepherd's Bush Market Leicester Custom House .for ExCeL Ealing Common i Hyde Park Corner Piccadilly Circus South . Acton 1 Blackwall Limehouse Kensington , (Olympia) ' Barons ) Court Monument Tower RXPin Reset Pin i> i> o Digital. ^ Pins -1 O i> o Mcrocontroller Mni-B USB Jack Reset button Pin 13 (L) LED VINPin Ground Pin Reset Pin 5VPin Analog — Input 1== H l 2 C - SCL i l 2 C - SDA Analog 3 j i Analog 2 j i Analog 1 4 1 Analog 0 4 Analog Reference 3.3V Output Digital Pin 13 SCK l 2 C Analog SPI 100576-11 different modes, such as 'analogue', 'digital' and 'wait'. The operating mode is selected by sending a full stop character '.' followed by a single letter abbreviation as follows. .a Analogue .d Digital .c Configuration .e EEPROM access .i l 2 C .1 System LED .m Macros .r SRAM access .t Timer/Counter .u UART .w Wait In each mode there are three basic commands available: help ('?'), status ('#') and command line ('%'). The help command '?' causes the built-in help system to list the avail- able commands. The '#' command displays status informa- tion. The percent character '%' introduces a command line: this means that subsequent characters are collected until the end of the line (indicated by a CRLF) and then executed. Within the commands themselves capitals are distinct from lower-case letters. Each command consists of letters, nu- meric values, or a combination of the two. A complete list of commands would occupy more space than we have available here, but is available for download from the Elektor web- site [2]. As a taster will we show here some of the commands available in analogue, system LED and wait modes. Analogue mode (.a): T Display the value read from ADC channel 1 's' Read all four of the ADC channels and display their values System LED mode (.1): 'h' Switch system LED on T Switch system LED off 's' Read system LED status Wait mode (.w): hhh Wait for hhh (hex) milliseconds (hhh = 000 to FFF) Commands (and this goes also for mode-changing com- mands) can be strung together into sequences, as hinted at above. For example, the following sequence switches on the system LED and then reads analogue channel 3: '. Ih. Elektor 7/8-2012 97 a3; A semicolon can be used to mark the end of a command sequence. The sequence \mdA .ll.wlOO.Ih.m' defines a macro called 'A' which turns the system LED off for 256 ms and then turns it on again. The macro can be executed using the command '.mA', On reset, the system automatically executes the macro called 'O'. This macro can therefore be used to store all the com- mands and settings that need to be execut- ed whenever the AVI- OM system is booted. As mentioned above, the 'multi-tool' can also be controlled by a pro- gram running on a PC, written by the author using Visual C# 2010. The screenshot shows the graphical user in- terface in action. The ADC values are shown at the top left under 'Analog'. Pressing the 'Scan' button starts a cyclic reading of ADC val- The COM port that is used for communication with the AVI OM module is set under 'COM :Config' at the upper right. Once a connection has been successfully established the field turns green and the rest of the user interface is activated; other- wise the field remains grey. The C# software uses the 'ALab' framework developed by the author, which offers a very wide range of basic func- tions for using a PC to control operations in a microprocessor net- work. Communication between the PC and network nodes is done using messages which are kept in queues. Re- plies received are pro- cessed and displayed in the AVIOM user inter- face. The whole thing is of course written with a little help from threads. One of the most impor- tant features of the PC software is scripting. Scripts, written in the Python program- ming language, can be entered in the script text window. To do this, the AVIOM system uses the freely-available IronPy- Automation using macros and scripts ues: below to the left the cycle timing can be set in millisec- onds. The area marked 'Digital' shows the current state of the digital pins. Clicking on the relevant button switches a pin between output, high-impedance-input, and input- with- pull- up- resistor modes. Clicking on the display (when in output mode) changes the state of the output. Radio buttons are used to change settings in the area marked 'Timer Counter PWM'. In 'Count_R' mode the counter counts rising edges, while in 'Count_F' mode it counts falling edg- es. Clicking 'TCN' reads the current value in the counter and clicking 'Z' resets it. I n PWM or frequency generator mode ('Fgen') the 'Frequen- cy' and 'Duty Cycle' fields are enabled. Since only integer values are allowed in the AVR's ICR and OCR registers, the actual frequency and duty-cycle values are displayed, which may differ somewhat from the values the user has entered. thon ('Python for .NET') implementation [3]. The scripts are stored as text files in a workspace directory. A complete list of the script files found there is shown in the list box in the middle of the screen. The working directory can be changed by clicking on the 'C' button. If a script is selected in the list box, the name of the file will appear in the text box above it and can be edited there if necessary. A copy of an existing script with a new name can be created by editing the filename suitably and clicking on 'SaveAs'. If you have entered or edited a script in the large window at the bottom right, you can try it out using 'Exe' or by double- clicking the script name in the list box. The file will auto- matically be saved first. Text output from the script (from 'print' commands) and error messages appear in the window above. Make sure that 'scan' mode is not active when execut- 98 Elektor 7/8-2012 E CD E CD 4 — » CD > TD < ing scripts. User script files are automatically provided with a header that imports a few handy name spaces and defines two special objects: 's' for system functions and 'a' for AVI OM functions. The AVIOM object 'a' is an essential part of any script file. All AVIOM commands that can be executed by a Python script are implemented as methods of this object. (A click on the 'Help' button lists the built-in functions.) In many cases the methods return 'true' or 'false' to indicate whether the com- mand was successful or not. A complete list of the AVIOM script commands can be found in the document available from the Elektor website. The following example shows how commands can be exe- cuted. # # Demo: Tl MER COUNTER # s et p wm # f = 1. 0 dc =7.0 res = a . TCPpwm( f , dc ) pri nt "PWM f = ", res, " DutyCycl e = ", dc, " %" O SiliconRoij Online Electronics Store ■ Boards * Kits * Modules * Components ■ Tools * Instruments FOR * Companies • Professionals * Students • DtYers * Amateurs USB SIC 8051 MCU Programmer Free For 8051 Developers SEN1060 GPS Module With Antenna Small, Low Cost, Easy To Develope $50 Add Eg carl (HMC5883L) 3 Axis Compass Module Integrate Compass Easily $ 12.5 wit 6P3P 7.5Wx2 Tube Amp Kit CNC enclosure, hifi sound quality, easy to build $156 Simplify your electronics projects by visiting http://www.siliconray.com Further examples can be found in the 'Demo' workspace. Note that the 'I2C_..._PCA8581' demonstration scripts only work when a suitable EEPROM device is connected. You will doubtless now want to try the system out for your- self. The first step is to install version 1.0 of the Arduino development environment [1]. The download from the Elektor website includes a directory 'AVIOM_1_0' which should be copied to any convenient place on the computer. 1 1 is now a good idea to create a shortcut to the file \.\AVIOM_l_0\AVIOM\AVIOM\bin\Release\AVIOM. exe". The next step is to launch the Arduino I DE and set the 'sketch- book' location to point to the directory \.\AVIOM_1_0\AR- DUINO'. Connect the Arduino board and select the 'sketch' 'AVIOM_Arduino_l_0', compile the program and load the hex file into the microcontroller. A first test can be carried out using a terminal emulator program (with settings 115200 baud, 8N1) or using the au- thor's dedicated program, which can be run by clicking on the shortcut. The demonstration scripts should appear in the script list. And away you go! (100576) [1] www.arduino.ee [2] www.elektor.com/100576 [3] http://ironpython.net FRONT PANELS & HOUSINGS Cost-effective single units and small production runs Customized front panels can be designed effortlessly with the Front Panel Designer. The Front Panel Designer is available free on the Internet or on CD. • automatic price calculation • deliveryin 5 -8days • 24-Hour-Serviceif required Schaeffer AG • Nahmitzer Damm 32 • D-12277 Berlin • Tel +49 (0)30 8058695-0 Fax +49 (0)30 8058695-33 • Web info@schaeffer-ag.de • www.schaeffer-ag.de r rrrr Sample price: 34,93€ plus VAT/shipping Elektor 7/8-2012 99 TAPIR Sniffs it Out! Ultrasensitive wideband E-smog detector Attention boy scouts, professionals and grandfathers! This electrosmog sleuth offers you two extra senses to track down noise that's normally inaudible. TAPIR also makes a nice project to build: the kit comprises everything you need — even the enclosure, ingeniously consisting of the PCB proper. ? By Thijs Beckers (Elektor UK/I NT Editorial) Why build an electrosmog ('E-smog') detector? The answer is quite simple. More and more of our everyday ob- jects are based on some sort of elec- trical 'core': your toothbrush, camera, cellphone, TV set, and so on. Each and every one of these devices generates electrical radiation in some way. There are of course rules manufacturers should abide by, but that doesn't mean that devices are completely free from electrosmog. In fact, even with the widespread 'CE' certification stamped onto your device, it is not certain that a device complies with all the rules and doesn't interfere with other electronic devices. Ever tried calling someone (or, when receiving an incoming call) hold- ing your mobile phone close to a cheap alarm clock radio, or a set of low-end PC speakers? (your guitar amp prob- ably loves those cellphones too...) An E-smog detector is designed to de- tect the 'radiant misbehaviour' of near- by electronics. The TAPIR — short for Totally Archaic but Practical Intercep- tor of Radiation — is a simple design capable of detecting, and audibly pin- point, any source of electric or — with the appropriate antenna — magnetic field. Its application area extends from home use {"Where can I sit without being microwaved?"), to practical use {"Where's that Wi-Fi-antenna aimed at?"), to professional use {"Who the devil is jamming me?! I'm trying to do some sensitive measurements here!"). It's even suitable as a first SMD solder- ing project — with your (grand)child 100 Elektor 7/8-2012 Measure SI — since it's so easy (and fun!) to as- semble. Different fields TAPIR is able to detect electric as well as magnetic fields of high frequencies. Magnetic fields are mostly generated by transformers and loop antennas, while electric fields are emitted by high voltage transmission lines, EL back- lights and old mopeds passing by. Elec- tromagnetic fields are a combination of both fields, mostly occurring in the 'far field' at a larger distance from the gen- erating object. Two different antennas can be con- nected to TAPIR, each optimised for one type of field. Magnetic fields are detected with a ferrite cored coil, while electric fields are detected with a rod antenna, which can be constructed very easy from a piece of installation wire. How does it work? The schematics show the simplicity of the design and are very similar to an Elektor circuit published in 2005. Basi- cally it consists of a three-stage low- frequency amplifier with high gain. There is no low-pass filter in the cir- cuit, consequently high frequencies are passed on to the gain stages. This way the non-linear characteristics of the transistors have a demodulating effect on these high frequency signals, so they can also be heard via headphones. The bias point of the gain stages is au- tomatically adjusted via a DC feedback path from the output through R4 and Rl. To suppress the AC component C3 is added, which shorts this part of the signal to ground. The output voltage level has an offset of about 0.7 volts, hence C4 is added to remove this offset and protect any con- nected headphones (or other devices). The total gain is high enough to be able to 'hear' the intrinsic noise of transistor Tl, so it's best to pick a low noise tran- sistor for this. We went for the BSR17A, which has far better noise figures at high frequencies than a BC847B. Sig- nals of mere microvolts are audible via headphones connected to the output. The whole circuit starts to operate from 1.2 to 1.5 V, so a single AAA cell can be used as its power source. The low supply voltage also acts as a kind of limiter; even if strong signals drive the amplifier into saturation, the output levels and thus the headphone levels never become excessive. Don't flee 4 the SM-Dee This E-smog detector is available as a low-cost kit [1] with the PCB and all the components included (except the bat- teries). Worried about soldering those tiny SMD components? No need! Even though there are some components with the '0805' shape, it can all be done with your standard tools, provided you have a reasonably small soldering tip at hand for your soldering iron, and a pair of precision tweezers. First, clean up your desk! You might drop an SMD component from your tweezers in which case you want to be able to find it again... Assuming the light conditions on your desk are op- timal, you may begin with opening the first bag and sorting the components, with or without the help of our on- line assembly manual [1]. Now you're ready to start soldering. To get the hang of it, start with some larger components, switch (SI) and the headphones jack (K2). Be frugal with the solder on K2, otherwise you may have some trouble assembling the PCBs together into the housing. When finished, remove PCB #2 and #4 from the panel and flatten the sides where it used to be held into place. Now you're Listen in on electromagnetic pollution Elektor 7/8-2012 101 ready to start with the 'real deal'. A convenient way to solder SMDs is to 'wet' one pad first. Hold the end of the solder wire (thin wire is preferred) onto the pad and shortly touch it with the solder tip. A thin layer of solder should now cover the pad with some flux from the core still active. Now use twee- zers to align the component onto the PCB, holding it down while you gently touch the lightly tinned soldering pad with your soldering iron again, reflow- ing the solder. The flux now helps the tin to flow, creating a solid connection between the component and the pad. Cubism, it's a work of art When finished, remove PCB #3 from the panel using a fretsaw. Make sure there's a small ridge left. This is need- ed to put the PCBs together forming its housing. Solder the RCA connector (Kl) onto the PCB. Now we're going to solder PCBs #5, 6 and 7 onto PCB#3. Remove the PCBs from the panel, leaving a short pin in place where it used to be connected to the panel. Place PCB #3 in front of you with Kl pointing away. Now put PCB #5 in its place, making sure it's perpen- dicular and the soldering pad for the 4 next to K2. Put PCB #4 down and sol- der the RCA connector onto PBC #4. Also solder the 'upper' PCB pads to the rest of the PCBs. Put PCB #2 in place and solder it to the rest of the PCBs, making sure it all stays nice and square. Make sure all pads are soldered! Solder the two M2x6 PCB pil- lars in place. They should be flat on the PCB and right in the middle. Bracket tweezers can be helpful with this. Use a sharp drill to countersink the screws into PCB #1 and check if the last PCB (#1) fits nicely. If needed, correct the position of the PCB pillars. Place the Track down wretched interference sources You may even reheat the pad to posi- tion the component better. When the component is in position, solder the other pad by pushing the solder wire onto the pad and shortly touching it with your soldering iron. The flux should work its magic and evenly spread out the solder onto the pad and the solder connection of the component. Short soldering actions create the ti- diest connections. But do make sure you're actually soldering and not only wetting the pad or the component. Adding some fresh solder to the first pad while shortly reheating it can tidy it up if you made it a little messy. Now you're ready to proceed with the rest of the components. PCB pillar is at the RCA connector side pointing upwards. Solder the pad on the right corner only, so adjustments are easier later on. Put PCB #6 in place, again making sure it's perpendicular. The PCB pillar pad should be pointing upwards and away from the RCA connector. Solder the right corner pad only. Finally put PCB #7 in its place and solder all three pads. Continue sliding PCB #4 into its place. K2 should be right through the hole in PCB #7. The small ridges on PCB #5 and 6 should enter the cut-outs on PCB #4. Now solder the 'lower' PCB pads of PCB #4 to PCBs #3, 5 and 6, start- ing from the middle, pressing the PCBs together tightly. Don't forget to solder the 'normal' pads between PCB #3 and spring and a battery (AAA type) and close the lid. Your TAPIR is now ready for use. Constructing antennas To detect electric fields, a simple rod antenna can be constructed using an RCA connector and 20 cm (8 inches) of electrical installation wire (or any type of wire, but installation wire is quite stiff and can be bent the way you like). Strip 3 mm (0.1 inch) off the isolation and solder the wire to the centre pin of the RCA plug. When locating interfer- ence on circuit boards a small loop at the end of the rod could prove useful. Magnetic fields are picked up by an inductor-based antenna. This antenna is constructed using a piece of instal- lation wire as a frame to hold the coil, 102 Elektor 7/8-2012 Measure ALKALINE EATTEBY 24A * U=?Q3 - SIZE AAA * i .S C P'Btffea of Quit# Frit Q i www.jff ,1 corn while one end of the coil is connected to the centre pin of the RCA plug and the other to the outer connection. Make sure the 'ground' (outer con- nection) is securely connected to the TAPIR, otherwise the inductor acts as an electric field antenna. More detailed information about the construction can be found on our website [1]. TAPI R in use Using the TAPI R is dead easy. Connect the headphones and an antenna and switch it on. Move it around any elec- trical device and you'll hear different noises with each device, depending on the type and frequency of the emitted field. Give these a try: a TFT PC dis- COMPONENT LIST Resistors (SMD 0805) R1,R4 = lOOkft R2,R3 = lOkft R5 = lkQ Capacitors Cl = lOnF 50V, SMD 0805 C2,C3,C4 = 10 |jF 25V, SMD 1206 Semiconductors D1 = BAT54S T 1 = BSR17A T2,T3 = BC847B Miscellaneous K1 = RCA socket, SMT K2 = mini jack SMT, CIU SI = switch, JS102011SAQN PCB #120354-1, see [1] Battery spring Two PCB pillars, M2x6 Two Phillips screws, M2x6 Two RCA connectors Two pieces of installation wire, approx. 20 cm (8 inch) One inductor coil (H-field antenna) A kit consisting of the PCB and all the needed parts (AAA cell excluded) is available from Elektor [1] order no. 120354-71. .••a Elektor 7/8-2012 103 play, a cellphone, an iPad or e-reader, a fluorescent tube lamp or any energy saving lamp, a fridge, a microwave oven, a light dimmer, a PC, a laptop, a (switch-mode) wall wart, a (wireless) router or access point, a Wi-Fi hotspot, et cetera (and then test them all again using the other antenna with different results). Don't be surprised to find your battery charger sounding like someone blowing a whistle, or your telephone tap dancing through TAPIR. LC dis- plays in particular (actually the circuits controlling them) produce interesting sounds. There's a video available on Elektor's YouTube channel [2] where we demonstrate various noises (fields) generated by devic- es used daily. Take a stroll down the High Street and marvel at the levels of e- smog present there. Switch-mode power supplies, neon light- ing, routers, repeaters, GSM/3G/4G antennas, police officers, auto- mated ticket dis- pensers and vending ma- chines all emit their own charac- teristic bleeps, buzzes and whistles. You can also use TAPI R for listening in on the in- ductive loop transmission system frequently present in museums and other public places. It's actually quite fun to have access to a sixth and seventh set of senses. But it also makes one aware of a world our own senses cannot detect. And what goes on in this world might not be as nice as you'd hope it would be. We would like to thank all contributing partners for making this pro- ject possible: PCB production: PCB- Pool [3]; design: Museum Jan Cor- ver [4] and YiG Engi- neering; original design: Burkhard Kainka. (120354) I nternet Links [1] www.elektor.com/120354 [2] www.youtube.com/ElektorlM [3] www.pcb-pool.com [4] www.jancorver.org/en/index.htm Partners THE ORIGINAL SINCE 1994 P HR-POET Beta LAYOUT Museum Jan Corver Dutch HAM Radio Museum Elektor have partnered with Beta LAYOUT to manufacture the PCBs required for the TAPI R project. Beta LAYOUT, is a leading European manufacturer of PCBs (from prototype to produc- tion), and developed the original PCB-POOL® concept. Beta LAYOUT customers range from small one-man companies and electronics hobbyists to the R&D departments of some of the largest and most recognisable companies in the world. Today, Beta LAYOUT not only delivers PCB prototypes and small series but also laser-cut SMD stencils, Front Panels, SMD soldering solutions and a recently introduced 3D rapid prototyping service. For more information please visit: www.beta-layout.com The PCB design was generously donated by the Museum Jan Corver Foundation and YiG Engineering. Visit www.jancorver.org/en/index.htm for more information. 104 Elektor 7/8-2012 Recently acquired by The Elektor Group, audioXpress has been providing engineers with incredible audio insight, inspiration and design ideas for over a decade. If you're an audio enthusiast who enjoys speaker building and amp design, or if you're interested in learning about tubes, driver testing, and vintage audio, then audioXpress is the magazine for you! Tune. $01 ie State. Loudspeaker leehri Choose from print delivery, digital or a combination of both for maximum accessibility. Subscribe to audioXpress at \ www.audioamateur.com today! ^ What will you find in audioXpress ? * In-depth interviews with audio industry luminaries * Recurring columns by top experts on speaker building, driver testing, and amp construction • Accessible engineering articles presenting inventive, real-world audio electronics applications and projects * Thorough and honest reviews about products that will bring your audio experiences to new levels LoudipeciK* Audio a m ateu r .s, “jfo >1 fcw l*r than th 2 Then MSComml . InputLen = 0 indata = MSComml . Input indatal = Mid (indata, 2, 1) Info = Asc (indatal) End If End Sub Things to watch out for The PL2303 (built into a USB connector with attached cable) is readily available on eBay at prices in the 4 to 8 euro/pound range, including shipping costs. Make sure you are getting a four-pin cable. The 5 V pin is necessary for supplying power to the circuit. When programming the ATmega88(P), make sure you get the fuse bit settings right (see the screen dump in the down- load file for this project [3]). If you connect the USB control board to a different USB port, the computer may assign a different COM port number to the board. Check for this, or always use the same USB port. The supply voltage for the microcontroller and the operating voltage for the LPT port are taken from the USB/serial con- verter. Only a limited amount of power is available with this arrangement, so you should restrict yourself to driving a few ICs (e.g. buffers) or LEDs. In other words, you can't drive a motor or other power device this way. The free version of Bascom AVR, which you can use to com- pile the software and program the ATmega88, can be down- loaded from the website [1]. Final remarks The USB control card was developed for a hobbyist club, to allow a small lathe to be controlled in real time using Visual Basic and the SMC1500/800 driver board. The successful re- sults can be seen in a YouTube video [2]. The source code for the ATmega88 firmware, a program for testing data transmission rates, and a program for bit bash- ing via the USB port are collectively available in a free down- load zip file on the Elektor website [3]. (120345-1) I nternet Links [1] www.mcselec.com [2] http: // www. youtube. com/ watch?v=maxNgXApeOQ&fe ature=channel [3] www.elektor.com/120345 COMPONENT LIST Resistors R1 = lOkft Capacitors C1,C2 = 22pF C3 = 4.7pF 16V radial C4 = lOOnF C5 = 10|jF 16V radial Semiconductors IC1 = ATmega88(P), DIL-28 case Miscellaneous XI = 18.432MHz quartz crystal K1 = 4-pin pinheader, pitch 2.5mm K2 = DB25 socket, right angled pins, PCB mount J PI = 2-pin pinheader with jumper PCB # 120345 (see [3]) 108 Elektor 7/8-2012 Z 3 3 0 3 3 1 " 3 s : : c c c ' : : 3 3 c g : ' c c e c c c 3 ^. A P H ^ P v f ¥ t 6 ^ 35300005 C C C £ C CCC 0GGQC3CC oficcoccr CCC33C33 r C C'C'C c c c Read Elektor with the cut-rate PLUS membership! Join now or upgrade: www.elektor.com/member I've Got the USB Power But how much in milliamps? This small tool allows you to monitor current consumed by any USB device plugged into your PC, showing the value on a voltmeter module. Alternatively, why not trace it on the oscilloscope? By Miroslav Batek (Czech Republic) More and more devices have USB connectivity and many engineers design devices which are powered by the USB port. However if you want to measure the current drawn from the USB port you'll soon find that's not a simple affair. You have a few choices though like disconnecting the circuit and connecting the ammeter in series with your device, or insert series resistors in the Vbus line and measure voltage across them. Both solutions are quite simple but have disadvantages. Your ammeter or series resistor could introduce a considerable voltage drop, causing problems to the 110 Elektor 7/8-2012 Measure USB device. Moreover if you want to watch the current on your 'scope you have to use a differential probe, or two probes, because the current is not measured relative to ground. In case you insert the series resistor in the GND line, the voltage levels for the USB device and the USB host will be different as a result of the voltage drop. The small tool presented here solves the problems by incorporating a high- side current sense circuit. There are components except the current sensing resistor. The schematic of the USB Power Monitor shows two USB (type A) connectors. One is male (plug type) and the other, female (socket type), meaning our little circuit is connected in series with the USB device whose current consumption you are keen to know. Data lines D+, D- as well as GND are passed 'straight through'. Shunt resistor R1 sits in the Vbus line, turning the current through it into a Voltcraft 70004 voltmeter module. Note that there are three versions of the TSC101, suffixed A, B and C, each having a different gain. The A version used here has 20 V/V. Each version also has a slightly different bandwidth. In practice, you'll notice that the resolution of the proposed meter is limited at low currents and that's why a separate current test point, TP2, is available. The millivolts measured on TP2 equate to milliamps of current consumed by the USB device. Sticklers a few methods of making a high-side current sense circuit, like a standard opamp or instrumentation amplifier with a few resistors. Here we went for an integrated circuit type TS101, which is basically a high-side current monitor [1]. This IC doesn't need any external corresponding voltage (drop). This gets amplified by IC1 and converted such that it exists relative to ground. Cl is the supply decoupling capacitor for IC1. Components R2, R3 are a voltage divider to match the TSClOlA's output voltage to the input of the for precision may measure the Vbus voltage on TP3. At 500 mA theoretical maximum current from the PC the voltage drop of our circuit is just 25 mV which is negligible for most if not all USB devices. Elektor 7/8-2012 111 Elektor Flash drive 32 mA (Idle) 58 mA (Copy files) USB Hub , .I . A .... N 75 mA (Flash drive 100 uA (standby) 45 mA (idle) / connected) USB Flashlight 7 mA (Battery check) 55 mA (Charging) HTC Legend 430 mA (initial charging cur- rent, from PC) 560 mA (initial charging cur- rent, from AC line charger) 1 pad 2 570 mA (charging current at 30% from PC with Asus Ai Charger tool) The circuit is built on a double-sided PCB shown here and it's available ready made [2]. USB connectors Kl, K2 and shunt resistor R1 are through- hole components. R1 is a 1% precision 4-wire connection shunt resistor type OAR1-R050FI specially designed for this purpose. The rest of the parts are surface mount. The TSC101A comes in a TSOP-5 package which is not too difficult to solder if you use a fine tipped soldering iron. If you mount a 13-pin 0.1 inch pitch socket strip on the converter board, the Voltcraft module may be plugged on top of it. The monitor should work first time and there are no adjusting points. Simply connect it between your PC or charger and your USB device, and read the current from the display. To close off, here are some results from measurements carried out by the author: (110568) Internet Links www.st.com/internet/com/ TECHNICAL_RESOURCES/ TECHNICAL_LITERATURE/ DATASHEET/CD00 153725. pdf www.elektor.com/110568 Smoke Alarm Power Supply Simple but effective By Jacob Gestman Geradts (France) Smoke alarms are extremely useful devices, but they suffer from one significant disadvantage, which is that they're battery powered. This can't really be avoided, since a smoke alarm should still function when the AC grid cuts out. Unfortunately, it still runs off the battery even when the AC line supply is present, with the result that for some types of smoke alarm you need to replace the batteries at an alarming rate. This circuit lets the smoke alarm run off the AC grid normally, and only switches to the battery when it is really necessary, in other words, when there is a power cut. The circuit itself is fairly simple, but as is often the case, the circuit's strengths are in its simplicity. In this instance an AC power adapter is used to power the smoke alarm. The circuit has been designed such that just about any type of adapter can be used. The polarity of the power plug isn't important and it doesn't matter if the power adapter outputs an alternating or direct voltage, thanks to the presence of a bridge rectifier (D1 to D4). The only thing to watch out for is that the output voltage of the adapter should be 9 V or more. After the bridge rectifier and smoothing capacitor is voltage regulator IC1 (an LM317), which keeps the voltage constant. The output voltage of the IC can be varied by adjusting the value of resistor Rl. D5 and D6 make up an 'electronic switch' that automatically selects the highest supply voltage for the smoke alarm, so either the AC line supply or the battery supply. Rl has to be chosen such that there is a reverse voltage of about half a volt across diode D6 (with a full 9 V battery) when the smoke alarm is switched on. This prevents the battery from discharging, unless 112 Elektor 7/8-2012 Measure : K1 D5 1M4004 R3 K2 +) Bn “ 9 V l r 120199 - 11 * • « * * ■ the AC power fails. To mitigate the self- discharge of the 9 V battery, resistor R3 has been added, which delivers a minute current that can somewhat compensate for the self-discharge of the battery. This will keep the battery in a charged state for as long as possible. (Note from the editors: this method is usually not recommended with normal (i.e. non-rechargeable) batteries, as it can sometimes result in battery leakage. However, due to the very high value of R3 it's very unlikely to happen. For those of you who want to be absolutely safe, you can just leave out R3. The diodes aren't critical and have been selected from the 1N4000 series, in this case with a larger than required 400 V rating. The electrolytic capacitor may also be larger, both in value and in voltage. AC power adapters often output a somewhat higher voltage than is stated, which should be taken into account when choosing the dectrolytic capacitor. The condition of the battery can easily be tested (once a week) by switching off the AC adapter and running the self-test of the smoke alarm whilst it is being powered only by the battery. (120199) COMPONENT LIST Resistors R1 = 1.5kft R2 = 220ft R3 = lOOkft Capacitors Cl = lOOOpF 25 V Semiconductors D1-D6 = 1N400X IC1 = LM317 Miscellaneous K1,K2 = 2-way PCB terminal block, pitch 5mm 'Elex' prototyping board Elektor 7/8-2012 113 Equipment 'ON' Counter for 68 Years Max. By Vladimir Mitrovic (Croatia) xv *3 ■ -■ Have you ever wondered how long a piece of electric equipment has been switched on and consuming AC power? The simple circuitry shown here counts the seconds of the ON time periods and keeps the total accumulated time in the EEPROM inside the ATtinyl3 microcontroller. Just read the EEPROM with the help of an appropriate ISP programmer or the dedicated readout STOP know how "old" the equipment really is! The watchdog It is supposed that the equipment is AC-outlet powered because the microcontroller counts cycles of the AC grid voltage. The input terminals should be connected after the equipment Power (On/Off) switch (or relay) or to the secondary winding of a power Stop! Calculate R1 The microcontroller needs less than 1 mA to function properly, and at least 1 mA should flow through D2 for it to do its stabilizing act. Therefore, at least 2 mA should flow through Rl. Its maximum permissible value can be calculated with the following formula: Rl = KicXl-4 — 3.5 ^ The 3.5 constant in the formula comes from the estimated voltage across D2; at such low currents, you should expect a slightly lower voltage across a zener diode than rated. Some experimentally proven values for Rl are given in the table below. You can always use a smaller value for Rl, at the cost of higher power consumption. With values for Rl as given in the table, the total power consumption of the circuit is 10-50 mW depending on the input voltage. If you experiment with values for Rl, be sure that the DC voltage across Cl is not lower than 3 V, and not exceeding 5 V. transformer. Any voltage upwards of about 4 VAC, 50 Hz or 60 Hz, will be appropriate if resistor Rl is chosen correctly. Returning to the schematic of the pulse counter, zener diode D2 limits the AC voltage to 4-5 V pp square-wave(ish) pulses which are used not just for the system timing, but also to power the circuit via Dl/Cl. Soon after the (AC) power is switched on, the voltage Rl as a function of input voltage Input voltage Rl 4- 5 V AC 1 kQ 5-6 VAC 1.5 kQ 6-8 VAC 2.2 kQ 8-10 VAC 3.3 kQ 10-12 VAC 4.7 kQ 12-15 VAC 6.8 kQ 15-18 VAC 8.2 kQ 18-22 VAC 10 kQ 114 Elektor 7/8-2012 Measure across Cl rises to a value at which the microcontroller starts to execute the program inside its memory. Initially the program reads the previously accumulated time from the internal EEPROM and starts to count pulses at the ATtinyl3's PB3 input. Every level change at this input is recognised, so there will be 100 or 120 transitions per second depending on the grid frequency (50 Hz or 60 Hz). As soon as a single transition is counted, the microcontroller enters Idle mode. This way, the average consumption of the microcontroller is kept under 0.5 mA. Simultaneously, TimerO counts clock pulses. Once started, it will count to the top value, overflow and cause an interrupt. This would happen after some 50 ms in the absence of input pulses. However, the input pulses are not just being counted. They also repeatedly reset the TimerO, preventing it from reaching the top value. Therefore, as long as the input pulses are present, TimerO will not overflow and the associated interrupt will not execute. When the input voltage is switched off, the voltage across Cl starts to decrease. The capacitance of Cl is sufficient to keep the microcontroller working for at least one second. However, if the input voltage is switched off, the pulses at PB3 disappear abruptly. Without being reset, TimerO will cause an interrupt some 50 ms after the last transition at the PB3 input has occurred. The interrupt wakes up the microcontroller from Idle mode and causes the associated interrupt subroutine to be executed. This effectively writes the second counter back to the EEPROM. This way, the counter state gets preserved when the supply voltage drops under the safe level. The EEPROM writing procedure lasts takes about 10 ms and then the microcontroller enters Idle mode again and waits for one of the following events to happen: IC2 LCD1 LCD 16x2 • If the power is switched on again within a short period of time, i.e. before the voltage across Cl drops significantly and still is within the safe operating area, the microcontroller will wake up and start to count input pulses as soon as they occur. • If the voltage across Cl drops below 2.7 V, which happens a few seconds after switch-off, the ATtinyl3's on- chip Brown-out Detection (BOD) circuit will reset the microcontroller. The BOD circuit should be activated during the programming session, and the BOD trigger level should be set at 2.7 V (BODLEVELfuse 1 = 0, BODLEVEL fuse 0 = 1). This will ensure that the microcontroller stops running before the supply voltage drops under the safe level, when the RAM contents would be corrupted as well. When activated, the Elektor 7/8-2012 115 BOD circuit constantly monitors the V cc level during operation by comparing it to the fixed trigger level. If the supply voltage drops below 2.7 V, BOD will reset the microcontroller and keep it in this state as long as the supply voltage does not reach the safe value again. Waking from reset, the microcontroller will read the accumulated time from the EEPROM, and continue to count from that value. Back at the input of the circuit, the value of R1 should be chosen according to the input voltage, as its purpose is to limit the input current — see the text box on Rl. Readout circuit For sure you'll wantto read the counter value from time to time. In order to keep the circuit as simple as possible, no display was provided initially, and readings were taken using a low-voltage in- system programmer (ISP). Eventually a dedicated reading tool was developed and its schematic is shown here. The heart of this circuit is an ATtiny2313 microcontroller that produces all control signals required to read the contents of the Watchdog's EEPROM, converts them to a readable form and displays them on a 2x16 characters alphanumeric LC display. If you use the proposed readout circuit, you can connect it to the Watchdog circuit regardless whether the equipment in which the Watchdog is embedded is powered or not. Be very careful if the Watchdog is connected directly to the AC line voltage! If the Watchdog is active (i.e. if the equipment is switched on), the readout circuit should be switched on before it is connected to the Watchdog. This ensures well defined logical levels on all of the connecting lines, which will not disrupt the Watchdog operation. Failing to switch on the readout before connection to the working Watchdog might reset the Watchdog and cause a loss of time accumulated after the last switch-on. If the Watchdog is not active (i.e. if the equipment is switched off) it is irrelevant if the readout is switched on or off at the moment of connection. To read and display the measured time, just press the 51 pushbutton on the readout board for a short time. The readout will first activate the +5 V voltage, with the following consequences on the Watchdog: • I f the Watchdog was inactive, the +5 V signal from the readout will power- up the ATtinyl3 microcontroller and simultaneously switch transistor T1 in the Watchdog on, which in turn disables the program in ATtinyl3 from running. • If the Watchdog was already powered up and active, the +5 V signal from the readout opens T1 only. This will short-circuit the PB3 input to ground and prevent pulses from D2 from reaching PB3, forcing the ATtinyl3 to write the counter to the EEPROM. In other words, whatever state the Watchdog was in previously, the +5 V signal will ensure that the ATtinyl3 microcontroller is switched on and that the data in its EEPROM are up to date. Shortly after switching the +5 V signal on, the readout starts to communicate with the Watchdog and read the contents of its EEPROM. As soon as the reading is done, the readout switches the +5 V signal off, recalculates the data and displays the time in the "ddddd:hh:mm:ss'' form (days, hours, minutes and seconds). Flowever, bear in mind that the overall accuracy depends on the power grid frequency stability and long time intervals will not be accurate to a second! Besides reading, the readout can also erase the Watchdog's EEPROM if necessary. The erasing procedure is similar to the reading procedure, except for one detail: you should press SI and keep it depressed for at least 3 seconds in order to erase the counter in the ATtinyl3 microcontroller. If you use an ordinary ISP programmer to read the Watchdog EEPROM, be 116 Elektor 7/8-2012 Measure sure to switch off the equipment in which the Watchdog is embedded before the programmer is connected to the Watchdog! The ISP programmer should provide a 5 V supply for the Watchdog. The counter is written in the EEPROM starting from the address 0, in the form of a 4B variable (type Long), LSB first, and represents the Programs Two Bascom-AVR programs were written for the project: EE_T_on.bas is a program for the ATtinyl3 micro in the Watchdog. Be sure to set the CKSEL fuses for: calibrated internal RC Oscillator running at 9.6 MHz, and to set BODLEVEL fuses which is also the place for ordering ready- programmed micros for the project. Burn-a-Chip@Home fans: a free demo version of Bascom-AVR is available from [2], and Elektor also has books in its portfolio on this wonderful little compiler [3]. (100593) STOP Stop Again! Electrical safety! Should the circuit be connected directly to an AC outlet, consider replacing R1 with a series connection of: • a 2.2-kQ / 1-watt resistor and a 100 nF capacitor (for 115 VAC/60 Hz grids) or • a 4.7-k Q. / 1-watt resistor and a 68 nF capacitor (for 230 VAC / 50 Hz grids). In both cases, the capacitor should be rated for direct connection to the AC line voltage (for example, WIMA MKP-X2, WIMA MP3-X2, Epcos MKP X2 or similar). STOP Caution. The entire circuit is at Live AC potential and potentially hazardous to touch. Never work on the circuit while it is connected to the AC power outlet. The circuit must be enclosed in an approved enclosure preventing any part of it from being touched. When in doubt, ask for the assistance of a qualified electrical engineer. ON time measured in seconds. It will be necessary to do some calculations to decipher it (the readout does it for you!). The counter can be erased with an ISP programmer as well — if you erase the EEPROM memory. Note: erasing the EEPROM memory will write binary Is in the whole memory. This will set -1 instead of 0 as the starting counter value, but such inaccuracy may be totally neglected. as explained before. Erase the EEPROM during the programming session to reset the counter before first usage. EE_T_on_reading_tool.bas is a program for the microcontroller in the readout circuit. Set the CKSEL fuses for: calibrated internal RC Oscillator running at 8 MHz. Now get on the Internet! Both programs are in archive file 100593- 11. zip for free downloading from [1], I nternet Links 1. www.elektor.com/100593 2. www.mcselec.com 3. www.elektor.com/products/ books. 255. lynkx Elektor 7/8-2012 117 Universal Measurement Amplifier/Attenuator For laptop or PC A computer is very suitable for making (audio) measurements thanks to the sound card that is usually built in. Unfortunately, the audio input on laptops is usually too sensitive to measure somewhat larger AC voltages. A small amplifier/attenuator circuit then very handy. By Michiel ter Burg (Netherlands) If you build or repair audio equipment yourself, you don't always need an os- cilloscope. Any direct current or volt- age can be measured with a multime- ter. You can do a lot more if you happen to have a better model that can also measure (small) AC voltages. For more advanced measurements such as the frequency response or the distortion it is very handy to use the soundcard in a computer combined with some software. A laptop or note- book can also function without an AC outlet, which means you'll avoid earth loops and hum during measurements. However, a laptop often has just an oversensitive (microphone) input, so that you need to make a range of volt- age dividers for your measurements. This measurement amplifier has been designed especially for these situa- tions. It has an adjustable input at- tenuation and an input impedance of 1 M ft, so that standard scope probes with built-in attenuators can be used for even larger AC voltages. The input signal is first attenuated and then amplified to get the required 118 Elektor 7/8-2012 Measure transfer function. The input is DC cou- pled. The input signal is attenuated by at least a factor of 10; with the help of logarithmic potentiometers PI and P2 the signal can be attenuated further. Cl and C2 provide DC decoupling af- ter the input attenuators to prevent ir- ritatingly large time-constants caused by high-impedance probes. This is followed by an amplification stage (built round IC1.A and IC1.B). Potenti- ometers P3 and P4 are used to vary the gain of this stage between lx en lOOx. Bear in mind what the value of the GBP (Gain Bandwidth Product) is for the opamp used. The author first tried an LM258 and a TS912, which should have a GBP of about 1 MHz (typical). In practice a bandwidth of 15 kHz was measured with the gain set to 30x and a 9 V supply voltage. This means that the GBP was 450 kHz, although that can be compensated for by the meas- urement software. The best opamp is a TS922 (GBP of 4 MHz), which managed the complete audio bandwidth at a gain of lOOx. This is also the type that was used in the prototype built at Elektor Labs. The power is supplied by a 9 V battery that has its voltage split into a negative and positive component with a Ground in between. LED2 functions as a Low- Battery LED (it has to be a type that lights up at 2.5 V); the addition of R15 makes it light up when the battery volt- a computer soundcard running measurement software makes a useful tool age is above 7 V, which is high time to replace or recharge the battery! The inputs of the opamps are protected by diodes against very high input volt- ages or electrostatic discharges, since you can never be sure what voltages you'll find in (switched off) audio cir- cuits, especially when valves are used! A printed circuit board has been de- signed for this project, which has room for all components, including the con- nectors and potentiometers. The lay- out can be downloaded freely from the usual place [1]. Standard through-hole components have been used through- out, which makes the construction very easy. The potentiometers are put through the solder side of the board and screwed into place, after which the solder tags are bent onto the pads on the board and subsequently soldered. Elektor 7/8-2012 119 COMPONENT LIST Resistors R1-R4 = 1.8MQ R5,R9 = lkQ R6,R7,R8,R10 = 1MQ R11,R13 = lOkft R12,R14 = 4.7kQ R15 = 3.9kQ P1,P2 = lOOkft potentiometer, logarith- mic law P3,P4 = lOOkft potentiometer, linear law □ Capacitors C1,C2 = lOOnF MKT, pitch 5mm C3,C4 = lOpF 16V, 6mm diam., pitch 2.5mm Semiconductors D1-D9 = BAT48 (DO- 35 case) IC1 = TS922IN (dual opamp, DIP-8 case) LED1,LED2 = LED, green, 5mm Miscellaneous K1 = 3.5mm stereo socket (e.g. Lumberg 1503-09) K2,K3 = BNC connector, right angled pins, PCB mount (e.g. TE connectivity 1-1337543-0) BT1 = 9V battery clip PCB # 120272-1 (www. elektor.com/ 120272) □ Since logarithmic input potentiometers can deviate by as much as ±20% it is best to calibrate them after they have been mounted in the box. The calibra- tion should be carried out in steps of 10 dB (= a factor of 3.1623) using the measurement software. First mark out the calibration points on a piece of paper placed over the potentiometer, then scan this into the computer and use a drawing package to create a pro- fessionally looking scale. During the calibration P3 and P4 should be set to a gain of lx, which is normally only used with very small input signals that still need some amplification. (120272) I nternet Link [1] www.elektor.com/120272 120 Elektor 7/8-2012 Ui l)KT(^[!^Hmg4nFtg(i< mWEST Cfl t>H LK*Ti;^ iuwtij LK*'^ y^iK Rjtt-i (MJJT n t*£F 1* ■•■,■■' I M !,*,« tl L(?>1V* IWSMt W1 u 2012 ?C£ FOR £ME£0D£O DECEMBER SOU ISSUE 257 Build a ci MCU-Based Sleep-Stag Checkout Analysis Hardware with a USi DIY Smart Electronic Electronic Load Design Thermal A Embedded Linux System Platforms An mcu-e Network c Interference Immunity l #Acqi4n t hpHr for Electronic Designs iawuiPNIM. « I T1WM Mwu n n iri nt ^°y s4 ' c k Control with I 1 Bluetooth Connectivity Insida IFis M> n-d of Microprocessor D«Volopcr H T«li 10 CWtffliil 0*|iyn {,' Th# UichdrHn t of Vwlteg NDL fl C*±‘.jo L**'i Ptogruiiftrjbt* L>jic WAftfl Hof * Aiiio ia!!on Kraixet iIfi* tia>t <■ Orif 0». M" lli.^ r™-.*' CrKifml P^nJ:! ' - if VfcrtlkJ&0<>, A V* -Jdlt-.Hi u AM Mwi Subscribe now to the leading computer applications magazine specializing in embedded systems and design! 12 issues per year for just Digital: $50 : : Print: $75 : : Combo (Print + Digital): $110 Select your personal subscription at Loudspeaker Resonant Frequency Meter Byjac Hettema (Netherlands) This system is designed to facilitate the determination of loudspeaker resonant frequencies. What components do you need for this? A good variable oscillator, an amplifier, and meters for reading the frequency and the voltage. The oscillator here is based on the function generator described in the April 1995 issue of Elektor Electronics. Only the sine-wave function is used here. The main advantage of this oscillator is that it can be adjusted over a wide frequency range with a single potentiometer. If you use a ten- turn potentiometer for this, you can set the frequency very precisely. The sine-wave signal also has a very stable amplitude and low distortion. The sine- wave signal generated by IC3 and IC4 is fed to the output amplifier (TDA2030) via potentiometer P3. Switch SI allows the amplifier to be operated in two different modes: constant voltage and constant current. The latter option is helpful for determining the position of the peak amplitude at the resonant frequency, since this can best be seen with constant-current drive. The loudspeaker voltage is measured by I C5a, which is wired as a differential amplifier with a gain of 1. IC5b converts the loudspeaker current into a voltage. Switch S2 selects one of these two outputs, and the selected measurement signal is fed to an active rectifier built around IC6a and IC6b. The rectifier output is fed to IC8, a voltage to frequency converter (type XR4151). Its output signal is routed via S5 to a frequency counter. Switch S5 selects either the frequency or the loudspeaker voltage or current. The author used a type 74C925 1C as the frequency counter for frequency measurement, along with a time base and the necessary peripheral circuitry. Although this 1C is no longer available, the associated devices (I Cl, IC2, IC9 and I CIO) have been included here for completeness. The time base uses a crystal oscillator with a watch crystal to generate a 10-second counting window, and the counter allows the frequency to measured with a resolution of 0.1 Hz. The above- mentioned ICs can be omitted if you use a frequency counter module. Power is supplied by a mains 122 Elektor 7/8-2012 Measure I R2 R1 C5 22p | R40 [I C13 II In I R41 IC2.A JT& CM II +12V -<±) I CZB In +12V ©“Jr IC2.C C15 II 470p | R42 | R43 3 0 © ■lev R16 R17 R19 hU JT& .10 C16 II 470p ICZD 12 13 JT& u! ■RESET COUNTER o o o o LLLLLUJo IC2 = CD4093B IC3 =71.072 IC4 =TL072 IC5 =TL072 ^^17 ^^12 +iev £ ICll C17 lOOOu 25V ^^19 ^^20 CIS lOOOu 25V 4x 1N4001 120241 - 11 S' -16V C19 lu C20 lu 10u 16V C22 10u 16V 1C 12 transformer rated at 2 x 12 V, followed by a pair of voltage regulators. The output amplifier is powered from the unregulated supply voltage. When making measurements, take care that the measuring voltage does not become too high. If the loudspeaker has a nominal impedance of 4 £ 1 , the impedance at the resonant frequency can easily be a factor of 10 greater. If you measure with constant current, this will cause the voltage on the loudspeaker at the resonant frequency to be 10 times the normal value. The loudspeaker voltage must always be well below the clipping voltage of the output amplifier. A clipping indicator could be a useful addition. Beforestarting to makea measurement, ensure that the level control P3 is set to zero. Then increase the level until the loudspeaker generates a barely audible tone. Set switch S2 to voltage measurement mode and adjust the frequency with PI to maximise the measured voltage. The measured current at this point should not deviate from the initial value. If it does, repeat the measurement with a lower setting of P3. At the maximum loudspeaker voltage, read the frequency from the counter. This is the resonant frequency of the loudspeaker. (120241-1) Elektor 7/8-2012 123 PtlOO Simulator By Ralf Beesner (Germany) PtlOO is the designation for a platinum resistor that exhibits a value of 100 ft at a temperature of 0°C. If the ambient tem- perature rises (or falls), its resistance increases (or reduces), demonstrating a positive temperature coefficient. The pro- gression for the PtlOO is not exactly linear but across a range from around zero to several hundred °C, and can be deter- mined with adequate precision using a quadratic equation. The exact relationship is defined in a standard that you can consult in the form of look-up tables. Temperature sensors of this kind are used widely in industrial automation equipment. Anyone developing circuits that contain PtlOO elements has to reckon with elaborate test set-ups involving iced water baths and adjustable heat sources, which may not arouse great pleasure. But you can avoid this inconvenience with the circuit presented here, which simulates the behaviour of a PtlOO resistor in the temperature range -25 °C to 350 °C. Constructing the circuit is relatively straightforward: termi- nal K1 connects the simulator to the circuit calling for the PtlOO element. The individual resistor paths represent the resistance value of the PtlOO at a specific temperature (see values indicated on circuit diagram). A jumper field allows you to select the resistance combination for the temperature required. Normal off-the-shelf resistors with 1 % accuracy are fine for building our PtlOO simulator. As the standard values of the E24 series do not correspond exactly to the resistor values of PtlOO we use combinations of resistors connected in series to provide an adequately close match. This table gives an overview of the series resistor combinations (ft sim ) and the corresponding standard values of the PtlOO standard (ft Norm ) together with the deviation in each instance. (120325) PtlOO is the designation for a platinum resistor that exhibits a value of 100 A at a temperature of 0°C. Resistor values for the PtlOO simulator T [°C] D ■'Norm Rsim Individual resistors Deviation [«] [«] 1 2 3 t°/o] -25 90.2 90 68 22 0 -0.22 0 100 100 100 0 0 0.00 25 109.7 110 82 27 1 0.27 50 119.4 120 120 0 0 0.50 75 129 129 82 47 0 0.00 100 138.5 138 120 18 0 -0.36 125 148 148 68 68 12 0.00 150 157.3 157 120 22 15 -0.19 200 175.8 176 120 56 0 0.11 250 194.1 194 150 22 22 -0.05 300 212 212 100 100 12 0.00 350 223.9 229 100 82 47 2.28 124 Elektor 7/8-2012 ADuC841 Microcontroller Design Manual: From Microcontroller Theory to Design Projects If you’ve ever wanted to design and program with the ADuC841 microcontroller, or other microcontrollers in the 8051 family, this is the book for you. With introductory and advanced labs, you’ll soon master the many ways to use a microcontroller. Perfect for academics! Q uC841 Microcontroller Now Just $35.00 Buy it today! www.cc-webshop.com Shoo Heron! Outsmart a clever bird More and more pond owners suffer from herons that help themselves to the fish in the pond. Although several devices are for sale in the trade to scare away herons, they are often not completely effective. The 'perfect' heron scarer doesn't exist, unfortunately. These birds have a justified reputation for their intelligence! Even electric wire fencing doesn't work, as the heron just steps over it. However, the system described here was found to work very well. By Will J .B. Hus (Netherlands) If you have ever observed herons, you will have noticed that they always ap- proach a pond from some distance. The idea is to protect the pond with an The protection consists of an infra- red transmitter and receiver that are mounted close to each other. The beam is made to go round the object to be protected (the pond) by means of a series of mirrors. Should the infrared for example, mounted on a small post. The best height is about 20 to 30 cm (8 to 12 inches). The infrared transmitter and receiver used in this project came as a set and are widely available (e.g. from Con- This setup should also fit other types of surveillance system invisible barrier that is connected to a powerful water spray. Herons dislike being sprayed and will leave. Further- more, they can't easily determine what causes the spray to start. beam be broken, it causes an electro- magnetic valve to open, which causes the spray of water to start. The heron definitely doesn't like this! For the mir- rors you could use rear-view mirrors, rad) . The receiver has a 'normally open' (NO) contact. The rest is taken care of by a simple microprocessor that drives a solid-state relay (IC2). The relay of the receiver module is closed when the 126 Elektor 7/8-2012 Share K1 fO IC4 +12V O 3 , , 1 V T V T fN C5 C4 fM 1C 3 +5V O lOOn lu 63V C3 lu 63V C2 lOOn IC1 +5V +12V O O GP5/0SC1/CLKIN VDD GP4/OSC2 GP3/MCLR/VPP GP2/T0CKI GP1/ICSPCLK GPO/ICSPDAT VSS PIC 12F509-I/P 110337-11 beam is broken. When pin 2 of the micro- processor goes low, the spray rou- tine is activated. Pin 5 then drives the LED of the solid-state relay. And that's all there is to it! The extremely simple program turns on the sprayer three times for five seconds. To avoid that the sprayer is turned on continuously, when the beam is permanently broken for ex- ample, the routine has a loop that is only exited when the beam is restored again. As usual, the program for the microprocessor can be downloaded from the Elektor website [1]. A PCB has been designed forthis circuit, which contains the power transformer, voltage regulators, microcontroller and solid-state relay. The infrared transmit- ter and receiver and the electromag- netic valve are easy to connect to the board, using screw terminals. To set up the system properly requires a high level of precision. The transmit- ter, receiver and the mirrors have to be Elektor 7/8-2012 127 p shop lined up exactly. This is best done using a simple laser pointer. First, the laser pointer is put in front of the transmitter and pointed at the first mirror. A piece of masking tape on the mirror can make it easier to see the laser light. From then on, you follow the same pro- cedure for all successive mirrors until you get to the receiver. This is some- thing best done at dusk or at night! Once that is done, the transmitter and receiver have to be aligned as well as possible with the first and last mirrors respectively. If possible, you should use twin beam modules for the transmitter and re- ceiver. This will prevent smaller birds or even a falling leaf from breaking the beam. With only minor modifications, this system can also be used for other se- curity purposes. The output is capable of switching all kinds of AC line pow- ered devices. ('110337) I nternet Link [1] www.elektor.com/110337 Tiny Compass groups of four LEDs each. The cath- odes of the LEDs in each group are con- nected together, and the common cathode lead is con- nected to a port pin via a series resistor. Sets of four LED anodes are also connected to common port pins. If suitable signals are generated on the port pins, only one LED at a time will be lit, and this arrange- ment needs only eight port pins in- stead of sixteen. The intelligence of the circuit is vested in the microcontroller firmware, start- ing with the 1 2 C interface. This is nec- essary because the ATtiny84 does not have a hardware l 2 C interface (which Atmel calls Two Wire Interface' or TWI), but instead only a 'Universal Se- rial Interface' (USI). The l 2 C function- ality must therefore be emulated using By Wilfried Watzig (Germany) from a two-pin l 2 C port (most easily done with a microcon- troller). The compass circuit is built around an ATtiny84, communicates with the compass module MODI over the l 2 C bus. The two pull-up resistors R5 and R6 have standard values. The circuit can be powered from a 9 V bat- tery, among other options. The voltage regulator reduces the input voltage to 5 V. The compass direction is indicated by a set of 16 LEDs, divided into in four A compass is an invaluable orienta- tion aid, especially when you're trav- elling by foot or bicycle. Some smart- phones and navigation systems do not have built-in compasses, so they can determine direction only if you move fairly quickly. Old-fashioned hik- ing or cycling maps also still have their place, since they provide a much better overview than any display. Accordingly, the author went looking for a robust com- pass, and it quickly became clear that what he wanted was an electronic model — and of course, of his own de- sign. The implementation of this sort of project is simplified by the fact that compass models with simple interfaces are available commercially. The author decided on a module with the designation HDMM01, which can be obtained from Pollin Electronic [1]. It incorporates a type MMC2120MG two-axis magnetic field sensor from Memsic. All you need to do is provide the module with a 5 V supply voltage, and you can read out the compass data 128 Elektor 7/8-2012 Share Is I PA6(ADC6/DI/MOSI/SDA/OC 1A/PCINT6) PA5(ADC5/D0/MS0/0C1B/PCINT5) PA7(ADC7/OCOB/ICP/PCim7) PB3(dVWRESET/PCINni) PB2(CKOirr/ocoA/ii^nypciNTio) PBKXTAL2/PCINT9) PB(XCLKI/XTAL1/PCIMTB) PA4(ADC4/USCK/SCL/n/PCINTT4) PA3(ADC3myPCINT3) PA2(ADC2/AIN1/PCINT2) PAKADCI/AIIWCINTI) PAO(AtX(VARE F/PC I NTO) GW) ' ATT1NY84-PU 10 n 12 B R1 R2 D15 un- H W W R4 -| IkO D14 DB H o o o o o°°o °oo° o o o o K R3 OEQ ^^12 ^^11 ^^10 ^^9 120045 - 11 the USI # in the manner described in an Atmel application note [3]. The compass module supplies the X and Y components of the magnetic field as signed numbers. The corre- sponding quadrant can be determined from the signs of the numbers, and the angle within the quadrant can be obtained using the expression Angle = arctan(abs(Y/X)), where the function abs() returns the absolute value of the quotient of Y and X. The average values of X and Y are calculated from a set of eight samples in an endless loop in the main routine of the firmware and are used to compute the angle. From this the LED that points to the north can be determined. To allow the direction to be indicated with sufficient precision, the LEDs should be arranged in a cir- cle with equal spacing and in the same sequence as shown on the schematic diagram. LED D1 must be aligned to the top edge of the module (oriented so that the 1C marking can be read normally). For best results, you should use another compass to calibrate the assembly and adjust the orientation of the module (connected to the circuit by loose wires) accordingly. Then secure the module to the PCB with a drop of heat-melt glue. The firmware (source code for WinAVR Always on the right path and hex code) can be downloaded from the Elektor website. The main routine is contained in the file tiny_compass.c; the routine USI_TWI_Master.c han- dles l 2 C communication and the rou- tine led_driver.c drives the LEDs. The microcontroller can be programmed directly on the PCB via connector Kl. The fuse bits must be configured as follows: EXT = OxFF, HIGH = OxDF, LOW = 0xE2. If you don't want to pro- gram the microcontroller yourself, you can buy a pre-programmed device from the Elektor Shop [4] (order num- ber 120045-41). (120045) [1] www.pollin.de [2] www.pollin.de/shop/downloads/ D810164D.PDF [3] www.atmel.com/lmages/ doc2561.pdf [4] www.elektor.com/120045 Elektor Products & Services • ATtiny84 microcontroller (pre-programmed): # 120045-41 • Free software download: 120045- 11. zip All products and downloads are available from the web page for this article: www. elektor. com/ 12004 Elektor 7/8-2012 129 shop Two-Transistor Regenerative Receiver By Frank de Leuw (Germany) Regenerative? What's that? In the age of Twitter and smart- phones, you can't assume that things not related to the In- ternet are still generally known — or maybe they are? Amaz- ingly, Google delivers nearly 80,000 hits for the search term 'regenerative receiver' and much more for the German name Audion, even though it lacks a lower-case i as a prefix ('iAu- dion' also exists, but it yields only 12,000 hits). From this we can conclude that this type of receiver is not entirely un- known nowadays, even if some of the search results have nothing to do with radio circuits. In any case, it's a reasonable assumption that you all have idea of what 'regenerative' means. If not: it's a super-simple but nevertheless sensitive type of radio receiver. If you want to know more, check the references. The Wikipedia entry on this topic [1] is also quite extensive. The author is a fan of the many HF experiments and projects dreamed up by the well-known Elektor author Burkhard Kainka. Based on Kainka's regenerative receiver circuit, the author developed an especially simple but high-performance version using DIY Retro Radio modern components — a regenerative receiver using only garden-variety transistors, but with good reception charac- teristics. The author has published a version of this design on his website [2]. The Elektor version, which is perhaps a bit easier to build yourself, is described here. Instead of breadboard construc- tion, which was common in the days before PCBs were in- vented, the component layout of the design presented here has been optimised with the Lochmaster 4 program for as- sembly on an Elex prototyping board (a.k.a. UPBS-1 and available from the Elektor Shop). First a few words about the circuit. A noteworthy feature is that both transistors are type BC548 in the 0815 package. Apparently types that are actually designed for audio use are adequate for use with HF signals in the medium-wave broadcast band from 0.5 to 1.6 MHz, which is what we're 130 Elektor 7/8-2012 Share interested in here. Variable capacitor Cl and coil LI form the usual parallel reso- nant circuit that determines the receiver frequency. The spe- cial feature of a regenerative receiver is that an active com- ponent, or more precisely the gain of an active component, is used to implement a form of feedback that is adjusted to the point where the circuit is just on the edge of oscillation. This reduces the load on the resonant circuit and increases its selectivity, and the high gain makes the receiver fairly sensi- tive. The active component in this case is Tl. The feedback is provided by PI and the tap on LI. Here Tl does double duty: it provides HF gain and (thanks to the nonlinear char- acteristic of the BE junction) it demodulates the AM signals commonly transmitted in the MW band. T2 provides additional gain for the audio signal. A small loudspeaker or (preferably) headphones can be connected to coupling capacitor C6. The headphones should have high impedance to improve matching. For this reason, it's a good idea to connect the two earphones in series. Assembling the circuit is straightforward thanks to the layout for the prototyping board. A bit more dexterity is required for making the aerial, but even here you don't need much more than the usual hobbyist tools. You can have planks and laths sawn to the dimensions given in the components list in any home improvement shop for a small charge. Fit the PCB in the middle of the baseboard between the vari- able capacitor on the left and the potentiometer on the right. Screw the lath cross to the baseboard behind the PCB as shown in the photo of the prototype (note: in the prototype the author fitted a trimpot directly on the PCB instead of us- A (350x20x 10 mm) B (300 x 20 x 10 mm) 110211 - 12 ing an external potentiometer; this is also shown in the com- ponent layout for the Elex board). Wind 20 turns of enam- elled copper wire on the cross, with a tap at the end of the fifth turn. The exact arrangement is not as critical as it might appear to an HF novice. The prototype built in the Elektor lab drew 1.4 mA from a 9 V Elektor 7/8-2012 131 p shop battery. The measured frequency range with this construc- tion was 0.4 to 1.4 MHz. The reception quality is surprisingly good, once you get the hang of adjusting the feedback with potentiometer PI. In terms of reception, the regenerative receiver can hold its own against superheterodyne receivers. If you want to connect an amplifier instead of headphones, you can replace R6 by a potentiometer with the positive end of C6 connected to its wiper. If you can't scare up a suitable variable capacitor rated at 500 pF or so, you can purchase the VCAP4 from [3] and connect the two 265-pF gangs in parallel. Incidentally, in the Elektor lab it was necessary to reduce the turns count of the aerial loop by three in order to roughly match the receiver frequency range to the MW band. In our opinion this regen- erative receiver is not only a good example of a loop aerial receiver, but also a good candidate for a 'father and son' project where you can try out lots of things and learn from them. And don't forget that a loop aerial receiver is a direc- tional receiver! (110211-!) [1] en.wikipedia.org/wiki/Regenerative_circuit [2] www.elektronik-radio.de/39994.html (in German) [3] www.ak-modul-bus.de/ (in German) Same PCB Shoots Again! A thermometer with an unusual readout By Luc Lemmens (Elektor Labs) 1 n the April 2012 edition of Elektor we published a design for a thermometer that uses two counter wheels from a 1960's pinball machine to display the temperature. With few minor modifications to the firmware, a credit unit from a pinball machine can also be used as a display device. The counters used in the original design are a pair of mod- ules normally used in a pinball machine to show the player's score. Each module can display a number from 0 to 9. These modules can only count up, which means that a change from 2 to 1 requires spinning the counter wheel all the way around to reach the new position. EM pinball machines contain another type of counter called the credit unit, which shows how many games the player can still play before inserting more coins in the machine. It has a wheel that can display a number from 1 to 20. Some credit units can even go as high as 37 (the experts in this area disagree on the highest number ever). Unlike score counters, credit units can count down because they have a dual mech- anism and two actuator coils. These units also have contacts to indicate the zero and maximum positions of the wheel. The numbers are smaller than those on score counters, and the available range of numbers is usually not especially large — but this can be taken as a challenge for developing version 2.0 of the thermometer. Two contacts, two coils and two digits; what can we do with that? The readout is a bit different, but the circuitry for the previous version of the thermometer has everything we need for driving this unit as well. With a few changes in the con- 132 Elektor 7/8-2012 Share nections and of course a few modifications to the firmware, it should certainly be possible. The vast majority of the original firmware is unchanged; only the readout routine has changed. The algorithm for this is not difficult. After power-up, the microcontroller pulses the counter until it reaches the zero position. This position is signalled by the opening of the zero contact. Next, the temperature is measured and a pulse is sent to the counter for each measured degree Celsius to increase the indicated number. The circuit waits 15 minutes before making a new measurement. The new value is compared with the previous value and the difference between the two is translated into the number of steps up or down that are necessary to show the right temperature. That's all easy enough, but with a 20-credit unit — such as we had here in the lab — the range is rather limited and not even sufficient for measuring the room temperature. The wheel has enough room for more numbers, and in prin- ciple the unit could certainly make more steps; if necessary it could even turn the wheel in a full circle with a modified mechanism. Our credit unit came from a pinball machine made by Williams, but a unit from another brand is equally suitable (just like the counters for the previous version), such as Bally or Gottlieb. Credit units also differ somewhat from one brand to the next, and some manufacturers occasionally make changes to their own modules, but the connections and operation are always the same. A bit of exercise with a graphic design program on the computer delivers a nice strip of paper with a series of numbers from 0 to 48, which can be taped onto the original wheel. However, there's a bit more to be done. As already mentioned, the unit has a contact that indicates when the wheel has reached its maximum count. On the photo you can see the contact for the 0 position at the left, and to the right of it a ratchet wheel with two pins fitted to it. The upper pin opens the zero contact when the wheel has been rotated far enough anti-clockwise, and the lower pin opens the maximum-position contact when the wheel reaches the maximum position in the clockwise direction. We removed the second pin to make the range as large as possi- ble. In the worst case the pin intended to operate the contact for the zero position will also operate the contact for the end position. If this happens, the firmware prevents the wheel from stepping any further. The new firmware for the ATtiny2313 used in the original circuit published in the April 2012 edition (PCB # 110673-1) is available on the web page for this project [1]. (120251-1) Internet Link [1] www.elektor.com/120251 Advertisement Great Value in HRMEG Instruments Test & Measuremen A Rohde&Schwarz Company Digital Oscilloscope HAMEG UK Ltd. Tel. 01536 416 464 ■ Fax 01536 416 474 ■ sales@hameguk.co.uk HM01024 100MHz, 4 Channel 0 2GSa/s Real Time, Low Noise Flash A/D Converter (Reference Class) 0 2MPts Memory, Memory J2) oom U P t0 50,000:1 0 MSO (Mixed Signal Option HO3508) with 8 Logic Channels 0 Serial Bus Trigger and Hardware accelerated Decode incl. List View. Options: l 2 C + SPI + UART/RS-232, CAN/LIN Elektor 7/8-2012 133 news p shop Laser Projection with Arduino By G. van Zeijts (The Netherlands) This device can project attractive laser beam patterns on virtually any desired surface. The basic idea is to manipulate the path of a laser beam from a source such as a laser pointer. The beam is de- flected by a small mirror fitted to the end of a motor shaft. The mirror is not perfectly perpendicular to the axis of the shaft, so the originally linear beam path is converted into a cone. This cone strikes a second mirror on end of the shaft of a second motor. The beam from the second mirror goes to the projection surface. The motor speeds are high enough that viewers see a stationary figure instead of a moving point of light, thanks to the +24V DC ©- pi 10k *1 / ON/OFF -o 6Vdc +6Vqc 28_ 27_ 26_ 25 24 23 22 21 20 _ 19_ 18_ 17 RESET 3.3V 5V GND GND VIN ANO-i AN1 AN2 AN3 AN4 AN5 J 8 V N +5V <±> P2 \ 10k MODI ARDUINO AREF GND D13 D12 PWM/D11 PWM/D10 PWM/D9 D8 D7 PWM/D6 PWM/D5 D4 PWM/D3 D2 TX > D1 L RX < DO 10 11 12 13 14 15 16 • -© □ lOu 1 2 3 4 1 110166-11 Ml M2 M M 10 CD+ 11 01 12 [ > 02 13 03 14 04 15 05 ULN2803 16 06 17 07 18 08 Gr JD -» — ( \ 17 vl6 i — Vl5 .18 M4 si 2 ^l 1 140mA LASER ss TIL 119 1XH +5V © 10k |— o °"[ 10k 10k °-[ 10k 10k °-[ 10k 10k °"[ 10k h H > 1- — o H > 1- — o H 1- — o 134 Elektor 7/8-2012 Share persistence of human vision. A wide variety of fascinat- ing figures can be created by varying the speeds of the motors. All of this is controlled by an Arduino microcontroller, us- ing a program written in C. The software can be down- loaded free of charge from the web page for this article from a 5-V supply voltage. The current is limited to ap- proximately 140 mA by a 15-ohm resistor. To avoid problems with pulse noise from other supply rails, the Arduino is powered from a separate 6 V source, such as a rechargeable battery. The speeds of the two motors are set by potentiometers PI and P2 (which are fitted with the red and blue knobs in the photo), whose positions are read by the microcontroller. The microcontroller converts these two input signals into PWM outputs that determine the speeds of the motors. The rest of the circuit dia- gram is simple. The outputs of the Arduino MCU are fed directly to the ULN2803 driv- er 1C, which can handle up to 500 mA per channel. The two motors (scavenged from printers) operate at 24 V with current consumption well below 500 mA. To be on the safe side, two channels of the ULN2803 are wired in parallel for each motor. The laser diode is energised by the microcontroller im- mediately after start-up and is always on. It is powered The author used the po- tentiometers to find vari- ous combinations of mo- tor speeds that produce attractive figures. They have been arranged in sequence to provide a show lasting several minutes, with a re- peating series of fascinat- ing figures in an automatic loop. This is included in the C code. This loop, as well as other pre-programmed figures, can be selected us- ing a set of four switches. A short video demonstrating the projected figures can be viewed on Elektor's YouTube channel [2]. (110166) I nternet links [1] www.elektor.com/110166 [ 2 ] www.youtube.com/ Elektorl M Caution: laser beam! Always be careful when working with laser beams. The light emitted by the laser diode in a laser pointer is relatively harmless and does not cause any problems if the beam passes quickly through your field of vision, but you should never look directly into a stationary laser beam, even if the laser power is very low. Elektor 7/8-2012 135 news p shop Physics teachers often rely on test equipment to make cer- tain phenomena observable. Stroboscopes are useful for getting a closer look at vibrating strings and rotating mo- tor parts. Conventional stroboscopes however will often not flash at a rate fast enough to 'stop' the motion for obser- vation. The author is of the belief that a hands-on physical demonstration is worth a hundred hours of 'chalk and talk' whiteboard explanations. Strings vibrating at a frequency high enough to be audible will be oscillating at a few hundred hertz. This flash rate is difficult for achieve with a xenon flash tube. Flash tubes also have a reputation for be- ing fragile and require the applica- tion of a high DC voltage for the flash. The words 'lethal volt- age', 'fragile' and 'glass' used in the same sentence as 'classroom environ- ment' are likely to arouse the interest of health and safety offi- cials. An alternative (not just an iPhone strobe app) is to use a power LED in a low-voltage stroboscope design. It would not produce such an intense flash as a xenon version but still be bright enough in a partially shaded room. A battery powered LED stro- boscope would make a robust and useful teaching tool. This was reason enough for the author to set about design- ing and building this mini stroboscope using an LED light source. The design is built around the NE556; the dual-ver- sion of the biggest selling chip ever designed. One half of this chip (IC1B) takes care of the flash frequency generation and is therefore configured as a standard astable multivi- brator. Variable pot PI allows the flash rate to be adjusted from around 120 to 650 Hz. The design includes a switch- able loudspeaker in the emitter path of T2 to make the flash 136 Elektor 7/8-2012 Share 650 Hz LED strobe frequency audible. Transistor T2 is only necessary if you, like the author, use the CMOS version of the NE556. The second half of the dual tinner chip is configured as a monostable multivibrator to provide a pulse shaping func- tion. The differentiating RC network formed by C4 and R1 produces a 10 ps pulse on the positive and negative edges of the output signal from IC1B. The negative going pulse is transferred to the trigger input of I Cl. A via diode Dl. R4 and C6 are chosen so that I Cl. A gives a 50 ps positive output pulse in response to the trigger pulses. The pulses are connected to the gate of MOSFET T3 via re- sistor R5. LEDs are driven by a constant current source, in this circuit the voltage drop across the shunt resistors R7, R8 and R9 is added to the forward conduction voltage V F of D2 to control transistor Tl. When the voltage drop over the shunt resistors reaches 300 to 350 mV Tl begins to conduct the drive voltage of T3 to ground thereby limiting current through the LED to around 1 A. Cl effectively reduces the source impedance of the power supply so that high current pulses can be delivered to the LED even when the circuit is powered by four AA size dry batteries. The author used an LED 'OSLON SSL LCWCQ7P' type LED from OSRAM. According to its data sheet [1] this small LED can be pulsed with a current of 2 A for 50 ms. Running with 1 A pulses of 50 ps duration neither the LED or T3 will require any additional cooling. This particular LED has an electrically isolated 'thermal pad' between the two power connections which can be used as a heat sink contact point. With a heat sink in place the LED will be able to pass a higher current. I Cl. A outputs a constant pulse width so the LED dissipates more power if the value of C5 is reduced to increase the maximum strobe flash frequency. It is of course possible to experiment with more powerful LEDs and to increase the LED current by reducing the size of the three parallel shunt resis- tors. T3 still has a little more in hand even when running with a pulse current of 3 A in this application. To achieve maximum brightness it is better to avoid warm white LED variants. Higher colour temperatures are perceived as being brighter. Using the suggested components and a CMOS version of the NE556 the LED current has an average value of around 20 mA when running at 650 Hz. With the speaker switched on this rises to around 40 mA. Using the standard non-CMOS version of the NE556 increases the current drain by about 5 mA. The author has supplied a PCB layout for this design. It uses standard non-SMD components so assembly is very simple. The PCB can be ordered from the project web site [2] where the layout files are also available for download. (120055) I nternet Links [1] http://catalog.osram-os.com/catalogue/catalogue.do? favC)id=000000020000263308030023&act=showBook mark [2] www.elektor.com/120055 COMPONENT LIST Resistors R1,R6 = 4.7kO R2 = 22kO R3,R5 = IkO R4 = 2.2kO R7.R8.R9 = lO RIO = 2200 Rll = lOkO PI = 47kQ, potentiometer, linear Capacitors Cl = lOOOpF 10V, radial, pitch 5mm, diam. max. 13mm, 1 A ripple current (Farnell # 1165601) C2,C3,C5,C7 = lOOnF, MKT, pitch 5 or 7.5mm C4 = 2.2nF, MKT, pitch 5 or 7.5mm C6 = 22nnF, MKT, pitch 5 or 7.5mm Semiconductors Dl = 1N4148 D2 = BAT42 D3 = Power-LED, OSRAM type LCW CQ7P. PC-KTLP-5J7K Tl = BC546 T2 = BC639 T3 = I RLU024NPbF (TO-251AA) IC1 = TS556 or TLC556 (DIP16) Miscellaneous 51 = on/off switch, 1 A 52 = on/off switch LSI = loudspeaker, 80 200mW BT1 = 4 pcs AA alkaline battery with holder 3 pcs 2-way PCB screw terminal blocks, pitch 5mm, for BT1, SI and D3 3 pcs 2-way pinheader, pitch 0.1", for LSI, S2 and PI PCB # 120055-1 (see text) Elektor 7/8-2012 137 INFOTAINMENT EUC Penta-Hexadoku 9 ; 6 6 ; B 2 F A 1 6 IlIJIHLilllJI 5 E 7 4 1 4 1 B D E A 5 . . „ , . i „ . » i . . . . . . i i . ; F 2 _ i . . . i D . . . . j ■s B T S J 3 : 6 7 A B 3 0 13 F C D G 1 5 0 9 6 0 F jc_ 7 i 4 D A 5 4 . . . b ■ > i 5 0 i I _ 1 1 J A I . D 0 5 A 1 7 A 7 6 3 F i 4 9 — * 1 2 9 E A B 3 A 6 9 B : 8 8 4 I I ■ H .1 J I D 0 D 0 I . ... . 1.11 By Claude Ghyselen (France) i E i F : C Cl 1 0 6 s' 5 8 G ' 7 B U j 9 ■■.■I iii A : F 2 3 0 0:D;C:B 3\2 ■ 3 it 5 0 3 C C D 7 3 A 1 0 E 3 4 : A A : 6 : A 7 i 8 n ™ E 1 : 5 8 • i i .1 i . n c f A B 8 3 2 A 7 6 D 1 ■ t a j u ■ i D SBC 3 B f 2 ; 4 i F j 5\ | E 1 0 7 A 9 t 7 ■ ■ ■ ■ - - 4:3 F ; C F 4 3 9 2 F 0 ■ G : ' 1 . I. . J ■ s - 9 : 1 6 : j B ■ 4 : 5 C 1 r s 3 2 _) c F S » i. i . i i 1 _ . - l i b . j 1 I U U i . I. L 3 2 F _ ; 7 i 3 1 ... 4 9 8 D a ■ ■ .ir g?rn-jta> I i-H.-r Cr~V- if 144 Elektor 7/8-2012 ORDERING INSTRUCTIONS, P&P CHARGES All orders, except for memberships (for which see below), must be sent BY POST or FAX to our Brentford address using the Order Form overleaf. Online ordering: www.elektor.com/shop Readers in the USA and Canada should send orders, except for memberships (for which see below), to the USA address given on the order form. Please apply to Elektor US for applicable P&P charges. Please allow 4-6 weeks for delivery. Orders placed on our Brentford office must include P&P charges (Priority or Standard) as follows: Europe: £6.00 (Standard) or £7.00 (Priority) Outside Europe: £9.00 (Standard) or £1 1 .00 (Priority) HOW TO PAY All orders must be accompanied by the full payment, including postage and packing charges as stated above or advised by Customer Services staff. Bank transfer into account no. 4027021 1 held by Elektor International Media BV with The Royal Bank of Scotland, London. IBAN: GB96 ABNA 4050 3040 2702 1 1 . BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or members. We regret that no cheques can be accepted from customers or members in any other country. GCredit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL-protected for your security. COMPONENTS Components for projects appearing in Elektor are usually available from certain advertisers in this magazine. If difficulties in the supply of components are envisaged, a source will normally be advised in the article. Note, however, that the source(s) given is (are) not exclusive. TERMS OF BUSINESS Delivery Although every effort will be made to dispatch your order within 2-3 weeks from receipt of your instructions, we can not guaran- tee this time scale for all orders. Returns Faulty goods or goods sent in error may be returned for replacement or refund, but not before obtaining our consent. All goods returned should be packed securely in a padded bag or box, enclosing a covering letter stating the dispatch note number. If the goods are returned because of a mistake on our part, we will refund the return postage. Damaged goods Claims for damaged goods must be received at our Brentford office within 10-days (UK); 14-days (Europe) or 21 -days (all other countries). Cancelled orders All cancelled orders will be subject to a 1 0% handling charge with a minimum charge of £5.00. Patents Patent protection may exist in respect of circuits, devices, components, and so on, described in our books and magazines. Elektor does not accept responsi- bility or liability for failing to identify such patent or other protection. Copyright All drawings, photographs, articles, printed circuit boards, programmed integrated circuits, diskettes and software carriers published in our books and magazines (other than in third-party adverti- sements) are copyright and may not be reproduced or transmitted in any form or by any means, including photocopying and recording, in whole or in part, without the prior permission of Elektor in writing. Such written permission must also be obtained before any part of these publications is stored in a retrieval system of any nature. Notwithstanding the above, printed-circuit boards may be produced for private and personal use without prior permission. Limitation of liability Elektor shall not be liable in contract, tort, or otherwise, for any loss or damage suffered by the purchaser whatsoever or howsoever arising out of, or in connexion 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 in respect of the goods. Law Any question relating to the supply of goods and services by Elektor shall be determined in all respects by the laws of England. January 201 2 MEMBERSHIP RATES FOR ANNUAL MEMBERSHIP United Kingdom & Ireland Standard £54.00 Plus £66.50 Surface Mail Rest of the World £68.50 £81.00 Airmail Rest of the World £86.00 £98.50 USA & Canada | See www.elektor.com/usa for special offers HOW TO PAY Bank transfer into account no. 4027021 1 held by Elektor International Media BV with The Royal Bank of Scotland, London. IBAN: GB96 ABNA 4050 3040 2702 1 1 . BIC: ABNAGB2L. Currency: sterling (UKP). Please ensure your full name and address gets communicated to us. Cheque sent by post, made payable to Elektor Electronics. We can only accept sterling cheques and bank drafts from UK-resident customers or members. We regret that no cheques can be accepted from customers or members in any other country. Credit card VISA and MasterCard can be processed by mail, email, web, fax and telephone. Online ordering through our website is SSL-protected for your security. MEMBERSHIP CONDITIONS The standard membership order period is twelve months. If a permanent change of address during the membership period means that copies have to be despatched by a more expensive service, no extra charge will be made. Conversely, no refund will be made, nor expiry date extended, if a change of address allows the use of a cheaper service. Student applications, which qualify for a 20% (twenty per cent) reduction in current rates, must be supported by evidence of studentship signed by the head of the college, school or university faculty. A standard Student Membership costs £43.20, a Student Plus Membership costs £55.70 (UK only). Please note that new memberships take about four weeks from receipt of order to become effective. Cancelled memberships will be subject to a charge of 25% (twenty-five per cent) of the full membership price or £7.50, whichever is the higher, plus the cost of any issues already dispatched. Subsciptions cannot be cancelled after they have run for six months or more. January 2012 ELEKTO SHOWCASE NEW: ELEKTOR PREFERRED SUPPLIERS • now on www.elektor.com 365 days per year preferred suppliers online with up to date and relevant information, To become a preferred supplier contact Johan Dijk by j.dijk@elektor.com COAST ELECTRONICS www.coastelect.com Our site links to our E-Shop for Components, Gas Analyzers, Industrial parts, Kits, PICs, Development tools, Valves, Pneumatics, Short-range radio, REPRAP, LED lighting. ...and more. We offer contract design, programming, PCB layout. LCD Displays 2 line x 16 character LCD’s with Backlight £4.00 each + p&p 4 line x 16 character LCD’s with Backlight £3.50 each + p&p www.cstech.co.uk/elektor EASYSYNC LTD. www.easysync-ltd.com/ Supplier of communications and instrumentation products with specialist expertise in serial connectivity solutions based on USB, CAN and RS232/RS422/ RS485 interfaces. • USB to Serial RS232/RS422/RS485 converter cables. • CANbus solutions • Ethernet to Serial Adapters or to USB hubs. • USB based Logic Analysers, Oscilloscopes & Data Loggers. • OEM & ODM design services. ELNEC www.elnec.com Europe’s leading device N programmers manufacturer: • reliable HW: 3 years warranty for most programmers • support over 69.000 devices • free SW updates • SW release: few times a week • excellent technical support: Algorithms On Request, On Demand SW • all products at stock / fast delivery First Technology Transfer Ltd . FIRST TECHNOLOGY TRANSFER LTD. http://www.ftt.co.uk • Training and Consulting for IT, Embedded and Real Time Systems • Assembler, C, C++ (all levels) • 8, 16 and 32 bit microcontrollers • Microchip, ARM, Renesas,TI, Freescale • CMX, uCOSII, FreeRTOS, Linux operating systems • Ethernet, CAN, USB, TCP/IP, Zigbee, Bluetooth programming FLEXIPANEL LTD www.flexipanel.com TEAclippers - the smallest PIC programmers in the world, from £20 each: • Per-copy firmware sales • Firmware programming & archiving • In-the-field firmware updates • Protection from design theft by subcontractors FUTURE TECHNOLOGY DEVICES INTERNATIONAL LTD. www.ftdichip.com FTDI specialise in USB silicon, hardware and software solutions. • USB WHQL complaint drivers. • USB host and slave solutions. • Free firmware development tools. • USB IC’s, modules, cables and turnkey custom solutions. ^ • World renowned FOC application support. USB MADE EASY HEXWAX LTD www.hexwax.com World leaders in Driver-Free USB ICs: • USB-UART/SPI/I2C bridges • TEAleaf-USB authentication dongles • expandlO-USB I/O USB expander • USB-FileSys flash drive with SPI interface • USB-DAQ data logging flash drive THE NEXTb GENERATION OF u- MAXSONAR The HRLV - MaxSonar Sensors •Amazing One-Millimeter Resolution •Simultaneous Multiple Sensor Operation •Superior Noise Rejection •Target Size Compensation for Accuracy •Temperature Compensation ($4.95) •Outputs now include TTL Serial $3495 (msrp) f www.MaxBotix.com Great Value in TEST & MEASUREMENT ROBOT ELECTRONICS http://www.robot-electronics.co.uk Advanced Sensors and Electronics for Robotics • Ultrasonic Range Finders • Compass modules • Infra-Red Thermal sensors • Motor Controllers • Vision Systems • Wireless Telemetry Links • Embedded Controllers — IS* - — fy 1 u _ : .* = ROBOTIQ http ://www. robotiq .co . u k Build your own Robot! Fun for the whole family! Now, available in time for X-mas • Arduino Starter Kits *NEW!!* • Lego NXT Mindstorms • Affordable Embedded Linux Boards • Vex Robotics (kits and components) • POB Robots (kits and components) email: sales@robotiq.co.uk Tel: 020 8669 0769 www. elektor. com 146 Elektor 7/8-2012 products and services directory TYDER >P '° rDSf ‘ http://www.tyder.com • ONEoverT Digital Filter Design Software (Full version for only £30) • Design FIRs, HRs, NCOs, FFTs for DSPs and FPGAs _ • VHDL Code Generators • Makes DSP design simple • Download demos from website ELEKTOR Preferred Suppliers Coast Electronics • CS Technology • Easysync • Elnec • FTDI Chip • Robot Electronics • Surf to www.elektor.com 365 days per year preferred suppliers online with up to date and relevant information. Take out a free subscription to Elektor Weekly Do you want to stay up to date with electronics and information technology? Always looking for useful hints, tips and interesting offers? Subscribe now to Elektor Weekly, the free Elektor Newsletter. Your benefits: * The latest news on electronics in your own mailbox each Friday » Free access to the News Archive on the Elektor website lh You’re authorized to post replies and new topics in our forum 0 vireekly fcijurlnsr^hpwllh ■ iiuniU L*. fir ikUbi Awn Hiiur -uHtiiiu a. I s Hj-hH •MPM Wrwi-# ri i « •. r-» »>■ -*“H -ir+- r -* JHW 1 IfcS M - r H |- p — y -T -rairi la iHi ■ i ■ ■ ■ r« :Hn waii I.M^ naia^i l kn Register today on www.elektor.com/newsletter Fascinated by technology’s impact on the future? Check out Tech the Future! r Computing power and global interconnectivity are pushing tech innovation into overdrive. Pioneering technologies and creative workarounds affect even the couch potato 24/7. Tech the Future reports on technology strides that shape the future — yours included. w : 'tJcv wsawrr it™ www.techthefuture.com Follow Tech the Future Elektor 7/8-2012 147 ROUTE t w. . i • WITH PROTEUS PCB DESIGN Our completely new manual router makes placing tracks quick and intuitive. During track placement the route will follow the mouse wherever possible and will intelligently move around obstacles while obeying the design rules. All versions of Proteus also include an integrated world class shape based auto-router as standard. PRQTEUS DESIGN SUITE Features: ■ Hardware Accelerated Performance. ■ ■ Unique Thru-View™ Board Transparency. ■ ■ Over 35k Schematic & PCB library parts. ■ ■ Integrated Shape Based Auto-router. ■ ■ Flexible Design Rule Management. ■ ■ Polygonal and Split Power Plane Support. ■ Board Autoplacement & Gateswap Optimiser. Direct CADCAM, ODB++, IDF & PDF Output. Integrated 3D Viewer with 3DS and DXF export. Mixed Mode SPICE Simulation Engine. Co-Simulation of PIC, AVR, 8051 and ARM7. Direct Technical Support at no additional cost. Prices start from just £150 exc. VAT & delivery Electronics Labcenter Electronics Ltd. 53-55 Main Street, Grassington, North Yorks. BD23 5AA. Registered in England 4692454 Tel: +44 (0)1756 753440, Email: info@labcenter.com Visit our website or phone 01756 753440 for more details