JUNE 2006 £3.80 i: fu jj j www.elektor-electronics.co.uk ' kl * > 1 9 770268 451128 for’06 microchi lectronics Tel: 01635 40347 fu: HlU c-rrutf: CHCLHl5Crvrwbcrr.lHn.cd.ut. Nuwbujy EBcCtnmics Ud rralfyncri ife**, *r wy™ "^ntHjrptks&mwiLC'yuk. dii ■ I.VrJ, v-f-.-; HKDfln,y-i ! .' • Alice .r.rtjV ipring 1 . ■Tjrwnr. \ i Tul ■ Lcrtw I ---> QJTs i llV ’■Urn SoflU ak-i ■^i.h ir I ■ . * **** Deutschland - Au&li'alien fGPHtfyl JAwWM SJad- jn FMrttiun ^ lSJNjn 05-n O0 h YIP H .lij-ptii i burnt- Pm I -L_ - 12 1 1 r iiiaiil^nip i ii I •■k-i* HH.1 Hill I Hill II I II I in n L j QUASAR electronics G4F frtiQQmi A nt Quasar Efieciromns Limited PQ Bos S935. Bishops Stertterd CM23 4YVP, United Kingdom Tel: 9870 246 1926 taemUHNC E-mail: 5a!es#quai4'retectTOnk:s.cpfii Web: www.OuasarElectrorties.Eom FectegtM PflckNifl Dpkfii (yp !o 2Kfl prowweigltS UK Standard Day Delivery - £3 95 UK Mainland Next Gay Delivery - £B && Europ* I ELI I - - ntet df World - £9 95 (up hr d 5Kg] Wt accEpL jI major owdiCj'd n-bil card*. Wake- ChiqLinJFO'i payable in Qiiawr EiKijprdce Pric« Include 17.5% VAT Cal I now for Mir FREE CATALOGUE with dvEa lh ot onr iM Wl*„ IMoJwrlm, rrttidulwc in d pubH£«tyE)fv*. Qfscaunte hirlfeuft quanlTtan. 0871 CREDIT CARD SALES 717 Male# Olivers Contiollars Here are just a few of our controller and driver modules tor AC, DC. unipdlar.bipdi.ir stepper motors and servo motors. See website for full details Contnlsrs A Lofftn Here are just a few of (tie controller and: dai a acquisition and control units we l ave. Se-E vrebSite Tor full details Suitable PSU fnr all units Order Cade PSLJ3M5 £3 3 E- NiffT 1 .Bidirectional DC Motor Controller Of control IS Tram Fully Controls the speed of most common DC molars frated up to 3£wc£A) m boui the forward and reverse direction The rand* FF to fully ON in both dlreCttOfi* The directs and speed are con- trolled using i single potentiometer Screw terminal block for connections Kii Order Code: 31 66KI - E15.9E Assembled Order Cede: A S3 100 - E29.85 DC Motor Speed Coni roller (9A ! 1O0V| CorMrol (he speed of almost any common DC molor rated up to lOGVi'SA Puteewksm modulation output for maximum motor tonque at all speeds Supply 5*1 SVdc Box supplied DimensKjns (mm): 6GWx1 0GU6GH, K# Order Code:: 3067KT - £12.95 Assembled Ordof Code: AS3G67 - £29.96 *> n> PC f Standalone Unipolar Supper Motor Du yet Drives any S s 6 er $-tead unipolar stepper meter riled up to 6 Amps max Provides speed and dinse- tw3rt GdfUToi . Cp& dio® In stand-alone or PC- confrolted mode Up to six 3179 driver beards can be connected to a single paiaiiel port Supply: SVdc PCS BQxSOmm KH Order Code 3179KT El 1.H Assembled Order Code- A 331 T9 ^ El » r » ■ rt Bi -Polar Slipper Motor Driver Dove any bipolar stepper motor using externally sup- plied 5V levels for stepping arid direction oofifru! the#e usually come from software running on a computer. Supply B-30Vdc PCS 75xS5mm KM Order Code 315»KT - E 14. 9 5 Assembled Order Cede: AS31W- £29 95 Most Items are available in kit form fKT Suffix] or assemblid and: ready for use |AS prefix). Rolling Code 4-Channd UHF Remote Slate-eMhe-Art High security, 4 channels. Momentary or latching relay output Range Up to 40m Up to 1 5 tu’s can be learnt by one Rx (kit in- cludes one Ta bul more avail- able separately) 4 Indicator LED s R* PC0 r?xe5rrrm. 12Vdc/@mA (standby). Two end Tm charms/ veraions a/so avatfebte KM Order Code 3T80KT * £39. 96 Assembled Order Cod^ A S3 ISO - EM 7 . 95 Computer Temperature Data Logger 4-chann#l temperature jog- ger for serial port P C or S F Continuously logs up to 4 separate sensors located 200m+ from board Wide range of free software appir- cations Tor storing‘ii5Jng data PCG |ust 3Bx36mm Powered by PC Includes one DS1820 sensor and four header cables. Kfl Order Code 314GKT - £17.95 Assembled Order Code: AS31 4S - £23. 96 Addllional DS 1B2Q Sensors - E3.95 each ***' DTMf Telephone Relay Switcher Call your phone number using a DTMF phone from anywhere m the world and remotely turn on- oft any of I he 4 relays as desired User settable Security Password, Anti- Tamper, Rings to Answer, Alto Hang-up and Lookout Indudes plague case,. Not L3 T ap- proved. l3DKl1Cbt30mm. Power; 12Vdc P til Order Code 31 4QKT - EMM, 95 Assembled Order Code AS31 40 - £94.95 Serial Isolated TO Module Computer controlled 8- channel relay board Sa. mains rated relay puiputs 4 isolated digilal inputs. Useful m a variety of control and sensing a^plKallons CorMraliled via senal pwi fgr programming (using our new Win- dows interface K terminal emulator or batch files), Includes plastic case I30xl00x30inm Power Supply l2¥dc/$D0rnA KH Order Code 3T0BKT - E54,9E Assembled Order Code A S3 1 08 - £94.95 infrared RC Relay Board Individually cannot 12 on- tward neteys with mcluded infrared remote control unit Toggle or momentary. T5m+ range 1 1 2*l 22mfn Supply 1 2Vdc a 5 A Kit Order Code: 3142KT - £42.95 Assembled. Order Code: AS3f 42 - £52.95 PIC & AT MEL Pk^ w hiw We have a wide range of low cost PIC and ATMEL Programmers. Complete tenge and documentation available from ouf web site Programmer A c emssoriesr 40 -pm Wide IFF socket i2IF4tiW) £15.00 IGVrtc Power supply (PSU019) E19.S5 Leads: Parallel (L DC 06) £4.95 / Serial (LDC441) £4.35 / USB (LDC944) £2.96 8M*» USB All-Fla&tr PIC Programmer USB PIC prOgremFiief fur ill Fiflsh' devices No external power supply making i truly portable Suppired wnh box and Window Software 2 IF Sockel and USB Plug A^B fead nol incl As-^-ntiled Order Code: AS312B ^ £39.95 PIC ALL" PIC Programmer "PiCALL" wit program virtu- ally alt 3 to 40 pin sorted mode" AND pjfatfef-mode (P1C1 6CSx fa mily)* pio- grammed PIC micro controF lens Free fully functional software. Blank Chip auto deted for super fast bulk programming P a ral la I port connection Supply 1 6- 1 8 Vdc Assembled Order Code ASSl 17 - £24.95 AT MEL S9hjlxi Progranimei Uhs serial porl and any standard terminai cgmms program. 4 LED's display tbe states ZlF sockets not included Supply IB- 10 VdC Kr| Cider Code- 3123 KT - £ 24,85 USB 3 Serial Pont PIC Programmer LF$€JSertal conneefron Header cable for ICSP, Free Wndovis software Wide range of sup- ?d PlCs - see website for T complete hating ZtF Socket'U SB Plug A-B lead not incl*. Supply: 13-1 3Vde Kil Order Code 1 31 4GEKT- £37,94 Assembled Order Code: A£3t4BE - £52.95 MikroEtaktronika MICROCONTROLLER DEVELOPMENT TOOLS HCniicru Easy ^ 3 plCmicro Starter Pack £99.00 4 Kjuylily di)vuk»pirtviTfl I.KMiU 4 OuilMn USB 2. ft programmer * Winctawa9a^i , ?00(J.^P oompatfele - SUppoflg 8. 14. 18. 26 and 4flpm DIP niKiioci5fiirDii^i^rforntnenpf. 12#-. 16 F and 18 F P ICmicro Families « Qn-befltf'd le d*. switch®, 7- segment displays- polemiomelm RS-23E mis riaoe USB and PS 2 come do is * AM I'D lines Available lor expansion 4 Ea&yPlC3 Slide-1 Pack ihcHrd**: - PtCiaF452 microcontroller < 16x2 characlar LCD ■■' 126*64 pixel graph*; LCD ^ DG1S320 Eomporalurt terser J USB pf-ogramminqi power load *' Programming software and examples Easy sPIC2 dsPIC Starter Pack £9900 * Hgh qiMhty dwekHmwl bowd 4 Built-in USB 2.0 progiammer * Windows Ha*MEt!200a:>EF' J comp/ilibla * Support 18. 28 and 40-pm Dip tkqdal cMiro«eni Irqm cfePlC30 fanny 4- QrhtKwudLED*. switches. peiertti omfllfitf* Rs-232 inferlae#. PS^E and ICD;-? conoedoiE, a nd MMC-SD card Biol * All ID Unas available lor expq Soil waiu and samples BIG' 3 80-pin PlCmicro Starter Pack £119.00 V ' ■■.■ t. ■ ■ - JL - >. ■ - •-«.- ' * High quality cfcrvefcpnwnt board ■ BuiR-n USB 2,0 p logrummar ■ Window* ®t'M£ i'2000/XP- compatfclfl * Supports Ihfl 1316*1 SQ-pln tifl4»W iFdrn |he 18f PlCnucro lamily * Cn board LEDs, *w4ch«s. poRonti- orhfllbl^, Iwn FIS 232 !rH 0 ifflCfl&, PS-2 connedor, and MMC'SD and Corn- pad Flash caid dots ■ Alt ID lines available tor expansion ■ BKJPIC3 Slartar Pit*, UndudR: ^ PtClsFB52D MCU module i 1 5x2 charade r LCD J 126X84 pixel graphic LCD * DSl852flterhpemlur6 mmtu ■ USB programming.'power lead ■' Pragrammng softwaie and examples IsPK PRO 64/80-pin dsPIC Starter Pack £14900 * High Quality devflidprne m tenid * BuiH in USB 2.0 progiarnniei * Windf'jws- 93 HI ?itO" XI 1 compair.’lo ■ Suppofl* 64 JWKl W-piri chgMal SKjnif 11 tfinlmlEflr& trnm the d*PlC?b limtly - Orhbowd LCD*. * wile he*, iwe Fts 232 inlarlaew. fiS-485 menace 1WO CAN interfaces, real- time dock 12-bfl AD and DA and C F card skn ■ All 1*0 bnas available lor axpanston 4 rfcPICPF&O srortflf PmM mciludw: dsFIC30F6D14 DSC module *' 16x2 character LCD r 128x64 pixel graphic LCD - DS18S20 Iflmfflrsturfl Sfln&5r k' USB pforjramniiingfjciwfir lead ■■■ Programming software and examples- BIG M i 64-pin AVR Starter Pack £119.00 « High q*. :-.lil y davalopmarrl boaid ■ Suit- m USB J.&piogrsmmflr ■ Wndows Sfl-'ME *2806 XP compalbla « ^uppoils 64 -pin AVR m ic rocord rotters ■ Qn-b04td LED*. tWflCNSt, pfltfllllp- flPMrtett, l wo FiS-232 iintflrlncflt. ps-? Cfjfinflddr am MHCi^D and Coni- pad Flash card slots -■ All LD Rnas available loi expansion - Si^AVFt Siader Padc indutfw: * ATffl*gal2&MCU mflduto 16x2 diarader LCD 128x64 pixel graphic LCD osi8S20tflmi>tiF3tute sof *■' U$8 pfbgfamruwi^powflf l&sd « Programming! software and examples PSoC Starter Pack £119.00 » High quaMy baufllqpmerK board * Birfl ‘Hi USB 2,8 prcpniim«f ■■ WmxIowe W campalibUe * Supports B, 20, ?i and 4fl-pm DIP PSoC mixfld sAjnfli'Mntrollfli* * Dn-board LEDfi SMrtche*. polenli- emetofs. RS-232 IfMitooa, R^-485 mlarTace. CAM pttariace. real-time dock, and MMCiBD and CF card slots r An ID lines available lor expansion ■ Ea*yP$oC3$lartflrPflcif includes v 45 pm PSoC mrcroooniroler * 1 6x2 character LCD ^ 126x84 pfXat graphic LCD v DS 1 8 S 26 lempflrfliiKfl 4 USB programming-power lead ^ Piogr3mnnng *Oltwaae ^hd examples ^readboarcung System* ean supply al MikroE tettrarnkfi prcwhicfcs frem, ntocR cradfl and *bfl tards accepi&d Pnee* shewn extf nde daiivflry and VAI Bread boarding Systems Software and hardware development tools Tel: 0845 226 9451 Web i www.b read boardi ng .co.uk w **Y Mil I- tawi l-,w ELECTRONIC ► Ihe [Qnticl^ss (h-p can [■‘Itegrabefi info cirher t*< kw p*$« $r tht di'i p|qt mifare nsceive Principle lot i 1 INSFLGY - - ■ MILLiRnHiiHf DATA - - - LDfeD modi, i.ilrd DATA ■ -> WIZ-C for the PIC - Rapid Application Development in C NOW available with USB Development System USB development Support * Add on library provides point and click CDC support to WIZ-C * installs as a virtual com pen - access easily from C, Visual BASIC, Hypcrterminal eEc, + Development board (pictured) based on 18F2550 supplied with bootloader and sample application * See website Tor details WIZ-C “ ANSI Compiler and Rapid Application Development in C * WIZ-C is more than a C Compiler for the PIC - it i$ a complete development environment with rapid access to fibrary components with point and click set up, ■ Ideal for beginners, includes full tutorial manuals and an introductory manual to I he C language, * Syntax highlighting editor, * Full ANSI C Compiler ■ Large libraries included for displays, ports, data iransfer, keypads, graphics, bootloader and C standard functions, * Extensive simulation capabilities- very rapid program execution, includes simulation of LCD. LED' switches, I2C, RS232 terminals etc. fnspecl C variables in C formal * Logic analyser can display waveforms of FIC pans and internal registers simplifying debugging. » Includes assembler to allow you to develop assembler projects In their own right, or as part of C projects * LITE version supports the most popular FIC devices - academic users may choose these lypes. * UK written and supported. * Priced from ESS.OQ We accept major credit cards and Switch. Order securely from our site wwvy.fored.co.uk or contact us by phone or fax on 01 590-68151 1 . email inf o@fored .co.uk , Forest Electronic Developments, 12 Buldowne Walk, Sway, Lymington Hampshire, SG4T 6 DU www.fored.co.uk info@fored.co.uk PicoSccpe 3000 Series PC Oscilloscopes- The PicaScopL 1 3000 scries Q5 cilia scopes arc the latest offerings from the market lender in PC cscuil&s copes conn biding high bondwidths with hirst buffer mcmariet. Using the latest advances in elect-mini cs, the oscilloscope?. connect tn the USB pert of any modern PC, rooking lull use of the PCs' processing capabilities, large screens and familiar graphical user interfaces. • High performance: 10-GS * wattling rate & L 5 C J M HI z bandwidth ■ 1MB buffer mernpvy * High speed USB 2.Q interface * Advanced display £ trigger modes ■ Compact £ portable 4 Supplied with PicoSccpe & Pica Log software Tel: 01480 396395 www. pi cotech .com/ scope346 aout-iF lrateEn.MJ i mi !b>^i #■! I 1 '■ 7 L ti5 Enti* - Sl* in Lk ^DlhI.b U * ■ F'.Mlii 7SLHTI I-XMlir kchii 7 l t iL trq|V lap hi * - I ^ EPrflldr Tt-H |H l*’SCl -TV Cl !■ MH| 1 jc. In li ifV. . Whi CJ ■« IOCIMHj- y*rii ^ litK>ipVh« ±2U¥ US BPC ILrifti ’ Li ■ Iiotrt Technology Limited Tel. 01293 70012 >Fwi# i ■ A 11 * Ml* Tin .If “na1 Adfaplers available anywhere We o#er converter tAftl**. ■mul ti p «t lAdoturv ilyle mod-el* in itiildl And pl-AthL, 4hGo farlh mount pmlf with integral fSU puth am I ha USB I&CC3M BW Srrtal InEertacKE iuppcrEed include HSU- 2.. ftS42I acd K5?4Hj We alia supply Opte^MlAUd A! 54 J 2 And RS485 vttrfton* fdt f«!(lM« dJ*l*rK6 ro n* n'lijir? i-raf hp-n-a. All our IJSfi Serial priodurts air hated an the premium chipsets and drivers Iran FlOI Chip lor superior c □ mps-Eibilil* per fur hi# he# and Eechti k.#l *upirurt At rS'ii Window*! M AC - OS* CF ami Linus platforms. netcom-813 £350 ESW‘3001 M £125QD I Po rt Industrial Ethernet R3232 / RS422 / N5485 Swill falW T with wall motwH bracket and ■Single Part high liidvBhll WEilltff EthAifWi ■ 5132 / A 5-4 32 / B 54=3 5 S4Fl#f Server with PS If end welt mount brachat, Soonfiflt wited Hh. Ethernet and Wi Fi 802 1 f b g RS232 422.485 Serial Servers Rv i 1 J u * * is <1* m. . L \ ^ yPCl Serial Cards from £15 | uPCl 1001 ) OlAcdver our -pfdll value Tdt mb rtty rAdge fi-P ihultt-pdri uPO AdriAl cards juppilHingi IngiWi aa« Id eight pprtti t h# rpng* uni I y dtp ■5332 J ftS+2 2 r RSdAB and opto isolated versions. Our 4 pn-rt end IF port models can conned Sh rough talvrn-nl allies dr She inndvASive wet m Burning COM BOX On* Id * 14 hit port indue! rial strenglh EChemel and Wlrele-sc ethem>El serial KS‘2J-l/IIB422/R.i>A-S§ BervEra. Connect Ed your se-rrei device te«yidte!y ovir yout n*lwofh # ilhitPtt et via the intMMt. Ba«ed on ihe 12 bit ARM CPU Ehear ftyalem-s. aMer pnwerfui w-riaP cDPnerE'vIv arid m wnolfBi dl feaiures. WLAM models comply with l€Ef @D2,13b/fF r irmn. 54 Mb/c- And alto ol^et a- 10/ LOOM bp* iNondafy etherneE ronurrhan All mnceKconie rompl-pfe with PBLI Rrkea s-EarE At duly liS Utf $ NetCOM 111 ] ; EasySync Ltd 373 Scot Id nd Strfrtt Gldiguw G5 HQ0 U K. Tel; 444 ( i4i) 4ii-ai5L Wmnt +44 {14|) 415-0110 Web ; titt|>“//www ! eas¥svfic H c.o yk E-Mii il: sal es #ea sys yn c to . u k * pneej mown carnage arid VAT whm Applicable I I I I I I I I SgSSBI ■tow CX 5 O cd cd cd cd cd cd CD CD CD CD CD CD CD CD oo §3 o □ CD CD CD O CD CD w *--* OG OX) ~ ~ CD O O 0 □o oo;: o O o CD O cdo oo;; CD CO £3 O * 8 O KD 01 Number One Systems for Windows Lichfield Electronics 6/2006 - elektor electronics 47 Help! The network is down! What's wrong? Is it the cable? The NIC? The patches? The plugs? A gremlin in the patch bay? Cable and connector faults are relatively common and this simple tester will help you find the culprit in no time. The tester is suitable for Gigabit, 1 OBASE-T and 1 OOBASE-T cables, with the ability to check Gigabit crosswire cables, too. The initial purpose of this circuit design was to implement a simple Gigabit cable tester that supports both straight-through and crossover UTP/STP cables with the ability of selecting which pair(s) to test and detecting the defective pair(s) if any. Each pair is represented by an LED that flashes whenever the corresponding pair is properly connected; otherwise it remains off. A switch selects between straight-through and crossover (a.k.a. crosslink) modes and a pushbutton initiates the testing process. Once done the systems goes to sleep. As the design evolved, it was realized that Gigabit cables are really no more than a logical follow-up to the earlier 10BASE-T and 100BASE-T standards, so provision was made to test these ‘slower’ cables too. However, 10BASE-T / 100 BASE-T crosslink cables can not be tested. Because it has to be used in less accessible places like a patch bay of large network, the little instrument is portable and pow- ered by a 9-V battery. The tester needs to be connected to the RJ45 plugs at either end of the cable under test and performs a simple continuity test using a pulse transmitted over wire pairs in the cable under suspicion. Sure, a continuity test is also possible with an ohmmeter or similar but then those thin con- elektor electronics - 6/2006 Majdi Richa Figure 2. Circuit diagram of the Cable Tester for 1 0/1 OOBASE-T and Gigabit Cables. nector contacts on an RJ45 plug are difficult to reach individually with a test probe. Also, you have to do a lot of counting up and down the contact row to positively identify a contact number — twice over so you soon wish you had two pairs of eyes, infrared vision and three hands. A nice job for a micro- controller. The cable standards Computer network cable can be sup- plied off the reel, cut to length and fit- ted with press-on RJ45 connectors. That’ how most professionals do their cable installation work in large offices. Most home users however will buy standard lengths of these cables (usu- ally CAT-5) with the connectors ready fitted. CAT-5 cable has eight wires and is suitable for data speeds up to 100 Mbit/s. Inside the cable the eight wires are organized as four pairs of two (usually twisted) wires. The wire colours are usually, but not always, to the U.S. T568B standard. A crosslink or ‘patch’ cable is only required between two computers that have to talk to each other directly, or between two telecom-related equip- ments with the same functionality. Crosslink cables are rarely seen in lengths greater than 5 m or so. They may be compared to the ‘zero-modem cable’ for the now slightly antiquated RS232 standard. In the traditional star- like configuration with several PCs connected to a common router, straight-through network cable is used and this by far the commonly seen. For reference purposes, Figure 1 shows an overview of commonly found cables of the straight-through and crosslink variety. All employ the RJ45 connector, which is shown along with the pin order on the plug. Note that the colour coding is not obligatory and that our tester is not compatible with 10/100BASE-T crosslink cables. Practical circuit The circuit diagram of the Cable Tester is given in Figure 1. A PIC 16F874 with machine code ticking inside is reading the configuration set on DIP switch SI, as well as the status of pushbutton S2 and mode switch S3. In response to all this user input, it generates pulses to travel over the wire pairs connected between RJ45 sockets K1 and I<2 to which the cable under test is con- nected. The PIC of course checks the arrival of the pulse and acts accord- ingly by making an LED light if the wire pair is okay for continuity. No dynamic test is performed on the cable. For reference, Table 1 shows the 6/2006 - elektor electronics 49 HANDS-ON TEST & MEASUREMENT relation between the connector and PIC pins for a Gigabit crosslink cable. The circuit has a conventional 5-volt power supply based on a 7805 voltage regulator complete with its usual decoupling capacitors — there’s C2 and C3 to combat high-frequency noise and C2 to keep low-frequency ripple to a minimum and improve the general stability. Pull-up resistors R1-R4 keep the RA0-RA3 inputs of the PIC at a default level of +5 V. The same goes for R9 and RIO for the RBO and RBI inputs connected to S2 and S3 respectively. The PIC oscillator section ticks at 4 MHz using ceramic resonator XI as the external frequency determining element. The PIC is capable of driving LEDs D2- D5 directly using 1-kW current limiting resistors. Low-current LEDs have to be used, though. Software Less hardware means cleverer soft- ware. The object code to run in the PIC was written in the C language and compiled using the CCS C compiler (www.CCSinfo.com). The software was coded using an interrupt-based technique, i.e. , the processor remains in sleep mode (reduced power con- sumption). It is woken up by a logic Low on the RBO/INT line (refer back to Figure 1). The interrupt service routine initiates the testing process depending on cable type defined by the setting of switch S3. If the designated wire pair is OK, the corresponding LED will blink for a short time. Table 2 shows an overview of functions implemented in the software, along with short descriptions. Both the PIC source code and hex object code files are available free of charge from our website as archive file 050302-11. zip. These files allow read- ers with suitable assemblers/compil- ers and programmers to burn their own PIC for the project. As a bonus, the 050302-11. zip archive also contains files you can use to simulate the circuit using Proteus. [A section of] the C pro- gram listing is shown in Figure 3. Those without access to PIC program- ming tools can buy the programmed controller from the Publishers, the order code is 050302-41. Construction The design for the printed circuit board is shown in Figure 4. The board is sin- gle-sided with generous copper pour areas as a ground plane helping to keep stray radiation to a minimum. As only through-hole components are involved, construction is a doddle pro- vided you are in the clear regarding your choice of the enclosure for the tester as that will determine the height at which the DIP switch, LEDs and pushbutton are fitted above the board surface. Do not make the mistake of fit- ting these parts as close as possible to the board surface and only then start- ing to look for a suitable enclosure — you’ll find that you have to remove and refit the relevant parts one by one which is a waste of time, not even mentioning the danger of damaging the board. We recommend using a good quality socket in position IC1 as it will hold the valuable PIC micro. Finally, there’s four wire links which must not be overlooked while populat- ing the board. Practical use On power-up, the LEDs blink once sequentially. Connect the cable to the Table 1 . Gigabit crosslink cable connections K2 pins K1 pins IC1 pins 1—2 — > 3—6 15— 17 — > 27—28 3—6 — » 1—2 23—24 — > 19—21 4—5 — > 7—8 25—26 — > 22—20 7—8 — > 4—5 18—16 — > 29—30 50 elektor electronics - 6/2006 Table 2. Main functions in microcontroller program Function Parameter(s) Description & returned value inti TestSTPair(int8 p) An 8-bit number representing the wire pair to test Function takes the wire pair number of a straight-through cable and returns 1 (Boolean) if OK void TestSTCable () None Void function that scans and tests all selected wire pairs of a straight-through cable using the above mentioned function inti TestCOPair(int8 p) An 8-bit number representing the wire pair to test Function takes the wire pair number of a crosslink cable and returns 1 if OK void TestCOCable() None Void function that scans and tests all selected wire pairs of a crosslink cable using the above mentioned function void EXT_isr() None External Interrupt service routine that initi- ates the testing process according to the selected cable mode void main() None Main function of the software. It holds all initializations, port directions and inter- rupt enabling Figure 3. Part of the C program written for the project. Also useful for the PIC fuse settings. ////////////////////////////////////////////////////////////////////////////// void TestSTCable ( ) // Test straight-through cable { int8 pair; PORTD = 0; PORTB = 0; for (pair = 0; pair < 4; pair++) // scan pairs { if (TestSTPair (pair ) && bit_test ( PORTA, pair ) ) // selected & connected? bit_set( PORTB, pair+4 ) ; // turn on LED delay_ms ( 500 ) ; // wait a bit PORTB = 0; > } ////////////////////////////////////////////////////////////////////////////// inti TestCOPair ( int8 p) // Test crossover pair p { switch (p) { case 0: bit_set ( PORTD, 0 ) ; if ( !bit_test(PORTC,4) ) return 0 ; bit_clear ( PORTD , 0 ) ; if ( bit_test ( PORTC , 4 ) ) return 0 ; bit_set ( PORTD , 2 ) ; if ( !bit_test(PORTC,5) ) return 0 ; bit_clear ( PORTD , 2 ) ; if ( bit_test ( PORTC , 5 ) ) return 0 ; break; case 1: bit_set ( PORTD, 4 ) ; if ( !bit_test( PORTC, 0 ) ) return 0 ; bit_clear ( PORTD, 4 ) ; if ( bit_test( PORTC, 0 ) ) return 0 ; bit_set ( PORTD , 5 ) ; if (ibit test (PORTC, 2 ) ) // test High // test Low // test High // test Low // test High // test Low // test High 6/2006 - elektor electronics 51 HANDS-ON TEST & MEASUREMENT \ COMPONENTS ] : list : Resistors R1 / R2 / R3 / R4 / R9 / R1 0 = lOkW R5,R6,R7,R8 = lkW Capacitors Cl = lOmF 63V radial C2 = 1 mF MKT lead pitch5 or 7.5mm C3 = lOOnF Semiconductors D1 =1 N4001 02,03,04,05 = LED, red, low current IC1 = PIC 1 6F874-20/P, programmed, order code 050302-41 * IC2 = 7805 Miscellaneous XI = 4MHz 3-pin ceramic resonator K1,K2 = PCB mount RJ-45 socket, Molex # 95009-2881 (Farnell # 257102) 51 = 4-way DIP switch 52 = pushbutton with tactile feedback, 1 make contact, footprint 6x6mm 53 = switch, on/off, 1 make contact, chassis mount BT1 = 9V battery with holder (and optionally an on/off switch) 4 wire links PCB, order code 050302-1* * see Elektor SHOP pages or www.elektor-electronics.co.uk Figure 4. Copper track layout and component mounting plan of the PCB deigned for the network cable tester. instrument and use the DIP switch to select the wire pairs you do not want to test (the selection is inverse). Next, select between straight-through and cros swire mode (the latter for Gigabit cables only) and then press the TEST ONCE button. If the pair passes the test, the associated LED will light. If not, the LED remains off. Simple but very useful! To prevent the battery being drained when the instrument is not is use, it should be disconnected by removing the clip-on lead. Alternatively, wire an on/off switch into the +9-V line. The current consumption during standby is about 5 mA, while 10 mA is briefly drawn when pulses are being trans- mitted across the cable. Note that on (old) 10BASE-T cables not all wire pairs may be present or con- nected to pins as only two are required functionally. These cables are now rare and should not be used for new installations. ( 050302 - 1 ) Majdi Richa - myr@cyberia.net. lb Further reading 1 . Gigabit Crossover Cable, Elektor Electronics July/August 2005, 2. Home Network for ADSL, Elektor Electronics July/August 2004. (both articles available as downloads from our website) 52 elektor electronics - 6/2006 E-blocks Easy AVR Kit Quick start to Atmel AVR microprocessor programming AVR Kit i This kit is a complete solution for learning C programming for AVR microcontrollers, and for AVR microcontroller project work. The E-blocks Easy AVR Kit contains everything you need to program AVR microcontrollers and develop real-life applications. To help you learn C programming for the AVR the kit includes a CD-ROM ( ‘C for AVR Microcontrollers’) with a complete HTML course in C program- ming, an Integrated Development Environment (AVR studio), and a full unrestricted C compiler. The CD-ROM course includes unique simu- lations of the AVR microcontroller running C code which are designed to make it easier to learn C programming. The hardware is based on E-blocks and an AVR Multiprogrammer board, LED board, Switch board and 2 line 16 character LCD board are included. An ISP programmer, also included, connects the Multiprogrammer board to the serial port on your PC. The Multiprogrammer board C for AVR microcontrollers single user £118.00 E-blocks AVR multiprogrammer £ 77.65 E-blocks LED board £ 14.65 E-blocks LCD board £ 19.30 E-blocks Switch board £ 14.65 Total value: £ 244.25 \ 30 °/° L Special Offer: / £171.80 Learn more about E-blocks? For more information, visit www.elektor-electronics.co.uk/eblocks can program a selection of 20 and 40-pin AVR micros (90S1200, 90s2313, Tiny2313, Mega16L, Mega16, Mega32L , Mega32, Mega8535L, and Mega8535) and offers four full E-blocks connectors while all pins are also available on a 40-way connector. Ordering Use the order form at the back or go to www.elektor-electronics.co.uk E-blocks will be shipped after receipt of payment. Prices are exclusive of postage. e lektor lectronics HANDS-ON INSTRUMENTATION This small signal generator uses an ingenious technique to generate a sine wave with very low distortion, a mono (L+R) baseband signal and an FM stereo signal. Jo Becker (DJ8IL) n 11 This test signal generator is particu- larly notable not just because of its high precision, but also because of the original method it uses to produce its waveforms. The many features are listed in the ‘Output signals’ text box. Rather than using special-purpose ICs, whose exact internal workings would be hidden from view, this design just uses ordinary HCMOS logic. All audio-fre- quency signals are produced using binary counters and combinatorial logic from a crystal reference of 9.728 MHz. The audio output can be switched between the tone and the baseband sig- nal. It can deliver a maximum of 2 V pp from its relatively low impedance short- circuit proof output. The FM oscillator is free-running, but is very stable in fre- quency at around 100 MHz in the VHF FM broadcast band. The frequency can be adjusted over the FM band by chang- ing a capacitor value, and a trimmer offers fine adjustment over a range of ±300 kHz. The RF output level, at 12 mV eff into 50 Q, is more than ade- quate to drive a connected receiver and obtain its maximum signal-to-noise ratio. Digital sine wave The method used to generate the audio signal is particularly interesting. Figure 1 shows how a divider chain made from flip-flops and some exclu- sive- OR gates can be used to produce a quantised signal with the various con- tributions being summed in such a way that the third and fifth harmonics are both absent. Only the very weak harmonics from the seventh upwards need to be filtered out. This idea has the advantage that phase relation- ships, for example between the pilot tone (at 19 kHz) and the 38 kHz sub- carrier, remain precisely fixed. The required amplitude ratio of (1 + 2 1/2 ):1 appears in the circuit diagram (Fig- ure 2) as the resistance ratios R3:(R4+R5) and R6:(R7+R8). The seventh harmonic of the pilot tone 54 elektor electronics - 6/2006 Output signals • Sine wave test signal at 594 Hz with less than 0.06 % distortion for testing audio amplifiers; • Multiplex stereo (L and R) signal for measuring and minimising crosstalk; • Sum (L+R) signal for adjusting balance; • FM signal, modulated by the multiplex signal, for testing FM stereo receivers and wiring; • Audio/multiplex output impedance: 1 .8 k£2 to 3 k£2; • Audio/multiplex output level: maximum 2 Vp p ; • RF output impedance: 50 Q; • RF output level: 1 2 mV e ff into 50 Q. is at 133 kHz, above the third harmonic of the 38 kHz subcarrier at 114 kHz, and will surely not cause interference in a receiver. The 594 Hz audio test sig- nal (whose phase is not important) is filtered by C3 and the following active low-pass filter at a total of 18 dB per octave. This reduces the theoretical distortion level from 21 % to below 0.05 %. For comparison, if we had started with a square wave instead, the residual distortion would have been thirty times greater. In the Elek- tor Electronics laboratory we meas- ured a distortion of 0.055 % on the pro- totype with total harmonic distortion plus noise at -86 dB. The output ampli- tude can be altered by changing C3. The multiplex (MPX) signal For FM stereo transmissions the carrier is frequency modulated by the so- called multiplex signal, or MPX. The multiplex consists of three compo- nents: • the sum signal, L+R (the normal mono signal), from 30 Hz to 15 kHz; • the difference signal, L-R, which is modulated onto a 38 kHz subcar- rier (the subcarrier itself is sup- pressed); • the 19 kHz pilot tone. The three parts of the multiplex test signal can easily be generated. The 594 Hz audio tone directly gives us the mono signal. The 594 Hz signal, mod- ulated by the 38 kHz signal, would pro- duce either a pure left-channel or a pure right-channel signal, depending on the polarity of the 38 kHz signal with respect to the phase of the pilot tone, if the 38 kHz signal were a sine wave. However, the on-off modulation used is equivalent to multiplying by a square wave, and so the sidebands produced are correspondingly wider, and it is necessary to mix in a small amount of tone signal with the oppo- site phase to compensate. This is done using R14 and PI. IC5 serves as the switching modulator, the switching phase being determined by IC3.A (pin 3 of IC3) and IC2.B (pin 6 of IC2). At the summing point (pin 2 of IC4) the 19 kHz pilot tone is mixed in. The pilot can be removed from the multiplex by removing jumper JP1 to allow the mul- tiplex modulation to be checked using an oscilloscope. Unadjusted (with PI set to around 10 kkl) a channel separa- tion of around 35 dB to 40 dB is observed, which is adequate for most purposes. Using a TCA4500A as a test decoder for the stereo signal, a chan- nel separation of up to 50 dB has been a 76 kHz b 38 kHz 1 c 19 kHz a =/= b L F 2 c = — 71 ^ . sin+x sin5x smx + b K.. V 3 5 x = 2nf(c)-t J f sin5x sin5x sin7x 7 A J \ J Figure 1 . Waveforms and Fourier series of the signals in the quasi-digital sine wave generator. 6/2006 - elektor electronics 55 HANDS-ON INSTRUMENTATION Figure 2. Circuit diagram of the stereo test transmitter. The FM transmitter itself is the highlighted area around transistor Tl. The remainder of the circuit produces the modulating signals which are available at the audio output (via R15). An optional external modulating signal can be coupled in via C33 and R34. FM transmitter The FM stereo test transmitter consists of a signal generator that produces the baseband signals (test tone, pilot tone and multi- plex signal) and a small FM transmitter that is modulated by these baseband signals. The FM transmitter itself is shown in the highlighted part of the circuit diagram in Figure 2 and is built around a single-transistor oscillator circuit. If you wish to con- struct a mono FM transmitter, only this part of the circuit is required and the rest can be dispensed with (even R16 is no longer needed). The RC-network consisting of C33 and R34, shown dotted, allows an external modulating signal to be connected, which can be any audio frequency signal with a level of up to around 200 mV. This RC-network applies so-called pre-emphasis, which is necessary to emphasise higher frequencies for correct modulation according to national standards. In Europe an RC time constant of 50 jjs is used; in the USA 75 pis is used. This is easy to arrange: the resistor R17 is already given, and so simply use a value of just 33 nF for C33 (rather than 4.7 jjF) and we have a high-pass filter with the wanted time constant of 50 \js. To change the sensitivity of the modulation input we can adjust R34, although we then also need to change C33 so that R34 times C33 remains equal to 50 \js. A potentiometer (4.7 k£2 or 10 k £ 1 ) can also be fitted at the input. And be sure to observe the remarks at the end of the main article text before switching the oscillator on! 56 elektor electronics - 6/2006 Figure 3. The double-sided printed circuit board, whose holes are not plated through. obtained by adjusting PI: only 6 mV pp of crosstalk on a 2 V pp signal. C6 and C25 remove spikes from the tone and multiplex signal, and C6 also reduces the distortion in the residual crosstalk signal. Bits and pieces The printed circuit board (Figure 3) has a ground plane over the whole of the component side. Details of con- struction can be seen from the compo- nent mounting plan and from the pho- tograph of our final laboratory proto- type (Figure 4). The only coil (LI) should be mounted without a gap between it and the circuit board. The current consumption of the test transmitter is only 12 mA and so a 9 V alkaline PP 3-type battery should give several years of occasional use. The state of the battery is indicated by LED D6 using an original circuit which takes advantage of the voltage drop across the 5 V voltage regulator IC6 and which does not itself consume extra current. The LED lights as long as the voltage drop across the regula- tor is at least 2 V to 2.5 V. If the battery voltage falls to 7.5 V or 7 V, the LED will go out, indicating that the battery should be changed. The circuit will operate happily on voltages from 6.7 V to 12 V, over which range the oscillator frequency, if set to 98 MHz, will vary by about 100 Hz. Over a period of 10 min- utes the frequency should drift by no more than 1 kHz. For occasional laboratory use there is no need to put the circuit in an enclo- sure. To this end the connections for switches SI to S4 have been brought out to headers so that jumpers can be used instead of the switches. For the same reason potentiometer P2, which adjusts the signal level at the audio/multiplex output, is a trimmer mounted on the circuit board. A BNC connector for the FM output can be sol- dered directly to pins on the board (near R24). In other words, when the device is used without an enclosure, everything except the battery is securely attached to the board. When we built our prototype in the Elektor Electronics laboratory we sub- stituted ordinary radial electrolytics for the tantalum types specified by the author, without measurably impairing the performance of the circuit. It would therefore seem not essential to use tantalum types. As we have already mentioned, it is possible to adjust the oscillator fre- quency over the FM band by changing the value of C18. Of course, the fre- quency also depends on the induc- tance of coil LI and on the capacitance of varicap diodes D3 and D4. On our prototype board we used a value of 18 pF for C18 and found that we had to compress the coil somewhat to obtain an operating frequency of 102.7 MHz. The author used a value of 15 pF for C18 and obtained a frequency of slightly over 108 MHz. The difference may have been due to the fact that we used slightly thicker silver-plated wire (1.3 mm) for LI. As with most varicap diodes, the BB405 6/2006 - elektor electronics 57 HANDS-ON INSTRUMENTATION Figure 4. Our populated laboratory prototype board. is now hard to obtain new. This device varies in capaci tance from 2 pF (at 28 V) to 16 pF (at 1 V). At 3 V it has a typical capacitance of 11 pF and at 7 V about 6 pF. In the region of inter- est for our circuit, around 5 V, its capac- itance varies at about 1 pF/V. Among the alternatives given in the parts list is the BB208-03 in an SOD323 package, which is still in production, and the printed circuit board has been laid out so that this device can be fitted instead. The BB208-03 has a transfer slope of around 1.5 pF/V at 5 V, some 50 % higher than the BB405; the value of R17 must therefore be changed to 1 kfl so that the modulation level, determined by the ratio of R16 to R17, is correct. Also potentially hard to obtain is a quartz crystal with a frequency of 9.728 MHz, which is not a standard value. Custom crystals can be obtained from sources such as Euro- quartz (www.euroquartz. co.uk) in the UK or Andy Fleis- cher (www.andyquarz.de) in Ger- many. In view of the of the high cost of a one-off special frequency quartz crystal, readers wishing to build the project should definitely consider post- ing a topic in our online Forum to find fellow enthusiasts, place a larger order and get the crystal at a much lower price. The unit in operation The audio output can be switched between the multiplex signal and the 594 Hz sine wave test signal using S3. COMPONENTS LIST Resistors R1 = lkfl R2 = 1MO R3 = A70kO R4 = 1 SOkO R5 = 15k£2 R6 / R27= lOOkfl R7 = 39kO R8 = 2kOA (or 2k£X43 from E96 series) R9,R1 0,R25,R26,R28,R29 = 1 OkO R 1 1 = 5k£2l (or 5km 1 from E96 series) R1 2,R1 3 = 120kH R 1 4 = A7kO R1 5 = 1 kW8 R 1 6, R1 8 = 22kO R 1 7 = 1km R 1 9 = 330 R20 = 2km R21 = 4kf27 R22 = 630 R23 = 4700 R24 = 560 R30 = 5k£26 R31 = 33CK2 R32 = ]00O R33 = 3200. PI = 25k£2 preset P2 = 4k 07 preset Capacitors Cl = 47pF C2 = 56pF C3 = 22nF MKT, lead pitch 5mm 04,09,01 3 / C15 / C26-C30 / C32 = lOOnF ceramic, lead pitch 5mm C5,C10 = 47pF 6V3 tantalum or radial electrolytic 06, Cl 2 = 68pF 07 = 4nF7 MKT lead pitch 5mm C8,C16,C 17,021-025 = InF, lead pitch 5mm 011= 4|jF7 16V tantalum or radial electrolytic 014 = 220pF 10V radial Cl 8 = 1 8pF 019= lOOpF 020 = 22pF PTFE trimmer capacitor 03 1 = 4|jF7 16V radial Inductor LI = 6 turns 0.8mm ECW or CuAg, internal diameter 5mm Semiconductors D1 ,D2,D5 = 1N4148 D3,D4 = BB405 (alternatives: BB205, BB505, BB208-03) D6 = LED, red, low current T1 = BF199 101 = 74HC4060 102,103 = 74HC86 IC4 = TLC277 (TS922IN) 105 = 74HC4066 IC6 = 78L05 Miscellaneous: JP1 = 2-way pinheader w. jumper 51 = on/off switch (and/or 2-way pinheader w. jumper) 52 = 1-pole, 3-way switch (and/or 3-way pinheader w. jumper) S3, S4 = changeover switch (and/or 3- way pinheader w. jumper) XI = 9.728MHz quartz crystal, HC- 49/U, fundamental frequency, parallel resonance, load capacitance 30 pF, ±10 ppm, (see text) BT1 = 9V battery with clip-on leads BNC socket 50£2 (optional) PCB, order code 050268-1 58 elektor electronics - 6/2006 Figure 5. The author's prototype. The multi- plex sig- nal allows stereo decoders to be tested by connecting the out- put of the generator to the MPX input of the decoder. We discussed above the adjustment of PI to obtain good channel separation, while P2 allows the level of the test signal to be adjusted. Using the MPX signal as an input to the decoder allows measure- ment not only of its output channel separation, but also of its output sig- nal-to-noise ratio and distortion. S2 selects whether the test tone is output on the right or left stereo channel. With the switch in the middle position the tone is at equal amplitude in the two channels, allowing balance to be tested. With S3 set to ‘TONE’ the 594 Hz sine wave is routed to the output. The low distortion of this signal makes it ideal for measuring the distortion of audio amplifiers. The RF output of the test signal gen- erator can be connected directly to the antenna input of an FM stereo tuner or receiver. We have already discussed the adjustment of the carrier fre- quency, and fine adjustment (approxi- mat ely ±300 kHz) can be carried out using trim- mer C20. The FM signal output allows the measurements described above (channel separation, distortion and sig- nal-to-noise ratio) to be performed for the receiver as a whole. It is important when measuring the signal- to-noise ratio to ensure that the resid- ual FM of the transmitter is sufficiently small. To do this we stop the crystal oscillator completely using SI, so that only an unmodulated carrier wave is produced. On his prototype the author measured a residual FM of only 60 Hz, measured as a quasi-peak value over the audio band from 20 Hz to 23 kHz, which is a negligible level of interfer- ence. Note that you will be broadcast- ing the FM output of the test signal generator, at least to the extent that what you have connected to the out- put forms an antenna. The operation of radio transmitters in the UK is reg- ulated by Ofcom, and operating an unlicensed transmitter can incur a fine of up to five thousand pounds or even a spell in prison. Ofcom has facilities for monitoring radio transmissions and does prosecute offenders: only licensed radio amateurs are allowed to use their home-built equipment within strictly allocated parts of the radio spectrum (which does not include 88- 108 MHz). Despite the low RF output power of the device (only 3 jL/W), it is still necessary to ensure that no FM signal leaks out of the system, and that the oscillator itself does not act as a transmitter. If you use a screened cable, ideally coax, to connect the transmitter to the receiver there should be no difficulty as the device is operating as a signal generator for test and measurement purposes rather than as a radiating transmitter. ( 050268 - 1 ) Figure 6o. Spectrum of the RF output signal in mono operation. The carrier frequency is 102.7 MHz. ■Mi 13 Pur jiOTfe #rr |'| aTT ICW 1 A.un fi.r.Lr.- i rfc* , n tail ■:FH7rP IrtJ. TOi. r4ir LFAJ-i I .Wii Mr ilHm 1 i H? fin I I, H 7 hT.Ci ■ F' krill' ■\ ■ i v ■ ■ftfv# i fin, -mm.* .► Figure 6b. As Figure 6a, but here in stereo operation. a I! 50C? ~E jt tel ^ n -it F Figure 6c The multiplex signal at the audio output (S2 set to L or R). 20k 22k 25k 30k 32k 35k 42k 45k Hz Figure 6d. Spectrum of the signal in Figure 6c (stereo multiplex signal). Frequency modulation of the 38 kHz subcarrier is clearly visible. 6/2006 - elektor electronics 59 HANDS-ON This instalment uses an 8052 core derived from the T51 open-core design. We modified it slightly to make it easier to use in our FPGA module. The internal operation of the microcon- troller falls outside the scope of this course. However, we’ll show you how to use the microcontroller and how to connect it the peripheral digital logic. That will be illustrated by building a four-channel voltmeter. Cores Our example here is built from various pieces of digital logic. You’ll find the example project in the ‘ex9’ folder of the software for this instalment (060025-3-11). After opening the proj- ect file in that folder, you will see a schematic diagram as shown in Fig- ure 1 . The circuit is built around the block labelled ‘T8052’, which repre- sents the 8052 microcontroller. The associated files are located in the ‘T51’ and Altera Cyclone’ folders. This microcontroller is derived from an 8052 core design that can be found at www.opencores.com. We modified the core slightly so it would use the internal memory of the FPGA more efficiently. We also added a wishbone interface. We’ll have more to say about those changes in next month’s instalment. The important aspect of this microcon- troller is that it has 8 KB of program memory and 4 KB of XRAM. It is also compatible with a standard 8052, so you can use regular 8052 development tools with it. FPGA Paul Goossens This month we'll use the FPGA to construct a simple microcontroller system using a (free) 8052 microcontroller core. The microcontroller drives various peripheral elements of the prototyping board, including the l 2 C interface. Finally, we'll use it to build a four-channel multimeter. In this example, we operate the 8052 at a clock rate of 25 MHz. This clock signal could be generated using the 50-MHz clock on the board and a flip-flop. How- ever, we decided to use the two PLLs in the FPGA for this example. The PLLs can be used to generate clock signals at frequencies that differ from the 50- MHz signal provided by IC7. In the Quartus package, Quartus pro- vides IP cores under the ‘Megafunc- tions’ designation that allow you to use the PLL. These megafunctions can be used as symbols via the same sym- bol toolbox that contains the input pins and so on. Refer to the Quartus manual if you want to know more about using megafunctions. 60 elektor electronics - 6/2006 In this case, the megafunction is con- figured to accept a 50-MHz input clock and generate a 25-MHz clock. When you use the PLL, you have to allow it a bit of time to generate a stable clock. The ‘locked’ output goes to T when the PLL output is stable. 8052 The 8052 in our circuit is clocked by the 25-MHz sig- nal. Its reset input is a logic OR function of the ‘ switch 1’ input and the inverted ‘locked’ output of the PLL. That ensures that the microcon- troller will be in the reset state if the PLL is not supplying a sta- ble clock signal. The microcontroller can also be reset by pressing button SI on the prototyping board. The two external interrupt lines are tied to ground (‘0’) because they are not used in this example. I/O ports PO-P3 require a bit more explanation. In a standard 8052, these ports can act as inputs as well as out- puts. The pins are thus bidirectional. In an FPGA, it’s often impossible to use bidirectional pins. For that reason, each port of the 8052 has an 8-bit input and an 8-bit output. Unused inputs are simply connected directly to the corresponding outputs of the same port. For example, if bit 0 of port P3 is not used as an input, it must be connected to bit 0 of the out- put of port P3 The final thing that deserves mention is the XRAM_AC input, which forms part of the wishbone bus. We’ll discuss that bus in next month’s instalment. i 2 c The I 2 C bus requires two bidirectional signal lines. As we just mentioned, it’s usually not possible to use bidirec- tional signal lines with an FPGA. For- tunately, the type of FPGA used here does allow I/O pins to be used for bidi- rectional signals. Two such pins are shown in the schematic drawing. These bidirectional pins are located in the same list as the input and output pins, with the designation ‘bidir’. We also need a bidirectional buffer in order to use these bidirectional pins. In this case, we used the ‘ALT_OPBUF’ symbol, which consists of an output buffer with an Enable input and an input buffer. When the Enable input is set to T, the outputs can source or sink current according to the signal levels at the buffer inputs. The outputs are in a high-impedance state if the Enable input is ‘O’. In that state, an external device can drive the pin with a high or low level without causing a short-circuit condition. The outputs of the input buffer can be used to read back the states of the pins, regardless of whether the output buffer is enabled. As you already know, the I 2 C lines must be connected to open-collector Figure 1 . Schematic diagram of the embedded system. i 9 e i pi aiiaiirpaiipiipaainpipiii i i i “ i t p p ■ i i ■ ii r i ■ t ■ ■ *i ppii P ■ 1 1 P 1 1 1 ■ 1 1 1 1 1 1 1 I 1 pap i pi i rpeiiP'iipapiBB 1 . 1 B 1 1 L J a 1 ■ ■ 1 ii fa i p i a i i pi i r a a ■ a a i i p i ’l l i p ■ a r a a i a r ■ ■ ■■.III 1 ■ ■ J ,i i a a ■ i fa ■ a i. i ■ i j i aa i ah i i in i a p a ppiii a i a paa papa ppa i i a ■ ■ r a a papi ppa pib i i p a a r a a a a r pi paaa pra pi a la paa paaa apa ri a ia raa p a a a a-ra pi a i a paa raaa 4 fail i a fa i b i. a i. i a i i i a a Lab i Lb i i i ■ i ■ ■ i a i a b i b b >i u a i i n a j ■ a a i 4 i a ki i i i a li 4 ■»! a i a ■ a ■ i . i lli ii a i a i a a bac i aba i ■ a i i baa i a a i — a-— p-t— * - n l a - l . a&lMi 1 i S I ■ k i m 1 - a ■ 1 i J L a a 1 a fa 1 b 1 . 1 1 Ii 1,1 fa J J 1 a a 1 a i ■ ■ i - a l ■ i a fa ■ ■ a ■ u . ■ i - ■ i > i. . . i u i • > ■ - - i ■ fa J ■ ■ - i ■ i. ■ i a a J j i a.a i a i. a ll a li a u l a a i a b i fa i a li a 11 fa a a i. 4 b s b l 4 li a i a b 44 l 4 a 4 "l—. i lU % It- »- 1 MfrV •■■■»*= ■'ll ! A 1 ■ F fa ™ F pep nil' if I SM . I p- - -* 'fi* ^ r --riWi”Dftirjpr ii| k snrar pi u It n PTETlTn ■ 'I rT 7 i •2 F I I L i ■ r ■ a i i j i n J 4 I I m II 1 11 I I I * i ■ r i i i ■ i ■ i i p i ii ■■ i r s Ji P a ill ill IR-eH £ f-L.'l Tirun ■ : r M? JT : -.i , ! ■■ii'- ! ■i : hFmT I C...TP.J" miiiL VllJU'L HOAJB1 mm. “j •■•JC n-Qj- a I’n -■» taATCYf ft iff SUTF-J fliHTtr ’ ’ 1 ■ .nra: ' “L 1 nr ■ il J r . . *if\ . 1 . lr48l.-j *n i: r- ' . ! ' ■' r“j« I *. rI! Ml. 1 1 I 1 I I I i r i i . i . l i k i ■ • ■ . j . i . I. ■ ta . ■ r i r i p p ■ ■Hill ■ m . i St i. I L a. I I I. ILL a l i a ■i p i ■ 6/2006 - elektor electronics 61 HANDS-ON FPGA l 2 C bus The prototyping board includes an l 2 C bus that can be used to drive various ICs. The ICs that provide the digital and analogue I/O signals on connectors K3 and K 5 communi- cate with the FPGA via this bus, and the 1C that drives the LCD uses the same l 2 C bus. The general structure of the l 2 C signals is shown in the adja- cent figure. There you can clearly see that all ICs connected to the bus drive the SDA and SCL lines via open-drain out- puts. In other words, an 1C can pull the level of a signal line to ground, but it can never connect it to the supply voltage. The pull-up resistors cause the level to be the same as the supply voltage when none of the connected ICs is pulling the line low. Each communication is initiated by a 'Start condition', which can be recognised by a falling edge on the SDA (data) line while the SCL (clock) line is high. After that, the SCL line also goes low. The end of the communication is indicated by a 'Stop condition', which consists of a low-to-high transition on the SCL line followed by a high state on the SDA line. These two conditions are the only cases where the SDA line can change levels while the SCL line is high. After a Start condition, the master first sends an l 2 C address. That is an 8-bit value, with the final bit indicating whether the communication is a read operation or a write operation. It is '1 ' for a read operation. The other seven bits are used to address a particular 1C. The 1C that recognises its address will pull the SDA line low on the ninth clock pulse as a sign that it has been addressed. This is called 'ACK', which is short for 'Acknowledge'. If the eighth bit is a '1 ', the master will then start sending its first data byte. It does this by placing the most significant bit of the first byte on the SDA line and then issuing a clock pulse. It then places the next bit on the SDA line and issues the next clock pulse. That process is repeated up to and including the least significant bit. On the ninth clock pulse, the slave pulls the SDA line low again as an ACK signal. After this, the master can send another byte if desired or terminate the communication with a Stop condition. The situation is different with a read operation. In that case, the master generates a Start condition and then sends the address of the desired 1C with the least significant bit set to 'O'. The addressed slave device generates an ACK, just as before. Next, the slave places the first bit (most significant bit) of the byte to be sent on the SDA line. The master then generates a clock pulse and receives that bit. After the master receives the eighth bit, it generates an ACK. The master can then decide to receive another byte or terminate the communica- tion with a Stop condition. It's important to bear in mind that the master always gener- ates the clock signal. However, the slave can affect this by delaying the clock. That works as follows: after the master returns the SCL line to the high-impedance state, it must wait until the level on the SCL line goes high. The slave can hold the SCL line low during this interval if it needs extra time, for instance for processing data. The slave can thus use this mechanism to slow down communications. outputs. That means the ICs con- nected to the lines are only allowed to sink current in order to pull the signal lines to a low level. For that reason, the input of the output buffer is connected to ground (GND) in the example. The signal line can then be pulled to ground by setting the Enable input to T. Here the Enable line for the SDA signal is connected to the inverted bit-0 out- put of port PO. The Enable input will thus go to T when that bit set to ‘O’, which will cause the SDA line to be pulled low. The state of the SDA signal line of the I 2 C bus can be sensed at any desired time via bit 6 of the input buffer of port PO. The SCL line is handled in the same way, but using other bits of port PO. This arrangement allows the I 2 C pro- tocol to be implemented in software. Firmware By now, you may be wondering where the program for the microcontroller is located. The program memory is incorporated in the T8052 core. This memory is also a megafunction. During compilation, the megafunction uses the ‘firmware. hex’ file in the ‘firmware’ folder to populate the program mem- ory. The firmware can be modified quite easily, as you will soon see. We used the free SDCC compiler to generate the firmware for this exam- ple. You can find the compiler on the home page of SDCC. You will need this compiler if you want to modify the firmware according to your own wishes. After downloading the com- piler software, run the setup program. We recommend leaving the standard settings unchanged. When the installer asks whether you want to install SDCC using the default path, confirm this by clicking on ‘Yes’. The firmware for this example is located in the folder under ‘ex9/firmware’. That folder also con- tains a file named ‘make.bat’. To 62 elektor electronics - 6/2006 Figure 2. Memory peeking via JTAG. Figure 3. Downloading new firmware. H I ffllirTn:! rxl In Syi-hc* Mcmhv 1 CiHtiiint Editc fr^SeM ln!i-.sncE l& i[?iT0 <1 lay. I^Md^ln jwhp-m-h Ih»* 1 X Jl flh 1Jl.ii i C Vb Jy r .till in i r'Xi hue]} 1 SWi* 1 Wk»h 1 Deplh 1 T«h |ra|0 PRDG *UfVWm & W*& PAM^QM fttad-^W^e P .Hrt^i/ilr | Rp-n=.-.-^lMv |J PH | jj. » t IhRM’I ■J-:* rtMvwg O 4Q9G FWJ4.fi DM Device [ ®1 : EP1 n 3 |0y035S3SOCl d t ^ | 0 PfiOG: GOUQOO 02 00 03 75 01 21 12 Ij'i r«7 Zb 32 50 03 0 2 OG BOUQ1E 75 A0 00 £4 03 F2 AJ OB DO 00 0? 05 AO DO E 4 hlkickic; IIU hU III 7 9 ii All UU Y. 4 ba IIH UM K 715 i-.a tll.HJLIb.jV D9 FA 02 UU 5 If 12 UD t ■; 0U FE 7% 0U UU 17 uy e ooo to 12 OC GO 00 DO 2A 74 01 FO 00 ID 3C 75 FO OG DDflLI'lfc 71 K? lit 1 7 |]H 'J 3 7hi 02 nn 17 ll H *f 3 17 UK A fi GU0LIU4 17 00 it AA 02 ^5 U2 U1 CU U2 17 U0 it ... Li 02 GOOOD2 01 DO fli 75 02 GO tD 02 CO q? CO 04 1£ 00 &C II LIOCI KEI ll'h 3,7 UK th Mil Uh DO lie 3IM D| Mb 13.' CM M. oi GUU1UZ to FU 74 00 CU FU 74 uu CU ZU L ' CU ZU 17 UD GD012C 00 00 20 El FO A3 FO EA 30 E7 1? OO ID £L E4 ii i mi 4 a 30 Kh It m IK 711 b;4 0j i-p: 74 Ill 13 YV an □n GUBl&a b U EA !U Eb It au 3 b 2ti E4 03 bF 74 til 0J b> 00 01 Co 39 A3 FO EA 3G E4 1C 9G J D £7 E4 03 FE 74 01 fiu ni 4 4 Ko Kb 10 A 3 KSI V. A 313 K 3 1C a 13 IK 70 >4 aa k>: GUU1G2 hr. 2a ZU EF aa A'j FU EA jU £2 It 0U lb 2b 1l4 floniEO oo 20 EE £0 FO EF 30 A3 FO EA 3B El 1C 00 ID ii inn kp: P H '*□ ii n 2 II KK 7 K bn ¥.¥ aa A3 Klb Ka ail pm if GUUZlt A3 E'3 Fa 00 L".l 2D FA IY FU ZE JB A3 FU 7 A UG GOO£3A 94 27 40 OF DA DA OP 01 OE EF £4 EG FF o 34 UUO^hH ^ 3, KA Hll 00 137 yn 7A Hi 7b: [113 Cl KK 14 p .■ Kfl GUU27ti Ft Fa au EO EA ii Ff 02 ZE lb fb 0i hi G0B294 ■34 00 40 OF DA DA 00 01 OE EF £4 OC FE EO 34 000387 ^'i KA vu 00 IIS Ml a i] Uw 70 b:t fa A3 Ml P H JG 11002110 EA FU A3 EE b'U Ft 70 Eb It 0U lb 73 El 03 b'A G0D£EE EA ?F FO EE n A3 FO ED 20 E5 1C 00 ID £5 Ei ininHisi: IIU 711 K1 7K k>:i KH HK All KLI KM jU KlC It an IK 0 U U i 2 A Ed 9U uu 20 E A 2b FU EE ia A3 b 0 hy. JU Ej It 000340 ft J EO FO 00 00 20 EA 2F FO EE 3B k 3 FO ED 3G nQ4mA F FF 13 FO Ffl no ?fl FA F FO RE 12 Fit -JUU 304 UO 2U zu FF AJ FU b 0 0G UU 2U b A 7F FU EE ja 000 3 42 ED 00 00 £0 EO EE A J EG FF 00 00 20 EA £E EG goo^o PR Cl FF 94 IG EF 34 ?? 40 OF OA RA GO 01 OP GUU3DZ bid it lb Fi 03 £4 03 FA 0U UU UA Fa 7 A UU 7b 0003FC EL 24 10 EE EF 34 FC FF 00 EO EA 24 li F5 02 i n n i i a no C3 FF 9 4 h4 EF 9 4 nn 40 OF OA RA GO 01 OR 0 UB43a hi' 74 itt b b 03 £4 03 b'A au UU UU FU au UU 7 A 000450 PO 05 DO 04 CG fU CD 05 74 54 CO EO 74 ID CB 5F 79 OG El 44 00 OG IB 7 A 00 90 IB 7A 78 40 . . u i HA F£ 75 AO FE E4 70 FF F& DG ED 70 oo EG 44 u r , , >:m (4 IMI h-CI Hr 71 131 Hll MU C3U Y.i bll 12 L3M Yt V ii EJ 17 Ub D3 au UU 7A E4 FU 90 lb 31 ■n EU au „ + .d 1£ OC 09 75 00 00 U 07 ED 75 02 OE u OG 01 r t i i i ■ t , 17 □ 7 PH ?■& an P K 7b. ¥7 aK 12 i;;-: Ml 7 4 K7 HI u D u DU U7 7!> 112 U1 tu U2 tu U3 Ijf U0 it AC 02 DU . 1. u. . AD 02 ptJ 04 □0 03 DG 02 CO 02 CO 03 CO 04 CD , . . U . M H4 CD HK 74 Ji EH 7 4 IK ■ n p ll 74 _io_ F H [»njp[jrl 1 > u- 1 • i B c [X| P V 2 X [i m r h 7 n i L R [*l J Ir^wJ-we ] 0 forifrwB l*e-> v : *• □ Da* Inyjl ] &***-BI CJTJ* |SHrr^iT.-., l H|lrtJFciTn^|l t |- tw-*\ ^T] C«iwd - ) , . #■ G , ■ n ii i 9 . .< (I V 4 u L 51 AJ rU Eb 3U zu It 9U lb 2F Ei 97 FA 74 U1 as i. b i i i ■ i j V . B ED 3F A3 EO 7 A 00 7D oo 00 DO 20 EO FE A3 EO ■ Ini RF 74 pn FF FF 34 rifl RF flO R5 Rl 74 M F5 a? tfU C3 EE 94 ZU EF 94 03 4U UF OA bA UO 01 utr 4 s-1, ED 34 ID F5 03 E4 93 FA 00 OG OC FO 7A 00 7D , S , 4 . 5 RF. 74 9C! FF FF 24 FF RF GO FA FA ?4 U f*: d > E4 FU 00 UU UU 7b FU UU cu U4 tu U5 12 DU 09 4 i ( 1 -A EO 74 GO cq EO 74 DG CO ED 74 flq CD EB E4 CD tT E . f |:r- Wi: 6/2006 - elektor electronics 63 HANDS-ON FPGA recompile the firmware, simply double- click on the ‘make.bat’ file. All the intelligence of the circuit is con- tained in the firmware. Among other things, it looks after driving the I 2 C bus, the A/D converter and the LCD module. The source code is relatively simple and should not present any problem for anyone with a reasonable knowledge of C. Hands-on Start the program and configure the FPGA using the example project for this instalment, which you will find in the ‘ex9’ folder. After you configure the quently, the contents of the memory locations shown in the box under ‘PROG’ are filled with question marks. Select the program memory by clicking on the word ‘PROG’. You will see ‘Instance manager’ somewhere near the top of the window, with several buttons next to it. Click on the leftmost button (an icon showing a document with an upward-pointing arrow next to it), which is called ‘Read’. Quartus will read in the content of the program memory and display it in the box below. That all happens without causing any problem for the 8052. In fact, there’s no sign of any sort of slowdown. Figure 4. Specifying the location of the firmware on the hard disk. FPGA, you will see a welcome mes- sage on the LCD. Starting around 4 seconds later, the LCD will continu- ously display the voltages measured at the four analogue inputs of the proto- typing board. Congratulations - you just built a four-channel multimeter! As you know, the FPGA now contains a microcontroller with program memory and working memory. Thanks to the modifications we made to the micro- controller, you can use Quartus to view and modify the memory contents. In the ‘Tools’ menu, click on ‘In-System Memory Content Editor’. That will open a new window as illustrated in Figure 2. Two memories are listed at the top left, with the names ‘PROG’ and ‘XRAM’. PROG contains the firmware that is executed by the 8052. At this point, Quartus does not know the content of that memory. Conse- New firmware The next exercise is to try making changes to the firmware. For example, you can change the string in line 57 to ‘Test’. Save this change, and then dou- ble-click on ‘make.bat’ in the previ- ously mentioned folder in the Windows Explorer window. SDCC will recompile the program and generate a new ‘firmware. hex’ file. Return to the Memory Content Editor window and position the mouse cursor somewhere in the data area. Now right-click with the mouse and select ‘Import Data from File. . .’ in the popup menu. Navigate to the ‘firmware’ folder and select the new ‘firmware. hex’ file. The program will now load the content of the selected hex file into the mem- ory buffer. A warning message will also be displayed to indicate that the length of the hex file is not the same as the length of the memory buffer. You can simply ignore that message. Next, press button SI on the prototyp- ing board to reset the microcontroller in the FPGA. While holding this button depressed, click on the ‘Write’ button on the screen. You can recognise it by its icon (a document with a down- ward-pointing arrow). That causes the program to transfer the content of the memory buffer to the FPGA memory via the JTAG interface. Now you can release the reset button. The wel- come message on the LCD will be different now, which proves 0 t V|*J On your own that the new firmware has been loaded into the 8052. While you’re waiting for the next instalment, it’s a good idea to work on your own to acquire more experience with the 8052. The easiest approach is to copy the ‘ex9’ folder to a new folder. You can then experiment to your heart’s content with the copied version. Don’t forget that the compiler expects to find the firmware at a particular location, but it’s easy to change that location. In the Project Navigator win- dow, select the ‘Hierarchy’ tab. Click 64 elektor electronics - 6/2006 on the + sign next to ‘T8052’. A list will be displayed underneath, with among other things the entry ‘rom_cyclone’. Double-click on this entry. That will bring up a ‘MegaWiz- ard’ window. Click on ‘Next’ to proceed to the next window of the wizard. Keep going in the same way until you reach window 7 (Figure 4). In this win- dow, enter the exact location and name of the hex file you want to use for the firmware. Finally, click on ‘Finish’. Be sure to leave all other settings unchanged. Now you can recompile the design, and the program memory will contain the firmware you want to use. ( 060025 - 3 ) Web links www.opencores.com www.sourceforge.com http:/ / sdcc.sourceforge. net Earlier in this series Versatile FPGA Module, Elektor Electronics March 2006. FPGA Prototyping Board, Elektor Electronics March 2006. FPGA Course (1), Elektor Electronics April 2006 (with free downloads). FPGA Course (2), Elektor Electronics May 2006. STD_LOGIC Starting with part 1 of this course, we have been using signals of type STD_LOGIC. That signal type can have various states, but up to now we have only used the ' 1 ' and "O' states. Signals of type STD_LOGIC can also have other states, of which 'Z' and '-' are the most important. The 'Z' state indicates that the signal is in a high-imped- ance state. An example of where that can happen is the output of a buffer with an Enable input. It is recommended not to use this state if you are generating a design to be implemented in an FPGA, because most FPGAs cannot generate internal high-impedance signal states. However, most FPGAs (including the one we use) can generate high-impedance states on their I/O pins. It is thus possi- ble to use the 'Z' state for such signals. Another state is '-', which is called 'don't care'. If you set a signal to '-' in a particular case, you effectively tell the compiler that you don't care whether the output is '1' or 'O' and it has no effect on the overall operation of the design. That allows the compiler to simplify functions where possible, with the result that the circuit may take up less space in the FPGA. We used an ALTJOBUF in Quartus for the l 2 C interface. That is a buffer with an Enable input, which means that the buffer outputs go to a high-impedance state when the Enable input goes to 'O'. The level on the output (I/O pin of the FPGA) can be read via a second buffer. Open cores This 8052 core we used here is derived from the T51 core. That core is avail- able free of charge from the www.opencores.com website. We modified the T51 core slightly to suit our purposes. All cores (which are also called 'IP', which stands for 'intellectual property') on this website are free. That means they can be used without paying any licence fee. We made a few modifications to the 8052 core, primarily to enable it to work properly with the internal memory of the Cyclone FPGAs. We don't intend to describe the internal operation this 8052 here. That's any- how not particularly relevant with a core (aside from the educational value). A designer can simply regard a core as a black box that performs a particular function. It's the same as with an 1C - you need to know how you can use it, but the details of its internal operation are not important. We placed all the necessary files for this core in the 'T5 1 ' subfolder. The VHDL files in that folder collectively constitute an 8052 microcontroller. The top-level document for this core is the 'T8052.vhdl' file, and that is the only file you have to use directly. It's not particularly difficult to use this core in a new design (such as your own design). Nevertheless, we recommend that you copy the 'ex9' folder to a new folder if you want to use it in your own designs, after which you can modify the copied files as you see fit. Most of the signal names of the 8052 core are self-explanatory, but the ones that start with 'XRAM' need a bit of explanation. These signals collective form what is called a 'wishbone bus', and that's something we'll explain in the next instalment. For now, it's quite important to know that the 'XRAM_ACK' signal must always be set to '1 ' if this bus is not used, since otherwise the microcon- troller can hang unexpectedly. 6/2006 - elektor electronics 65 HANDS-ON MODDING & TWEAKING Wireless switches controlled via your PC Modeling for Home Wireless mains switches can be very useful: a remote control is used to turn an electrical device on or off. But when nobody's at home, during the holidays for example, things become more difficult. In those circumstances this mod will come in handy. It could be turned into an inexpensive burglar deterrent quite easily. This mod is also very useful for those of you who are too lazy to search for the remote control when they're sitting in front of their PC. These are the units that we'll use. There are four mains sockets, of which one can be used as a dimmer, bundled with a remote control unit. Many computer hobbyists who have an interest in expanding their system would like to use their PC to turn mains equipment on and off. Others with an electronics background would also find it useful if they could easily control 230 V equipment via their PC, for example as part of a home automation project, a burglar deterrent, or just for fun. At first sight this doesn't seem very difficult. You can go a long way using the parallel port, a few transistors and a relay. But it turns out that this solution does have a few disad- vantages. Easy First of all, the PCB used for the controller has to be con- nected directly to the mains. This isn't an insurmountable problem of course, but it does introduce an element of danger. And secondly, you always need to run a cable between the PC and the device that needs to be con- trolled, which is difficult if they're not in the same room. Since this circuit is only temporary (Fig. 1) it is built straight onto the DB9 plug without using a circuit board. 66 elektor electronics - 6/2006 The transmitter. This is used to control the four outputs and the dimmer function. There is also a master switch that can turn all outputs on or off at the same time. In this way we can tap into the signal from the control 1C to the RF transmitter. The orange/white wire supplies power to the whole unit. Jeroen Domburg & Thijs Beckers Once Lire has read all the buttons, the final circuit (Fig. 2) is also built directly onto the plug. The zeners have been replaced with UV LEDs that the author had lying around. And this is how the complete circuit is connected to the author's server. If the circuit is placed on the floor it would make sense to house it in a box. 6/2006 - elektor electronics 67 HANDS-ON MODDING & TWEAKING Figure 1. The circuit used by Lire to learn the remote control signals. The BC550 can be replaced by virtually any low- power NPN transistor that you have lying about. Figure 2. The final circuit with which the computer can control everything. Figure 3. The program isn't really that big. The Linux version (600 KB) is twice as large as the Windows one. 0 1 jJH— H’O r< V ^ ^ 0 M — r< -f 0 yj « > i z 0 T 1 1 M- 1 0 Both these problems can be solved at the same time if you use a wireless link between the PC and the relay. The disadvantage of this is that you need to be a lot more knowledgeable to design such a project: at the transmit- ting side the signal has to be encoded and converted into RF, and on the receiving side the opposite process has to take place. This quickly brings us into the realm of micro- controllers and not everybody knows how to use these, let alone have a few in their spares box. But all is not lost: a few clever chaps have already solved these problems for us. From many DIY stores you can buy small devices that go between the mains socket and elec- trical appliances and which can turn the appliance on W IflL rnc CsnrtftUf alien Pad I COM! ~31 H*™*! W" r- 1 ^ KKfevtf a |t15MG 3 ftiwhiw Tjms lAjJaflfwJ- ^ | YllurfiMtai | UnwJy, sHotid ^ 11 52W S-s ir*r**i vjh h Nfl* QK P Wflhfl- tfon ■ piDg’-ii'h C-ancd | IiwiEntliH I r h*i[fci£ro g&kh CnTFi r TX f \F, \¥trk: Cl ft ^AiTfilr d Eir " y:f and off via radio waves. Some types even have a dim- mer function built in. These devices usually work using radio waves in the 433 MHz band. There is no longer a need for a cable connection and a wall (or two) between the transmitter and receiver doesn't affect the operation. Seen it before? We have previously covered these devices in Elektor Elec- tronics. The October 2005 issue had a circuit with which devices that listened' to these remote controls could be turned on and off automatically ('Remote Control Opera- tor'). In this case, the remote control unit was controlled with the help of electronic switches that shorted the indi- vidual buttons. This method can of course also be used when a PC is used for the control. It is possible to use the parallel port and a handful of transistors to simulate the pressing of buttons. This method has the disadvantage that it requires a fair number of components and can only control a max- imum of four devices. On top of that, it probably won't work with every type of remote control. It only works when the buttons are scanned in a particular way. Not the same then Fortunately, there is a better way. From an electronic point of view such a remote control has just three sec- tions: the buttons, an 1C that scans these buttons (and passes a signal to the transmitter when a button is pressed) and the transmitter itself. These sections can be easily found when we open the remote control. The 1C that takes care of the encoding is usually underneath a black epoxy blob, with tracks going out to the buttons. Sometimes it is an ordinary SMD 1C or even a DIP ver- sion. There are many PCB tracks that go from this 1C to the buttons, and a single track that goes to the RF trans- mitter. The RF transmitter is often easily recognisable: it is usually built using a large number of analogue compo- nents, whereas the rest of the board doesn't have much more than the single 1C and some parts for interference suppression. The transmitter usually takes nothing more than the supply and the encoded signal from the 1C. This signal line often has an LED connected to it, to indicate when the remote control is transmitting. The encoded signal line is of particular interest to us in this case. As the signal from this line is sent over a 433 MHz connection, it won't have a very high fre- quency. It can also be assumed that a burst will appear on this line whenever a button on the remote control is pressed. If we could record this burst and reproduce it later, it becomes possible to control the wireless switches remotely. Software Fortunately there already is a (free) application that does exactly what we want. (For those of you who aren't clear on this: we need to store the pulse-trains and play them back later.) This program is called Lire [1], which stands for Linux Infrared Remote Control. The program was orig- inally written for Linux, but there also is a Windows ver- sion: WinLirc [2]. This program was really written to interface a computer with an infrared remote control and let it communicate with devices that react to these infrared signals, but it can also be used for our project. The program can, using extra hardware of course, receive, process and transmit infrared signals. The 68 elektor electronics - 6/2006 infrared signal is, just as our signal, a single line that goes high and low at certain times. Construction We first have to teach Lire which signals have to be sent to control a specific mains socket. Depending on the model used, it's possible that somebody has done this already and that the configuration is available [3]. If that is the case, you can skip this step. If you can't find a ready-made configuration you will have to build the circuit shown in Figure 1 . With this Lire can learn what codes are sent by each button. You have to put Lire in its learn-mode and follow the instructions. It won't be a problem if you need to control more devices than you have buttons for on the remote control. First pro- gram a set of buttons, then change the channel number of the remote control and program another set. You can repeat this until you have programmed enough buttons to control all units. Once all buttons and their signals have been read in, we have to get Lire to transmit them again. The cheapest method, and the most successful, is to use the transmitter built into the remote control. Build the circuit shown in Figure 2, break the track between the encoding 1C and the RF transmitter and connect the output of our circuit to the track at the RF side (which is the input to the RF trans- mitter). The supply is also taken care of, so you can remove the batteries from the remote control. The zener diodes in the circuit have been chosen for use with a remote control that has a 3 V supply. Should the supply voltage for your remote control be different you have to change the values of the zener diodes to provide the cor- rect voltage. And that is it: the computer is now ready to control the wireless mains switches. And finally... When you download Lire you will also get information on how it should be used on the computer. Linux users can use the program 'irsend' that is included with Lire; Win- Lire users get a file called 'transmit. epp' with their down- load. This gives a short example how Lire can be used from Windows. And just a final remark: instead of wrecking your remote control you could use a licence-exempt, type-approved 433 MHz transmitter module. This should be connected in the same way as the RF transmitter from the remote control. But first make sure that you've changed the val- ues of the zeners so you have the correct supply voltage for the transmitter module. ( 065115 - 1 ) Web links [1] www.lirc.org/ [2] winlirc.sourceforge.net/ [3] http://sprite.student.utwente.nl/ ~jeroen/ projects/kaku-lirc/ Advertisement DON'T LOSE YOUR TEMPER Before phoning us - if you are looking for a hard-to-find part. We have over 20,000 items in stock - including obsolete and up-to-date parts. WHY NOT VISIT OUR WEBSITE www.crickIewoodelectronics.com 2N 2SA 2SB 2SC 2SD 2P 2SJ 2SK 3N 3SK 4N 6N 17 40 AD ADC AN AM AY BA BC BD BDT BDV BDW BDX BF BFR BFS BFT BFX BFY BLY BLX BS BR BRX BRY BS BSS BSV BSW BSX BT BTABTB BRWBU BUK BUT BUV BUW BUX BUY BUZ CA CD CX CXA DAC DG DM DS DTA DTC GL GM HA HCF HD HEF ICL ICM IRF J KA KIAL LA LB LC LD LF LM M M5M MA MAB MAX MB MC MDAJ MJE MJF MM MN MPS MPSA MPSH MPSU MRF NJM NE OM OP PA PAL PIC PN RC S SAA SAB SAD SAJ SAS SDA SG SI SL SN SO STA STK STR STRD STRM STRS SV1 T TATAA TAG TBA TC TCA TDA TDB TEA TIC TIP TIPL TEA TL TLC TMP TMS TPU U UA UAA UC UDN ULN UM UPAUPC UPD VN X XR Z ZN ZTX+ many others We accept Mail, telephone & email orders. Callers welcome. Opening hours Mon-Sat 9:30-6:00 r VISA Cricklewood Electronics Ltd 40-42 Cricklewood Broadway London NW2 3ET Tel: 020 8452 0161 Fax: 020 8208 1441 sales @ cricklewoodelectronics.com Are you passionate about Electronics? Do you love building kit and making things work? Would you like to build a career on getting paid for what you enjoy doing? If you answered yes' to these questions then launch or upgrade your prospects by studying for a qualification in Electronics H BSc Electronics H BSc Electrical & Electronic Engineering H HNC & HND Electrical & Electronic Engineering H Foundation Year Electrical & Electronic Engineering Courses designed for people who love electronics, taught by people who love electronics. Both part-time and full-time modes of study are available, suitable for the school leaver or the mature learner. There are easy upgrades from HNC to HND through to BSc (Honours). The final year options allow for specialist training in current hot topics including digital signal processing, embedded systems, EMC and power electronics. For further details: view http://vertigo.derby.ac.uk/ email: Dr Amar Bousbaine - a. bousbaineraderby.ac.uk phone: 01332 591350 University of Derby, Kedleston Road, Derby, DE22 1GB. UK UNIVERSITY of DERBY 6/2006 - elektor electronics 69 TECHNOLOGY E-BLOCKS John Dobson Home automation is a popular topic for many readers and in this article we describe how to take advantage of the popular X-10 Power Line Carrier standard. r 1 !U 1 L r to (JfJ/ A 1 D fI r* X-10 is the brand name given to a range of equipment first manufactured in the 1970s by a small company in Scotland called Pico Technology. X-10 was designed to use the Power lines in a domestic house to convey signals that could control a wide range of domestic devices like lamps, heaters etc. Since then X-10 as a company has grown to include other communication mediums like the Internet and RF, but here we want to focus on the use of existing domestic power installations for communication — often referred to as Power Line Carrier control. The diagram above shows you the basic top level concept: a wide range of electrical devices are controlled through the mains wiring using devices that are inserted between the actuating device (switch or controller) and the device under control (hi-fi, lamps, heaters, etc). X-10 modules The simplest way of introducing X-10 is to buy an off-the-shelf set of mod- ules. You don’t need to do any design 70 elektor electronics - 6/2006 Figure 1. UK lamp and appliance modules. work here - you can simply buy con- trollers and actuators. For example in Figure 1 you can see two X-10 appli- ances for the UK: an appliance mod- ule (on or off) and a lamp module (with dimming function). Similar devices are available for all Continen- tal European countries with the appropriate mains plugs. The range of devices here is large — you can buy X-10 thermometers, motor controllers, remote door chimers etc. you can also buy off the shelf a range of controllers from wall mounting light switches to multiple switch consoles, and units that are controlled from a PC. More importantly, the range of devices available is also cheap - a typical appliance socket for a lamp costs £ 18. The technical bit So how does it work technically? The X-10 transceiver units modulate a low- level 120-kHz burst of carrier onto the household electrical wiring system just after the relatively quiet zero-crossing points of the 50-Hz (US: 60-Hz) wave- form. The datastream is derived from the presence or absence of the 120-kHz waveform at the zero-crossing points. Here a binary T is represented by a 120-kHz burst at the zero-crossing point and a binary ‘0’ is represented by the absence of a 120-kHz burst. Fig- ure 2 shows the representation of binary code 10010. Note that to make X-10 compatible with three-phase sys- tems the 120-kHz burst should also be repeated at 120-degree intervals in the waveform corresponding to the post- zero crossing points of the other two cycles, but we will not consider that here. Clearly there is potential for confusion here as the point at which you start sampling the message can determine the message itself. Because of this, all messages start with a synchronisation sequence of ‘1110’ which is a pattern that is not repeated by any other parts of the data packet. This works out because all of the subsequent trans- missions are sent in pairs in ‘true com- plement’ form where a whole cycle is used for each data bit. So for a data bit 1 you should send 10, and for a data bit 0 you should send 01. Having defined how the data bits are sent we next need to look at the overall packet structure. Data bits are sent in two groups of 9 bits: in the first group of 9 bits, the first four are the house code (A to P) and the next five are the key number code. You can see this in Fig- ure 3a. As the 9 bits of data are sent in compliment form the basic X-10 ‘frame’ takes up 22 bits or 11 cycles of the mains waveform. The second group of 9 bits again Figure 2. Transmission of 10010. 6/2006 - elektor electronics 71 TECHNOLOGY E-BLOCKS 2 4 5 2 4 5 3 2 4 r\ A r Lrlrlrirlr U 1 J u IJ U AJWWVu 1 / 1 J \ pi Pl f \ ifl | 1 1 1 1/ u V IJ U 1/ U lAAAAAa V\j START HOUSE KEY START HOUSE KEY START HOUSE COMMAND Figure 3b. A complete data packet of 47 cycles. includes the house code, as well as a 5-bit command code which is used to instruct the target device. To make the system more immune to noise, each frame is sent twice, with a three cycle pause between each pair of frames. So that the whole packet — made up of four data frames — resembles that shown in Figure 3b. Within the data packet, 5 bits are used as a Key Number or a Command. The Key Number is used to refer to the unit within the house (0 to 16). The Com- mands are used to give the unit an instruction. Table 1 shows you how this works. The house address can be set between A and P: this allows for the possibility of several houses using X-10 on the same phase of the power supply in your area. The key number is used for Table 1 • X-10 address/number/command overview. | House address Key number Command A 0 1 1 0 1 0 1 1 0 0 All units Off 0 0 0 0 1 B 1 1 1 0 2 1 1 1 0 0 All Lights On 0 0 0 1 1 C 0 0 1 0 3 0 0 1 0 0 On 0 0 1 0 1 D 1 0 1 0 4 1 0 1 0 0 Off 0 0 1 1 1 E 0 0 0 1 5 0 0 0 1 0 Dim 0 1 0 0 1 F 1 0 0 1 6 1 0 0 1 0 Bright 0 1 0 1 1 G 0 1 0 1 7 0 1 0 1 0 All Lights Off 0 1 1 0 1 H 1 1 0 1 8 1 1 0 1 0 Extended code 0 1 1 1 1 1 0 1 1 1 9 0 1 1 1 0 Hail request 1 0 0 0 1 J 1 1 1 1 10 1 1 1 1 0 Hail Acknowledge 1 0 0 1 1 K 0 0 1 1 11 0 0 1 1 0 Preset Dim 1 0 1 X 1 L 1 0 1 1 12 1 0 1 1 0 Extended data (analogue) 1 1 0 0 1 M 0 0 0 0 13 0 0 0 0 0 Status = on 1 1 0 1 1 N 1 0 0 0 14 1 0 0 0 0 Status = off 1 1 1 0 1 O 0 1 0 0 15 0 1 0 0 0 Status request 1 1 1 1 1 P 1 1 0 0 16 1 1 0 0 0 72 elektor electronics - 6/2006 addressing an individual unit on your mains network, (0 to 15) or for sending a command to a unit as in the table. Note that in Figure 1 you can see two dials for the actuator and lamp units: the red dial here is a 16-way rotary switch for the house address (A to P) and the blue dial is a 16 way rotary switch for the unit number (1 to 16). Our solution At this point we could start to look at the actual design of the X-10 trans- ceivers, but there are safety implica- tions here and the off the shelf units are not that expensive. Instead we will focus on how to get an X-10 communi- cations system up and running as quickly as possible, and for this we will use a ready-made Power Line Con- troller interface — in the UK this is the XM10U shown in Figure 4. We are told that the European Continent equiva- lent is the XM10E and the US equiva- lent is called TW523. The XM10U has a TTL serial interface which conveniently connects to the E- blocks X-10 board — shown in Fig- ure 5 — using a simple RJ11 phone style cable. The RJ11 socket is in the top of the unit in Figure 4. The cost of the XM10U is £ 25 from the Simply Automate website. The E -blocks interface contains cir- cuitry designed to protect your micro- controller from the spikes and surges of the XM10U. In Figure 6 you can see the E -blocks setup we have used: • a PICmicro 16F877A microcontroller; • a sensor board on port A; • an LCD board on port B; • the X-10 unit on port C; • a keypad on port D. To get us started we are going to make a simple electronic light switch that reads the light value from the light sen- sor on the sensor board, and turns a remote light on when it gets dark. To control the X-10 unit I happen to have obtained some C code for X-10 communi- cation. It has three key routines: X10_Initialize() X10_SetAddress(char house_code, char unit_code) X10_Send(char function_code) The block of C code takes care of all of the tasks required by the lower layer of the X-10 communications protocol: this includes routines that wait for the mains zero-crossing point, sending Figure 4. The XM10U Power Line Controller Figure 5. The E-blocks X-10 interface. Interface from the Simply Automate website. individual start and stop codes, send- ing individual bits etc. However the three routines above will allow us full control of the X-10 protocol for sending commands. I don’t have the code for receiving X-10 commands but we can deal with that later. The way we use X- 10 is to initialize the unit for communi- cation, set the house and unit address and then send a function code. Turn on the lights As an example of how to operate X-10 control we are going to make an elec- tronic light switch using the small light Figure 6. The E-blocks X-10 prototype system. 6/2006 - elektor electronics 73 TECHNOLOGY E-BLOCKS Figure 7. The entire X-10 electronic light switch program. Earlier in this series Electronic Building Blocks, November 200 5. E-blocks and Flowcode, December 2005. E-blocks in Cyberspace, January 2006. E-blocks - now you CAN, February 2006. E-blocks Making Waves, March 2006. E-blocks Making Waves at C, April 2006. E-blocks for Prototyping Systems, May 2006. Articles may be downloaded indi- vidually from our website. For a complete overview of available E-blocks visit the relevant SHOP pages at www.elektor-electronics.co.uk Resources www.letsautomate.com www.simplyautomate.co.uk sensor on the E-blocks sensor board. First, however, a little more about Flowcode and C. As we saw in a previous article (May 2005) it is possible to embed C into the Flowchart using the C icon as Flow- code first makes C before compiling the C into object for the PICmicro. However, if you simply embed the C code into the flowchart then that C code is only available for running at that point in the flow chart. What we need to make our X-10 system work is a way of embedding a large block of C code which contains subroutines that can be called from many points in the flow chart. This will give us a library of flexible commands we can use. The way we do this is to use the Flowcode #DEFINES component. #DEFINE is a C protocol for defining constants that can be referred to many times in a C program. This component also allows us to enter a block of C con- taining subroutines which is compiled at the top of the C code program. Imple- menting this is a two step process: first we add a #DEFINE component to the work space area and paste the C code we want to include into the component text window. Then we put a #DEFINES Macro into our flow chart so that the flow chart compiler includes the C code. The first icon in the flow chart in Fig- ure 7 does this for us. Here is an expla- nation of the whole flow chart. The first icon is the #DEFINE macro described above. Next we have icons to clear the LCD display, initialise the X-10 unit, Set the X10 address to be B 4, then enter an endless loop. In the loop we sample the ADC channel 0 (which has the light sensor on), then take the most significant eight bits and put it into variable LIGHT, position the LCD display cursor, and print the value of the light sensor so we can see what the light reading is. Then we test for the light level: if more than a value of 128 is returned then the light level is low (note that the sensor is the bottom half of a potential divider chain and the impedance increases as light level falls, meaning that the voltage, and the value of the LIGHT variable, at the PIC ADC pin increases as light level falls). When the light level is low, an X10_ON message is sent to turn the light on, and print ‘ON’ on the LCD display. Conversely if we detect less than 128 then light level is high and we turn the light off. A one-second delay is included to make sure the X-10 mes- sage has time to send. The entire program - including C code - is available for free downloading from the Elektor Electronics website. The name of the Flowcode program is JDX10_2.fcf and the file number is 065033-11. zip. This starter program should be sufficient for those who want to make an X-10 controlled sys- tem at home. If there is sufficient demand then we will get a custom X- 10 component designed for Flowcode - please give us your opinion on the Elektor Electronics Forum. ( 065053 - 1 ) 74 elektor electronics - 6/2006 RETRONICS INFOTAINMENT Elektorscope ( 1976 / 1977 ) This classic from Elektor's pub- lishing history has survived in two ways, really. Firstly, the design history can still be told (well, globally) by a member of our current design staff and sec- ondly, the actual prototypes could be found in our relics cab- inet, having survived thirty years of storage and hauling around Europe. One day in 1976, a slightly over-confident member of the Elektor design staff claimed that under his total supervision the team would be able to design a two-channel all-transistor oscillo- scope from scratch in exactly one week. Although all other work was dropped and sub-tasks were assigned to various design- ers, at the end of the week just two things were in the clear: the power supply design and the strong suspicion that the rest of the circuit had been copied from a design found in a technical catalogue from a German sup- plier called RIM. After careful study of the two designs, one printed in the catalogue and the other carefully produced with pencil and paper, one of the younger designers discovered that the pencilled design had npn transistors for pnp types in the RIM schematic and the other way around, and that the supply voltages had been transposed. Further serious design flaws soon surfaced. The Editor/Publisher was informed and the project was given a complete redesign which took the usual period of a couple of months. The final design was for a 2- channel transistor 'scope with a 3-dB bandwidth of 2 MHz. Part 1 of the article was pub- lished in the December 1976 issue of Elektor, discussing the power supplies (!), the blanking amplifier and the choice of CRT (cathode ray tube) that could be used in the project. Probably as a teaser, the front panel of the 'scope was already shown (sub- scriptions due for renewal in Jan- uary...). The next two instal- ments, January and February 1 977, were also pretty large which indicates the scale of the project although remarkably it was never mentioned on the magazine cover. Looking closer at the design, the home constructor was able to select different types of CRT, albeit you had to use a tube without an acceleration voltage terminal. The choice of the CRT had important consequences as not only the high-voltage supply had to be adapted to suit, but also the oscilloscope enclosure and with it the ready-made front panel Elektor was selling at the time. Two front panels were available: one for 7-cm diameter CRTs and one for 1 3.5-cm types. The photograph shows finished instruments of either version, the smaller one had a DG7-210 CRT and the larger, a D 13-620, both from Telefunken and com- pete with their mu-metal covers. By the way, the prototypes shown above have Perspex top covers allowing inquisitive enthu- siasts to see the innards of the 'scope without the danger of touching anything. Reportedly the Elektorscope boards, controls and electronics were carefully designed to fit in a commercially available case, and not the other way around as cus- tomary with many hobby projects. Unfortunately the case used was not specified. Also, a 'special transformer' was used in the power supply, with the optimistic announcement that it would become available from "various advertisers and kit suppliers in this magazine". Although I was unable to find adverts listing the transformer or the enclosure in subsequent editions, the March 1 977 magazine had a follow-up article describing how the Elek- torscope modules could be built into a rack-style Vero case. Due to size restrictions, this could only be done using the 7-cm CRT version. Although home construction of an oscilloscope was accepted practice in 1976, most instru- ments at the time (including my own) were valve-based and sin- gle-channel, not just because valves were easy to get, cheap and resilient but also because several excellent designs were available that could be assem- bled from parts salvaged from an old TV or radio. By contrast, the Elektorscope was innovative, semi-professional and light- weight — at the time! ( 065046 - 1 ) Retronics is a monthly column covering vintage electronics including legendary Elektor designs. Contributions, suggestions and requests are welcomed; please send an email to editor@elektor-electronics.co.uk, subject: Retronics EE. 6/2006 - elektor electronics 75 HANDS-ON DESIGN TIPS Solder pistol os demagnetising tool Luc Lemmens Metal tools, in particular screw- drivers, may become magnetic. The powerful magnets in loud- speaker drive units fitted close to the tool storage rack may pro- duce a few 'sticky' tool heads after some time. Not just screw- drivers, but all iron-based tools may be affected and even turn into permanent magnets. True, the property may come in handy, for example, when fishing for small parts accidentally dropped in inaccessible locations in equipment. However, a mag- netic screwdriver is also a nui- sance in many cases, especially if you are working on delicate constructions and small bolts and nuts keep sticking to the screw- driver head. The solution to the problem is to demagnetize the tool by inserting it into a strong, varying magnetic field. The magnetic property is removed when the magnetised tool is slowly passed through the field. Demagnetisers with a specially designed coil to generate the required field are available com- mercially in several sizes. How- ever, there's a fair chance you already have one in your work- shop — the solder 'pistol'. A solder pistol with its pair of steel 'wires' and a copper wire 'loop' doubles as a perfect demagnetising tool. The loop forms part of a transformer sec- ondary winding and encloses a magnetic field when the pistol is switched on. To use the solder pistol as an effective demag netiser, the iron or steel tool to be treated has to be inserted into the copper wire loop. Pull the 'trigger' on the pistol and slowly withdraw the tool (or tool shaft) from the loop. Repeat the treatment if the tool is not suf- ficiently demagnetised. If the loop on the solder pistol is too small for the tool, a larger loop may be made. Be sure to use copper wire with a cross-sec- tional area (c.s.a.) of at least 5 mm 2 , as appreciable currents are involved. ( 060064 - 1 ) NOPs for faultfinding Luc Lemmens It's a reality that a newly built microprocessor board does not work spot-on, or a board gives up the ghost after many years of service. This usually marks the start of a cumbersome search for bad solder joints, broken or short- circuited PCB tracks, defective components or problems with fail- ing software. Such faultfinding jobs can turn out to be very time consuming, particularly if the microcontroller has internal pro- gram memory and no external address- or data bus. Consider- able extra 'fun' is thrown if the operation of the software is not known! In many cases, however, it's the hardware that's playing up, instead of the software. If the microcontroller has an external data/address bus, at least the problems become manageable. Address bus faults are fairly easy to track down using an oscillo- scope — you should only see 'neat' rectangular waves, as opposed to the data bus, where 'half levels' may appear, indicat- ing the bus line is switched to tri- state (high impedance). In the pic- ture, the lower trace shows an address line, the upper trace, a data line. An address line 'doing nothing', often reveals a defective micro- controller, or does it indicate that the software does not employ a certain part of the address range? The same question is rel- evant to the selection lines of the 'chip enable' and 'output enable' variety, hardware-decoded out of the address bus and used for the communication with peripheral hardware devices. Often, we find combinatory logic devices (based on PALs, GALs and the like), which may not function correctly, while it is difficult to find out which output should be low to enable a certain address or address range. Still, it is remarkably easy to debug address decoding devices by making the processor execute a program that actually covers the complete address range. In the vast majority of cases, that program is the sim- plest you can think of, because it should do... nothing! We sim- ply fill the entire program mem- ory with No Operation instruc- tions (NOPs) which cause the micro to faithfully step through its entire address range. The lowest address line, AO, will then exhibit the fastest switching rate; A1 will be two times slower, A2 four times slower, and so on. Moreover, in most circuits the chip select lines and similar will go active, allowing you to check their operation using the oscillo- scope. In this way, you can at least verify if the addressing on the board is functioning, that being an obvious requirement for a properly working microcon- troller board Please note that an external watchdog is used in some sys- tems. A watchdog will reset the microcontroller if it is not trig- gered at regular intervals. The operation of the watchdog may frustrate the execution of the NOP program as the controller is reset before the full address range has been completed. In that case, break the connection between the watchdog and the reset input of the microcontroller and connect a standard Power On Reset net- work (refer to the microcontroller's datasheet). In some case, it may be easier to connect the watch- dog's trigger input to a low address line like AO. ( 060072 - 1 ) 76 elektor electronics - 6/2006 PUZZLE INFOTAINMENT Hexadoku Puzzle with an electronic touch This June 2006 issue marks the sixth Hexadoku puzzle. We're sure it will give you a few enjoyable hours to solve. So, no reason to get bored if the weather is not as it should be (dry & sunny). Send us your solution and win one of the fantastic prizes! The instructions for the puzzle are straightforward. In the diagram composed of 1 6x1 6 boxes, enter numbers in such a way that all hexadecimal numbers 0 through F (that's 0- 9 and A-F) occur once in every row, once in every col- umn, and in every one of the 4x4 boxes (marked by the thicker black lines). A number of clues are given in the puz- zle and these determine the start situation. Your solution may win a prize and requires only the num- bers in the grey boxes to be sent to us (see below). The puzzle is also available as a free download from our website (Magazine — » 2006 — > June). ( 065042 - 1 ) Prize winners The solution of the April 2006 Hexadoku is: CDA48. The E-blocks Starter Kit Professional goes to: John Baraclough (Isle of Arran). Entering the competition Please send the numbers in the grey boxes by email, fax or post to Elektor Electronics Hexadoku Regus Brentford 1 000 Great West Road Brentford TW8 9HH United Kingdom. Fax (+44) (0)208 2614447 Email: editor@elektor-electronics.co.uk Subject: hexadoku 06-2006. The closing date is 26 June 2006. Competition not open to employees of Segment b.v., its business partners and/or associated publishing houses. An Elektor SHOP Voucher worth £35.00 goes to: Rune Grysbaek (Tarm, DK), Brian Unitt (Bishops Stortford, UK) and John Phillips (Chiswick, UK). 2 6 9 8 E 5 D A B F 3 B 7 D 9 6 8 A D 3 4 1 0 C E 0 5 C F 3 8 D 4 3 7 6 8 E 5 9 C C 5 1 2 F 8 9 4 1 7 3 D F 5 1 B 5 4 6 9 7 2 6 9 3 1 7 0 D F E 5 5 2 7 0 E B 9 8 B 8 1 A C 2 7 4 D E A 5 3 C 6 8 9 A B 0 2 9 D 4 4 5 B A 6 C 0 E 3 C 8 0 9 5 6 6 5 3 D E F Solve Hexadoku and win! Correct solutions qualify for an E-blocks Starter Kit Professional worth £248.55 and three Elektor Electronics Shop Vouchers worth £35 each. We believe these prizes should encourage all our readers to participate! 6/2006 - elektor electronics 77 ELEKTOR SHOWCASE To book your showcase space contact Huson International Media Tel. (0) 1 932 564999 Fax 0044 (0) 1 932 564998 ATC SEMITEC LTD www.atcsemitec.co.uk Thermal and current-sensitive components for temperature control and circuit protection; • NTC Thermistors • Current Diodes • Thermostats • Re-settable Fuses • Thermal Fuses • Temperature Sensors Call today for free samples and pricing Tel: 0870 901 0777 Fax: 0870 901 0888 BETA LAYOUT www.pcb-pool.com Beta layout Ltd Award- winning site in both English and German offers prototype PCBs at a fraction of the cost of the usual manufacturer’s prices. DESIGN GATEWAY www.design-gateway.com PalmLogic II .... US$ 399.00 • Compact Logic Analyzer (L1 1 6mm x W73.3mm x T3mm) • High sampling rate (400 MHz/ 8ch, 200 MHz/1 6ch, 100 MHz/32ch)(i| • USB 2.0 high speed mode • 8MB memory storage • Bus Analyzer function • Multiple waveform windows • Waveform save/restore DESIGN GATEWAY www.design-gateway.com True PCI Starter Kit .... US$135.00 • PCI Development Kit • Based on 200,000 gates FPGA • Extension connectors for 72 pin I/O pa • Configuration support for JTAG and slave serial • Free PCI Core for Target Mode DESIGN GATEWAY www.design-gateway.com Ethernet 10 .... US$115.00 • 8 bits embedded network microcontroller • 6 channels available for 10 bits ADC • Ethernet 1 0 BASE T 1 0 Mb • UART port RS232/RS485, Max Speed atl 1 5200bps • 35 bits general purpose I/O • 500 bytes user area flash memory DESIGN GATEWAY www.design-gateway.com VariClock... US$163.00 • Adjustable clock signal synthesizer • 3 rotary switches for frequency setting • Standard DIP pin arrangement • Support both 3V/5V by on-board regulator VC250M14P Frequency range : 25-400 MHz Frequency setting : 1 MHz step VC100M14P Frequency range : 25-100 MHz Frequency setting : 1 00 kHz step for 25- 50 MHz : 200 kHz step for more than 50 MHz AVIT RESEARCH www.avitresearch.co.uk USB has never been so simple... with our USB to Microcontroller Interface cable. Appears just like a serial port to both PC and Microcontroller, for really easy USB connection to your projects, or replacement of existing RS232 interfaces. See our webpage for more details. Only £29.99 inc vat. COMPULOGIC LTD www.compulogic.co.uk Internet Remote Control Starter Kit £139.99 Create a simple web based remote control interface for many applications • Miniature Web Server Module • Analogue/Digital Module •PSU • Manuals, software, example HTML code CONFORD ELECTRONICS http://www.confordelec.co.uk Lightweight portable battery/mains audio units offering the highest technical performance. Microphone, Phantom Power and Headphone Amplifiers. Balanced/unbalanced signal lines with extensive RFI protection. DANBURY ELECTRONICS http://www.DanburyElectronics.co.uk Transformer manufacturers since 1 983. Visit our new site! Also link directly to Mike Holme’s Valve/- Tube DIY amplifier site, featuring our standard Audio Transformers (Mains, Output, Chokes, PP, SE, etc). EAGLEPICS http://www.eaglepics.co.uk Embedded Internet Solutions • Stand alone TCP/IP module • Platform independent • Simple "AT-like" command set • GPRS or modem connection • E-Mail, FTP, HTTP, UDP • Development board available • Free development utilities • Free UDP-only stack EASYSYNC http://www.easysync.co.uk EasySync Ltd sells a wide range of single and multi- port USB to RS232/RS422 and RS485 converters at competitive prices. ELNEC www.elnec.com m • device programmer manufacturer • selling through contracted distributors all over the world • universal and dedicated device programmers • excellent support and after sale support • free SW updates • reliable HW • once a months new SW release • three years warranty for most programmers FIRST TECHNOLOGY TRANSFER LTD. http://www.ftt.co.uk/PICProTrng.html Microchip Professional C and Assembly Programming Courses. The future is embedded. Microchip Consultant /Training Partner developed courses: • Distance learning / instructor led • Assembly / C-Programming of PIC1 6, PIC1 8, PIC24, dsPIC microcontrollers • Foundation / Intermediate FUTURE TECHNOLOGY DEVICES http://www.ftdichip.com FTDI designs and sells USB-UART and USB-FIFO interface i.c.’s. Complete with PC drivers, these devices simplify the task of designing or upgrading peripherals to USB FUTURLEC http://www.futurlec.com Save up to 60% on . • Electronic Components ' _ • Microcontrollers, PIC, Atmel • Development Boards, Programmers Huge range of products available on-line for immediate delivery, at very competitive prices. HEROS TECHNOLOGY LTD www.herostechnology.co.uk Introducing Modular Concept for microcontrollers. Suitable for Developers, Pre-production, Educational and Hobby applications. • WinPIC2006 USB full speed programmer. • CPU microcontroller modules. • Peripheral modules for all microcontrollers. IPEVA LIMITED http://www.ipeva.com IPEVA sell low cost USB FPGA ■ ipwa development boards. IPEVA ^ provide Design Consultancy for Embedded Systems, OpenCores-IP, FPGA, ASIC, HDL translation and migration. Tel. 0870 080 2340. 78 elektor electronics - 6/2006 products and services directory JLB ELECTRONICS www.jlbelectronics.com Suppliers of electrical / electronic parts and consumables. Including: • Cable ties / bases • Tools / hardware • Bootlace ferrules • Connectors • Solvent sprays & cleaners • PVC Tape • Heat Sink compound KMK TECHNOLOGIES Ltd. http://www.kmk.com.hk Low Cost DIY Robotic Kits and Computer Controller Boards. LONDON ELECTRONICS COLLEGE http://www.lec.org.uk Vocational training and education for national qualifications in Electronics Engineering and Information Technology (BTEC First National, Higher National NVQs, GCSEs and Advanced Qualifications). Also Technical Management and Languages. MQP ELECTRONICS http://www.mqpelectronics.co.uk Leaders in Device Programming Solutions. • Online shop • Low Cost Adapters for all Programmers • Single Site and Gang Programmers • Support for virtually any Programmable Device I NEW WAVE CONCEPTS www.new-wave-concepts.com Software for hobbyists: • Livewire circuit simulation software, only £34.99 • PCB Wizard circuit design software, only £34.99 Available from all Maplin Electronics stores and www.maplin.co.uk. t OLD COLONY SOUND LAB www.audioXpress.com Premier source for DIY audio for 35 years! New catalog features: • Books •CDs •Test & Measurement • Kits Full range of products and magazines for the DIY audio enthusiast! PCB WORLD http://www.pcbworld.org.uk World-class site: Your magazine project or prototype PCB from the artwork of your choice for less. Call Lee on 07946 846159 for details. Prompt service. ULTRALEDS lUJ traJ http://www.ultraleds.co.u!^^^ tel: 0871 7110413 Large range of low cost Ultra bright leds and Led related lighting products. Major credit cards taken online with same day depatch. 1 SHOWCASE YOUR COMPANY HERE Elektor Electronics has a feature to help customers promote their business, Showcase - a permanent feature of the magazine where you will be able to showcase your products and services. • For just £220 + VAT (£20 per issue for eleven issues) Elektor will publish your company name, website adress and a 30-word description • For £330 + VAT for the year (£30 per issue for eleven issues) we will publish the above plus run a 3cm deep full colour image - e.g. a product shot, a screen shot from your site, a company logo - your choice Places are limited and spaces will go on a strictly first come, first served basis. So please fax back your order today! I wish to promote my company, please book my space: • Text insertion only for £220 + VAT • Text and photo for £330 + VAT NAME: ORGANISATION: JOB TITLE: ADDRESS: .TEL: PLEASE COMPLETE COUPON BELOW AND FAX BACK TO 00-44-(0)1932 564998 COMPANY NAME WEB ADDRESS 30- WORD DESCRIPTION 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 SK PANG ELECTRONICS http://www.skpang.co.uk • ELM OBDII 1C • VAG-COM Interface • OBDII connector and cable • Modtronix Micro X board • Embedded Ethernet Controller • PIC Microcontroller, CAN Bus driver Major credit cards taken online. SYTRONIC TECHNOLOGY LTD www.m2mtelemetry.com Supplier of wireless modules and accessories for remote monitoring M2M applications. •GSM/GPRS TCP/IP modules • Embedded GSM/GPRS modem • Development Kits • GPS modules • GSM/GPS antennas • Adapter cables Online ordering facilities. Tel (01 394) 210911 USB INSTRUMENTS http://www.usb-instruments.com USB Instruments specialises in PC based instrumentation products and software such as Oscilloscopes, Data Loggers, Logic Analaysers which interface to your PC via USB. VIRTINS TECHNOLOGY www.virtins.com PC and Pocket PC based virtual instrument for electronics enthusiasts, students, professionals and scientists, including sound card real time oscilloscope, spectrum analyzer, and signal generator. Free to download and try. ELECTRONIC ENTHUSIASTS Only one magazine tests its projects and circuits in its own lab before publication ELEKTOR ELECTRONICS THE ELECTRONICS & COMPUTER MAGAZINE Contact: Worldwide Subscription Service Ltd, Unit 4 Gibbs Reed Farm, Pashley Road, Ticehurst TIMS 7HE Telephone: 01580 200657 Fax: 01580 200616 www.elektor-electronics.co.uk 6/2006 - elektor electronics 79 This Issue SCOPEMETERS COMPARED 10 mobile oscilloscopes compared for performance Next Issue: SUMMER CIRCUITS EDITION 2006 More than 1 00 small circuits, tips and ideas also! GAMEBOY AS HOME AUTOMATION CONTROLLER Want to know everything each month? Subscription rates and conditions may be found at the back of this issue. Offer available to Subscribers who have not held a subscription to Elektor Electronics during the last 12 months. Offer subject to availability. < 0 »"' 'o' .