71
EPE Online, Febuary 1999 - www.epemag.com - XXX

EPE_10-1999

Embed Size (px)

DESCRIPTION

practical electronics magazine

Citation preview

Page 1: EPE_10-1999

EPE Online, Febuary 1999 - www.epemag.com - XXX

9ROXPH,VVXH

2FWREHU

Page 2: EPE_10-1999

EPE Online, February 1999 - www.epemag.com - XXXEPE Online, October 1999 - www.epemag.com - 937

PROJECTS AND CIRCUITS

PIC16F87x MINI TUTORIAL - by John Becker Practical guidance on using the new PIC microcontroller family. 974

PRACTICAL OSCILLATOR DESIGNS - 4 Negative resistance oscillatorsWorking examples and circuit info for hands-on constructors. 965

CIRCUIT SURGERY - by Alan Winstanley and Ian BellLow Voltage 555; Digital Panel Meters; Sound Levels and Decibels

990

REGULARS AND SERVICES

NEWS - Barry Fox highlights technology’s leading edge. Plus everydaynews from the world of electronics.

998

READOUT - John Becker addresses general points arising. 1004

SHOPTALK - with David Barrington The essential guide to component buyingfor EPE Online projects.

1002

EDITORIAL 938

SERIES AND FEATURES

MAINS CABLE DETECTOR - by Robert PenfoldThis simple Starter Project detects mains cables by sensing their “hum” 946

INTERFACE by Robert PenfoldMore on serial interfacing your PC

986

MICRO POWER SUPPLY - by Andy Flind Supplies a well-regulated +/-5V even if your battery’s nearly flat!

960

INTERIOR LAMP DELAY - by Steve ChallisDon’t you just hate being pluged into darkness when the car door shuts?Here’s a solution! Plus lights on alarm and battery saver 940

INGENUITY UNLIMITED - hosted by Alan WinstanleyShoestring MW Radio ; Auto Supply Crowbar

958

NET WORK - THE INTERNET PAGE surfed by Alan WinstanleyExplore New Options (MSIE 5.0); 1984 And All That; Looking Ahead

996

QWL LOUDSPEAKER SYSTEM - by John DixEnjoy superb hi-fi sound at a fraction of the cost of an equivalent commercialspeaker system

950

NEW TECHNOLOGY UPDATE - by Ian Poole Sensing electron spin-directions increases hard disk densities

963

Page 3: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - XXX

TIME FLIES LIKE A FRUITBAT…It was only as we were putting this October 1999 issue to bed that we realized that this was

the twelfth issue of EPE Online – that’s right, we’ve now been up and running for an entire year!

To be honest we don’t know where the time has gone – it seems like only a couple of weeksago that we started working on our first issue (November 1998). Our personal theory is thateveryone is given 24 hours-worth of “time particles” to get them through each day, but thatsome swine is absconding with half of ours.

If this is the case, then someone out there is basking in the glow of having 36 hours to playwith in each day, while we’re left desperately trying to get everything done in only 12 hours! Ofcourse this may not be the best theory in the world, but it would certainly explain the way thingsseem to work around here …. but we digress …

INNOVATIONSSince we started EPE Online, you will have noticed that we are constantly evolving and

improving our web site and our web-delivered capabilities. Well following requests from anumber of readers, this month we feature something new – from now on the EPE Online Librarywill contain postscript files of the copper foil master patterns for our printed circuit boards, whichwill be tremendously useful for those of you who like to make your own circuit boards.

KONRAD ZUSEKonrad Zuse was one of the all-time greats in early computing, yet thus far he has remained

largely unknown outside his native Germany. At the end of this month, there is going to be aKonrad Zuse Colloquium & Z23 Dedication in Mountain View, California. At the same time,Konrad Zuse is going to be made a Fellow of the Computer Museum History Center.

For the last two months we have been working with Konrad’s eldest son – Horst Zuse – tobring you a world-exclusive article on Konrad Zuse's life and work. This article, which can befound at the EPE Online web site at www.epemag.com features many hitherto unpublishedphotographs and images from Horst’s private collection. Now be honest, you don’t get this sortof treat with any other magazine, do you?

EPE Online, October 1999 - www.epemag.com - 938

Page 4: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 939

EPE ONLINE TEACH-IN 2000o) During this 10-part series we shall lead you through the fascinating maze of what electronics is all

about!

o) We shall assume that you know nothing about the subject!

o) We shall take individual components and concepts in simple steps and show you, with lots of ex -amples, that using electronic components need not be a complex task and that you too can actu -ally design and build something that works!

Much of electronics is about building blocks, and once you have understood what they can do and whythey can do it, these blocks can be combined in many different ways to achieve increasingly more sophisti-cated goals. To assist you in getting to know about the various building blocks, a set of illustrative computerprograms has been prepared. We believe these to be capable of running on any comparatively recent PC-compatible computer (from Windows 3.1 upwards). We stress, though, that it is not necessary to own a com-puter in order to gain benefit from following this Teach-In series.

The programs not only illustrate particular electronics concepts discussed in each Tutorial, but also offeryou interactive involvement, with the ability to specify your own component values and voltages. Self-testand experimental exercises are included. The programs also allow you to use your computer as an item oftest equipment, letting you input data from both analog and digital circuits, displaying it as meaningful screendata and/or waveforms.

STOPWATCHAPIC-based LCD stopwatch design giving Start, Stop, and Lap functions and a maximum time of 10

hours in increments of hundredths of a second. Not only can the functions be triggered by pushbuttons or byremote infrared beams via a radio frequency link, but the unit will also output serial data to feed a large, highbrightness LED display.

Part 1 describes the design and construction of the Stopwatch and radio links, etc. Part 2, in the Decem-ber issue, gives details of the large LED display – each digit measures approximately 200mm by 125mm.

This versatile unit could be used for timing – and displaying times to competitors and crowd – athletic,equestrian, sailing, cycling, or motoring events, and so forth.

ACOUSTIC PROBEThis project could be regarded as the audio equivalent of a telescope. Its basic function is to pick up

sounds via a microphone, greatly amplify the resultant signal, and then feed it to a pair of headphones. Thisgives users a sort of “larger than life” version of what they would normally hear, permitting them to detectsounds that would otherwise be inaudible.

Apart from making sounds louder, it is often possible to place the microphone very close to the soundsource, or even actually touching it, so that otherwise inaudible sounds can be monitored. When used in thisway the unit acts as a sort of electronic stethoscope, and the barely audible sound from a watch can be madeto sound more like a shipyard in full production. It is even possible to place the microphone underwater, per-haps to monitor the wildlife in a pond, provided the microphone is given adequate waterproofing.

Page 5: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 940

It’s a sad fact that you oftendon’t appreciate something untilyou no longer have it! This wasdriven home recently to theauthor when he acquired a “new”car. The first dark evening hejumped in and shut the door, andwas plunged into total darkness.The mere 12-second delay fittedto the previous vehicle wasample to settle in and drive away.It was then decided that someform of interior lamp delay was amust.

There have been plenty ofpast articles showing potentially

connection. Capacitors C1, C2and C3 provide supplydecoupling for the regulator.

Because IC2 runs at 5V,each of its inputs needs to beconditioned prior to application.In the case of the door switchinput, this is effected byresistors R8 and R9, capacitorC6, and diode D3. Resistors R8and R9 form a potential divider,which reduces the input voltageby half. For a supply voltage of13¬¬¬8V this would give 6¬¬¬9V.

This is still too high for IC2,whose recommended operatingvoltage should not exceed 6V.Consequently, Zener diode D3is included to limit the voltage to5¬¬¬1V. Some of you mightwonder why the potential dividershould not be arranged to givethe correct voltage without theuse of a Zener diode. Well, the

supply voltage in amotor vehicle can vary over alarge range, from typically 9Vwhilst cranking, to just over14minimal load.

¬¬¬5V when charging with a

Thus the potential dividerconfiguration used here isarranged to give the correctlogic level inputs under most

Add a touch of luxury and practicality to your vehicle.Also provides light on warning and battery saving.

,17(5,25/$03'(/$< E\67(9(&+$//,6

usable circuits based aroundchips such as the ubiquitous555. Whilst perfectly functional,these circuits are limited inadditional features. In thisdesign, full advantage is madeof a PIC16x84 to providefeatures that would haverequired a large amount of logicnot so long ago. The basicoperational features are asshown in Table 1.

CIRCUITDESCRIPTION

The complete circuitdiagram for theInterior Lamp Delayis shown in Fig.1.The vehicle 12Vbattery supply is fed

through diode D1 tothe voltageregulator IC1, whichsupplies +5V forPIC microcontrollerIC2. The diode isincluded to provideprotection againstreverse supply

Table 1. Operational Features

Interior lights on for 30 seconds thenfade off.

Interior lamps directly off.

Interior lamps directly on.

Interior lamps fade off after 30seconds.

Interior lamp delay function cancelledbut lamps fade off.

If the ignition is turned from on to offwith the lights on (or having been onwithin the last 10seconds) then theinterior lamp will fade on and remainilluminated for up to 30 seconds beforefading off again. If the ignition is turnedon during the 30-second period thenthe interior lamps will fade off.

If the doors are left open for more thanfive minutes the interior lamps areswitched off to reduce battery drain.

If a door is opened with the side lampson and the ignition off then an audiblewarning is activated for 10 seconds.

Unlock the vehicle:

Lock the vehicle:

Open the door:

Close the door:(ignition off)

Close the door:(ignition on)

Side lamps on:

Battery saver:

Lights on warning:

Page 6: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 941

conditions. Capacitor C6 isincluded to filter out anyunwanted noise. The samecircuit arrangement is used onthe other three inputs.

The vehicle’s interior lampis controlled by the PIC throughthe network around transistorsTR1 to TR3. To provide adimming feature, pulse widthmodulation is employed. Power-FET (field effect transistor) TR1is switched on/off at a highfrequency. The on/off ratioaffects the average powerdelivered to the lamp and henceits brightness, as illustratedgraphically in Fig.2.

Since TR1 is either on or offit does not dissipate anyappreciable heat. As a result itdoes not require a heatsink and

runs cool in normal operation.Even when running a 100W testlamp, the case temperatureremained within acceptablelimits. It is expected that mostinterior lamps will be around10W to 20W!

In order to turn TR1 hardon, a voltage of around 12V isneeded at its gate terminal.Transistors TR2 and TR3convert a logic 1 output at IC2pin RB7 from 5V to 12V. WithRB7 at 0V, TR2 and TR3 areturned off. When RB7 goes high(5V) current flows via R7 intothe base of TR3.

Transistor TR3 thenconducts, drawing current viaR2 and R3, the resulting voltagedrop at their junction causesTR2 to turn on. The collector

potential of TR2 then rises to 12Vand this is applied via R6 to thegate of TR1 causing it to conduct.The drain to source resistance ofTR1 falls to a low value and theinterior lamp illuminates.

When the RB7 output of IC2goes to 0V, TR3 switches off, asdo TR2 and TR1, and so currentno longer flows in the interiorlamp.

Resistor R1 is fitted toprovide a “pull-up” voltage fromthe 12V power supply for the doorswitch input.

During periods of fullbrightness, the RB7 output of IC2has to remain at 5V. Whendimming is required a pulse-widthmodulated signal is generatedand the On time is graduallyreduced until the interior lamp isoff. Diode D2 is included toprevent any reverse voltagespikes entering TR1.

Resonator X1, in conjunctionwith capacitors C4 and C5, formsthe 4MHz oscillator needed byIC2.

An audible alarm facility hasbeen included in the form of

&RQVWUXFWLRQDO3URMHFW

21

2))

$9(5$*(

6+257 21 7,0( ',0 /21* 21 7,0( %5,*+7

Fig.2. Pulse width modulation varies the average power/bright-ness of the lamp, as represented by the dotted line.

J

G

V

E

F

H

E

F

H

5N

5N

5N 555

NNN

555NNN

5N

5N

75%&

75%&

756031

&S

&Q

&Q

&S

&&&µ

µ

;0+]

5%

222666&&&

555$$$

%%%

5

9(0&/5

*1'

,&3,&;

,&/

:'

'1

'1

D

D

N

N

DDD

DDD

N

N

NNN

'9

'9

'''999

555NNN

555NNN

&(175$//2&.,1*

,*1,7,21

666,'(/,*+76

'225:,7&+

,17(5,25/$03

*5281'

,12879

&20

9

5%

Fig.1. Complete circuit diagram for the Interior Lamp Delay.

Page 7: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 942

WD1. This is connected directlyto IC2 pin RB5, which pulsesthe buzzer when the vehiclelights are inadvertently left on.

CONSTRUCTIONAND TESTING

The components for theInterior Lamp Delay aremounted on a single-sidedprinted circuit board (PCB),whose details are shown inFig.3. This board is availablefrom the EPE Online Store(code 7000244) atwww.epemag.com .

Begin construction by usingthe board as a template to drillthe equivalent mounting holesin the suggested case.

Solder the components intothe board observing theircorrect orientation, whereappropriate, and using a socketfor IC2. Do not insert IC2 yet.Once all the components havebeen fitted, carefully check theboard for solder splashes andother signs of bad soldering. Acurrent-limited power supply (ifavailable) set to 12V shouldnow be connected to the board.

With a multimeter, checkthat the 5V supply is correct atpin 14 of the socket for IC2. Ifnot, switch off the supply andcarefully check the orientationof IC1.

It is necessary to next checkeach of the used inputs to IC2,namely socket pins 1, 2, 6 and 7(RA2, RA3, RB0 and RB1). Thevoltage reading at pin 1 shouldbe about 5¬¬¬1V. Now ground thedoor switch input to the board.The reading at pin 1 shoulddrop to 0V and return to theprevious value when the groundis removed.

Next move on to pin 2. Thevoltage here should be 0V.Apply 12V to the side lamp

input and the voltage should riseto approximately 5¬¬1V. Theignition and central locking inputs(pins 6 and 7) must be checked inthe same manner. If any errorsare found then rectify thembefore continuing.

Re-apply power to the board.The lamp should not light. If itdoes, then carefully check aroundTR1, TR2 and TR3 for any errors.Also check the orientation ofdiode D2. Using a small piece ofwire, carefully bridge pins 13 and14 of IC2’s socket. The lampshould illuminate. If not, onceagain, check for errors. If allappears OK disconnect the

supply, remove the link, andinsert IC2 (which needs to havebeen pre-programmed, ofcourse).

Again re-apply power. Thelamp should remain off. Usinganother link wire, carefully applypower to the central lockinginput. The lamp shouldilluminate when power isapplied and go off whenremoved. There should be nodelay. Leave power applied tothe lock input. Now ground thedoor switch input. After 30seconds, the lamp should fadeoff.

The main features of the

&RQVWUXFWLRQDO3URMHFW

&&&

&

F

F

H

H

NNN N

N

N

DDD D

D

D

''' '

'

'

555

5

5

555

&

&&&&

5

5 555

5

;

,1287

&20

E

E

7575

75

6,'(///,*+76

,*1,7,21

&(175$/2&.,1*

'2256:,7&+

9

/$03

9

:'

*5281'

JGV

Fig.3. Component layoutand (approximately) full sizecopper foil track pattern for

the Interior Lamp Delay.

Page 8: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 943

circuit have now been tested.Full functional tests can becarried out on the vehicle.

Remove power from theboard and finish construction byattaching the board to the caseand fitting suitable lengths ofthe correct gauge insulatedwire.

The accompanyingphotograph shows how theauthor attached the buzzer tothe PCB, making use of themounting bolt for TR1, plus anadditional bolt for which anextra hole was drilled in thePCB (no pad exists for thishole). A hole should be drilled inthe case above the buzzer toallow the sound to be emitted.

SOFTWAREIt is beyond the scope of

this article to describe fully theinternal operation of thesoftware that is programmedinto IC2. The main flow chart,however, is shown in Fig.4.

&RQVWUXFWLRQDO3URMHFW

Basically, the PWM signalis generated by an interruptroutine. The value passed to it(BULB) controls whether thelamp is turned on, faded on/off,or turned off. A second variable(BUZZ) is used to control thelights-on buzzer WD1.

The source code waswritten in C and is fullycommented. It was compiledusing the excellent CustomComputer Services PCMcompiler. Their web site is atwww.ccsinfo.com and is wellworth a visit.

All the files for the software,both source and hex code, areobtainable from the EPE OnlineLibrary at www.epemag.com .The PIC should be initialized forHS oscillator, power-up timeron, watchdog timer on.

WARNINGPlease read the following

notes carefully before installingthe unit.

A car battery can deliver avery high current. This willalmost certainly result in a fire ifnot treated with caution. Inaddition to this, modernvehicles are fitted with a varietyof electronic modules. A wrongconnection can be costly!

When tapping into supplywires (permanent supply,ignition, side lamps, centrallocking) it is advisable toconnect a low value fuse asclose as practical to the tappingpoint. This will protect youradditional wiring should a fault

COMPONENTSResistors

R1 470 ohm 0.5WR2, R4 2k2 (2 off)R3, R7 to R15 10k (10 off)R5 1kR6 330 ohms

See also theSHOP TALK Page!

All 0.25W 5% carbon film or betterexcept R1 (see above)

CapacitorsC1 100u radial electrolytic, 35VC2, C3 100n ceramic (2 off)C4, C5 22p ceramic (2 off)C6 to C9 10u tantalum 10V (4 off)

SemiconductorsD1, D2 1N4001 rectifier diode (2 off)D3 to D6 5V1 400mW Zener diode (4 off)TR1 SMP40N10 power FETTR2 BC558B pnp transistorTR3 BC548B npn transistorIC1 78L05 +5V 100mA regulatorIC2 PIC16C84/04P (or 'F84) microcontroller (preprogrammed)

Miscel laneousWD1 buzzer, low current, 3V to 16VX1 4MHz ceramic resonator

Printed circuit board availablefrom the EPE Online Store, code7000244 (www.epemag.com );18-pin DIL socket; terminal pins(9 off); plastic case to suit; cableties; cable connectors (see text)connecting wire, solder, etc.

$38Approx. CostGuidance Only

Page 9: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 944

occur. The author used 20mm1A fuses in suitable holders.These are available from

accessory shops.

Another item thatrequires respect is theAirbag. If your vehicle isfitted with one of thesedevices then it is advisableto disconnect the vehiclebattery and wait for at least10 minutes before attemptingto fit any electricalaccessory. Finally, if youhave a coded radio, pleasemake sure you know thesecurity code beforedisconnecting the supply!

If you are at all unsureas to what you are doing…. don’t do it! Instead youare advised to consult aqualified auto electrician.

INSTALLATIONDo not be tempted to use

the “scotch lock” type ofconnectors. These are greatfor temporary use, but couldcause trouble at a later date.If possible solder allconnections. Once again, ifyou are at all unsure, thenenlist the help of acompetent friend. It’s betterto be safe than to have towalk!

Choose a location for theunit where you will be able to

hear the buzzer, but away fromheat and moisture. Nylon cableties are excellent for mountingthe completed unit.

You will need to locate thewire that connects between theinterior lamp and the doorswitch. Cut into this wire andconnect the wires from the unitas indicated schematically inFig.5. Connect the remainingwires and secure neatly. Ensurethat the wires are not restingagainst any sharp edges or indanger of becoming trapped inany moving object.

The central locking inputmust be connected to a wirethat is at 12V when the doorsare unlocked. If your vehicle is

&RQVWUXFWLRQDO3URMHFW

$5( $1< '2256 23(111$1' %$77(5< 6$9(5 &28 7(5/(66 7+$1 0,,,187(6"

,6 ,*1,7,216:,7&&&+21$1' $5( '2256 /26('"

+$9( /$036 %((121 )25025( 7+$1 0,11187(6"

+$9( '2256 %((1 8 /2&.('"

+$9( '2256 %((1 /2&.('"

,6 '22523(1,*1,7,212))$1' /,*+76 21"

+$6 ,*1,7,21 666:7&+ %((17851(' )520 21 72 2)) $1' 7+( 6,'(/,*+76 21 25 +$9( %((1 21 :,7+,1

7+( /$67(&21'6"

$5( $// '2256&/26('"

%%%888/%%% /$$$036',5(&7/<21

%888///%%% )))$'''(((///$$$00033362))

% % % ///$$$000333666',,,555(((&777/<<<222))

8///%%% '''&&&/// 1

%%%888/$036 ,5( 7 < 2))

== 6281' %8==(5

%8== 12 %8==(5

6(783 ,17(51$/ 5(*,67(5675,657&&

67$57

666(((777/$03 9$/888(%8/%%8==(5 9$/8( %8== )25

86( ,1 ,17(55 37 5287,1(

21

5(6(7 %$77(5<6$9(5 7,0(5

<<<

<<<

<

<<<

777+++(((,17(55837 5287,1( :,// 7$.(((7+(9$/8(((62) %8== $1' %8/% $1' &21752/

'(9,&(6 $&&25',1*/<,17 55837&$// ' $3352;(9(5<PV

Photo: Interior view of the as-sembled printed circuit board

mounted inside its plastic case.Note that the buzzer is bolted to

the board.

6,'(/$036

,*1,7,216:,7&+

&(175$//2&.,1*

&211(&772&(175$/ /2&.,1*259 6833/<

&211(&7 72 ,*1,7,216:,7&+(' 6833/<

&211(&7 726,'( /$036

9

9

,17(5,25/$03

'2256:,7&+(6

%5($.:,5(

/$03

'225 6:,7&+(6

*5281'

,17(//,*(17,17(5,25 /$03'(/$< 02'8/(

Fig.5. Schematic representa-tion of the connections be-

tween the PCB and the car’sutilities.

Page 10: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 945

not fitted with central locking ora suitable wire cannot be found,then connect this wire to thepermanent supply. If it isgrounded or left open circuit theunit will not function.

When completed, reconnectthe vehicle battery and continuetesting the unit.

FINAL TESTINGSit in the vehicle and close

the door. After 30 seconds theinterior lamp should fade off.Open the door and the interiorlamp should illuminate. Theinterior lamp will remainilluminated for as long as thedoor is open (up to five

minutes). Now switch on theignition. When the door isclosed the interior lamp shouldfade off after a delay of abouttwo seconds.

Switch off the ignition. Theinterior lamp should remain off.Turn on the side lights. Nowswitch the ignition on then off.The interior lamp should fadeon. Turn on the ignition. Theinterior lamp (if still on) shouldfade off. Finally switch off theignition and open the door. Thelights-on buzzer should nowactivate for 10 seconds or untilthe door is closed or the lightsturned off.

If you feel patient, thebattery saving function can now

be tested. Leave the door open.After about five minutes theinterior lamps should extinguish.To re-enable the lamps closethe door and re-open it.

Finally, if the central lockinginput has been connected,switch off the lights, ignition,and close the door. Lock thevehicle. The interior lampshould extinguish immediately.When the vehicle is unlockedthe interior lamp shouldilluminate immediately andremain illuminated for up to 30seconds.

Now wait for it to get darkand reap the benefits.

&RQVWUXFWLRQDO3URMHFW

Page 11: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 946

Probably most keen do-it-yourself enthusiasts are aware ofthe dangers of drilling into thewalls of practically any building,and use some form of pipe/cabledetector to check that it is safeprior to doing any work of thistype. Such precautions shouldensure that there are no nastysurprises, but some types ofcable can be difficult to detect.

Most pipe and cable locatorsare actually metal locators thatare optimized for this application.They are quite good at findingthings like nails in doors andplasterwork, locating metal pipes,and finding cables in metalconduits. However, they tend tobe less effective at findingelectric cables that are in plasticconduits.

The problem seems to bethat there is simply not that muchmetal in an electric cable,especially a lighting type that isonly designed to carry modestcurrents. This makes such cablesdifficult to detect unless they areclose to the surface of a wall.

MAKING A HUMThe project featured here

uses an alternative approach tofinding cables, which is to pick upthe 50-Hertz mains “hum” signalproduced by the cable. Thissignal seems to be relatively easyto locate, even with a small cablethat is buried deep in a wall.

One obvious drawback of this

in the cable, which effectivelybecomes the primary winding ofa transformer. An inductor atthe input of the detector circuitacts as the secondary winding,and a small 50Hz “hum” signalis produced in this inductor if itis close enough to the cable.

Practical tests with this typeof cable detector were not veryencouraging, and the signalfrom the inductor was often soweak that it was virtuallyimpossible to detect. The designfinally evolved uses the slightly

A back-up mains cable locator for your DIY toolbox.

0$,16 &$%/( '(7(&725

E\ 52%(57 3(1)2/'

method is that it will not detectany form of pipe or small metalobjects such as screws andnails. It is, therefore, best usedas a backup to a conventionalpipe and cable locator ratherthan as the sole method ofdetecting drilling hazards.

SYSTEM OPERATIONUnits of this type sometimes

use an inductive coupling fromthe cable to the detector. Thisrequires a current to be flowing

8978 J

2E665B

1=@

=19>C

CE@@<I

C5>C?B

@<1D51=@<9695B

=19>C

1@@<91>35

51B@8?>5

Fig.1. Block diagram for the Mains Cable Detector.

2!)FB"

! =

B%#)[

C5>C?B

@<1D5

3"" "P

B&! [

B!! =

3!! P

B#! =

B$! =

93!<6#%!>

3#!^

C;!

51B@8?>5

B'!=

?>?66

C!

3$! ^

#

"

'

&

$

Fig.2. Complete circuit diagram for the MainsCable Detector.

Page 12: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 947

different arrangement shown inthe block diagram of Fig.1.

Rather than an inductor, thesensor is a small metal plate.The mains cable and the plateform a very low value capacitor,with the air, etc. between themacting as the dielectric.

This gives an extremelyloose coupling from the cable tothe input of the detector circuit,but the large signal level in thecable of around 650V peak-to-peak helps to give a reasonablesignal level from the plate. Ahigh impedance buffer amplifierat the input of the detectorcircuit also helps to minimizelosses through the capacitive -coupling.

This stage is followed by avoltage amplifier that furtherboosts sensitivity, but only amodest amount of amplificationis needed here. The outputsignal is monitored via a crystalearphone, and it is due to thegood sensitivity of this type ofearphone that high gain is notneeded in the detector circuit.

CIRCUIT OPERATIONThe full circuit diagram for

the Mains Cable Detector

appears in Fig.2. In Fig.1 theunit is shown as havingseparate buffer and voltageamplifier stages, but in the finalcircuit these have been mergedinto a single amplifier based onoperational amplifier, IC1.

Having a very high inputimpedance plus some voltagegain in a single stage can causeproblems with stray feedbackand consequent instability.However, in this case thevoltage gain of the circuit isquite low and no stabilityproblems were encountered.

The circuit is basically just anon-inverting mode amplifier.The non-inverting input (pin 3)of IC1 is biased to half thesupply voltage by resistors R1to R4. IC1 is a bifet device thathas a JFET input stage and anextremely high inputimpedance. In fact, its inputimpedance at low frequencies isso high that it can be ignored.The input impedance of thecircuit as a whole is thereforeequal to the parallel resistanceof R1 and R2 in series with R3and R4, or some 25 megohms.

&RQVWUXFWLRQDO3URMHFW

COMPONENTSResistors

R1 to R4 10M (4 off)R5 39kR6 10kR7 1M

See also theSHOP TALK Page!

All 0.25W 5% carbon fi lm

CapacitorsC1 100u radial electrolytic, 10VC2 2u2 radial electrolytic, 50VC3 1n mylarC4 100n ceramic

SemiconductorsIC1 LF351N bifet opamp

Miscel laneousS1 s.p.s.t. miniature toggle switchSK1 3.5mm jack socketB1 9V battery (PP3)

Small plastic case, size to choice;multi-project printed circuit boardavailable from the EPE OnlineStore (www.epemag.com ) code7000932; copper clad board oraluminum plate for sensor, size50mm x 50mm approx; crystalearphone; 8-pin DIL socket; batteryconnector; connecting wire,solder pins, solder, etc.

$15Approx. CostGuidance Only(Excluding Batt. & case)

Components mounted on the multi-project printed circuitboard. Note the single link, top right.

Page 13: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 948

LOOP GAINThe closed loop voltage

gain of IC1 is controlled bynegative feedback resistors R5and R6, and is equal to (R5 +R6)/R6, or approximately fivetimes in other words. CapacitorC3 provides increased negativefeedback at middle audiofrequencies and above, andtherefore provides aprogressive roll-off in the gainof the circuit over this frequencyrange.

The “hum” signal ispredominantly at lowfrequencies, and the highfrequency roll-off does notreduce the sensitivity of the unitto this signal. It does help toreduce general noise andbreakthrough of RF (radiofrequency) signals. It alsoreduces the risk of instabilitydue to stray feedback at highfrequencies.

Capacitor C4 and resistorR7 couple the output signal tothe crystal earphone andremove the DC component inthe signal at the output of IC1.The unit is unlikely to workproperly using any other type ofearphone or headphones. Asmall 9V battery is adequate to

power the circuit, which has acurrent consumption of less thantwo milliamps.

CONSTUCTIONThe Mains Cable Detector

project is based on the EPEOnline multi-project printed circuitboard. This board is availablefrom the EPE Online Store (code7000932) at www.epemag.com .The component layout, togetherwith the (approx.) actual size foilmaster pattern and interwiring areshown in Fig.3.

The usual warning regardingthis PCB therefore has to begiven. Unlike a normal customprinted circuit board, the multi-project board has numerous holesand pads that are left unused. Inorder to avoid placement errors itis therefore essential to takeslightly more care than normalwhen fitting the components, andto thoroughly check the finishedboard for errors.

Construction of the boardfollows along the normal lines,with resistors and capacitorsbeing added first, taking care tofit the electrolytic capacitors withthe correct polarity. There is asingle link-wire towards the top

right hand corner of the board,which should also be fitted atthis stage. This link can bemade from a piece of wiretrimmed from a resistor leadout.

Single-sided solder pins arefitted to the board at the pointswhere connections to switch S1,socket SK1, the battery, and thesensor plate will be made. “Tin”the tops of the pins with agenerous coating of solder.

Finally, add IC1, beingcareful to fit it the right wayround. This device is not static-sensitive, but it is still a goodidea to fit it in a holder.

MAKING SENSEPractically any small to

medium size plastic case shouldaccommodate this project. It isbest not to use a metal case,as this would make it difficult toget the sensor plate workingeffectively.

The general layout of theunit is not too important, but tryto keep output socket SK1 andits wiring reasonably wellseparated from the sensor plateand the wire that connects it tothe circuit board. The sensorplate can be a piece of copper

&RQVWUXFWLRQDO3URMHFW

D9@

B9>7

93!

B

! B

%

B"

B

&

B#

B

'B$

3! 3"

3

#

3

$

B54F5

2<13;

F5

D? 21DD5BI2!

D? 51B@8?>5

C!

?>?66

C;!C5>C?B

=5D1<

@<1D5

@32 ?663ED

Fig.3. Multi-project printed circuit board component layout, underside (approx.) full size foil mas-ter, and wiring to off-board components. Not all holes/copper pads are used, so you must

double-check component positioning before soldering in place.

Page 14: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 949

laminate board (as used for do-it-yourself printed circuit boards)having an area of around fivesquare centimeters or so.

As supplied, this type ofboard often has a rather dirtyand corroded finish on thecopper side.

Scrape asmall area of thecopper with the blade of apenknife to produce a cleansurface to which a reliablesolder connection can be easilymade. The sensor is glued inplace at the front of the unit,inside the case.

A small piece of aluminumcan be used instead of copperlaminate board, but soldering toaluminum can be difficult evenif the special solder is used. It iseasier to bolt a solder tag to thepiece of aluminum and thenmake the connection to the tag.

IN USEWhen first switched on

there will almost certainly besome “hum” and general noiseon the output of the unit even ifit is not placed close to a mainslead. The output level should be

&RQVWUXFWLRQDO3URMHFW

quite low though. Placing theunit near to the mains lead ofany appliance that is pluggedinto the mains supply shouldproduce a loud 50Hz “hum”signal from the earphone.

In practice, there is a fairamount of noise on the “hum”signal, which will consequentlyproduce more of a “buzzing”sound from the earphone. Itseems to be possible to detectcables whether or not they areactually passing a current, butdetection is certainly easier ifthere is a current flow.

Walls, floorboards, etc. donot significantly hinder signalpickup, but there can be a

general spreading of theapparent signal source. Evenso, it is not usually too difficultto follow the path of power orlighting cables.

The completed detector, above left, and layout of compo-nents inside the prototype case. The sensor plate is glued

in place at the front of the unit, inside the case.

Page 15: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 950

This design originallyappeared in 1988 (ETI, Aug ’88),and a modified version ispresented here describing theincorporation of improved driversand a matching crossover.

After many hours ofmeasurement and listening, it ishoped that the design will appealto existing owners of the QWL interms of an upgrade, as well as tonew constructors looking for awide frequency rangeloudspeaker system occupying areasonable floor space.

INTRODUCTIONThe factors governing the

size of a loudspeaker invariablyinvolve considerations of overallperformance, cost, and domesticacceptability. Referringspecifically to moving coil driveunits and their enclosures, thelarger the size of the enclosurethe more extended is the bassresponse, which in turn adds tothe scale of the sound byproviding a certain low frequencyambience.

The full benefit of thisimproved ambience can only beachieved in a large room where,of course, the larger size ofenclosure stands a better chanceof being domestically acceptable.Unfortunately, the larger sizeloudspeaker system also tends tobe more complex, because theuse of a larger diameter bass unitrequires the addition of a smaller

from the smaller enclosure stemfrom the dimensions of both thecabinet and the loudspeakerdrive units. The smaller cabinetdimensions provide not only areduction in material costs butalso a significant increase instructural stiffness, reducingunwanted radiation from thecabinet walls. The narrowerfrontal area also improves thesound distribution.

By using a smaller bass unitthe complete frequency rangecan be covered simply byadding a high frequency unit ortweeter. The “seamless”coverage provided by the smallbass/mid-range unit can then bemade to extend smoothly justbeyond the critical mid-frequency range easing thecrossover design and producing

An updated design that should appeal to allaudiofiles!

4:/ /28'63($.(5 6<67(0E\ -2+1 ',;

unit, to cover the critical mid-frequency range adequatelysmoothly, before handing overfinally to a high frequency unit.

Overall then, the designbecomes more expensivearising from difficulties inintegrating the responses of theindividual drive units over thecomplete frequency range andconstructing the cabinet to keepwall vibration to a minimum.

SYSTEM OPTIONSFrom what has been

outlined above, it is notsurprising to find that theloudspeaker systemmanufacturer has concentratedon the smaller enclosuredesigns to achieve a costreduction without anappreciable sacrifice inperformance.

Although it is more difficultto maintain the low frequencyresponse of the small enclosurespeaker, there are also anumber of importantadvantages associated with areduction in the dimensions ofthe enclosure. Thus, it is notunusual to discover a so calledbudget design that representsreally excellent value for moneywith a performance that canonly be surpassed by designscosting a great deal more;sometimes by a factor of threeor more.

The advantages arising

Page 16: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 951

a radiation pattern conducive toa natural spread of sound and ausefully wide stereo soundstage.(1)

IN RESPONSEAs far as a reduced power

handling at low frequencies isconcerned, it does not representtoo serious a disadvantage.This is because in most types ofmusic, including the organ, thepower is distributed in such away that, below about 200Hz,spectral levels fall off naturallyat a rate of about 3dB/octave.(2)

However, if the small enclosureresults in too abrupt a roll-off inbass level below 100Hz thenthe bass lightness becomesreadily apparent, reducing theenjoyment of certain types ofmusic. It follows that there is alimit to the economy feasiblewith the small diameter bassunit if it is to provide reasonablylinear long-throw coneexcursions necessary foradequately low frequencyradiation.

When it comes to domesticacceptability, the smallenclosure has an obviousadvantage particularly if it couldbe tucked away inconspicuouslyon, say, a shelf. However, closeproximity to a wall can give riseto interfering standing wavepatterns. These can causesome deterioration in the stereoimage and, in the author’sexperience, an obvious audibleimprovement, in terms of depthand precision of stereo image,is obtained by spacing theloudspeaker units out from thewall by anything up to about onemeter.

Continuing to follow thesmall enclosure approach, theadditional requirement is for apair of loudspeaker stands tolocate the enclosures in spacesuch that they are (a) stable and

(b) at a height such that the highfrequency information reachesthe ears of a seated listenerwithout undue absorption by softfurnishings. Possibly the nextlogical step is to considerwhether the space within andunder the stands could beusefully utilized perhaps toenhance the low frequencyperformance.

Bearing all these points inmind, the author embarked on adesign aimed at satisfying therequirements for low cost, free-standing configuration, and theminimum of dimensionsconsistent with an adequate lowfrequency performance.

DESIGNCONSIDERATIONS

A free-standing loudspeakercabinet with similar dimensionsto that of a small enclosure on astand, if of conventional designand construction, can present adifficult acoustic problem to thedesigner because of the longnarrow parallel cabinet walls.The walls will tend to vibrateand resonate at similarfrequencies giving rise to aresonant pipe-like coloration tothe low frequency sound, whichis difficult to control andeliminate.

An alternative approach,that is satisfying from an

acoustic engineering point ofview, is to deliberately use andexploit the characteristics of aresonant pipe in such a way thatthe loudspeaker unit is correctlyloaded and terminated at the lowfrequencies, whilst adequatelysuppressing unwanted piperesonant modes. The lowfrequency efficiency of such anarrangement is somewherebetween that of a horn and a bassreflex enclosure and thereforereduces the demands made onthe low frequency excursions ofthe small diaphragm bassspeaker unit.(3)

The principle involved utilizesthe properties of a closed-at-one-end quarter wavelength pipe asoriginally proposed by Voigt(4) inhis patent and subsequentlyadapted and described by R.West and R. Baldock in theirdesigns. The design produced byR. West(3) was intended for acorner position with the speakerunit firing into the corner tospread the high frequency soundby reflection from the walls, andR. Baldock’s designs wereintended for either a semi-omnidirectional sounddistribution(5) or a wall reflecteddistribution.(6)

Present day practice favorsloudspeaker operation away fromcorners and walls, firing directlyat the listeners. It is the author’saim to revise the previous design

&RQVWUXFWLRQDO3URMHFW

!

!

"

T2

6B5AE5>3I

$ ! $ ![8j

Fig.1. Bass response comparison between quarter-wave design (solid) and 10 liter sealed enclosure

(dashed).

Page 17: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 952

to cater for this latest approach,which is more closely matchedto the improved stereo depthand imaging available fromsome of the current stereosources.

QUARTER-WAVELOADING

Having finally decided tokeep to the original Quarter-Wave Loading (QWL) enclosuredesign, an overall view andcabinet dimensions (tworequired) can be gained bylooking at Fig.10 and Fig.11.The finished appearance of thecompleted two-speaker“column” can be seen from the

accompanying photographs.

The bass enclosure consistsof a quarter wavelengthrectangular section pipe with alinear taper, resonant at about50Hz. The bass loudspeaker unitis situated at approximately halfway along the acoustic axis in thebest position to suppress higherorder resonant modes.

At resonance the acousticpressure is high at the taperedend and is still reasonably high atthe loudspeaker unit. Thisensures that effective acousticloading is presented to theloudspeaker cone and smallexcursions of the cone at highpressure are manifested as muchlarger low pressure movementsof air out of the port at the bottomof the enclosure.

Such a process, similar tohorn loading, contributes toefficient bass frequency operationwith low distortion, up to afrequency of 200Hz, where directradiation from the cone takesover. The enhanced bassresponse produced by thismethod of loading compared withthat from the same unit in a 10liter sealed enclosure is shown inFig.1, where the curves wereobtained under identicalmeasurement conditions.

Bearing in mind this result, itcan be seen that this enclosurenot only satisfies therequirements of being free-standing, with the drive units at aconvenient height, but alsoprovides an enhanced bassresponse, using the space thatwould otherwise have been takenup by a stand. Furthermore, onlysmall cone excursions arerequired in the bass loaded regionand this places the minimum ofdemands on linearity of the conesuspension and the magneticfield in the voice coil gap,allowing reasonably low priceddrive units to be employed.

The effect on powerhandling was quite dramaticallydemonstrated to the authorwhen two nominally identicalbass drive units werecompared: one in a 10 litercompletely sealed enclosureand the other in a quarter-waveloading enclosure. Switchingfrom one to the other and slowlyincreasing the power level, theunit in the sealed enclosure wasthe first to show signs ofdistress.

Continuing the quest for alow price design, it is temptingto consider a wide range twin-cone unit for use in thisenclosure. As can be seen inFig.2, the high frequencyresponse of a 165mm diameterpaper cone bass unit used inthis position showedconsiderable ripple in theresponse due to cone break-upmodes. Also, when a smalltweeter cone is added to themain cone to widen thefrequency range, anyimprovement in frequencyresponse is accompanied bymain cone break-up ripple asshown in Fig.3.

A smoother performer wasfound to be a 165mmpolypropylene cone bass unitwith the frequency response asshown in Fig.4 and this type isrecommended for use in thisdesign. (Needless to say thelatest polypropylene bass unitadopted for this updated designis even smoother!)

HIGH FREQUENCIESBecause of the

unsatisfactory response of twincone units, space is provided inthe top of the quarter-waveenclosure (see Fig.10 andFig.11) to house a suitable highfrequency “tweeter”. Referringagain to Fig.10 and Fig.11, itcan be seen that the speaker

&RQVWUXFWLRQDO3URMHFW

!

!

"

T2

" % ! [8j

Fig.2. Frequency responsefor a 165mm paper cone

bass unit.!

!

"

T2

" % ! " [8j

Fig.3. Response of a twin-cone unit.

!

!

"

T2

" % ! " [8j

Fig.4. Frequency responseof 165mm polypropylene

bass unit.

Page 18: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 953

unit baffle board has been keptas small as possible both for thesake of rigidity and the need tokeep the frontal area to aminimum for good stereoperformance.

The top of the bassenclosure also serves to stiffenthe unit baffle. The baffle isdeliberately sloped to time-alignthe outputs from the two unitsand to improve the coupling ofthe bass unit to the air columnin the enclosure.

The original speaker unitsused in this design weresupplied by Tandy and a simplecrossover arrangement, wherethe tweeter was fed from acapacitor, kept the overall costto a minimum whilst yielding avery good performance for themoney. However, as the originalspeaker units are no longeravailable, it provided an idealopportunity to investigate thepossibility of upgrading thechoice of loudspeaker driverunits.

The advantage of thequarter-wave loading is that it isnot sensitive to the bass drivercharacteristics in the way that

&RQVWUXFWLRQDO3URMHFW

the bass reflex cabinet designis. All that is asked for is areasonably low bass resonantfrequency.

One further considerationwas that of the type ofcrossover to employ. Theoriginal capacitor feed to thetweeter and direct connection tothe bass speaker meant that thebass unit worked up to 6kHz orso before its contribution wastaken over by the tweeter. Thisis fine in some respects, suchas maximum damping from theamplifier, but the directivity ofthe bass speaker increases withoperating frequency and theoptimum stereo listeningposition becomes quiterestrictive and critical at thehigher frequencies.

Also, the tweeter capacitorfeed with its low rate of cut-offwith frequency means that thedrive voltage at tweeterresonance can beembarrassingly high. Thus anupgrade also meant theadoption of an improvedcrossover arrangement.

At this point, the authorsought the assistance of SouthCoast Speakers ofSouthampton, UK, for help inthe choice of loudspeaker unitsand a crossover design. Afterseveral visits, and a review andanalysis of the existing design,speaker units from theNorwegian firm SEAS wereconsidered for the upgrade.

The units finally chosenwere the P17REXpolypropylene bass speaker andthe 25TTF fabric dome tweeter(see Shop Talk ). These wereinstalled in the QWL enclosureand delivered to South CoastSpeakers where a 2nd orderLinkwitz-Riley crossover wasdesigned and evaluated.

CROSSOVERThe Linkwitz-Riley

crossover design originated as ameasure to control the directionof the main lobe of the forwardradiation of a two-unit speakersystem. It is unusual in that, atthe crossover frequency, eachfilter response is 6dB down (asopposed to 3dB) and the driversare wired in opposite polarity toachieve an in-phasecontribution to the overallradiated sound. As far as thephase response of the twosections of the crossover isconcerned, the Linkwitz conceptis to aim at a constant phasedifference between the twooutput signals to achieve a goodgroup delay response.

The final circuit of the QWLcrossover is shown in Fig.5 andthe measured loudspeakerfrequency response from 500Hzto 20kHz is shown in Fig.6,where it is compared with theresponse of the original 1988design. The advantage of thenew drivers and a morecomplex crossover is readilyapparent from the responses.There is also an improvement inpower handling from 25W to80W, which perhaps is notsurprising considering that theweight of the magnet of thebass speaker, for example,represents an increase of over afactor of two.

The frequency responsemeasurements, using 1/3octave noise between 1kHz and10kHz, have also beenrepeated in the author’s ownroom with a capacitormicrophone at two meters. Theupper frequency was limited to10kHz due to the response ofthe microphone available. Theresults are shown in Fig.7,where it can be seen that acomparison between the South

&]8

#]8

$ 'P

6B?=

1=@<9695B

6B?=

1=@<9695B

& (:

# #:

D?

DG55D5B

$ 'P

D? 21CC

C@51;5B

Fig.5 Crossover circuitdiagram.

Page 19: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 954

Coast Speaker calibration andthe in-room measurements ismost encouraging.

As far as the frequencyresponse below 500Hz isconcerned, measurementsbecome a little more difficult. Atlow frequencies the loudspeakerproduces sound both from thecone of the bass unit and therear port. It is the achievementof a true representation of thecombined response thatpresents a problem.

A straightforwardsummation of the output of thecone and port from the SouthCoast Speaker’s measurementsis shown in Fig.8, and onceagain in-room 1/3 octave noisemeasurements compare quitefavorably. This time themicrophone response cannot betrusted much below 40Hz.

Taking a view of thefrequency response as a whole,it can be seen that the responseextends from 40Hz to 20kHzwith an SPL(1W/1m) of 89dB,deviating by 3dB from 1kHz to20kHz and by +3dB/-6dB from40Hz to 500Hz. The lowfrequency properties of thecabinet can be associated withan intriguing mixture of tunedpipe and horn loading, theadvantages of which areevident in terms of an improvedtransient response from thebass unit.

The penalty for thisimprovement is the increase inresponse deviation below400Hz. However, thesedeviations are small comparedwith standing wave effects inthe listening room at thesefrequencies and the overall

response compares veryfavorably with other speakersof, what might be termed, anaudiophile status.

Finally, the impedancecharacteristic shown in Fig.9illustrates that the loudspeakerwill present a relatively easyload to most amplifiers,producing really loud resultswith amplifiers in the 50Wrange.

CONSTRUCTIONNow we have discussed the

various merits and selected ourspeakers, it is time to undertakethe construction of the QWLenclosure. This is made up from12mm (1/2in.) thick chipboardand 6mm (1/4in.) thick plywoodas shown in Fig.10.

The enclosure has been

&RQVWUXFWLRQDO3URMHFW

Fig.6. New frequency response com-pared with original design

Fig.8. Low frequency responsecomparison.

Fig.7. Frequency response compari-son test results.

Fig.9. System impedancecharacteristic.

Page 20: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 955

designed to make theconstruction as simple aspossible, and if the variouspieces shown in Fig.10 are cutaccurately square then thereshould be no difficulties inassembly. Referring to Fig.10and Fig.11 it can be seen thatthere are only two angle cuts tobe made, those at the top ofboth the long front and backpanels. All the rest are simple90 degree butt joints, and it isleft to the individual constructorto decide whether to attempt theangle joints or simply butt thejoints and fill the wedge shapegaps with whatever techniqueand material is convenient.

Dimensions quoted are notcritical, provided that everythingis checked to fit as shown in thediagrams so that airtight jointsare obtained, particularly in thehigh acoustic pressure areas inthe tapered wedge and aroundthe speaker unit. (It should benoted that the baffle cut-outdimensions in Fig.10 are for thenew loudspeaker units andexisting cabinets willsatisfactorily house the newunits simply by opening up thecut-out for the bass unit byabout 2mm (1/16in.) or so, andthe vertical dimension of theright hand cut-out for thetweeter by 6mm. It is desirableto ensure that the surrounds forthe two units almost touch onthe vertical axis.)

The front, back, bottom,top, and internal partitionmembers are all made ofnominally 12mm (1/2in.) thickchipboard, and should all bematched to the same width of178mm (7in.). The two sidepanels are made of nominally6mm (1/4in.) thick plywood, andit is recommended that one ofthe panels is marked out toindicate where the 12mm thick

panels are located. These canthen be cut to size and checkedfor fit and the assembly pinnedand glued together to form thestructure drawn in Fig.11.

As the assembly progressescheck it for squareness and, ifnecessary, secure one or twocross-pieces of plywood offcutswith pins driven a little way in tohold the assembly square whilethe glue sets. Being reasonablyliberal with the glue shouldensure airtight joints, but payparticular attention to the

&RQVWUXFWLRQDO3URMHFW

SEAS P!&REX bass driver

The 25TTF (H457) tweeterfrom SEAS

!( ]]

!!!( ]]

!"]]

389@2?1B4

"]]

389@2?1B4

2?DD?=

&]]

@<IG??4

" ?66

"# ]]

! ! ]] C945

!"]]

389@2?1B4

6B?>D''%]]

''%]]

!# ]]

!( ]]]]]]

!$&

44491

!!!( ]]]]

"]]

389@2?1B4

'&]91

'!]]

D?@ 6B?>D"! ]]

# %]]

# %]]

213;

!( ]]

!"]]

389@2?1B4

"!(]]

<?>7

2166<5

'#']]

!!!"]]

389@2?1B4

!"]]

389@2?1B4

( ]]

( ]]

D?@

C8?BD

2166<5

!( ]]

!!!!(]]

&%]]

#"]]

(]]

Fig.10. Cutting details and dimensions for a single enclosure (two for stereo)

The crossover boardmounted on the rear panel.

Page 21: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 956

pointed end of the wedge section, and, ifnecessary run a fillet of glue along this particularjoint.

Finally, complete the assembly by gluing andpinning the second plywood panel into place. It willbe noted that the enclosure is reasonably light andstiff and this minimizes the energy storage in theenclosure walls.

Tapping the sides of the enclosure producesdifferent notes at different positions indicating thatthe internal bracing and asymmetry is working tominimize undesirable reflections and panelresonances. Finishing tasks involve punching thepins home, filling, and sanding prior to painting orcovering with material or an iron-on veneer.

The enclosure was checked for anyundesirable resonances by very slowly sweepingthrough the low frequencies with a sine wavegenerator as well as taking account of theimpedance characteristic of Fig.9.The damping material is obtainedby buying a square meter ofTerylene wadding from the

dressmaking department of yourlocal store. It should weighabout 100 grams and is cut intwo: a piece for each enclosure.Each piece is folded lengthwisein two and the resulting strip isfolded again twice to form a25cm square, ready for insertionas shown in Fig.11.

LOUDSPEAKERMOUNTING

One final task now remains,and that is to mount the speakerunits and crossovers on eachcompleted enclosure. Theloudspeaker units are mountedfrom the outside of theenclosure and the bass unitneeds a sealing gasketfabricated from, preferably arubber-based, draught sealingstrip. It is also recommended

&RQVWUXFWLRQDO3URMHFW

'#']]

"# ]]

'%]]

! & ]]

( ]]

!!(]]

''%]]

# %]]

4111=@9>>>777

G 449

Fig.11. Enclosure dimensions andconstruction.

Once the wiring to thecrossover is completed it's

time to face the music.

that the tweeter is mounted on a sealing strip toavoid any extraneous noise set up betweentweeter surround and the cabinet.

Use chipboard screws and do not over tighten.Matching black screws can be obtained and withtheir extra length it is advisable to glue small softwood blocks behind each screw hole location.

The bass speaker signal lead is simply passeddown through the bass enclosure and out throughthe rear port, whilst the screened tweeter lead issecured by clips down the back of the enclosure,see photograph. Connections can then be made tothe crossover board fastened to the back of thecabinet and the board enclosed, if desired, in aplastic box. Readers may also wish to experimentwith the provision of steel or plastic spikes in thebase of the enclosure.

PERFORMANCEThe choice of loudspeaker is often a very

personal decision, and the present design is theresult of many hours of measurement andlistening. Over a period of time, friends have beeninvited to audition these speakers and theirperformance received very favorable commentsby even the most candid listener. It is felt that themajority of readers will not be disappointed withthe final results of this project.

Page 22: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 957

In summary then, theseloudspeakers are relativelycheap for the performanceobtained (as a useful rule ofthumb they compare veryfavorably with commercialdesigns costing in the order ofthree times that of the speakerunits and crossovers in thisdesign) and are fairly simple tobuild. They occupy very littlefloor space, are easily moved toa desired position for seriouslistening, and are of the rightheight to preclude the need forstands.

References

1. “Loudspeaker SystemDesign’’ by S. LinkwitzWireless World May 1978pp52-56; Jun 1978 pp67-72; Dec 1978 pp79-83

2. “Some Factors inLoudspeaker Quality’’ byH. D. Harwood WirelessWorld May 1976 pp45-54

3. “The Decca CornerSpeaker’’ by R. West HI-FINews Mar 1959 pp 724-726

4. Voigt Patent No 447749

5. “The Tricolumn’’ by R. N.Baldock HI-FI News Apr1961 pp 786-790 Vol 5 No12 May 1961 pp 853-855

6. “The Paraline’’ by R. N.Baldock HI-FI News Apr1963 pp 782-789

&RQVWUXFWLRQDO3URMHFW

Page 23: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 958

When power is removed fromCMOS logic, the rail voltage canwander for a few seconds,causing unpredictable behavior inthe circuit. If the power has beentemporarily removed, then inorder to “reset” the circuit it isoften necessary to count to tenbefore re-applying the power toensure proper operation.

A small power supply“crowbar” circuit, which has beenused in a burglar alarm where itwas necessary for the supply railto drop sharply to zero when thepower was removed, is shown inFig.1. However, in order to savethe standby battery if it is runningduring a mains failure, thecrowbar must not present too higha load on the power rail.

During normal running, with+12V present on the rail, theZener diode D1 conducts andfeeds a small current into

transistor TR1 base (b).This turns on TR1,which keeps TR2switched off. Thecurrent consumption isapproximately 0¬¬¬1mA atthis time.

If power isremoved, as soon asthe rail voltage dropsbelow approximately10V, the Zener diodeceases conduction,TR1 turns off and TR2turns on. Thiseffectively placesresistor R3 across the rail. Theresistor has a relatively lowvalue, and the increased currentwill pull the rail down muchsharper than allowing it to decaynaturally, especially if the circuitcontains filter capacitances.

Since most logic devicesswitch at around half the rail

voltage, there should be nomisbehavior during the initialdrift down to 10V. If a 5V rail isused, a 3¬¬¬3V Zener diode can besubstituted.

Barny Connell,Stoke Newington

London, UK

ROLL-UP, ROLL-UP!Ingenuity is our regular round-up of readers' own

circuits. We pay between $16 and $80 for all materialpublished, depending on length and technical merit.We're looking for novel applications and circuit tips, notsimply mechanical or electrical ideas. Ideas must be thereader's own work and must not have been submittedfor publication elsewhere. The circuits shown haveNOT been proven by us. Ingenuity Unlimited is open toALL abilities, but items for consideration in this columnshould preferably be typed or word-processed, with abrief circuit description (between 100 and 500 wordsmaximum) and full circuit diagram showing all relevantcomponent values. Please draw all circuit schematicsas clearly as possible.

Send your circuit ideas to: Alan Winstanley,Ingenuity Unlimited, Wimborne Publishing Ltd., AllenHouse, East Borough, Wimborne, Dorset BH21 1PF.They could earn you some real cash and a prize!

Win a Pico PC-Based Oscilloscope• 50MSPS Dual Channel Storage

Oscilloscope

• 25MHz Spectrum Analyzer

• Multimeter

• Frequency Meter

• Signal Generator

If you have a novel circuit idea whichwould be of use to other readers, then a PicoTechnology PC based oscilloscope could beyours.

Every six months, Pico Technology will beawarding an ADC200-50 digital storage oscil-loscope for the best IU submission. In addi-tion, two single channel ADC-40s will be pre-sented to the runners up.

Auto Supply Crowbar – A Sharp Drop

R

S

U

R

S

U

F

!"F

B"

!" [

DB!23%$'

4!

)F!

B!

!=%

DB"23%$'

B#

"["

Q[

Fig.1. Auto Supply Crowbarcircuit.

Page 24: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 959

Shoestring MW Radio –On A Budget

The medium Wave Radiocircuit diagram of Fig.2 usesrelatively few components butdelivers 500mW (0.5W) into an8 ohm loudspeaker. In CapeTown, with high selectivityselected, the radio picks up theVoice of America clearly afterdark.

In the circuit, coil L1 is 80turns of approx. 30 s.w.g.enameled copper wire, close-wound on a 5cm (2in.) diameterpiece of PVC piping. A center

tap at 40 turns provides greaterselectivity and may be selectedwith switch S1. The value of tuningcapacitor VC1 is not critical.

The Volume control VR1controls the gain in preamplifierIC1. The output of IC1 is fed, viatreble control/low pass filtercapacitors C4 and C5, to astandard LM380 audio amplifier IC.

A good aerial and earth areessential. The aerial may beattached to a metal window frameor a long wire. The earthconnection may be a metal spikesunk into the ground.

Experimenters could try using acrystal earpiece wired betweendiode D1 cathode (k) and 0V,which may give fair listeningvolume even with the battery(B1) disconnected.

Rev. Thomas ScarboroughCape Town

Republic of South Africa

,QJHQXLW\8QOLPLWHG

%9

/6:

Ω

5N

5550

5N

0

5N

5N

&Q

&Q9&

S&Q

&'Q2$

5N

95N

,&/0

,&/0

666. . . .3 ' 7

/785167$33('$778516

6(( 7(;7

($57+

$(5,$/

D N

9

6

212))

9

Fig.2. Circuit Diagram for the Shoestring MW Radio.

Page 25: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 960

This little project first saw thelight of day when it was realizedthat much time was being wastedin the workshop constructing reg-ulated five-volt supplies on bread-boards. With the ever-increasinguse of logic and microcontrollerssuch as the PIC, many projectsnow require such a supply volt-age.

The introduction of newopamps capable of high perfor-mance from low supply voltagesmeans that analog circuits canuse it too, though an auxiliarynegative supply is often still use-ful for these, especially where thenegative rail of the primary sup-ply is to be used as common or“ground”. Where this is the case,it is usually preferable to generatethe extra supply rail electroni-cally, particularly when the fin-ished project is to be operatedfrom a battery.

Also, with battery supplies inmind, it was decided that this pro-ject should use micropower com-ponents and the regulator shouldbe a “low dropout” type. Finally, itwas decided that the projectshould be miniaturized as far aspossible so that it would take upminimum space on the bread-board or in a case used for test-ing a prototype. In fact, it couldeven be included in a finishedproject if desired.

REGULATIONSThe choice of active compo-

nents for the project was straight-

which they operate may be ofinterest.

The basic principle, with ca-pacitor C1 connected to thesupply rails by a 2-pole two-wayswitch S1a and S1b, is shown inFig.1. When in the positionshown, the switch allows the ca-pacitor to charge from the mainsupply voltage VIN.

The switch is then set to theopposite position, so the voltageacross capacitor C1 appearsacross the output and is partiallytransferred to capacitor C2. Ifthe switch positions are alter-nated repeatedly, C2 will be-come charged to virtually thesame voltage as the supply, butconnected as shown it appearsas an additional, negative out-put.

ELECTRONIC SWITCHINGIn a practical circuit, having

realistic capacitor values, theswitches should be electronic ofcourse, and they must operateat high speed, typically severalkilohertz. They should have low“on” resistances and no “offset”voltages, such as the forwardvoltage drop of a diode, soCMOS devices are preferable.An oscillator is required to drivethem, and problems of protect-ing them from reverse voltagesmust also be overcome.

Fortunately, all these issuesare already addressed for usersof the SI7660, which containsan oscillator, drive logic, andthe output switches. With a 5Vinput it requires only a pair ofcapacitors to complete the cir-

A low-cost, low-power, mini board project that willprovide a regulated supply of plus and minus 5V.

0,&52 32:(5 6833/< E\ $1'< )/,1'

forward. The regulator is theLP2950, which is very similar tothe popular 78L05 3-terminal+5V regulator, even to the ex-tent of having the same pinoutconnections.

It does have improved regu-lation however, draws a muchlower supply current, and canoperate with a very low differen-tial between input and outputvoltages, typically down to100mV. This makes battery op-eration more economical sincethe supply voltage can be muchlower before replacement isnecessary.

ON THE FLYThe auxiliary negative sup-

ply is generated by an SI7660voltage converter chip (see theShop Talk page), which is in-tended specifically for this func-tion, especially with 5V supplies.These are sometimes known as“flying capacitor” devices, and ashort description of the way in

C!R

C9Q

3!

F F

F9>

3"

F?ED

F?ED

Fig.1. Principle of the “flyingcapacitor” negative rail

generator.

Page 26: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 961

cuit.

For a zero load, the outputvoltage is virtually the same asthat of the input, but it tends tofall with load. The output is of-ten described as being similar tothe input voltage in series withan 80 ohm resistor, so for a10mA loading it would drop to -4¬¬¬2V. Although often better inpractice, this makes it unsuit-able for use as a referencesource, but as an auxiliary sup-ply for opamps it is ideal.

MICRO POWER SUPPLYThe full circuit diagram for

the Micro Power Supply ap-pears in Fig.2 and is fairlystraightforward in nature. Theinput voltage is first reduced toa positive 5V supply by theLP2950 micropower regulatorIC1. Capacitors C1 and C2 de-couple the input to IC1, whilstC3 and C4 decouple its output.

The smaller value, non-electrolytic, capacitors C2 andC3 are often omitted by circuitdesigners, but the constructionof electrolytic capacitors, usinglayers of foil wound into a cylin-drical shape, gives them a fairdegree of self-inductance, whichcan make them ineffective athigh frequency. By contrast, thesmall ceramic capacitors workvery well indeed at high fre-quencies, so they are includedto take care of these frequen-cies where necessary.

The negative supply is gen-erated by the SI7660 negativesupply generator chip IC2. The“flying capacitor” is C5, a 10mfsolid tantalum type. The output,taken from pin 5, is decoupledby ceramic capacitor C6 andelectrolytic C7, another tanta-lum component.

The reason for the use oftantalums is that these have amuch lower self-inductance than

ordinary electrolytics, and shouldtherefore cope with the 10kHzoperating frequency of IC2 moreefficiently. IC2 is another microp-ower component, so the overallquiescent supply current for thiscircuit from a 9V supply is just140mA.

CONSTRUCTIONAll the components for the

Micro Power Supply are accom-modated on a small (32mm x17mm), single-sided printed cir-cuit board (PCB). This board isavailable from the EPE OnlineStore (code 7000243) atwww.epemag.com . The topsidecomponent layout, together withthe underside copper foil master,is shown in Fig.3.

&RQVWUXFWLRQDO3URMHFW

COMPONENTS

See also theSHOP TALK Page!

CapacitorsC1 220u radial electrolytic, 16VC2, C3, C6 100n resin-dipped ceramic (3 off)C4 100u radial electrolytic, 10VC5 10u tantalum bead, 16VC7 47u tantalum bead, 16V

SemiconductorsIC1 LP2950 low power +5V regulatorIC2 SI7660, "switched capacitor" voltage converter

Miscel laneousPrinted circuit board availablefrom the EPE Online Store, code7000243 (www.epemag.com );8-pin DIL socket; solder pins(5 off), solder, etc.

$19Approx. CostGuidance Only

3"

! ^

3!

"" P

3&

! ^

93"C!'&&

3%! P

3#

! ^

3$

! P

93!<@")%

3'

$'P

9> ?ED

3?=

(

" $

#

%

9>@ED

&F D? !"F %F

%F

F F ?ED@ED

Fig.2. Complete circuit diagram for the MicroPower Supply.

B"

! [

B!

" [

93!

%FFF

"%F

%F

1>I CD1>41B4

?@1=@57 '$!

!" <=#%( 5D3

Fig.4. Circuit diagram forgenerating a negative refer-

ence voltage.

Page 27: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 962

Construction of the unit con-sists of fitting all the compo-nents except IC2, taking care tofit all the electrolytics with thepositive side towards the topedge of the PCB, as viewed inthe diagram. The markings ontantalum bead capacitors aresometimes less than models ofclarity, so care may be neededto interpret these correctly. An8-pin DIL socket should be pro-vided for IC2.

TESTINGThe first test is to apply an

input voltage of between 6V and12V and check for the presenceof the positive 5V output. Thecurrent drawn should be tiny,just 140mA or so, though therewill be a small surge as theelectrolytics, especially C1, takeup their initial charge.

If the +5V output is presentand correct, IC2 can be insertedinto its socket and, when theunit is powered again, the nega-tive output voltage should ap-pear at the appropriate point.And that’s it! Testing is nowcomplete and the unit is readyfor use.

Although the +5V output iscapable of more than 100mAoutput, a watch should be kept

on its internal power dissipation toprevent overheating. This is cal-culated by subtracting the outputvoltage (5V) from the maximuminput voltage (9V for a PP3 bat-tery) and multiplying by the out-put current in milliamps (mA), forregulator dissipation in milliwatts(mW).

The maximum allowable de-pends to some extent on ambienttemperature, but a practical limitof 200mW seems reasonablysafe. It should be rememberedthat current supplied by the nega-tive rail generator also comesfrom the regulator. For manysmall low-power applications suchas signal processing withopamps, CMOS logic, or PIC mi-crocontrollers, dissipation will notbe an issue.

NEGATIVE USEThe negative output should

be regarded only as an auxiliarysupply as it is not nearly so wellregulated as the positive one. Itsmain purpose is to supplyopamps so that the common railmay be used as “ground” by al-lowing their inputs and outputs tooperate below this value.

Because the output of theSI7660 behaves as though in se-ries with an 80 ohm load, the out-put voltage will vary with load.Measured results taken with theprototype were - 5V for no load, -410mA.

¬¬¬75V at 5mA, and - 4¬¬¬5V at

If a reference voltage ofsome kind is needed, it should betaken from the positive supply. Ifit is essential to have a negativereference, one way to generatethis would be with an invertingopamp, as shown in Fig.4. Theoutput voltage for this is given by5(R2/R1) volts.

There will inevitably be some10kHz ripple on the negative out-put, although this is very small.

Measured values of this were25mV at 5mA and 50mV at10mA. In most cases thisshould not cause any difficul-ties, but some very sensitivecircuits may need careful designor extra filtering to avoid its ef-fects. Where the negative sup-ply is not required IC2 can beremoved, though in many casesit will be more convenient to justleave it in place.

IN USEThis little circuit should

prove invaluable to those wholike to experiment with their owncircuits. These days it is oftenfar simpler to regulate the sup-ply to a circuit than to try to de-sign it so that it will ignore sup-ply voltage variations, and theoption of just dropping this littleregulator board into designswith a blob of Blu-Tack or simi-lar will save much valuabletime, effort and space.

In fact, it could even be in-corporated into complete pro-jects where these are one-offs,perhaps constructed on strip-board, although if a PCB is usedit is more likely that it will becopied onto the board design insome form. The layout is notcritical in any way, save that thedecoupling capacitors should bekept reasonably close to theICs. Where it is to be used withthe plug-in type of breadboard,short lengths of single-core in-sulated wire could be connectedto the outputs and the otherends of these pushed into theboard where needed.

&RQVWUXFWLRQDO3URMHFW

3!

3" 3'

93!

93"

3$

3

#3%

3

&

9> 3?= ?ED&F

D?

!"F

F

F

%F

%F

"$#

?ED@ED

Fig.3. Printed circuit boardcomponent layout and

(approximately) full size cop-per foil master.

Page 28: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 963

Storage is one of the keyelements in any computersystem. Not only do computersrequire short-term memory likerandom access memory (RAM)or read only memory (ROM),but they also need long termmemory like disk drives. Like allother areas of computertechnology, the pace at whichdevelopment is taking placeseems to be increasing. Onlyten years ago, a 40Mbyte harddrive was considered to belarge. Now most computers soldin the High Street today comewith drives that have storagecapacities of a few Gigabytes.The access time of the drives isalso much shorter despite theirgreatly increased capacities.

To give an indication of thestaggering improvements thathave been made in thetechnology, industry reportsindicate that in 1991 theaverage disk size was only140Mbytes, whereas theaverage size in 1999 is just over7Gbytes. The cost has alsofallen dramatically from wellover 1,000 UK Pounds perGbyte in 1991 to around 20 UKPounds per Gbyte in 1999.

NEW RECORDIn May of this year, IBM

announced they had set a newworld-record in hard disk datastorage density with a figure of20 billion bits per square inch.This is more than three timesthe density of any disk drivethat is being manufacturedtoday. It would enable every

square inch of disc space tohold two TV quality films, fourCD ROMs worth of data, or thetext from about 2500 averagesized novels.

To achieve this densitymilestone, significant advanceshave been made in thedevelopment of the heads thatread and write the data. In1999, IBM launched the firstmagneto-resistive (MR) heads,and since then data density hasincreased at greater than 60%per year. However, in order tomaintain this trend, IBM havefurther developed thistechnology in the form of aGiant Magneto-Resistive head(GMR).

One of the problems withincreasing the data density isthat the space occupied by asingle bit becomes smaller andthe output from the head isreduced when reading it. Usingolder technologies the outputwould fall to the point wherenoise would cause the databeing read to be filled witherrors.

The new GMR head is nowthe most sensitive type of headavailable for reading magneticdata from disk. In addition to theGMR head required for readingthe data, a narrow track thin filminductive write head was usedin combination with theassociated disk electronicsusing a system known as PartialResponse Maximum Likelihood(PRML) that is used in manydrives today. The disk mediaitself was an integral part of thesystem and used an ultra-low

noise cobalt alloy magneticmaterial.

In tests data was written onconcentric tracks at a density of490,000 bits per inch, and thetracks themselves were spacedto give 41,400 per inch. Thedata rate was also exceedinglyhigh, being written and read at arate of 10 million bytes persecond.

The bit error rate is alsovery important. In tests thesystem gave less than one errorin a hundred million bits, andwhen error correction circuitrywas used this was reduced toless than one error in a trillion.

GMR HEADSThe basic principle behind

GMR heads was discovered atIBM in 1988, however it tookanother three years before theidea had been sufficientlydeveloped to a form where itcould be used in disk drivetechnology.

The sensors consist of fourfilms: a sensing layer; aconducting spacer; a pinnedlayer; and finally an exchangelayer. The sensing, spacer and

Even the spin direction of the electron is being harnessed to achieve greater harddisk densities!IAN POOLE REPORTS.

3_ 7=B

@9>>54 <1I5B

1>D965BB?=17>555D93

5H381>75 <1I B

3?>D13D 333?>D13D

81B4 291C

3_ @@@d3b

81BBB4291C

_ @d 3b

3?@ 5B 3?>4E3D9>7

C@135B

C5>C5 <1I5

>Y 6U

Fig.1. Representation ofGMR head construction.

Page 29: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 964

pinned layers are all very thinand they allow the electrons tomove freely between thesensing and pinned layers viathe conductive spacer layer.The magnetic orientation of thepinned layer remains constant,held by the exchange layer thatadjoins it. However, theorientation of the sensing layerchanges in line with that of themagnetic field from the disk.

SPIN DOCTORTo turn these magnetic

changes into electricalvariations that can beprocessed electronically, thehead exploits effects associatedwith the quantum physics ofelectrons. Electrons have twospin directions: spin up and spindown. Conduction electrons witha spin parallel to the magneticorientation of the material movefreely, but those with a spin inthe opposite direction arehampered, experiencing morecollisions. This is exhibited as ahigh resistance.

In a GMR head, electronswith one spin direction will passthrough the pinned layer. Thosewith the opposite spin directionwill not move freely and as aresult fewer will pass throughthe layer. These electrons willcontinue to move down to thesensing layer.

When the field from the diskresults in the sensing layerbeing magnetized in the samedirection as the pinned layer,the electrons will be able to flowfreely through the layer.However, when the sensinglayer is magnetized in theopposite direction, the electronswill generally have the wrongspin orientation to pass freelythrough the layer. This willmanifest itself as a highresistance.

In more familiar terms, thiseffect is similar to passing lightthrough two polarizing filters.When the two filters arepolarized in the same direction,light will pass through, but whenthey are cross-polarized nonewill pass.

MANUFACTURINGCONSIDERATIONS

The GMR heads that wereused in the demonstration of thecapability of the new techniqueclosely resemble the magneto-resistive (MR) heads inconstruction. This means thatthey will be able to be producedusing many of the sameprocesses that are currentlyused, enabling them to bequickly introduced onto themarket. It will also mean thatthe costs of the new heads willnot be significantly above theexisting ones. This factor willhelp to ensure that the headsswiftly gain a secure foothold inthe market place.

The technology required toproduce these heads borrowsmuch from the semiconductorindustry. Photolithography isrequired in view of thedimensions that are needed.Typically the read track width istaken as two thirds of the trackto track spacing. This is neededto accommodate the tolerancesin the track width, trackfollowing and track to trackspacing. It is estimated that toprovide a data density of 40Gbits per square inch that aread track width of 0is required.

¬¬¬3 microns

One of the majorrequirements is that the opticalequipment used in thelithographical process hassufficient depth of focus toaccommodate the non-planarhead features. It is anticipated

that the advances inphotolithography required forsemiconductor manufacturingwill drive the process forward,enabling the requirements ofthe hard disk drive headmanufacturers needs to be metas well.

The processes required tomass-produce heads capable ofattaining the record densities isnow well advanced, and it isexpected that it will be possibleto produce these heads by theyear 2000. With densities ofthese values, this type of headis certainly to be the head of thefuture.

1HZWHFKQRORJ\8SGDWHV

Page 30: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 965

The phenomenon of negativeresistance has been known andunderstood since the earliestdays of radio. Indeed, its applica-tion to oscillatory circuits pre-dates the thermionic valve. Putsimply, it occurs when the currentflowing through a device or circuitis rising whilst the voltage acrossit is falling and Ohm’s law ap-pears to have been reversed.

Cavity magnetron oscillators,which depend on negative resis-tance, are used in many homesfor generating the microwavesthat heat food. They also powerthe RADAR (RAdio Direction AndRanging) systems, which help toensure the safety of travelers byair and sea.

Some rather unusual transis-tor circuits, which exploit negativeresistance, form the subjects ofthis article.

MAINTAINING OSCIL -LATIONS

The sudden application of adirect voltage to a tuned circuitformed by an inductor (coil) andcapacitor shock-excites oscilla-tions. Because of resistive losses(mainly in the coil), the oscilla-tions gradually fade away, theirduration and magnitude being di-

age with rising current; i.e. neg-ative resistance.

They function by cancelingout the resistance in the tunedcircuit so that the oscillationscan continue. When circuits ofthis kind are analyzed from thefeedback standpoint, the posi-tive feedback is said to existwithin the device itself.

TUNNEL DIODEA Japanese scientist, Leo

Esaki (born Osaka, Japan 12Mar 1925 - now an Americancitizen), first described his tun-nel diode in 1958. A two-terminal device, it represents aparticularly vivid example of thephenomena of negative resis-tance, which enables it to func-tion as an oscillator.

Tunnel diodes comprise a

Most text books deal with oscillators in a theoretical way. This series, preparedwith the electronics enthusiast and experimenter very much in mind, is intenselypractical. Tried and tested circuits are fleshed out with component values, andtheir vices and virtues are exposed.

PART FOUR – NEGATIVE RESISTANCE OSCILLATORS

35$&7,&$/ 26&,//$725'(6,*16

E\ 5$<021' +$,*+

rectly related to the Q factor ofthe tuned circuit (the higher the Qthe lower the resistive losses).

Oscillations can be main-tained by connecting an amplifierto the tuned circuit and feedingback energy in order to continu-ally repeat the excitation. Earlierarticles in the series have de-scribed a number of oscillators ofthis kind.

The feedback eliminates orcancels out the resistive losses.Viewed in this way, it can be saidto create negative resistance.

It therefore follows that de-vices and circuits which displaynegative resistance, even thosewhich do not function as ampli-fiers, can also be used to main-tain oscillations. An electric arc,Hull’s Magnetron, the Esaki ortunnel diode, all have a charac-teristic which exhibits falling volt-

NEGATIVE RESISTANCENegative resistance is created when the current flowing through

a circuit is rising whilst the voltage across it is falling, and Ohms lawappears to have been reversed. Devices which display this charac-teristic can maintain oscillations in a tuned circuit by canceling out itsresistive losses.

The technique was used by early radio pioneers before the in-vention of the thermionic valve. Today, powerful microwave genera-tors and devices on the frontiers of semiconductor technology exploitthe phenomenon of negative resistance.

Page 31: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 966

junction of p and n-type semi-conductor material and, in thisrespect, resemble conventionaljunction rectifiers. Pure siliconand germanium have to bedoped with impurities beforethey can function as semicon-ductors. Pentavalent impurities,such as antimony, phosphorousand arsenic, convert the siliconor germanium into n-type mate-rial. If a trivalent impurity, suchas boron, gallium or indium, isadded, a p-type semiconductoris produced.

Normal junction diodeshave impurity levels of aboutone part in 108. Esaki discov-ered that if the doping levels areincreased to around 1 part in103, the characteristics of thediode are completely changed.

The current/voltage charac-teristic of a typical tunnel diode

is displayed in Fig.1b. Conduc-tion is high in the reverse direc-tion (p side of the junction nega-tive with respect to the n side)and current rises with forwardvoltages until a peak is reached.

Beyond this point, increas-ing the forward voltage reducesthe flow of current and the diodedisplays negative resistance. Afurther increase in forward volt-age restores the normal current/voltage relationship, and thebiasing of the device is critical.

A typical circuit diagram ofa negative resistance oscillatorusing a tunnel diode is given inFig.1a. The tuned circuit formedby coil L1 and variable capaci-tor VC1 determines the fre-quency of oscillation, and theresistor network, R1 and VR1,reduces the voltage of a singlecell (B1) to the few hundred mil-livolts needed to bias tunneldiode D1 to the correct operat-ing point. Preset potentiometerVR1 enables the bias voltage tobe adjusted to suit different de-vices.

When working at mediumand high frequencies, shuntingthe diode with a trimmer capaci-tor, VC2, makes the circuitmore willing to oscillate. As thefrequency of operation in-creases into the very high fre-quency (VHF) and ultra high fre-quency (UHF) regions, thiscomponent can be dispensedwith.

Tunnel diodes are low-cost,low noise devices, capable ofoperating at very high speeds.When they were introduced inthe late 50s it was widely antici-pated that, because of theseattributes, they would find wideapplication in the then newcomputer industry.

However, they have the dis-advantage of low output voltageswing and, being a two-terminaldevice, there is no isolation be-

tween input and output, and thiscauses circuit design problems.These drawbacks, combined withthe dramatic developments intransistors, seem to have easedthe tunnel diode into an early ob-solescence.

MORE NEGATIVEFollowing Esaki’s discovery

of the tunnel diode, more workwas done during the 60s on thedevelopment of negative resis-tance devices of this kind. Signifi-cant discoveries were made, andmuch effort seems to have beenexpended on the invention ofacronyms.

In 1964, American scientists,R. L. Johnston and B. C. deLoach, working at the Bell labora-tories, discovered the IMPATT(IMPact, Avalanche, TransitTime) diode. The application of aDC voltage to these devices re-sults in the direct generation ofmicrowaves.

Three years later, Americans,Prager, Chang and Weisbrod, de-veloped the TRAPPATT(TRAPped, Plasma, Avalanche,Transit Time) diode. Compara-tively high efficiencies wereclaimed for these devices, but themaximum operating frequenciesare somewhat lower than thoseachieved by the IMPATT diode.

In 1968, a British scientist, G.T. Wright, described a new nega-tive resistance microwave device,which he called the BARITT(BARier controlled Injection andTransit Time delay) diode. Capa-ble of operating in the microwaveregion, the BARITT diode sharesthe low-noise, low-cost advan-tages offered by other semicon-ductor structures of this kind.

Although the physics of thesedevices is extremely complex,they all depend for their operationon the creation of negative resis-tance, a phenomena first ex-

&RQVWUXFWLRQDO3URMHFW)25:$5'&855(17

)25:$5'92/7$*(

1(((*$7,9(5 6,67$1&(

327(17,20(7(5956(((7776777+('(((9,&(722223(5$7($7 +(0,'32,17 ) ,76 1(*$7,,,9(5 6,67$1&(&+$5$&7 5 6 ,&

% 9.

/ 9&

6,*1$/287

&S

9&

'

SS

5N

95N

D

E

Fig.1a. Typical circuit dia-gram for Esaki’s tunnel diodenegative resistance oscillatorand (b) tunnel diode current/

voltage characteristic.

Page 32: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 967

ploited more than half a centuryearlier. They are not readilyavailable to the home construc-tor, but any reference to nega-tive resistance oscillators wouldhave been incomplete without abrief mention being made ofthem.

Ordinary transistors can,however, be persuaded to oper-ate in this way, and a number ofcircuits will now be considered.

50KHZ OSCILLATORIt is not too widely known

that the emitter/collector struc-ture of some small signal tran-sistors can be made to display apronounced negative resistancecharacteristic. A circuit whichexploits this is given in Fig.2a,where the emitter/base/collectorjunctions of an npn bipolar tran-sistor are connected across apower supply via load resistorR2 and a voltage divider chaincomprising preset VR1 and re-sistor R1.

The characteristic curve ofthe semiconductor structure isshown in Fig.2b, and the devicecan be set around the mid-pointby means of VR1. No connec-tion is made to the base (b) ofthe transistor, and the polarity ofthe supply voltage has to be re-versed (supply positive to theemitter (e) of an npn transistor).

The impedance of the semi-conductor is low, and it is bestsuited to maintaining oscilla-tions in a series tuned circuit,which has a matching lowimpedance at resonance. Ac-cordingly, the tuned circuit isformed by capacitor C1 in se-ries with coil L1, and the com-ponents specified in Fig.2a canbe made to resonate at 50kHz.

The output signal is takenfrom across the coil via couplingcapacitor C2. Oscillation contin-ues to be maintained when the

&RQVWUXFWLRQDO3URMHFW

A 50KHZ OSCILLATORThe 50kHz negative resistance oscillator is the simplest and, at

the same time, the most unusual oscillator in the series. Illustrated inFig.2, and relying on the semiconductor junctions within a transistorto create negative resistance, it has something in common withEsaki’s tunnel diode.

The circuit will oscillate vigorously from low audio frequencies tomore than 100kHz and, when carefully adjusted, will produce a goodoutput waveform. Its characteristic curve (Fig.2b) clearly displaysfalling voltage with rising current.

95N

%%%&&&

1%&&

H EE FF H

92/76

&855(17P$

92/7$$$*($&5266 7+(((75$16,6725 )$//6(9(1 777+28*+7+((()/2:2) &855(177+528*+,7 ,1&5 $6 6 ,(,7 ',63/$<61(* ,9( 5(6,67$1&(

1&

1& 12 &211(&7,21

1&

&S &

S

6,*1$/2879 5 0 6$3352;

. . .

&$1$(.

/72.2&$1$(.

5N

75%&

$/7(51$7,9(75$$$16,6725/( '2876

9

D

E

E

F

H

Fig.2a. Circuit diagram for a 50kHz Negative Resistance Oscil-lator. This circuit exploits the negative resistance characteristicwithin a transistor. Note that the emitters of npn transistorsmust be connected to supply positive for this circuit to func-tion. The current/voltage characteristics of an npn transistorconnected as shown is given in (b).

output is fed into an impedance as low as 4¬¬¬7 kilohms, but signal volt-age is reduced and preset VR1 has to be set very precisely.

If possible, the input impedance of the accepting circuit shouldbe at least 100 kilohms and, preferably, 470 kilohms. The value ofcapacitor C2 should be as low as possible consistent with the deliv-ery of sufficient output.

Output and waveform quality depend, to a considerable extent,on the L/C ratio of the tuned circuit. Formulae relating inductance,capacitance, and frequency were given in Part One (see also Part

Page 33: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 968

Three), and the tuning capacitorvalues suggested there wouldensure good results with thiscircuit. Electrolytic componentscan be used to provide the com-paratively high values of capac-itance required for tuning below100Hz without there being anyperceptible deterioration in per-formance.

The circuit will oscillate vig-orously from the lowest audiofrequencies to around 150kHz,but 100kHz should be taken asthe upper frequency limit for re-liable operation. With a reason-able L/C ratio in the tuned cir-cuit, careful adjustment of pre-set VR1 will produce a perfectsinewave output in the region of5V RMS. Current flow throughthe device is a little more than4mA when the circuit is oscillat-ing.

All of the transistors listed inFig.2a will oscillate reliably upto 100kHz, but the various spec-imens of BC237 and 2N3707tried produced the greatest out-put. Readers who wish to exper-iment with this circuit will be as-sured of good results if theystart by using one or other ofthese devices.

A number of pnp transistorswere tried, with the supply po-larity reversed, but they couldnot be persuaded to oscillate.

&RQVWUXFWLRQDO3URMHFW

TWO TRANSISTOROSCILLATOR

The two transistor combina-tion depicted in Fig.3 is some-times offered as a tunnel diodesubstitute. The profile of itscharacteristic curve is certainlyvery similar, but the actual oper-ation of the circuit has nothingin common with Esaki’s tunnel

diode.

When the voltage acrossthe circuit is low, most of thecurrent flows through transistorTR2, and, as voltage increases,so does the flow of current.However, if the supply voltagecontinues to be increased, apoint is reached when transistorTR1 begins to conduct. Thistransition point is, of course, de-termined by the setting of TR1’sbase bias potentiometer VR1.

As the current through TR1increases, the voltage droppedacross its collector load resistorR2 increases. The collector (c)of TR1 is directly coupled to thebase (b) of TR2, and the fallingvoltage reduces the currentdrawn by the second transistor.The net result is a fall in the cur-rent flowing through the circuit,

100KHZ TO 10MHZ OSCILLATORThe two-transistor circuit shown in Fig.3 uses changing bias volt-

ages on a directly-coupled pair of transistors to create the rising cur-rent/falling voltage characteristic associated with negative resistance.It will oscillate from low audio frequencies to around 10MHz, and istolerant of high values of capacitance in the tuned circuit.

Waveform quality is reasonably good provided the controls areset to ensure that the output does not exceed 3V RMS. The internalcapacitance of the circuit is relatively high, and this will slightly curtailthe frequency coverages of the coil and capacitor combinationsscheduled in Table 1.

E

F

H

E

F

H

95N

95N

%%%&&&

111%&&

H EE FF H

&Q

&S

6,*1$/ 2879 5 0 6$3352;

. . .

9

5N

5N

75%&

75%&

$/7(51$777,9(75$$$16,6725/( '28 6

/6(( 7(;7

6

9&S

Fig.3. Circuit for a 100kHz to 10MHz negative resistance oscillator.

Page 34: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 969

even though the voltage acrossit is rising; i.e. negative resis-tance is being created.

When placed in series witha parallel tuned circuit, this two

transistor combination will main-tain oscillation from audio fre-quencies up to 10MHz or so.The tuned circuit of Fig.3 is con-nected on the negative side so

that the movingvanes and frame oftuning capacitorVC1 can begrounded. SwitchS1 selects induc-tors, L1, and theoutput is taken fromthe “hot” end of thetuned circuit, viacapacitor C2.

Earlier com-ments regarding theinput impedance ofthe accepting circuitapply equally here.Bypass capacitorC1 ensures consis-tent operation withvarious types ofpower supply.

Potentiometers, VR1 andVR2, should be adjusted to getthe circuit working at, say,200kHz, before refining the set-tings to ensure oscillationacross the highest frequencyrange. They can also be ad-justed to produce a good wave-form at the expense of output.

This arrangement thrives onrelatively high ratios of capaci-tance to inductance in the tunedcircuit (with parallel tuning, thislowers impedance at resonanceand increases the Q factor). Ca-pacitors of 2000pF can be wiredin parallel with inductors as lowas 50mH and the circuit will stilloscillate vigorously, with no re-duction in output, and the qual-ity of the waveform is improved.This should be kept in mind ifthe circuit is used as a spot fre-quency generator.

FET OSCILLATOR(100KHZ TO 30MHZ)

Although it is claimed thatvalves possess distinct advan-tages as the maintaining de-vices in oscillatory circuits,there are some transistor con-figurations that valves cannotemulate. One of these is thecombining of pairs of transistorsof opposite polarity.

An arrangement of this kindis shown in Fig.4, where a com-plimentary pair of field-effecttransistors (FETs) has beenused to create negative resis-tance. Close scrutiny reveals avariant of the Butler source(originally cathode) coupled os-cillator discussed last month.

In Fig.4, FET TR1 is asource follower and TR2 agrounded gate stage, and thedifferent polarity of the two de-vices (npn and pnp) enables theinputs and outputs to be directlyconnected. This combinationresults in a “two terminal” de-

&RQVWUXFWLRQDO3URMHFW

D N

'/($'2876

J

G

V

J

G

V

95N

11311313

-1311313

G V GJ J JV G V

&S

&Q

6,*1$/ 2879 5 0 6

$3352;. . .

9

5N

751311

753131

$/7(51$7,9( 75$16,6725 /($'2876

/6((((7 ;7

6

9&S

'9

N

D

Fig.4. Circuit diagram for a 100kHz to 30MHz negativeresistance oscillator using a complimentary

pair of FETs.

L W CAN1A350EK

BandRF Coi lL3/L4Fig.1b

Osci l latorCoil L1/L2

Fig.1a

PadderC2 (pf)Fig.1a

RangeMHz

RWR331208N2 150 0.14-0.3M W RWR331208N2 YMRS80046N 330 0.53-1.6

S W 1 154FN8A6438EK 154AN7A6440EK 680 1.5-4.0S W 2 1500 3.5-12S W 3 KXNK3767EK KXNK3766EK 2000 10-30

154FN8A6439EK 154AN7A6441EK

Table 1:NEGATIVE RESISTANCE OSCILLATORSFrequency coverage with Toko coils and a10pF to 365pF tuning capacitor.(see Fig4

and Fig5 for circuit diagrams)

Notes:(1) See Fig.6 for details of coil base wiring(2) Coverage can be varied, between fairlywide limited, by adjusting the coil ferritecores.

Page 35: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 970

vice, which will maintain oscilla-tion when placed in series with aparallel tuned circuit.

Preset potentiometer VR1enables the circuit to be set atthe mid-point of its negative re-sistance characteristic. It should

be adjusted to ensure that oscil-lation is maintained at the maxi-mum capacity setting of VC1 onthe highest frequency range.The circuit will then perform sat-isfactorily on all switchedranges.

The internal resistance ofthe power supply has to be rea-sonably low or operation be-comes erratic on the higher fre-quency ranges. The value sug-gested for VR1 should, there-fore, be adhered to.

Current changes triggeredby the circuit going in and out ofoscillation induce voltagechanges across VR1, making itdifficult to adjust the operatingpoint. Zener diode D1 holds thevoltage across the potentiome-ter constant and makes the set-ting up process much easier.

If the power supply deliversless than 12V, the value of re-sistor R1 should be reduced ac-cordingly. With low resistancesupplies of 6V or less, R1 andD1 can be dispensed with.

The negative resistancegenerator (TR1/TR2) is placedin series with the tuned circuitformed by L1 and VC1. The out-put is taken from the “hot” endof the tuned circuit via capacitorC1, and, again, it should be fedinto an impedance of at least100 kilohms to avoid excessivedamping. The power supply isbypassed by capacitor C2.

IN OPERATIONMost combinations of npn

and pnp field-effect transistorsshould work in this circuit, butonly those listed in Fig.4 havebeen tried. The use of a J310type ensures reliable oscillation,on the highest frequency range,with the tuning capacitor set atmaximum.

Frequency coverage with a10pF to 365pF tuning capacitorand a range of Toko coils isscheduled in Table 1. Details ofthe coil base connections aregiven in Fig.6. Readers whowould prefer to wind their owncoils should refer to Part Onefor details.

&RQVWUXFWLRQDO3URMHFW

100KHZ TO 30MHZ OSCILLATORSDirectly-coupled, complimentary pairs of transistors are used to

generate negative resistance in the 100kHz to 30MHz circuits givenin Fig.4 and Fig.5.

Bipolar and FET versions oscillate vigorously, from the lowestaudio frequencies to above 50MHz. Biasing arrangements are morecomplicated with the bipolar transistor circuit, but there are no settingup adjustments.

As with all of the negative resistance oscillators, a single winding,untapped coil will suffice, and this simplifies range switching. The fre-quency coverages obtained with Toko coils and the specified tuningcapacitor are given in Table 1.

Waveform is reasonable, but both circuits display slightly moredrift than the oscillators described earlier in the series. They are,however, perfectly suitable for use as simple signal generators.

131 7<3(6

%%%&&&

313 7<3(6

H E F

$/7(51$7,9(75$$$16,6725/( '2876

E

F

H

E

F

H

&S

&

&

Q

S

&Q

666,*1$/287 9 5 0 6$333352;:,7+$ 98 3/<

. . .

5N

5N

75313%&

75131%&

/6((((7 ;7

6

9&S

5N

9 729

Fig.5. Circuit diagram for a 100kHz to 30MHz negativeresistance oscillator using a complimentary pair of

bipolar transistors.

Page 36: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 971

Signal output is reasonablyconstant over the variousranges and across the swing ofthe variable capacitor, but itfalls to around 1V RMS at themaximum setting of the capaci-tor on the highest frequencyrange. Oscillation is maintainedfrom the lowest audio frequen-cies to above 60MHz.

If the circuit is to be usedexclusively for the generation oflow frequencies (100kHz andbelow), delete the Zener diodeand increase VR1 to 4¬¬¬7 kilo-hms. At low frequencies, ahigher supply voltage and ahigher ratio of capacitance toinductance in the tuned circuitensure a better waveform, andthe signal voltage is corre-spondingly increased.

Above 30MHz, the circuitbecomes reluctant to oscillatewith high tuning capacitor val-ues, and VC1 should be re-duced to 50pF or even 25pF.Leads must be kept as short aspossible, and stray capacitanceminimized, or the upper fre-quency limit will be curtailed.

BIPOLAR OSCILLA -TOR (100KHZ TO30MHZ)

A bipolar transistor versionof the previous circuit is given inFig.5. Biasing arrangements aremore complicated, but the cir-cuit oscillates vigorously anddoes not require setting up.

Base bias is applied to pnptransistor TR1 via resistor R1,and voltage divider resistors R3and R4 fix the bias on the base(b) of npn transistor TR2. Ca-pacitor C3 is necessary to en-sure adequate feedback at radiofrequencies. Low value resistorR2 prevents the circuit behav-

ing erratically. The base of TR1is grounded by capacitor C1,whilst C4, together with resistorR5, decouples the oscillatorfrom the power supply.

Again, the output is takenfrom across the tuned circuit,and its RMS value is approxi-mately equal to half the DC sup-ply voltage. Output coupling ca-pacitor C2 has been given avery low value in order to atten-uate the rather high signal level,which is extremely constantover the swing of the tuning ca-pacitor and the switched ranges.

The circuit has a slightlyhigher internal capacitance thanthe FET version, and this modi-fies coverage. However, theparticulars given in Table 1 stillapproximate closely to the fre-quency ranges achievable withthe specified variable capacitor.At low frequencies, below100kHz, operation may becomeerratic if the ratio of capacitanceto inductance in the tuned cir-cuit is low.

Most small signal transistorswill work well in this circuit.Those that are known to be suit-able are listed in Fig.5.

PERFORMANCEThe field-effect and bipolar

transistor versions of the widerange, negative resistance oscil-lator exhibit slightly greater driftthan the conventional feedbackoscillators described in earlierinstallments of the series. Thebipolar version also applies arough audio modulation to theRF output when the circuit isoscillating at high frequencies.Modifying the time constants ofthe various circuit elements didnot cure this.

Both versions of this circuitare vigorous oscillators, capableof delivering a constant outputwith a reasonably good wave-form. They are certainly suitablefor use as simple, wide-rangesignal generators, as audiomodulators, or for generatingspot frequencies.

PROBLEMS WITHBATTERIES

The current consumed bythe transistor circuits included in

&RQVWUXFWLRQDO3URMHFW

1 &. .

1 &. . 1 &. .

1 &. .

1 &. .

1 &. .

1 &. .

1 &. . = NO CONNECTION

D67$1'$5' &211(&7,21 E6(5,(6 &211(&7,2172 ,1&5($6( ,1'8&7$1&(

G&211(&7,21 725('8&( ,1'8&7$1&(

781('

&,5&8,7

781('

&,5&8,7

781('

&,5&8,7

781('

&,5&8,7

781('

&,5&8,7

781(' &,5&8,7

Fig.6. Base connection details for Toko coils.

Page 37: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 972

this series is extremely modest,and well within the capability ofsmall dry batteries. However,the voltage of dry cells variesover quite wide limits, fromwhen they are fresh to the pointwhen they can only just power acircuit.

Voltage reduces impercepti-bly, and the unwary can be leftwondering why an oscillatorwon’t spring into life when theproblem is one of fading batter-ies. Aging also effects the inter-nal resistance of dry cells, andthis can influence the perfor-mance of oscillators, even whenbypass capacitors have beenprovided. There is, therefore,much to recommend a mainspower supply unit to the seriousexperimenter.

MAINS POWERReaders who lack experi -

ence of constructing andcommissioning MAINS-POWERED equipment are re -minded that the voltages in -volved can cause DEATH ORSERIOUS INJURY. Anyonewho is uncertain about his orher ability to construct or

work on equipment of thiskind should seek the guid -ance of an experienced per -son, use batteries, or pur -chase a commercially pro -duced mains isolated powersupply.

LOW-VOLTAGE REG -ULATED SUPPLY

A circuit diagram for amains-driven Low-VoltagePower Supply, with alternativeregulated outputs, is given inFig.7.

The mains transformer,TR1, primary winding must, ofcourse, suit the local supplyvoltage, and the current ratingof the secondary winding needbe no more than 500mA if theunit is to be used solely for pow-ering the oscillator circuits in-cluded in this series. A benchpower supply of this kind will,however, be useful for otherprojects, and a transformer witha 2A or 3A secondary ratingwould be a sound investment.

The secondary winding out-put voltages should be 15V-0V-15V for the bi-phase, full-wave

rectifier arrangement. This willproduce a no-load DC voltageacross reservoir capacitor C3 ofaround 21V. Under maximumload, this will fall to approxi-mately 16V, leaving a safetymargin above the 15V minimuminput required for the 12V regu-lator, IC1.

An 18V-0V-18V secondarytransformer can be used if oneis to hand. This will produce anoff-load voltage of around 25V,which can exceed the input rat-ing of some 6V regulator ICs(this is usually 24V). If an 18V-0V-18V transformer is used, theinput to the 6V regulator, IC3,should, therefore, be connectedto the output of the 12V regula-tor, IC1 (i.e., the devices shouldbe connected in tandem) in or-der to avoid exceeding its inputrating.

SAFETY FIRSTThe inclusion of a low-

current mains fuse, an on-offswitch, and an IEC mains inputchassis plug are good featureson equipment of this kind.Mains Earth should be con-nected to the transformer core

&RQVWUXFWLRQDO3URMHFW

D

D

N

N

' $1' '

1

5N

&Q

&Q

&Q

&Q

&Q

&µ&

µ

'1

'1

D

D

N

N

9

9

9

'/('

,&

,&

,&

,1

,1

,1

287

287

287

&20

&20

&20

9

9

9

)P$

6

212))

)86(

,(&0$,16,1/(7

0$,16 ($57+ 7275$16)250(5&25( $1' $1<0(7$/&$6(2) 81,7

9

0$,1635,0$5<

/

1

(

D

N

/('

[[[

7$*72*5281'

,&72 ,&

7<3( 12

, 1 3 8 7 287

*5281'

0$,1675$16)250(5

9

9

Fig.7. Suggested circuit for a low voltage regulated mains power supply giving outputs of 12VDC, 9V DC, and 6V DC. (Please read the warning note, under “Mains Power”, given earlier.)

Page 38: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 973

and the case of the unit, whichshould be made of metal. It isbest not to connect the mainsearth to the output negative rail:electrical interference can becarried into sensitive equipmentvia the earth wiring.

The specified rectifierdiodes D1 and D2 are rated at1A. If a more powerful unit iscontemplated, 3A (1N5402)components must be fitted. Ca-pacitors C1 and C2 are con-nected across the rectifiers inorder to prevent any modulationhum.

The switching action of thediodes will modulate any RFcurrent flowing in the circuit at amultiple of the mains frequency,usually 100Hz, and this interfer-ence can be picked up by a ra-dio receiver powered by theunit. Modulation hum is tunable;i.e. it only becomes audiblewhen a signal is tuned in on thereceiver. These capacitorsshould be ceramic componentswith a minimum working voltageof 50V.

An “on” indicator, compris-ing a light-emitting diode (LED)D3, and its dropping resistor R1is a useful, but not essential,feature.

SMOOTH TALKThe DC output from the rec-

tifiers is smoothed by reservoircapacitor C3. An approximateformula for determining thevalue of power supply reservoircapacitors is:

Value of capacitor in PF =current drain in Amps x 2000.

This formula gives the lowerlimit of value, and a decentquality power supply shouldhave twice as much reservoircapacitance as this. However,when the supply is regulated,the regulator ICs remove muchof the ripple that develops underload, and the specified 2200PFwill be adequate provided thetotal current drain does not ex-ceed 1A.

The voltage regulators, IC1to IC3, are all 1A rated typeschosen to deliver dry-batteryrelated voltages. If difficulty isencountered obtaining the 6Vand 9V types, 5V and 8V regu-lators can be substituted withoutdetracting from the versatility ofthe unit.

If the power supply is to beused to deliver output currents

close to the regulator’s 1A maxi-mum rating, the ICs should befitted with small heatsinks, es-pecially if an 18V-0V-18V trans-former is installed.

Regulator ICs produceabout 40mV of broadband noisewhich extends into the RF spec-trum. The combination of ce-ramic and electrolytic capacitorsconnected across each outputbypasses this interference toground.

Outputs regulated in thisway have a very low resistance(around 70 milliohms) and ahigh degree of isolation fromone another. This last feature isparticularly desirable when pow-ering the different sections of anitem of equipment; e.g., an os-cillator stage and a buffer stage.

Next month: Crystal con-trolled oscillators will be consid-ered.

&RQVWUXFWLRQDO3URMHFW

Page 39: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 974

At long last Microchip’s newPIC16F87x family of microcon-trollers is actually availablethrough component distributorsand retailers. Forecast in late1998, production release com-menced in July 1999.

The author has had engineer-ing samples for some months andhas examined them with consid-erable interest. A general look atthe family was taken in thePIC16F87x Review (Apr ’99).Now we can encourage you toexplore the possibilities of thesevery welcome PICs, knowing thatyou can obtain the production de-vices.

The aim of this Mini Tutorialis to share with you some of thefindings made by the author whendesigning the 8-Channel AnalogData Logger, published in Aug/Sept ’99. The findings relate toinvestigations using thePIC16F877 but apply in principleto the PIC16F873, ’874, and ’876devices as well.

Readers should also studythe 200-page data sheet that cov-ers the devices, Microchip codeDS30292A (see later).

The following EPE subjectmaterial is also referred to in thisMini Tutorial:

o) PIC Tutorial (Mar-May ’98)o) PICtutor (CD-ROM version

of the PIC Tutorial)o) PIC Toolkit Mk1 (Jul ’98)o) PIC Toolkit Mk2 (May-Jun

’99)o) Virtual Scope (Jan-Feb ’98)

used is TASM (the differencesbetween TASM and MPASMwere discussed in Toolkit Mk1,PIC Tutorial and PICtutor).

All registers and bits re-ferred to by name should havethose names and their values“equated” at the head of anyprogram that uses them.

PAGES 0 TO 3The subject of Pages in re-

lation to PIC16x84 devices waswell-covered in the PIC Tutorialand PICtutor texts, and a lot ofreaders expressed gratitude forthe explanation.

Taking a programmer’s look at some of thePIC16F87x family’s facilities.

3,&)[ 0,1, 78725,$/ E\ -RKQ %HFNHU

PROTOCOLIn the course of this article,

reference is made to figuresfrom Microchip data sheetDS30292A and the referencestyle used is, for example, DS-FIG.11-2, meaning data sheetFigure 11-2.

Note also the use of the $(dollar) sign when referring tohexadecimal numbers, and the% (percent) sign for binary num-bers, e.g. $9F and %11001111.

Where PIC source code ex-amples are given, the dialect

PCFG3:PCFG0

AN7(1)

RE2AN6(1)

RE1AN5(1)

RE0AN4RA5

AN3RA3

AN2RA2

AN1RA1

AN0RA0

V REF+ V REF-Chan/Refs

0000 A AA A A A A A Vdd Vss 8/0

0001 A V REF+A A A A A A RA3 Vss 7/1

0010 D AD D A A A A Vdd Vss 5/0

0011 D V REF+D D A A A A RA3 Vss 4/1

0100 D AD D D D A A Vdd Vss 3/0

0101 D V REF+D D D D A A RA3 Vss 2/1

011x D DD D D D D D Vdd Vss 0/0

1000 A V REF+A A A V REF- A A RA3 6/2

1001 D AD A A A A A Vdd Vss 6/0

1010 D V REF+D A A A A A Vss 5/1

1011 D V REF+D A A V REF- A A 4/2

1100 D V REF+D D A V REF- A A 3/2

1101 D V REF+D D D V REF- A A 2/2

1110 D DD D D D D A Vdd Vss 1/0

1111 D V REF+D D D V REF- D A RA3 1/2

RA3

RA3

RA3

RA3

RA2

RA2

RA2

RA2

RA2

ADFM --- --- --- PCFG3 PCFG2 PCFG1 PCFG0

U-0 U-0 R/W-0 U-0 R/W-0

bit7 bit0

R/W-0 R/W-0 R/W-0

Note 1: These channels are not available on the 28-pin devices.

Fig.1. Selectable functions of the ADCON1 register.

Page 40: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 975

Whereas the ’x84 had onlyPAGE0 and PAGE1 to be set inrelation to the use of some Spe-cial Registers, the ’F87x de-vices have four Pages(Microchip actually calls them“Banks” – but we’ll stick withPages).

In the STATUS register, twobits (instead of one) control thePage selection, bits 6 and 5 re-spectively. Consequently, theshorthand technique used withthe ’x84 of defining the instruc-tion PAGE0 or PAGE1 to meanclearing or setting of STATUSbit 5 accordingly, is less easy touse when two STATUS bits areaffected. Therefore, in commonwith the Microchip data sheet,the STATUS bits will be referredto by their allocated names, ofRP1 (bit 6) and RP0 (bit 5).Their settings are as follows:

PAGE RP1 RP0PAGE0 0 0PAGE1 0 1PAGE2 1 0PAGE3 1 1

You will make life easier foryourself if you “equate” thesetwo bits at the head of your pro-grams:

RP0: .EQU 5RP1: .EQU 6

The Register File Maps inDS-FIG.2-3 and DS-FIG.2-4show which registers are inwhich Pages (Banks).

PIC PORTA ANDPORTE

PORTA is a 6-bit bidirec-tional I/O (input/output) port,whose bits RA0 to RA3 andRA5 can alternatively be usedfor analog input.

PORTE is a 3-bit bidirec-tional I/O port, whose bits RE0to RE2 can alternatively be

used for analog input.

The first matter of interestthat came to light when experi-menting with the PIC16F877was that its PORTA did not be-have as expected when used asa normal I/O data port.

The PIC16F877 was origi-nally loaded with the TUTTESTprogram that allows users of thePIC Tutorial and PICtutor devel-opment boards (which are foruse with PIC16x84 devices) toinitially test their system.PORTB behaved as expected,but not so PORTA.

Examination of the datasheet revealed that PORTA’sdefault mode is not for digitaldata I/O, but for analog data in-put.

The register which controlsPORTA’s digital or analog useis ADCON1, whose settings op-tions are shown in Fig.1 (takenfrom data sheet DS-FIG.11-2).This same register controlsPORTE as well.

Register ADCON1 is at ad-dress $9F, which is in PAGE1.Fig.1 shows that PORTA andPORTE are jointly set for ana-log use when ADCON1’s bits 0to 3 are set to 0000 (the defaultcondition on power-up). Tojointly use PORTA and PORTEfor digital purposes, the bits areset to 0111 (or 0110 since bit 0can be 0 or 1 in this instance),i.e. ADCON1 has to be loadedwith %xxxx111x – where x canbe 0 or 1.

You will already be familiarwith having to set the data di-rection (TRISx) registers de-pending on whether a port’s bitsare to be used for input or out-put. So, for both PORTA andPORTE to be fully set for digitaloutput, TRISA and TRISE haveto be cleared, which also has tobe done in PAGE1.

Thus, an example of initial-

izing your code to use PORTAand PORTE for digital output is:

BCF STATUS,RP1 ; clear; PAGE2/3 bit

BSF STATUS,RP0 ; set PAGE1; bit

MOVLW %00000111 ; all-digital; I/O code

MOVWF ADCON1 ; load it; into; ADCON1

CLRF TRISA ; all PORTA; for output

CLRF TRISE ; all PORTE; for output

BCF STATUS,RP0 ; reset to; PAGE0

Conversely, an example ofinitializing your code to usePORTA and PORTE for digitalinput is:

BCF STATUS,RP1 ; clear; PAGE2/3 bit

BSF STATUS,RP0 ; set PAGE1; bit

MOVLW %00000111 ; all-digital; I/O code

MOVWF ADCON1 ; load it into; ADCON1

MOVLW %00111111 ;MOVWF TRISA ; all PORTA

; for inputMOVWF TRISE ; all PORTE

; for inputBCF STATUS,RP0 ; reset to

; PAGE0

Note that TRISE ignores bits3 to 7.

A-TO-D PREPARA -TION

From Fig.1, you will recog-nize that ADCON1 is set toxxxx0000 when PORTA andPORTE are to be used for analoginput. You also need to set thetwo associated TRIS registers forinput (in the same way as settingthem for digital input).

There is another option thatcan be chosen for ADCON1 aswell – its bit 7 (ADFM) controls

6SHFLDO)HDWXUH

Page 41: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 976

how the 10-bit digital value ofthe converted analog signal isstored in the PIC’s registersdedicated to this purpose,ADRESH ($1E - PAGE0) andADRESL ($9E - PAGE1).

There is the choice ofwhether the result is justified tothe left or right in these bytes.Take the example of a conver-sion result of 1023 (the maxi-mum for a 10-bit conversion).The binary value of 1023 is, astwo bytes, 00000011 11111111,stored as 00000011 in ADRESHand 11111111 stored inADRESL.

This is the case when theADFM bit (bit 7) is set to 1 (DS-FIG.11-8). However, if theADFM bit is set to 0, the resultis formatted as 1111111111000000. This choice can beuseful in some post-processingoperations where it can savethe use of multiplying (rotationcommands).

As used in the Data Logger,a right-justified result was re-quired, and so ADFM was set to1. Since this design uses all ofPORTA and PORTE for analoginput, the ADCON1 register wasset with the commands:

BCF STATUS,RP1 ; clear; PAGE2/3

bitBSF STATUS,RP0 ; set PAGE1

; bitMOVLW %10000000 ; all-analog

; input codeMOVWF ADCON1 ; load it into

; ADCON1MOVLW %00111111 ;MOVWF TRISA ; all PORTA

; for inputMOVWF TRISE ; all PORTE

; for inputBCF STATUS,RP0 ; reset to

; PAGE0

ADFM ANOMALYWhen the first tests were

made using the PIC16F877 sam-ples provided by Microchip, theabove commands were dulygiven in the Data Logger softwarethat was being developed. To theauthor’s consternation, the ADFMbit had no affect on the justifica-tion, which remained doggedly tothe left when the result was dis-played on an alphanumeric liquidcrystal display (LCD).

It was eventually found thatbit 5, not bit 7, was being used asthe ADFM bit, and using that bitproduced the required justifica-tion. What led the author to theconclusion that it should be bit 5rather than bit 7 is that DS-Table2-1 showed the power-on-resetcondition for ADCON1 as being --0-0000, even though ADFM wasshown as bit 7 on the left of thetable.

Taking it up with Microchip, ittranspired that the samples pro-vided were Microchip’s early engi-neering samples (version A) inwhich bit 5 was indeed theADFM. They went on to say thatproduction devices (version B) dohave bit 7 as ADFM. This wasproved when they sent version Bsamples to the author.

However, Microchip haveasked us to advise anyone whohas early engineering samplesthat this situation exists. Readersbuying the chips from distributorsor retailers should automaticallybe supplied with the productiondevices where bit 7 is the ADFM.

The fact remains, though,that the ADCON1 reset valuesgiven in DS-Table 2-1 of the 1998DS30292A data sheet are incor-rect and should read as 0---0000.Other tables in the same datasheet are similarly incorrect (3-1,3-9, 3-12, 11-2).

A-TO-D CONVERSIONWe have seen that AD-

CON1 is the register that setsPORTA and PORTE bits foranalog or digital use, and thatADRESH and ADRESL hold the10-bit conversion value. Afourth register, ADCON0 ($1F -PAGE0) is responsible for theA-to-D control modes, as item-ized in DS-FIG.11-1, but sum-marized as:

Bits 7-6 Conversion clockrate

Bits 5-3 Channel selectionBit 2 Conversion statusBit 1 Not usedBit 0 A/D facility on/off

Prior to an A-to-D conver-sion being made, all bits haveto be set appropriately. An ex-ample of the conversion se-quence is shown in Listing 1,with entry point at ADCGET.

The channel number is heldin CHAN and could be anyvalue between 0 and 7. It has tobe set into ADCON0 bits 5-3,consequently the first six com-mands are concerned with tak-ing a copy of the CHAN valueand rotating it to fill bits 5-3 ofthe temporary STORE. If theChannel number is 7, for exam-ple, CHAN holds %00000111,and the rotation into STOREproduces %00111000.

The conversion clock rate isdetermined from DS-Table 11-1. The Data Logger’s crystalclock runs at 3¬¬¬2768MHz andthe nearest value to this, asshown in DS-Table 11-1, is5MHz and that a conversionfactor of 32Tosc is required,which is set into ADCON0 withthe bit 7-6 code of binary 10(DS-FIG.11-1).

The converter is obviouslyrequired to be On, so bit 0 is setto 1.

6SHFLDO)HDWXUH

Page 42: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 977

The values for bits 7, 6 and0 are thus set into W as%10000001, which is thenORed with the channel bits 5-3held in the STORE (%00111000in this example).

This composite value(%10111001) is then MOVedinto ADCON0. Notice that bit 2,the Start bit (quaintly called theGO/DONE bit by Microchip!), isstill at zero. The conversiondoes not start until this bit is setto 1. Also note that ADCON0 bit1 has no function.

SOPHISTICATIONAt this point it is possible to

get rather sophisticated – butwe’re not going to!

The sophisticated waywould be to use interrupt rou-tines and precise timings, and alengthy section in the data sheet

6SHFLDO)HDWXUH

discusses the options. They in-clude calculation of the timetaken to acquire the sample(which is relative to tempera-ture, line impedance, and ca-pacitance values), and then towait for an interrupt to occur oncompletion of the conversion.

Since the Data Logger isonly required to take samples atthe maximum batch rate ofeight (all eight channels) every0¬¬¬5 seconds, time is not at apremium and so two simple de-lay loops are used, shown inListing 1 as WAIT1 and WAIT2.

When WAIT1 has ended,the conversion is started by firstclearing the A/D interrupt flagbit (bit 6 of register PIR1 - $8C,PAGE0), and then setting AD-CON0 bit 2 (the GO bit).

The delay in WAIT2 thenoccurs, after which the GO bit ispolled in WAIT3 until it is read

as 0, signifying that the conver-sion is complete.

The values of the 2-byteconversion can now be read.The high byte (MSB) is held inADRESH, which is in PAGE0and so can be immediately readand stored in the user’s ownnominated location, in this caseMEMHI. The low byte (LSB),however, is held in ADRESL,which is in PAGE1, which has tobe set before the byte can beread. After which a reset toPAGE0 occurs and the byte isstored in MEMLO, so ending theconversion sequence.

As used in the Data Logger,the sequence is somewhat morepadded than shown here since itis written to read a conversionfor each of eight channels inturn, and then to store the 2-byte result in a chain of eightserial EEPROM memories, andto decimalize the result forshowing on an alphanumericLCD screen.

Apart from the ADFM prob-lem mentioned earlier, no sur-prises occurred when using theA/D facilities on all eightPIC16F877 channels, and theprogram worked first time.Which is more than can be saidfor storing the result in the serialEEPROM memories, as weshall reveal in a moment, plusthe solution, of course!

ADC REFERENCEVOLTAGES

Referring again to Fig.1,you will see that pins RA2 andRA3 can be used as the pins onwhich external ADC referencevoltages can be set, dependingon the code set into ADCON1bits 0 to 3. The columns 10 and11 show how the reference volt-age selection takes effect.

Although not discussed inthe Data Logger text, the

Listing 1ADCGET: BCF STATUS, C ; clear carry flag MOVF CHAN, W ; get channel number MOVWF STORE ; temporarily store it RLF STORE,F ; multiply it by 8 RLF STORE,F ; to set it into correctbits RLF STORE,F ; suited to ADCON0 MOVLW % 10000001 ; set clock Fosc/32 with A/D on IORWF STORE ; OR this with stored value MOVWF ADCON0 ; move new value into AD-CON0 CLRF DELAY ; set delay counter to 0WAIT1: DECFSZ DELAY,F ; dec delay 256 times GOTO WAIT1 ;SAMPLE: BCF PIR1,ADIF ; clear A/D interrupt flagbit BSF ADCON0,GO ; start A-D conversionWAIT2: DECFSZ DELAY,F ; again delay for 256 cy -cles GOTO WAIT2 ;WAIT3: BTFSC ADCON0,GO ; is conversion complete? GOTO WAIT3 ; noGETVAL: MOVF ADRESH,W ; get conversion high byte MOVWF MEMHI ; store it in MEMHI BCF STATUS,RP1 ; clear Page 2/3 BSF STATUS,RP0 ; set Page 1 MOVF ADRESL,W ; get conversion low byte BCF STATUS,RP0 ; reset Page 0

Page 43: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 978

printed circuit board (PCB) forthat unit has been designed sothat preset potentiometers canbe inserted on it to set desiredreference voltages on pins RA2and RA3 for other applications.(The Data Logger itself does notoffer this option through its soft-ware, so readers must writetheir own software to suit theirpersonal needs in this respect.)

The circuit diagram andPCB assembly details for theinsertions are shown in Fig.2and Fig.3. Note the additionaltwo link wires that are needed inorder to complete the circuit be-tween the wipers of the presetsand their respective RA2/RA3pins.

Preset VR2 allows a refer-ence voltage variation between

approximately 2¬¬5V and 5V onRA2, whilst VR3 allows varia-tion between 2¬¬5V and 0V onRA3. The use of a narrowerrange of reference voltage(which is normally 0V to 5V i.e.Vss to Vdd) has the effect ofproviding amplification to theanalog input signal being con-verted.

By variously selecting dif-ferent values for ADCON1 bits0 to 3, different reference volt-age combinations could be cho-sen for individual input chan-nels.

It should be noted that wheneither RA2 or RA3 is selectedas a reference voltage input, theselected pin cannot be used asan A-to-D input channel.

SERIAL MEMORYACCESS

Once you get to know them,Microchip’s 24LC256 serialEEPROM memories are reallyrather super little chips! It wastheir data sheet (DS21203D,1998) that the author had diffi-culty with.

Attempts were made towrite the routine that wouldstore data at consecutive ad-dresses in a 24LC256. Some-how, the logic of the datasheet’s description and illustra-tion eluded the author (it’s notoften he fails in such situations,but he failed this time!)

Running out of patience, heresorted to seeing if programswere available amongst Mi-crochip’s Applications Notes (ontheir CD-ROM and web-site).

There were several optionsavailable, of which the pro-grams 2WDPOLL.ASM and2WSEQR.ASM were selectedas appearing to have the bestoptions available (even thoughthey were not written for

PIC16F87x devices) and diskcopies were made.

Being Microchip’s own pro-grams, they were naturally writ-ten in MPASM, whereas the au-thor has a great preference forworking in the TASM dialect.Consequently, the MPASMsource codes were processedby the author’s PIC Toolkit Mk2and converted to a TASM for-mat.

Various modifications werethen made to the programs tosuit them to the Data Logger’sneeds, whereupon success wasachieved! Data could now bewritten to the serial EEPROMsand, equally importantly, couldbe read back as well.

Those of you studying theData Logger source code willfind entry into the serial memoryWrite routine at label WRBYTE,and entry to the Read routine atREAD. The routines are far toolengthy to list or describe here.

As a further plug for Mi-crochip’s Application Notes,they are well worth examiningfor all sorts of information andideas, plus an awful lot ofsource code listings as well. Dohave a good browse throughthem.

SERIAL OUTPUTWith the ability to write/read

serial data assured, the nextstage to be solved was that ofinstructing the PIC16F877 tooutput the data as a serialstream at a known baud rate.This turned out to be verystraightforward.

The PIC16F87x family havea built-in structure which allowsserial output through a dedi-cated pin, RC6, and for the rateof output to be selected accord-ing to the needs of the destina-tion for that data (e.g. a PC) andin relation to the PIC’s crystal

6SHFLDO)HDWXUH

5$$1

5$$1

5$$195()²

5$$195()

5$72&.,

5$$166

9(

,&3,&)

572 5

5

9

95N

95N

9

'

D N

&

5

&

9595 95

5

&;

9

999&

&&

50

287

&20

,1

Fig.2. Reference voltage set-ting presets added to Data

Logger circuit diagram Fig.1.and (below) Fig.3, their

positioning on theData Logger PCB.

Page 44: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 979

controlled clock rate.

Additionally, these PICs canbe instructed on such mattersas synchronous or asyn-chronous transmission, parity,stop bits, and byte size.

The ’F87x data sheet, onceyou have studied it for details ofserial interfacing, is actuallyquite helpful.

It was decided to use asyn-chronous serial transmissionfrom the PIC to the PC. Thisrequires only two lines to beconnected between the two sys-tems, one for data and one forthe ground (0V).

It was further decided thatthe rate of transmission shouldbe at the maximum likely to befound on the majority of read-ers’ PCs, 9600 baud, with noparity, one stop bit and with 8-bit transmission.

The registers associatedwith serial transmission are:

SPBRG ($99 - PAGE1) Baud rate generator

TXSTA ($98 - PAGE1) Transmit status and control

RCXTA ($18 - PAGE0) Receive status and control

PIE1 ($8C - PAGE0) Peripheral interrupt control

Data sheet tables are pro-vided for establishing the valueto be set into register SPBRG inrelation to several examples ofclock rate: DS-Table 10-4 andDS-Table 10-5. Since these donot quote a value for a3¬¬¬2748MHz clock, as used in theData Logger, the formulaquoted in the data sheet’s Ex-ample 10-1 was more useful onthis occasion.

TIMING FORMULAEIn fact, two formulae can be

derived from Example 10-1, de-

pending on whether the PIC isto divide the clock rate by 64 or16. The idea is to select a divi-sion rate to produce as large anSPBRG value as possible, up toa maximum of 255 (it’s an 8-bitregister).

In Listing 2 is shown a Basicprogram derived from the for-mula in Example 10-1. It calcu-lates the SPBRG value in rela-tion to the baud rate required,the clock rate available, and thetwo division factors of 64 and16. Bit BRGH (bit 2) of theTXSTA register has to be setlow if 64 is the divider, and highfor a divider of 16.

Running the program inListing 2 produces SPBRG an-swers of 4and 20

¬¬¬333333 (BRGH = 0)¬¬¬3333 (BRGH = 1). Since

the latter is the higher, theBRGH bit has to be set to 1.

The bit that tells the PICwhether it is required to transmitsynchronously or asyn-chronously is TXSTA register bit4 (SYNC). DS-Table 10-1shows that for asynchronoustransmission the SYNC bit is setto 0.

Prior to commencing trans-mission, the basic transmissionparameters are set as in Listing3, with entry at label SETBAUD.

Since some of the affectedregisters are in PAGE1, this isset first, as in command lines 1

and 2. Then the integer of thechosen SPBRG value (20) isstored into the SPBRG register,register TXSTA is conditionedfor SYNC = 0 and BRGH = 1,TRISC bit 6 is cleared for pinRC6 to be used as an output,and the transmission interruptbit (PIE1,4) is cleared (interruptnot required). A reset to PAGE0is made and the SPEN bit (bit 7)of register RCSTA is set.

This sequence is in accor-dance with the first three stepslisted in the data sheet at Sec-tion 10.2.1. Step 4 (9-bit trans-mission) is not required. Step 5(enable transmission) requires areset to PAGE1, and the trans-mission bit (bit 5) of TXSTA isset, followed by a reset toPAGE0. The scene is nowready for data to be transmittedfrom PIC pin RC6, and theSETBAUD routine is exited.

SERIAL FORMATIn the Data Logger the SET-

BAUD sequence is performedwhen power is first switched onand it remains in a state ofreadiness to send data to thePC until power is switched offagain.

Consequently, having readthe 2-byte sample data stored inthe selected serial memory, itcan be sent to the computerthrough the routine commenc-ing at label SENDPC, shown in

6SHFLDO)HDWXUH

Listing 2‘calculate SPBRG for required baud rate

BAUD = 9600 ; replace this value with one ofyour ownFOSC = 3276800 ; replace this value with one ofyour ownX = (FOSC / (64 * BAUD)) – 1Y = (FOSC / (16 * BAUD)) –1PRINT “BAUD =”; BAUD, “CLOCK =”; FOSCPRINT “SPBRG at div 64 = “; X; “bit BRGH =0”PRINT “SPBRG at div 16 = “; Y; “bit BRGH =1”

Page 45: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 980

Listing 4.

However, before it can besent, a slight readjustment ofthe data format is needed. ThePC register that receives theserial data shifts it left by oneplace (multiplying it by two).This means that the PIC cannotsend a data byte whose value isgreater than 127. If it were to,bit 7 would be “lost” at the PCend.

In order to overcome this,the least significant byte of re-called data (held in MEMLO, asdiscussed earlier) has to be lim-ited to a value of less than 128

and its eighth bit (bit 7) com-bined with the most significantbyte (MEMHI), whose recalledvalue is never greater thanthree.

On entry into routineSENDPC in Listing 4, this rear-rangement takes place in thefirst four lines. An example ofwhat happens is as follows:

Suppose MEMHI holds avalue of %00000011 andMEMLO holds %11111111.MEMLO is first rotated left intothe W register (leaving MEMLOitself untouched) so that its bit 7“drops” into the Carry register.

MEMHI is now rotated left andin doing so the Carry bit is ro-tated into it from the right.MEMLO’s bit 7 can now becleared, limiting MEMLO’svalue to less than 128.

The result is that MEMHInow holds %00000111 andMEMLO holds %01111111 andit is these values that are trans-mitted to the PC via the calledroutine whose label is SERIAL1(see Listing 5). How they arerestored to their “true” valueswill be discussed shortly. Oncethat byte pair has been transmit-ted, the next pair can be readfrom one of the serial memo-ries, and again transmitted viathe SENDPC routine.

REGISTERS TXREGAND TSR

The routine that allows eachbyte to be transmitted, SE-RIAL1, has only three activecommands. As soon as thePIC’s serial transmission regis-ter (TXREG) is loaded with abyte of data, transmission isstarted by the PIC’s own internalfacilities.

To summarize the PIC datasheet, the heart of the transmit-ter is the Transmit Serial Regis-ter (TSR), which obtains its datafrom the read/write transmitbuffer register TXREG. Theuser’s software loads TXREGwith the data byte to be trans-mitted, where it stays until theStop bit from the previouslyloaded data has been sent.

As soon as the Stop bit hasbeen transmitted, the TSR isautomatically loaded with thenew data from TXREG. Oncethis has occurred, TXREG isnow empty and a flag bit is setin register PIR1 (its bit 4, namedTXIF). When this flag is set, thesoftware can load the next byteof data into TXREG, an action

6SHFLDO)HDWXUH

Listing 3SETBAUD: BCF RP1 ; clear PAGE2/3 BSF RP0 ; set PAGE1 MOVLW 20 ; BRG val for 9600 baud ; from 3.2768MHz, brgh=1 MOVWF SPBRG ; put into SPBRG reg MOVLW %00000100 ; sync=0 (bit 4), brgh=1 ; (bit 2), clear otherbits MOVWF TXSTA ; put into TXSTA BCF TRISC,6 ; set RC6 as output BCF PIE1,4 ; clear interrupt bit(TXIE) BCF RP0 ; set back to PAGE0 MOVLW %10000000 ; set SPEN bit of RCSTAreg MOVWF RCSTA ; BSF RP0 ; set for PAGE1 BSF TXSTA,5 ; enable transmission(TXEN) BSF RP0 ; set for PAGE0 RETURN ; end of routine

Listing 4SENDPC: BCF STATUS,C ; clear Carry flag RLF MEMLO,W ; rotate MEMLO left intoW, ; bit 7 enters Carry RLF MEMHI,F ; rotate MEMHI left, ; Carry enters bit 0 BCF MEMLO,7 ; clear MEMLO bit 7 MOVF MEMLO,W ; get MEMLO CALL SERIAL1 ; send it to PC MOVF MEMHI,W ; get MEMHI CALL SERIAL1 ; send it to PC RETURN ; end of routine

Page 46: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 981

that clears the TXIF bit.

The routine entered at SE-RIAL1 first checks the status ofPIR1 bit 4. If the bit is low, aprevious transmission is stilltaking place. The routine loopscontinuously checking bit 4 untilit is set. Prior to entry to SE-RIAL1, the W register wasloaded with the data byte (asshown in Listing 4). When PIR1bit 4 is found to be set, the Wdata is loaded into TXREG, tobe automatically transmitted outby the PIC.

As soon as TXREG hasbeen loaded, the SERIAL1 rou-tine ends, and software can getthe next byte, or do whatever itis told to do, such as end the fulltransmission sequence becauseall the bytes have been sent.

IRREGULAR TRANS -MISSION

The Data Logger sends itsserial data to the PC in consec-utive blocks of data. However,in another design on which theauthor is working, the need isfor serial data to be output tothe PC at irregular intervals, twobytes a time.

Whereas for consecutivedata blocks, setting the BaudRate factors at the head of theprogram proved satisfactory, inthe random transmission de-sign, the author found it neces-sary to send a byte of zero priorto each double-byte being sent.

What subtlety of differencebetween the two programs

makes this action necessaryhas not been established, al-though it is believed that itmight be to do with PORTC be-ing read between data words inthe second design. PORTC isthat which has to be used forserial input/output, and it seemspossible that reading it (forswitch status) between datawords might affect the serialregisters. It has yet to be morefully investigated.

PC RECEPTIONA program for use on a PC

to receive serial data from aPIC is not included in Mi-crochip’s Applications Notessoftware listings library. Abrowse of the Internet for suit-able software did not revealanything that the author felt wassuitable either. Consequently,he wrote his own routinesspecifically to import double-byte serial data from the DataLogger.

The program is written in amixture of Basic (suited to run-ning from QBasic or QuickBA-SIC) and machine code. TheBasic program loads and callsthe machine code, which doesthe actual serial data importing,and then formats the data foroutput to disk, in several differ-ent file styles, as discussed inthe Data Logger text.

There are, in fact, severalways in which machine codecan be accessed from Basic.The example shown in Listing 6is the one on which the author

has standardized for severalyears.

The majority of the Basicroutines are self-explanatory toanyone who knows QBasic orQuickBASIC and will not be dis-cussed here. However, the rou-tines that access the machinecode, and the machine codeitself, deserve a bit of explana-tion.

On running the Basic pro-gram, integer variable arrayMA%(x) is first DIMmed for themaximum number of separatevalues (32766) as are requiredfor access by the machine code.All the values are in consecu-tive order within the PC’s mem-ory and their exact locations areaccurately predictable.

Referring to Listing 6, themachine code whose file nameis held in FILE$ is then loadedas binary data into string vari-able SERIAL$, at label LOAD-DATACODE. The address atwhich MA%(0) resides is thenobtained, and POKED into themachine code at two predeter-mined consecutive addresses.

Note that in line 10 (MC =)attempting to multiply by 256 asa “live” value would result in an“overflow” error and so variableA is used, having been allo-cated that value in line 6. Also,because integer variableswhose true values are greaterthan 32767 are returned as neg-ative numbers, line 8 interceptsthem if they occur, restoringthem to their correct positivevalue. Additionally note thatvariable MB is used for two dif-ferent purposes.

Once the routine in Listing 6has been run, the machine codeis accessed through the com-mand:

CALL ABSO-LUTE(SADD(SERIAL$))

6SHFLDO)HDWXUH

Listing 5SERIAL1: BTFSS PIR1,4 ; wait for bit 4 = 1 ; (showing TXREG empty) GOTO SERIAL1 ; NOP ; MOVWF TXREG ; put val in TXREG ready ; for auto-transmission RETURN ; end of routine

Page 47: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 982

When the machine coderoutine has ended, the programreverts to Basic.

It is important to note thatthere is a slight difference be-tween using QBasic and Quick-BASIC, in that QuickBASIC hasto be loaded with the commandQB/L, which automatically loadsan additional library program(part of the QuickBASIC suite)which allows machine code tobe run. QBasic does not requirethe additional library programand is simply loaded in theusual way with the commandQB.

The machine code routineis shown in Listing 7. It is basedon two PC interrupt calls to INT14H, whose functions are docu-mented in the PC Sourcebook –a publication which itemizes theprincipal registers and interruptcalls for base-standard PCs(seemingly compatible with pro-cessors from the 8086 upwards,including Pentiums).

On entry to the machinecode, the address of MA%(0) isacquired from the value held atlabel SETSEGMENT, as previ-ously POKED there from Basic.

Transmission format datapassed from Basic (held inMA%(0)) is then read andloaded into the AX register. The

data details the baud rate, par-ity, stop bit, and bit count con-figuration (assembled from thedetails in Table 1). The Basicsoftware also passes details onwhich COM port (COM1 orCOM2) is to be read (held inMA%(1)). This is loaded into theBX register to be then loadedinto register DX, whereupon in-terrupt INT 14H is called, whichpasses the data to the PC’s se-rial operating system.

Routine WAITDATASET isnow called, in which INT 14H ispolled until register AX returnswith a value less than 256, sig-nifying that a byte of serial datahas been received and that it isnow available in the low byte(AL) of register AX.

This data byte is an inver-sion of the byte presented to thePIC for transmission and isshifted left by one place. Theinversion is corrected by sub-tracting the byte from 255.

Returning to the callingpoint, the byte is stored in regis-ter CL as the least significantbyte of the double-byte re-quired. WAITDATASET is againcalled, where the second of thetwo bytes needed is similarlyacquired, and then stored inregister CH. Note that CH andCL are the high and low bytes,

respectively, of register CX.

Now a mixture of rotationand ANDing reconstitutes thedouble-byte data to its originalvalue as stored in the Data Log-ger’s serial memory. The valueis then stored in the pre-determined location in the PC’smemory relative to the integerarray position back in Basic(from MA%(0) onwards).

The value is also checkedto see if it is the end markervalue transmitted by the PICwhen a serial memory has beenfully read. If it is not that value(two bytes each of value 127),the next double byte of trans-mitted data is acquired, andstored at the next consecutivePC memory location.

Back in Basic, the locationsin which the machine code wasstored (MA%(0) onwards) isthen saved as a block whoselength is the count valuereached at the end of the ma-chine code sequence.

KEYBOARDINTERRUPT

A second serial input ma-chine code routine is includedwith the Data Logger software.This includes the ability to press“Q” to quit from the machine

6SHFLDO)HDWXUH

Listing 6LOADDATACODE: ‘ load machine code subroutineOPEN FILE$ FOR BINARY AS #1 ‘ open file named in FILE$B = LOF(1) ‘ get length of fileSERIAL$ = INPUT$(B, #1) ‘ load file into SERIAL$CLOSE 1 ‘ close fileA = 256 ‘ define A as value 256MA = VARSEG(MA%(0)) ‘ get segment address of MA%(0)IF MA < 0 THEN MA = MA + 65536! ‘ correct for negative valueMB = VARPTR(SERIAL$) ‘ get pointer to SERIAL$MC = PEEK(MB + 3) * A + PEEK(MB + 2) ‘ get address of SERIAL$MD = INT(MA / 256) ‘ get MSBMB = MA – (MD * 256) ‘ get LSBPOKE MC + 5, MB ‘ poke LSB into machine codePOKE MC + 6, MD ‘ poke MSB into machine codeRETURN ‘ end of subroutine

Page 48: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 983

code without waiting for the datatransfer to be complete. Thisroutine makes use of the INT16H keyboard access interruptto read which keys are pressedand to return a value accord-ingly.

A point of interest, however,is that although three of the au-thor’s computers would respondto the INT 16H call, a fourth (a“custom-built” machine used atEPEHQ) would not. This is puz-zling since it was believed thatthe basic interrupt calls on PCsare upwards compatible –seemingly not in some in-stances. Can anyone throw lighton this?

PIC EEPROM DATAMEMORY

The routines for writing toand reading from thePIC16F87x family’s internalEEPROM data memory areworth highlighting. You will nodoubt be familiar with the sameroutines as used with thePIC16x84 devices, and the’F87x routines are similar, butnot exactly the same since the’F87x devices use different reg-ister locations to those usedby the ’x84, as shown in Table2.

The EEPROM data memoryWrite/Read routines are shownin full in Listing 8 and Listing 9.More information on them is onMicrochip data sheet DS30292Apage 43.

As with the ’x84 program-ming examples given in the PICTutorial and PICtutor texts (towhich readers are also referred– either text source will do), theEEPROM Write routine at labelSETPRM is entered with Wholding the EEPROM byte ad-dress at which data is to bestored. The data to be stored isheld in STORE1. Whereas the

’x84 routine was actioned inPAGE0 and PAGE1, the ’F87xroutine is actioned in PAGE0,PAGE2 and PAGE3, hence the

various RP0 and RP1 paging in-structions.

It is worth noting that the’F87x data sheet gives a pro-

6SHFLDO)HDWXUH

Listing 7JMP STARTALL ; entry point from Basic

SETSEGMENT:MOV DS,01111 ; value changed from BasicRET ; for VARSEG(MA%(0))

STARTALL:PUSH DS ; store current data segmentCALL SETSEGMENT ; get MA%(0) segment addressMOV SI,0 ; set source address count tozeroMOV AX,[SI] ; get baud rate etc from MA%(0)MOV BX,[SI+2] ; get COM port number from MA%(1)MOV DX,BX ; load config data viaINT 14H ; interrupt call INT 14H

GETDATA:CALL WAITDATASET ; get first data byteMOV [SI],CL ; temporarily store itCALL WAITDATASET ; get second data byteROR CL,1 ; rearrange bytes to originalMOV [SI+1],CL ; format and store themRCR [SI+1][B],1 ; rotate byte rightRCR [SI][B],1 ; rotate byte rightAND [SI+1][B],127 ; clear bit 7INC SI ; double-incrementINC SI ; store addressCMP [SI-2][B],255 ; is this byte = 127?JNE GETDATA ; no, so get next sampleCMP [SI-1][B],63 ; yes, is this byte now = 63?JNE GETDATA ; no, so get next sampleMOV [SI][W],0 ; yes, clear last stored wordMOV CX,SI ; get count valueROR CX,1 ; multiply by 2MOV SI,0 ; and store itMOV [SI],CX ; in MA%(0)POP DS ; recall original data segmentRETF ; exit back to Basic

WAITDATASET: ; get data byteMOV AH,2 ; set interrupt factorsMOV AL,0 ;MOV DX,BX ;INT 14H ; call interrupt INT 14HCMP AX,255 ; is returned value =< 255?JA WAITDATASET ; no, repeat INT callMOV CL,255 ; yes, invert received valueSUB CL,AL ; (subtract from 255)RET ; return to calling routine

Page 49: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 984

gramming example (page 43) inwhich a SLEEP command andinterrupt are used to determinewhen the EEPROM Write func-tion has been completed, ratherthan polling EECON1 bit 4.However, when the author triedthe SLEEP method it failed towork. It is probable that anotherundocumented action has to betaken in addition to thoseshown, but this has not beeninvestigated.

The EEPROM Read routinein Listing 8 is entered at labelPRMGET with W holding theEEPROM byte address to beread. It is exited with W holdingthe data read from the EEP-ROM.

ASSEMBLERSOFTWARE

Readers who are interestedin learning how to program inmachine code suited to the8086 and above processors arerecommended to obtain the ex-cellent shareware A86/D86 As-sembler/Disassembler from thePublic Domain Shareware Li-brary (PDSL) whose details aregiven later.

The author has been usingit for many years and for manyPC-controlled EPE projects, in-cluding the Virtual Scope andPIC Toolkit Mk1. It is nearly aseasy to learn as PIC program-ming, but has far more com-mands available. A useful asso-ciated book is Intel’s 8086/8088User’s Manual.

OBTAINING BASICUntil fairly recently, by far

the vast majority of PCs willhave been supplied with eitherQBasic or QuickBASIC in-stalled. However, EPE and EPEOnline do sometimes get ques-

6SHFLDO)HDWXUH

Word Length 000 = 110 baud001 = 150010 = 30011 = 600100 = 1200 (default)101 = 2400110 = 4800111 = 9600

Allowable ValuesDescription7 6 5 4 3 2 1 0

Parity 00 = No parity01 = Odd parity10 = No parity11 = Even parity

Stop bits 0 = 1 stop bit, 1 = 2 stop bits

Word length 10 = 7 bits11 = 8 bits

Table 1. INT 14H Com port parameter byte.

Listing 8SETPRM: BSF STATUS,RP1 ; set for PAGE2 BCF STATUS,RP0 ; MOVWF EEARD ; copy W into EEADR toset ; EEPROM address BCF STATUS,RP1 ; set for PAGE0 MOVF STORE1,W ; get data value fromSTORE1 ; and hold in W BSF STATUS,RP1 ; set for PAGE2 MOVWF EEDATA ; copy W into EEPROM data ; byte register BSF STATUS,RP0 ; set for PAGE3 BCF EECON1,EEPGD ; point to Data memory BSF EECON1,WREN ; enable write flag ;MANUAL: MOVLW $55 ; these lines cause theaction MOVWF EECON2 ; required by the EEPROMto MOVLW $AA ; store the data in EE-DATA MOVWF EECON2 ; at the address held byEEADR. BSF EECON1,WR ; Set ‘perform write’flag BCF STATUS,RP1 ; set for PAGE0 BCF STATUS,RP0 ; ;CHKWRT: BTFSS PIR,EEIF ; wait till bit 4 of PIR2set GOTO CHKWRT ; BCF PIR2,EEIF ; clear bit 4 of PIR2 RETURN ; end of routine

Page 50: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 985

tions from readers who do nothave either and ask where theycan obtain one or the other.

So far as is known, neitherof the programs is actually sup-plied with PCs any longer – Mi-crosoft wishing, perhaps, thatusers should acquire the moreadvanced VisualBASIC. Theonce-popular GW-Basic haslong since been outdated and isnot compatible with regard tousing it with the QB machinecode routines illustrated here.

Readers who would like toget one or other of the QB ver-sions are recommended to ob-tain it through the Internet.There are quite a lot of sitesonce you start looking. A gen-

eral “search” call with the key-word QBASIC should begin tounravel the web of leads.

SOURCESThe full data sheets for the

Microchip devices used in theData Logger are available fromMicrochip: PIC16F87x family,code DS30292A, serial EEP-ROM memories: DS21203D(24AA256), DS21191C(24AA128), DS21189B(24AA64), DS21162C(24AA32). There are three waysto obtain them from Microchip:as downloads from their website, from their fully inclusiveCD-ROM (all products data andapplications info), or as individ-ual booklets.

Microchip Technology Ltd.,Microchip House, 505 EskdaleRoad, Winnersh Triangle, Wok-ing, Berks RG41 5TU, UK.

Tel: +44 (0) 118-921-5800Fax: +44 (0) 118-921-5835E-mail:[email protected]: www.microchip.com

Public Domain SharewareLibrary: PDSL, Dept EPE, Win-scombe House, Beacon Road,Crowborough, East Sussex TN161UL, UK.

Tel: 01892 663298Fax: 01892 667473

Intel data books are availablefrom Electromail (See our ShopTalk page).

The Programmer's PC-Sourcebook is a Microsoft Presspublication, ISBN 1-55615-321-X.

6SHFLDO)HDWXUH

Listing 9PRMGET: BSF STATUS,RP1 ; set for PAGE2 BCF STATUS,RP0 ; MOVWF EEARD ; copy W int0 EEADR toset ; EEPROM address BSF STATUS,RP0 ; set for PAGE3 BCF EECON1,EEPGD ; point to data memory BSF EECON1,RD ; enable read flag BCF STATUS,RP0 ; set for PAGE2 MOVF EEDATA,W ; read EEPROM data now in ; EEDATA into W BCF STATUS,RP1 ; set for PAGE0 RETURN ; end of routine

PIC16F87x PIC16x84 Equivalent

Register Address PagePIR2EEDATAEEADREECON1EECON2

$0D$10C$10D$18C$18D

02233

Register Address PageNoneEEDATAEEADREECON1EECON2

---$08$09$88$89

--0011

Register Bit Name/NoPIR2EECON1EECON1EECON1EECON1

EEIFRDW RW R E NEEPGD

40127

Register Bit Name/NoEECON1EECON1EECON1EECON1None

EEIFRDW RW R E N---

4012--

Table 2. Comparison of EEPROM data memory registers.

Page 51: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 986

ROBERT PENFOLDA SERIAL APPROACH TO PC ADD-ONS

There seems to be a steadystream of letters from readersinquiring about using the PCserial ports with user add-ons.This is understandable, sincemost PCs have at least oneserial port left unused.

With the increasing use ofmouse port mice and internalmodems, it is not uncommon forboth serial ports to be leftunused. The single parallel port,on the other hand, is usuallyoccupied by a printer, and aswitching unit or parallel portcard is therefore needed to useparallel interfacing.

As pointed out in previousInterface articles, providedspeed is not important it ispossible to interface practicallyany add-on project to a PCserial port, but serial interfacingis never as easy as the parallelvariety. A circuit based on aUART (Universal AsynchronousReceiver Transmitter chip) isneeded to provide parallel toserial and/or serial to parallelconversion. These days there isthe alternative of basing theproject on a microcontrollersuch as a PIC, which helps tokeep down the cost andcomplexity.

Single FileSerial interfacing circuits

have been covered in previousInterface articles, and thisaspect of things will not beconsidered here. Unfortunately,getting the hardwaresuccessfully connected to thecomputer is only half the battle.Most programming languages

have some form of support forthe serial ports, but it isnormally in a form that is oflimited use with user add-ons.

With your own add-ons it isbyte by byte communicationsthat is usually needed, but theserial port support invariablyseems to handle things on aone file at a time basis. It isreally intended for swappinglarge amounts of informationbetween the PC and anotherPC, a printer, a modem, etc.

One way around this is tomake add-ons emulatecomputer terminals, so that theycommunicate with the PC usingthe correct protocols. Whererelatively small amounts of dataare involved this is a slightlyclumsy way of doing thingsthough, and is difficult toimplement at all unless theperipheral device is based on amicrocontroller.

Direct ApproachIt is generally more practical

to ignore any built-in supportand control the port directly. Atits most basic level this justinvolves writing transmissiondata to theappropriateaddress, with thebaud rate and wordformat being set viathe operatingsystem. At the otherextreme the baudrate and wordformat are set bywriting to thecontrol registers inthe serial chip, and

the status registers are used toregulate the flow of data intoand out of the chip.

The serial chip used in PCsis the 8250, or in recent PCs itwill actually be a chip from the16550 family. To be moreprecise, the serial interfaces willactually be handled by one ofthe support chips. This willinclude circuitry that isfunctionally the same as adevice from the 16550 family.So do not bother looking on themotherboard to see which serialchip is used, because it will notbe there.

The manual for themotherboard should indicatewhich chip is being mimicked bythe support chips, but it doesnot really matter which “virtual”chip is used. The main controlregisters are exactly the samefor 8250 and all versions of the16550. It is only some of themore obscure functions that aredifferent.

Serial ports one and two areat base addresses &H3F8 and&H2F8 respectively, and theseare the addresses used whenreading and writing data. The

Address R/W Register DLAB

BaseBaseBaseBase + 1Base + 1Base + 2Base + 3Base + 4Base + 5Base + 6Base + 7

ReadWri teR / WR / WWri teReadR / WR / WReadRead---

00110

Received dataData for transmissionClock divider latch (LSB)Clock divider latch (MSB)Interrupt enableInterrupt identif icationLine controlModem controlLine statusModem statusReserved

Page 52: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 987

seven addresses above eachbase address are used forreading status information andwriting to the control registers.

The following is a full list ofthe registers:

Baud RateMatters are complicated

slightly by the base addresshaving three functions and theaddress above this having twodifferent functions. This is madepossible by having a control bitthat is used to switch theseaddresses between two modes.

This bit is called the DivisorLatch Access Bit (DLAB), and itis at bit seven of the line controlregister. With this bit set at 0,which seems to be its defaultstate, the base address is usedfor reading and writing data andthe one above is the interruptenable register.

With DLAB set at 1 thebase address and the oneabove are used for the clockdivider latch. This works in theusual serial interface fashion,with a clock signal fed to theUART by way of a “divide-by-N”circuit. The two bytes in thedivider latch together form a 16-bit value, and the clock signal isdivided by this amount.

The baud rate can therefore

be set by writing a suitablevalue to the divider latch, whichoffers a useful alternative tousing the operating system. Theclock frequency is at1¬¬8432MHz, but the UART hasan internal divide-by-16 action.

This gives a maximumbaud rate of 115,200 with avalue of 1 written to the dividerlatch. With some PCs it issupposedly possible to obtain arate of 23,400 baud with zerowritten to the divider latch, butin practice this does notnormally seem to work.

It is possible to set any ofthe standard baud rates byusing a suitable division rate,but it is not essential to usestandard rates for you own add-ons. On the other hand, crystalsintended for standard baud rategeneration are readily availableat low prices, so it is probablybest to use a standard rateunless there is good reason notto.

The division rate is obtainedby dividing 115,200 by therequired baud rate. Most useradd-ons will operate at baudrates of 115,200, 19,200, or9,600 baud, which respectivelyneed 1, 6, and 12 to be writtento the divisor latch LSB, andzero to be written to the MSB.User add-ons will normallyoperate at high baud rates, sothe required division rate iswritten to the LSB and the MSBis just set at zero.

InterruptsThe interrupt enable register

is used to select the sourcesthat will generate interrupts, andthe easy way of handling theserial port is to simply disableall interrupts. It is not essential

to use interrupts in order toutilize the serial port, andswitching them off shouldensure that conflicts betweenthe operating system and yourown routines are avoided.

If you should need to useinterrupts, the following tableshows the function of each bit inthe interrupt enable register. Toenable an interrupt source setthe appropriate bit of theinterrupt enable register high:

To determine whether or not

,QWHU)$&(

Bit Interrupt Source

01

234

5

67

Received data availableTransmitter holding register emptyReceiver l ine statusModem statusEnables sleep mode (16750 UART only)Enables low-power mode (16750 UART only)ReservedReserved

Bit2

SourceBit1

Priority

1

10

0

Receiver line statusReceiver dataTransmitter registerModem status

1

01

0

1

23

4

an interrupt is pending, and if soits source, the three leastsignificant bits of the interruptidentification register are read.If bit 0 is at 0 an interrupt ispending, and the binary code inthe other two bits indicates thesource.

This table shows the codefor each of the four possiblesources:

Word FormatThe word format can be

controlled via the operatingsystem, but direct controlensures that the serial portalways works with the correctformat for the add-on. The linecontrol register is used to setthe required format. The formatfor transmission and receptionhas to be the same incidentally,and any normal format can beset.

The functions of the linecontrol register are as follows.

Page 53: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 988

,QWHU)$&(

There is always one start bit:

RationalizationSuppose that we need to

set up the serial port foroperation at 9600 baud, andrequire the usual word format ofeight data bits, one stop bit, andno parity. A value of 12 must bewritten to the divisor latch, butDLAB must be set to 1 to giveaccess to these latches.

DLAB must then be setback to 0 and at the same timethe other bits are set-up to givethe required word format. Bits 0and 1 must be set high, all theothers have to be set low, givinga value of three to write to thisregister.

In GW BASIC (or VisualBASIC with the input and outputfunctions added) these fourinstructions will set up serialport two correctly:

OUT &H2FB,128OUT &H2F8,12OUT &H2F9,0OUT &H2FB,3

Bytes for transmission arethen written to the base

0¬¬000104s). Ten bits thereforehave a duration of 1¬¬04ms(1040Ps). Using a software-generated delay of at least thisduration will therefore ensurethat the serial chip is not

address, which is&H2F8 for serialport 2. If a value of255 is written to theMSB of the dividerlatch at address&H2F9, the baudrate will be set at avery low value. Infact, it will be so lowthat a LED used tomonitor the dataoutput line (seeFig.1) will flashslowly enough forthe binary outputpatterns to be

observed.

Hold-OffThere is a potential problem

when writing data to the serialport, and this is due to therelative slowness of a serialinterface. With the speed ofmodern computers andprogramming languages it iseasy to write data to the port atan excessive rate, causingbytes of data to be corrupted orlost.

There should be no problemif two bytes are written to theport in rapid succession,because the serial chip’sbuffering should store thesecond byte until it can betransmitted. Writing three ormore bytes in rapid successionwill almost certainly result in anerror.

There are two ways ofensuring that data is not sent tothe port at an excessive rate.The time taken for each byte tobe sent is easily calculated, andit is ten times the duration ofeach bit. At 9,600 baud each bitlasts 104Ps (1/9,600 =

Bit 0

Bit 2 at 0Bit 2 at 1Bit 3 at 0Bit 3 at 1Bit 4 at 0Bit 4 at 1Bit 5Bit 6 at 0Bit 6 at 1Bit 7

Bit 1 Data bits

0011

0101

5678

One stop bitTwo stop bits (1.5 with 5 data bits)No parity checkingParity checking enabledOdd parity (if parity enabled)Even parity (if parity enabled)Stuck parity bitNormal operat ionForces data output terminal to logic 0Divisor Latch Access Bit (DLAB)

Bit Funct ion

01

23

45

67

Received data readyOverrun (unread dataoverwritten)Parity errorFraming error (no stopbit detected)Break interrupt indicatorTransmitter bufferregister emptyTransmitter register emptyUnused (reads logic 0)

overloaded.

The alternative is to hold-offthe loading of data until theserial chip indicates that it isready for the next byte. This canbe achieved using interrupts,but the easier way is to monitorthe appropriate status flag in theLine Status Register.

A full list of the bit functionsin the Line Status Registerfollows:

When a byte of data iswritten to the chip it is firstplaced in the transmitter bufferregister, but it is immediately

Fig.1. Simple LED serial portmonitor circuit diagram.

Page 54: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 989

,QWHU)$&(

transferred to the transmitterregister if it is empty. Otherwisethe data is transferred as soonas the transmitter registerbecomes empty. The data isthen shifted out bit-by-bit, withany additional bits such as stopbits being added.

There are two transmitterstatus flags, and the one at bit 5

is set to 0 when the transmitterbuffer register is full. The flag atbit 6 is set at 0 when there isdata in either register.

A software loop can providethe required hold-off bymonitoring either of these flags,and preventing further databeing written to the port until theflag has returned to logic 1. This

equires a loop along the lines of“repeat until (&H2FD AND 32) =32”.

Receiving data is trickierthan sending it, and this issomething we will consider nexttime.

Page 55: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 990

One event in the integratedcircuit world seems to havegone unnoticed so far in thehobbyist arena. Quite a longtime ago we were tipped off bya reader about a new offeringfrom the chip manufacturerZetex, who introduced a newversion of the good old 555timer.

Now that the device hasbecome readily availablethrough some of the better mail-order channels, some of thefeatures of this intriguing “new”device can be described.

Low Voltage 555The Zetex ZSCT1555 low

voltage timer looks like anyother 555 timer but it has onevery important difference – it isguaranteed to operate downto +0 ¬¬¬9V supply voltage, eventhough it is a bipolar device!This opens up new applications

for this veteran part number,especially using low-voltagepower supplies (lithium coincell batteries for example) forwhich the device is eminentlysuitable. Its currentconsumption is reduced too,drawing a meager 75mA at1¬¬¬5V, claims Zetex. Themaximum supply rail is +9VDC.

This third generation 555timer has been co-producedby Zetex in association withHans Camenzind, thedesigner responsible for theoriginal Signetics 555 timerover 25 years ago. The newdevice is pin-compatible witholder versions, but there areslight changes to theformulae. In the monostabletimer of Fig.1, the period is1Fig.2, the frequency is 0

¬¬¬63RAC, and in the astable of¬¬¬62

(RA+2RB) C.

My own tests proved that itdid indeed operate as, say, apiezo disc sounder below 1¬¬5Vor so. But there is, of course, asevere restriction placed on theusefulness of the output signalat that sort of level, so don’texpect to produce an ear-splitting siren powered by a coincell! (It’s about as noisy as apeeved bluebottle.) By tuningthe oscillator frequency tomatch a piezo’s resonantfrequency, maximum outputlevel will be obtained.

A full data sheet in AdobePDF format and an applicationnote for the ZSCT1555 areavailable from the Zetex website at www.zetex.com . Thechip is now available forpurchase from FarnellComponents (Tel: +44 (0) 113-263-6311, Web:www.farnell.com ), their partnumber is 698-155, price 1.25UK Pounds + VAT for one-offs(minimum cash order 10 UKPounds). A surface mountversion is also produced.(ARW.)

Digital Panel MetersI have a mechanical analog

project meter with a 64mV full-scale deflection (FSD) andwould like to convert it to adigital display. I noticed thatmost digital modules indicate200mV. Can you tell me how touse one in my project?

D. LeeBirkenhead, UK

Most digital panel meters(DPMs) tend to be 200mV typesand are designed as a basicvoltmeter. The end user mustdecide how to “scale” the DPM,

A new variant of the 555 timer chip, also we return tothe topic of digital panel meters, followed by a maths-intensive analysis of a 22-step logarithmic volumecontrol.

by ALAN WINSTANLEY and IAN BELL

F33 )F D? )F 43

>3

?ED@ED

DB9775B

3

B1

DDDB97

8B

49C

$

&

"

'

93!JC3D!%%%

F

3F%

!

BCD F33

?ED#

(

F

d

d - C53?>4C

B1- ?8=C

3 - 61B14C

d - ! &# h B1H 3

FIg.1. Monostable low-voltage timer.

F33 )F D? )F 43

VVV--- &"B1"B23

!d

?ED@ED

3

BBB1

2

DDDB97

&8B

">33F

%

F

!

BCD

93!

49C

JC3D!%%%

$

'

(

?ED#

F33

F

d

Fig.2. Astable oscillator us-ing the ZSCT1555 will

operate below 1V.

Page 56: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 991

whether as an ammeter (usingthe meter to read the voltagedrop across a series resistor) oras a voltmeter for use at ahigher voltage range, which isusually how they are utilized.

Such a module often uses a7106 chip and will directly read199¬¬¬9mV (which is why they arecalled 3.5 digit types – theleading “1” being the half digit).This topic was briefly describedin Circuit Surgery, September1998.

An external attenuator mustbe added to a 200mV digitalpanel meter’s input to extend itsrange. You can assume that themodule will have an extremelyhigh input impedance(>100M:) so the attenuatorshould be about one tenth ofthis resistance to avoid loading.

To produce a 20V DCvoltmeter, a series input resistorof 9¬¬¬9 megohms would be used,followed by a 100 kilohm(100k:) resistor across themeter’s input terminals, seeFig.3. Thus, most of the inputvoltage is dropped across the9·9M: resistor and, at an inputof 20V, only 200mV appearsacross the DPM input terminals.A 200V voltmeter would use9·99M: and 10k: instead.

As regards fitting it into yourproject, due care is needed with7106-based meter modules asthey may require a completely

stereo system Iwould like to build a switchedvolume control for whichpurpose I have acquired a 22-position dual control rotaryswitch with gold-plated contacts.How could I calculate theresistor values? My sourceimpedance is 50 kilohms.

I’m still keenly interested inelectronics and always enjoyyour column. Many thanks from:

Johnny BruynsBenoni, South Africa

This is a good example of asimple question, which in theevent has a very involved reply:unfortunately it isn’t alwaysclear at the beginning just howtricky the solution really is, untilit’s actually been worked out!

One very simple solution(used on my trusty Marantzaudio amplifier – ARW) is touse an ordinary logarithmicpotentiometer with a “detent”mechanism on the shaft: theVolume control was calibratedin decibels and it clicks into oneof 20 or 30 positions whenrotated.

On The ThresholdBefore we tackle the query

directly though, we need toconsider why it is not astraightforward case of using 21or 22 equal value resistors. Thequick answer is that volumecontrols usually have alogarithmic response, with theconsequence that a given turnof the control at the “low”volume end results in a muchsmaller change in outputvoltage than the same turn atthe “high” volume end.

This means the resistors willhave to be scaledlogarithmically. We needlogarithmic volume controls,

independent DC supply voltage,which cannot necessarily betapped from an existing supply.Problems arise when the DPMsupply and the DPM signal input0V rails are commonedtogether.

A good supplier of verycompetitively-priced panelmeters is Vann Draper (Tel. +44(0) 116-277-1400, Web:www.vanndraper.co.uk ). Fullinstructions come with everymeter, and their liquid crystal(LCD) model can be modifiedwith a couple of track cuts readyfor “commoning” of the 0V rails.Vann Draper tells me that theycan also provide a LED type,subject to lead times.(ARW.)

Sound Levels andDecibels

Last month we discussed insome detail the rather involvedmathematics behind Root MeanSquare (RMS) values, and weexamined the meaning (oractually the total lack of anymeaning whatsoever!) of audioPMPO ratings (Peak MusicPower Output). This month,Circuit Surgery embarks onanother mathematicalextravaganza, courtesy of IanBell (whom as regular readerswill know hails from the Schoolof Engineering at the Universityof Hull).

The material that follows ismaths-intensive and is writtenwith the more advanced readerin mind. However, non-mathematicians shouldn’t bedisheartened as we are surethey will pick up plenty ofsnippets of valuable informationalong the way.

Unfortunately in thecomplex where I live, I have tokeep the noise down! For my

&LUFXLW6XUJHU\

" F

9>@ED

!)) )

]F

4@=

F9>@ED-

9>

B"

! [

B!B"

B"h " - " ]F

9>@ED

B!

)=)

9>

Fig.3. A voltage divider on aDPM input, produces a 20V

FSD meter.

Page 57: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 992

because human hearing, ormore specifically our perceptionof loudness, is logarithmic innature. This is one of thoseeveryday facts many of us knowand take for granted, and whichwe decided to investigate inmore detail.

The human ear is able tohear sounds of a very widerange of intensities, which ismeasured in Watts per squaremeter (W/m2). The quietestsound which can be perceivedis called the threshold ofhearing and is about 1 x 10- 12

W/m2. The threshold of pain isabout 10,000,000,000,000 timesmore than this at about 10W/m2 (these threshold figuresare only approximate and varywith individuals and frequency).For those readers interested inloud audio – a rock concert canreach 0¬¬¬1 W/m2 or more if youare positioned close to thespeakers!

An exponential increase insound intensity, from thequietest audible to the loudesttolerable sound, is perceivedbasically as a linear increase inloudness. Whilst sound intensityin Watts per square meter isrigidly defined, loudness is amatter of human perception andwill vary between individualsand with frequency, however,the general exponential natureof the relationship just describedremains valid.

Exponential is the inverseof logarithmic – the intensityvaries exponentially but ourears respond logarithmically,which is why we perceive alinear increase in loudness. Putanother way: each ten-foldincrease of sound intensitygives an equal step increase inloudness. We could also sayeach doubling of sound intensitygives an equal step increase in

loudness – these would besmaller steps than for a ten-foldincrease of course.

Going DecibelsExponentially varying

quantities can be difficult to dealwith (try plotting the full range ofsound intensities mentionedearlier on normal graph paper!)so a special scaling system isoften used. First, we take areference level (say thethreshold of hearing) and thenthe sound intensity level we areinterested in, and then we findthe ratio between them – i.e. bywhat factor our intensity islarger than the reference.

Now, taking a logarithm ofthe ratio we get a value relatedto the perceived loudness. Infact this approach is the basis ofthe commonly used decibelnotation.

The definition of a decibel(dB) is based on the logarithmof the power ratio of two signalsP1 and P2, such that the powerratio in decibels is given by 10 xlog10(P1/P2) dB. If we areexpressing power gain (e.g. ofan amplifier) then P1 would bethe input power and P2 theoutput power.

For measuring a powerquantity relative to a reference,P1 would be the reference leveland P2 the value we aremeasuring. Note that becausepower ratios are used in thedecibel definition, it does notmatter if P1 and P2 areexpressed as peak or RMSvalues as long as both areexpressed in the same way.

As an example, if yourpersonal stereo is delivering 2 x10-2 W/m2 of sound power toyour eardrums, this would be103dB relative to a threshold ofhearing reference at 1 x 10- 12

W/m2. The calculation is: 10 x

log10(2 x 10- 2/1 x 10- 12) = 103.Note if the measured value isequal to the reference, or if thegain of the system is 1, then weget 0dB.

Reduced PowerIf a circuit reduces power,

i.e. it is an attenuator, then weactually get negative decibelvalues. For example, if thepower output is 50 times smallerthan the input then the “gain” is- 17dB (10 x log10 x 1/50). If thepower is reduced by one halfthen the output is at –3dB .

This is a figure that manyreaders may know as the cut-offfrequency of a filter (or thebandwidth of an amplifier),which is usually quoted as thepoint when the gain falls to 3dBbelow the value in thepassband. At this frequency, theoutput power from the filter ishalf the value it is in thepassband (for equal inputpower). It is worth noting at thispoint that a volume control is anattenuator and that a usefulresponse to the reader’squestion would be to design acontrol with 22 attenuationratios in equal decibel steps.But before we go on with this weneed a few more commentsabout decibels.

So far we have onlydiscussed power ratios – thiswas obviously appropriate forsound intensities, but in circuitswe often measure signals asvoltages and currents. Power isrelated to the square of voltageor current. If we squaresomething inside a logarithm, itis equivalent to multiplying thelog by two (without the square).That is, log(V2) = 2log(V). So toexpress a voltage gain (V1/V2) indecibels we use 20 xlog10(V2/V1). Note that we aremultiplying by 20, not by 10 as

&LUFXLW6XUJHU\

Page 58: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 993

&LUFXLW6XUJHU\

we did with the power gain.

Strictly speaking, thisformula is only valid if the twovoltages are across the sameresistance value, but in manycases we are only interested inthe voltage gain (not the powergain) and the 20 x log10(V2/V1)formula is widely used for thispurpose (V2 being the output, V1

is the input). Similarly currentgains can be expressed indecibels using 20 x log10(I2/I1).

Divided VolumeTo design the volume

control, we will use thesimplified situation shown inFig.4. The volume control is apotential divider placed betweentwo amplifiers, it thereforeattenuates the output of the firstamplifier, A1, before passing itto A2.

We will assume that thetotal value of the resistor chainin the potential divider is Rt andthat the second amplifier drivesa load of value Rt also, thismeans that voltage gain in dBwill equal the power gain. Wewill also assume that theamplifiers have low outputimpedance and are not loadedheavily by Rt, and that thesecond amplifier has a highinput impedance and does notload the potential divider. Let’salso assume that both

amplifiers have unity gain (1).

In a real circuit theseassumptions may not be valid,but the effect will generally be toshift the actual power output fromA2 by a constant amount, ormultiply it by a constant factor.Since it is the relative loudnessproduced by each step of thevolume control which interests usthis will not matter. It is stillimportant, however, that theresistor chain does not heavilyload, and is not loaded by, theamplifiers.

Referring to Fig.4, the switchS1 has 22 positions so there are21 resistors. The first position (1)bypasses the divider andconnects the amplifiers directlytogether. This is full volume (0dBattenuation). The 22nd positionconnects the input of the secondamplifier to ground so no signalwill be output (infiniteattenuation): we could label thisposition “Mute”. This leaves 20remaining positions for differentvolume levels.

We can decide over whatrange in dB we would like tocontrol the volume. 90dB mightbe reasonable – the range from awhisper to a loud personal stereois of this order. If we chose 90dB,each of the 20 switch positionsincreases the attenuation by4¬¬¬5dB.

CalculatedFun

Now for thefun bit – how dowe calculate theresistor values?Recall that theformula for astandard two-resistor potentialdivider is Vout =Vin x RB/(RA +RB), as shown inFig.5. We can

write RA + RB as Rt, the totalvalue of the resistors in thepotential divider. The “gain” ofthe potential divider is Vout/Vin,which is simply RB/Rt.Expressed in decibels, this is 20x log10(RB/Rt).

Our potential divider is alittle more complex as it hasmany resistors, however it stillhas a total resistance that wewill call Rt. For now we will notlimit the number of resistors inthe volume control divider, infact we can assume there is aninfinite number getting eversmaller as we move down thechain from the amp output toground. We can label the nthresistor in the chain from theamp output as Rn.

If we consider taking anoutput from the volume controldivider below the nth resistorand compare this with the basicpotential divider, the equivalentto RB will be the sum of theresistor values from Rn+1 toinfinity (the sigma symbol (theone that looks a bit like asquashed letter “E”) meaning“sum of”). This is a gain of:

If we move up the chain tojust below the previous (i.e. (n-1)th) resistor, the gain will be:

The difference betweenthese two adjacent steps in thevolume control must be equal towhatever increment in gain werequire for each switch position.We chose 4¬¬¬5dB earlier, but we

?ED

9>

"!

B"!

""

B"

B"

B!

"

!

#

1"

1!

Bd

Fig.4. A 22-positionvolume control.

20log10 R r

r=n+1

inf ini ty

R t

20log10 R r

r=n

inf ini ty

R t

Page 59: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 994

&LUFXLW6XUJHU\

will keep things general here byusing A to represent theconstant step in dB attenuationfor each switch position.Thus, Aequals:

by dividing by 20, taking 10to the power of each side, andtaking the reciprocal, we get thefollowing:

In which it is convenient towrite 10(- A/20) as a constant k asshown. Rearranging, we get:

From which it can beinferred the resistor values for ageometric sequence withcoefficient k and initial value R1.That is, the resistor values areR1, kR1, k2R1, k3R1 ... and0<k<1 so the series converges,that is the sum of all resistancevalues is finite. This should notbe too surprising given thelogarithmic nature of theresponse we are after.

From the properties of ageometric series we know that thesum of resistances to the nthresistor, Sn is:

Sn = R1 ( (1 – kn) / (1 - k) )

Note that Sn is the equivalentof RA in Fig.4, if we take theoutput from just below Rn. Bytaking the limit in the aboveequation, in which n infinity,we get the value of Rt (the totalresistance of all the resistors):

Rt = R1 / (1 – k)

This is useful, because itallows us to calculate the value ofthe first resistor in the volumecontrol (R1 in Fig.4) once wehave decided on the attenuationstep and the total resistancevalue we want to use. From therewe can use the fact that eachresistor in the chain can be foundby multiplying the previous valueby k.

This is easy to do if you havea “constant” facility on yourpocket calculator – just keeppressing “equals” after multiplyingR1 by the constant k to get allresistor values. By using theequation for Sn for the total to twoadjacent resistors (say Rn-1 andRn) and taking the differencebetween them, we can also getan expression for the value of thenth individual resistor as follows:

Rn = R1 (kn-1 – kn)

Remember 0<k<1 so kn- 1 islarger than kn, so this will give apositive value for Rn as required.

of all the resistors left in theinfinite series after we stopusing it.

We shall call this resistor Re

(“e” for end). We will also use Nto signify the number ofresistors in the first part of thedivider (N = 20 in our example).The value of Re is obtainedsimply by subtracting the sum ofthe N resistors in the main partof the chain from the total, thatis Re = Rt – SN, where SN isobtained by putting n = N in theequation for Sn given above.

By substituting the formula

- 20log10 Rr

r=n+1

infinity

R t

20log10 R r

r=n

infinity

R t

so A = 20log10

R r

r=n

infinity

R r

r=n+1

infinity

= 10(-A/20) = k

R r

r=n+1

infinity

R r

r=n

infinity

=R r

r=n+1

infinity

R r

r=n

infinity

k

Res.Value

(ohms)

123456789

1011121314151617181920

21 (Re)

202169322593394326437054462505477666486696492076495280497188498325499002499406499646499789499874499925499955499973499984500000

Total(ohms)

Gain(dB)

202k120k

71·7k42·7k25·5k15·1k9·03k5·38k3·20k1·91k1·14k677k403k240k143k

85·3k50·8k30·2k18·0k10·7k15·8k

-4·5-9.0

-13·5-18.0-22·5-27.0-31·5-36.0-40·5-45.0-49·5-54.0-58·5-63.0-67·5-72.0-76·5-81.0-85·5-90.0off

Table 1. Divider resistorchain.

The only problem remaining isthat we have assumed an infiniteseries of resistors, which is notvery practical! For a practicalcircuit we need to terminate thesequence after a certain numberof resistors (20 in our example).

Special CaseThe last resistor must be

treated as a special case. Itsvalue must be equal to the sum

B1

B2

9>

?ED

Fig.5. Basic potential divider.

Page 60: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 995

&LUFXLW6XUJHU\

for Sn and Rt given above intoRt – SN and simplifying we get:

Re = Rt x kN

As an example if we use A= 4¬¬5dB (4¬¬5dB steps) we get k =10(- 4.5/20) = 0¬¬5957. If we choosea total resistance of 500k:

¬

(kilohms) and require 21resistors (20 in the sequence,plus Re) we get N = 20 and Rt =500,000, from which R1 =500,000 x (1 – 0¬5957) =202k(0

:, and Re = 500,000 x¬¬¬595720) = 15¬¬¬8:. The other

resistors can be found bymultiplying successively by k, i.e.R2 = 0¬¬5957 x R1 = 120k:; R3 =0¬¬5957 x R2 = 71¬¬7k:; and so on.It useful to add up all the resistorvalues (including Re) to checkthat they equal Rt.

Finally, Table 1 gives all thevalues for our example, plus thegain at each point at the tapbelow the resistor concerned, andthe accumulated resistance total.We do not know what the mostappropriate values are for thereader’s application, so thevalues we have used are as an

example only. However, itshould be straightforward toapply the formula given towhatever attenuation step size,total resistance, and number ofresistors are required. Phew!Well you did ask...! (IMB.)

WATTS WRONG?Oops! An error crept into

our article on power output rat-ings (RMS – Standby by for theMaths – Watts On, September1999 issue. (Actually it was justa test to see how many of younoticed.) The error was spottedfirst by Mark Daniels of ClayCross, Chesterfield, UK, whonoted:

“The RMS voltage of asquare wave with 50% duty cy-cle is not Vpk/2. We must con-sider the average power in theload resistor over time to deter-mine the effective (or RMS) volt-age.

If we take a square wavewith on time, ton and off time, toff

and peak voltage Vpk, we seethat the power into the load re-sistance, R, is V2

pk/R. This is thepeak power, Ppk. The averagepower over the entire cycle isGPpk, where G = ton/(ton+toff), soPrms = GPpk.

Substituting for Prms and Ppk

(using P=V2/R) we get V2rms/R =

G V2pk/R. Hence V2

rms = GV2pk

and thus:

The mistake was due to anattempt to simplify things thatwent wrong. Trying to avoid themaths was our downfall, the les-son to be learnt here is alwaysuse the maths to analyse anelectronics problem if it is feasi-ble to do so, never try to side-step it!

In the September article thestatement that the power for our50% duty cycle 0 to 12V pulsewave is half that due to 12V DCis correct, but the RMS voltageis 8¬¬¬49V (i.e. «(0.5*122) usingthe above formula), not 6V, sothe power is 9W not 4¬¬¬5W (thepower of 12V DC into 8 ohms is18W). Still 9W is less than the11W desired, and I think thegeneral argument still stands.

We contacted Mark to let himknow that we thought he wasright about our error and heagreed with our comment thatthe general argument in ouroriginal article still stood.

We will try harder in future,but let us know if you spot anymore errors, we might just betesting to see if you are payingattention....

And while were on the sub-ject of power, a footnote fromAlan on PMPO ratings - he wasrecently helping a friend choosea new stereo system, and theTechnics unit they settled forhad a rating of 70W per channelRMS. However the specificationsheet quoted a PMPO value of(wait for it)...... 3,000 watts!

2pkrms VV δ=

Page 61: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 996

Before leaping into thismonth’s Net Work, we’ll startwith a useful tip. It’s well worthremembering that when you usea Search Engine (for examplewww.infoseek.com ,www.yahoo.com , orwww.excite.com ) to track downa topic, then having arrived at atarget web page, the quickestway of pin-pointing that precisekeyword may be to use the“Find” facility of your browser. InMicrosoft Internet Explorer, thisis located under the Edit menu(“Find on this Page”) and it’s anoft-underused but extremelyuseful option when wadingthrough pages of text.

EXPLORE NEW OPTIONSThis month, I’ll suggest a

few ways in which your Mi-crosoft Internet Explorer (MSIE)browser can be improved. Ver-sion 5 is the one to go for, butdon’t bother trying to downloadit from the net as it will be foundon most current cover disk CDROMs!

There was a time when allweb browsing had to be per-formed online, so if you wantedto view or print a copy for laterreference or consumption youwould have to do it online whilethe phone bill was ticking away.Alternatively, you could use oneof the cache-reading programssuch as Nearsite or Unmozify toread the pages later on. Theability to “work off-line” was awelcome introduction in MSIEV4, but it’s a facility which istucked away on a menu ratherthan being readily accessible onthe button bar. This omission is

quite tiresome and not a littleannoying, as in my experienceit’s one of the browser’s mostused features.

The same is true of InternetExplorer Version 5. Just as Iwas cussing at this missed op-portunity to improve this latestbrowser’s functionality, I un-earthed several browser en-hancements on the Microsoftsite (www.microsoft.com/win -dows/ie/webaccess ) and I rec-ommend that readers hop overand have a look.

The most useful one is(fanfare!) a toolbar button forenabling off-line working. Thisloads an “off-line” button shortlyafter the browser has booted.Unfortunately, the only way youcan actually tell that you’re inoff-line mode is to check for asmall icon in the browser’s com-mand bar underneath the mainwindow.

More tools for MSIE 5.0 arealso on offer. I especially likethe optional extras for the rightmouse-click menu, including (atlast) the ability to highlight inyellow any text of interest. I findthis a great idea when checkingthrough long pages, or perhapslengthy lists of software optionsfor downloading: the highlighterenables me to scroll back up tothe areas of interest and to fo-cus on getting my work done.

IN CLOSE-UPWeb developers will enjoy

the new View Partial Sourceand Images List functions,which are also only a rightmouse-click away. Now you canselect portions of a web page

which look interesting, and thenView Partial Source will revealthe HTML just for that selection,rather than for the entire page.

The new Images List optionwill also be a tremendous boonfor many developers; it displaysthe file size and dimensions inpixels of every image on apage, as well as the imagesthemselves. More importantly, ittotals up the image content perpage and calculates the typicaldownload time at a variety ofspeeds.

Other MSIE 5.0 “tweak” op-tions are provided on the Mi-crosoft site, including the abilityto decorate the toolbar with abitmap. The toolbar “wallpapers”supplied are unimaginably dull,but you can always create yourown bitmap using a graphicsprogram. You will also discoverthat several third party develop-ers now offer plug-in toolbars,including Alta Vista’s search en-gine toolbar, which integratesinto MSIE 5.0. It’s nice to seeone or two worthwhile additions,not before time, which simplifythe work of experienced usersand developers for a change.

1984 AND ALL THATIt isn’t often that your scribe

has the time or inclination to in-dulge in any navel-gazing, but itis sometimes stimulating to stepback a little and maybe hazarda guess as to which way the“wired” world is going. TheFebruary 1984 issue of Every-day Electronics contained asmall but very prophetic newsitem, the significance of whichis only now starting to becomeapparent. In that issue, which

By Alan Winstanley

SURFING THE INTERNET

Page 62: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 997

featured a Sinclair ZX81 homecomputer on its cover, we re-ported on the advent of theworld’s first digital television inJapan, which we hailed as“marking a new generation thatwill serve as the focal point forthe home information system ofthe future”.

Nowadays the whole worldand his dog owns a mobilephone or pager and routinelyuses the Internet for chatting,mailing, and shopping. Ratherthan kitting everyone out with acomplicated home computer, tomy mind the increasinglywidespread use of Web TVprobably represents the finalpiece to fall into place in thehome consumer information jig-saw. Web TV uses the TVscreen as a monitor, and it canuse a wireless QWERTY key-board to communicate from thecomfort of the couch. Some E-mails I receive already bear the“webtv.com” or “webtv.net”monikers. Both Sky and On-Digital promise an electronicmail service through digital set-top boxes soon.

LOOKING AHEADLooking ahead, as pressure

on leisure time continues tosoar, I think that consumers willroutinely purchase more of theirgroceries via the Internet for

doorstep delivery, and usingtheir digital television, which willbecome the family’s main homecomputer “monitor”. Regularstanding orders could be placedor modified, relieving the cus-tomer of some of the chore anddrudgery of shopping. This isalready starting to happen viahome computer Internet links.

With the arrival of Web TV,viewers will be able to browsethrough on-line holidaybrochures complete with down-loadable movie presentations ofholiday destinations, reserve aflight or book a weekend break,send E-mails, and even down-load kids’ homework resources,all simply menu driven throughtheir digital TV. Need aplumber? Instead of thumbingthrough Yellow Pages, there willbe an interactive web directory(and you can bet that AAAPlumbing will be there at the topof the search engine results).

You will be able to leavevideo messages for others in a“video box” using integratedcameras, messages beingdownloaded on command. How-ever, the more sophisticatedpersonal computer user willcontinue to use separate PCdesktop or laptop systems alliedto a suite of imaging and print-ing peripherals, connected tothe Internet via wireless or ca-ble modems or eventually

ADSL. But those unable to getto grips with a PC systemshould find Web TV a breeze.

Twenty years after proph-esying the impact of the homeinformation revolution, the useof Web TV as an interactivehome information resource willgradually become as routine asusing teletext. American usersare already being exhorted toprepare for Web TV by buying a28-inch or 30-inch television!

This is to compensate forthe computer-screen orientatedweb material, which is designedfor PC monitors and is preva-lent today: they invariably fea-ture small graphics, tiny printand contain far too many navi-gation options. A Web TV win-dow cannot scroll sideways, ei-ther.

Before long, web sites willhave to be augmented or com-pletely redesigned to allow forthis new method of viewingthem, eight feet away on a lowresolution TV tube. One thing isfor sure, there are interestingtimes and choices ahead for theconsumer, and the way in whichnew generations will organizetheir lives is about to be trans-formed yet again.

You can contact the [email protected]

1HW:RUN

Page 63: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 998

Japanese electronics com-pany Sharp thinks analog audioamplifiers have had their day,because its new digital amplifierreproduces sound more faith-fully, costs less, is smaller andconsumes less power.

Conventional amplifiers areanalog, taking in a weak wave-form and putting out a morepowerful replica to drive loud-speakers. All add spuriousnoise, so designers have triedamplifiers which boost digitalwords of shape that describethe waveform. The circuitry isexpensive and runs hot. Sharp’sresearchers in Hiroshima haveworked with Professor YoshioYamazaki of Waseda Universityon 1-Bit Delta-Sigma Modula-tion. This uses a very rapidstream of single bits instead ofwords.

Sharp chops or “samples”the analog waveform at 64times the speed at which a CDsystem samples sound (64 x44¬¬¬1kHz). The level of the waveat each sample point is mea-sured, compared with previoussamples (in a network of sevenfeedback loops), and a singledigital bit switched between 1and 0 to represent whether thewave is moving up or down.The stream of 2¬¬¬8 million bits asecond is so rapid that thesteering description is very ac-curate. The bit stream switchesthe level of a power signal to re-create a waveform that repli-cates the original, but muchstronger.

Sharp has developed a chipset which reduces power con-sumption and heat generation toone half that of an analog am-plifier of similar audio perfor-mance. Bat-eared hi-fi buffsshould be happy, because thehigh sampling rate provides anaudio frequency range of 0-100kHz (which far exceeds hu-man hearing).

Super Hi-FiThe first product, a super hi-

fi amplifier, is expected beforethe end of the year. The tech-nology will then spin down intobudget home audio systems,portables, car stereos and PCs.

Sharp’s team leader Yasu-tomi Katano acknowledges twopractical problems. His amplifierperforms best when connecteddirect to one of the new superhi-fi DVD players promised forChristmas (by several manufac-turers including Sharp), becausethere is no need to convert ananalog waveform into digitalcode. But the record companiesworry that consumers will con-nect their disc players to arecorder instead of an amplifier,and make digital clones. Sharpproposes a deliberately non-standard 13-pin connector,which works intelligently, hand-shaking with a similar connectoron a disc player so that it onlysends high quality code to anamplifier.

Because the amplifier isswitching a powerful signal at

2¬¬8MHz, it is effectively a radiotransmitter with the speaker ca-bles working as an aerial in aband used for radio-location,maritime services etc.

Katano acknowledges that itis “a fundamental requirement”to trap all electromagnetic radi-ation with shielding and filtercoils. “We are confident wehave solved the problem”, hesays.

Twenty years ago, Sonylaunched a digital amplifier,which streamed digital words at500kHz, the radio frequency al-located for international radiodistress calls. The circuit leakedsignals and Sony quickly with-drew the product.

SOUNDLY DIGITALHave analog amps had their day?

Barry Fox discovers that Sharp think so!

A ROUNDUP OF THE LATEST EVERYDAY NEWSFROM THE WORLD OF ELECTRONICS

IN RECORDTIME

By Barry FoxSony is going back to ba-

sics with a new VCR, soon to belaunched in Europe. Smart Dialis for people who are baffled bythe timers on modern VCRs, orhave lost the remote controlneeded to set them.

The new VCR has a “rotarybutton” on the front. Press onceand turn to set the start time onan LCD. Press again to set thestop time. Press a third time toset the channel. Push to confirmand go out for the evening, surein the knowledge that the pro-gram will be recorded to watchlater.

Page 64: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 999

1(:6

We are always pleased to encouragepeople to take up electronics, especially theyoung, and it is good to report on others whodo so as well. For as long as we canremember, we have annually highlighted theYoung Electronic Designer Awards (YEDA),both as a forthcoming event and as aconcluded ceremony.

This year’s YEDA had 20 nationalfinalists and the winners received theirawards from His Royal Highness The Dukeof York. Ashley Jordan (17) of LudlowCollege, Shropshire, UK, with his ExcavatorBucket-Alignment System won the Duke’sown award for the most imaginative concept.The prize was 2000 UK Pounds, shared byAshley and his school.

Ian Thomas (16) of Trent College,Nottingham, UK, won the prize for the mostcommercially viable project with his GuitarAnti-tamper Device. The IEE Award for thebest new entrant to YEDA was won bySimon Green (16) of Helena RomanesSchool, Dunmow, Essex, UK – his designwas an Electronic Metronome for musicians,for which he and his school also received2000 UK Pounds.

It’s good to see that girls also featured asfinalists – electronics is a subject that can be explored and enjoyed by either gender. For example, LauraHaughian (16) of St Mary’s High School, Lurgan, Northern Ireland, was highly commended for her “EasyFind” sound-activated device for locating lost remote controls.

We were pleased to see that our friends at Radley College, Oxon, UK, participated as well. MaxHorsey’s student Chris Shelmerdine (15) invented “Catomatic”, a device for feeding a cat automatically fora five day period, for which he was “highly commended”.

The annual YEDA competition was sponsored this year by CPC (Combined Precision Components),DTI (Department of Trade and Industry), EMTA (Engineering and Marine Training Authority) and the IEE(Institution of Electrical Engineers). The competition is open to students between the ages of 12–25 insecondary schools, colleges and universities. It challenges young designers to invent and produce a novelelectronic device that meets an everyday need.

The overall objective is for contestants to have fun putting their ideas into practice and in doing so todiscover the exciting opportunities which a career in the electronics, communications and IT industriescan offer.

If your school or other educational establishment does not already participate in YEDA, persuade yourteacher/tutor to contact the organizers:

The YEDA Trust, 60 Lower Street, Pulborough, W. Sussex RH20 2BW, UK.

Tel: +44 (0) 1798-875559Fax: +44 (0) 1798-873550Web: www.yeda.org.uk

YEDA 1999 AWARDS

Page 65: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1000

1(:6

Shipping the printed copy ofEPE to customers outside of theUK is slow and/or expensive. Forexample, express airmail deliveryof a printed magazine can cost asmuch as $83 US Dollars for a 12-month subscription! This is one ofthe reasons why EPE teamedwith Maxfield & Montrose Interac-tive Inc (a polymedia design com-pany based in the United States)to launch the online version of themagazine – EPE Online – inNovember 1998.

Since its inception, EPE On-line has fulfilled its promise ofproviding the worldwide commu-nity with instant access to EPE’sstate-of-the-art technical informa-tion and high-quality construc-tional articles without delays orpaying exorbitant shippingcharges.

Online subscribers can pur-chase issues 24 hours a day,seven days a week, 365 days ayear from EPE Online’s highlysecure server in the USA, thendownload and read their onlinecopies of the magazine anytimethey wish. Furthermore, by cut-ting out printers, distributors, re-tail stores, and others who do notcontribute to the knowledge andinformation contained in our mag-azines, we are able to pass onthese savings to our internationalcustomers. In fact a 12-monthsubscription to EPE Online costsjust $9.99 US Dollars (about 6.25UK Pounds), which makes it

highly accessible to those read-ers in less affluent countrieswho simply cannot afford therates associated with print copyinternational magazines.

The pie-chart reveals thatEPE Online has met its man-date to supply a worldwide audi-ence. Subscribers cover theglobe from North and SouthAmerica, “Down Under”(Australia and New Zealand),South Africa, Western and East-ern Europe, Scandinavia, Asia,and the Pacific Rim.

Of course EPE Online con-tains many useful features in itsown right, such as active linksthat can take readers directly toany web sites of the companiesand suppliers featured in ourarticles, thereby augmenting theknowledge and information con-tained in our magazine.

EPE Online originally usedsophisticated locking technol-ogy, which was only availablefor use on the Windows 95, 98and NT platforms. More recentlywe’ve moved to a new scheme,which is much easier to use,and which has the added ad-vantage of making EPE Onlineavailable on Macs, UNIX, andindeed any computer for whichan un-ZIP utility is available.Furthermore, readers can nowdownload and read the maga-zine on multiple computers (forexample a desktop at home anda notebook whilst travelling).

EPE ONLINE UPDATE! EPE and EPE Online con-tinue to lead the magazine in-dustry by using state-of-the-arttechnologies to deliver theworld’s first (and easiest to use)web-delivered electronics andcomputing hobbyist magazine!

RIGHTCONNECTIONS

ESR Electronic Compo-nents will be well-known tomany of our UK readers for theirwide range of essential hard-ware components, such asplugs, sockets, switches, casesetc. They have also built up agood reputation for the qualityand low cost of their kits formany EPE constructional prod-ucts, which they supply and ad-vertise via their web site.

We are pleased to learnfrom ESR that they have intro-duced a new range of popularcable hardware. This, they say,is the beginning of many newadditions to the hardware sideof their business.

The new range of cablehardware includes all the popu-lar items required to completehobbyist or service engineerwork to a professional standard.The range includes such basicproducts as cable ties andbases, up to cable clips andglands. A large (and colorful)selection of heatshrink is addedas well, with sizes from 1¬¬¬6mmto 25¬¬¬4mm.

The new range is includedin ESR’s latest shortformdatasheet. To obtain a copy, orfor more information, contact:ESR Electronic Components,Dept. EPE, Station Road,Cullercoats, Tyne & Wear NE304PQ, UK.

Tel: +44 (0) 191-2514363Fax: +44 (0) 191-2522296

Page 66: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1001

1(:6

B.A.E.C.We are pleased to see that

the latest newsletter from theBritish Amateur ElectronicsClub shows that membership ofthe Club continues to grow, andthat all new members quote“their magazine” as EPE! Wedo try to encourage readers totake an interest in this worth-while Club and it’s obviouslypaying-off!

It’s difficult to summarizethe aims of B.A.E.C., but in anut-shell, it’s a forum whereelectronics enthusiasts canshare their enthusiasm andideas with each other. Its quar-terly newsletter is just one as-pect of this, get-togethers atvarious venues around the UKare another (Mr Chairman-Editor, why not include a briefparagraph on the Club’s aims ineach newsletter so that new-comers and newswriters have itspelt out for them?).

For more info on joiningB.A.E.C. contact the Secretary,Martyn Moses, 5 Park View,Cwmaman, Aberdare, Mid GlamCF44 6PP.

Tel: +44 (0) 1685-877808E-mail: [email protected]

RADIO SHOWThis year’s Leicester Ama-

teur Radio Show (the 28th) willonce again be held at Donning-ton Park, Castle Donnington,UK, between 24 and 25September, from 9.30am to5pm daily.

The show will feature 150stands of amateur radio, com-puter, electronics and relatedequipment. There will be aClubland area featuring bothlocal and national Clubs and

Societies, including the RSGB.There will also be (amongstmany other things) many com-ponent stalls and computerstands which will be of interestto electronics enthusiasts. En-quiries to Geoff Dover G4AFJ:

Tel: +44 (0) 1455-823344Fax: +44 (0) 1455-828273.Email: [email protected]

DUE CREDITWCN Supplies of

Southampton have sent us acopy of their 12-page catalogtogether with a letter sayingthat, as a goodwill gesture toreaders, they will redeem anycredit notes issued by Green-weld before they went into liqui-dation, provided the credit notesare only used to pay for up to50% of any order; i.e. if youhave a 5 UK Pound Greenweldcredit note, then you can use itas part payment for any orderover 10 UK Pounds.

Note that the company thattook over the Greenweld nameand customer list (see Newslast month) have not taken onresponsibility for the originalcompany's debts.

WCNSupplies are at 61Millbrook Road East,Southampton SO15 1HN, UK.

Tel: +44 (0) 1703-226522.

Page 67: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1002

AntexWeb: www.antex.co.uk

CPC Preston (UK)Tel: +44 (0) 1772-654455

EPE Online Store and LibraryWeb: www.epemag.com

Electromail (UK)Tel: +44 (0) 1536-204555

ESR (UK)Tel: +44 (0) 191-2514363Fax: +44 (0) 191-2522296Email: [email protected]: www.esr.co.uk

Farnell (UK)Tel: +44 (0) 113-263-6311Web: www.farnell.com

Gothic Crellon (UK)Tel: +44 (0) 1743-788878

Greenweld (UK)Fax: +44 (0) 1992-613020

Email: [email protected]:www.greenweld.co.uk

Maplin (UK)Web: www.maplin.co.uk

Magenta Electronics (UK)Tel: +44 (0) 1283-565435Web:www.magenta2000.co.uk

MicrochipWeb: www.microchip.com

Rapid Electronics (UK)Tel: +44 (0) 1206-751166

RF Solutions (UK)Tel: +44 (0) 1273-488880Web: www.rfsolution.co.uk

RS (Radio Spares) (UK)Web: www.rswww.com

Speak & Co. Ltd.Tel: +44 (0) 1873-811281

Interior Lamp DelayA number of components

called-up for the Interior LampDelay project could causeconstructors local sourcingproblems. Fortunately, mostseem to be RS components andcan be ordered through a localbona fide dealer or throughElectromail or RS, their mailorder outlet.

The SMP40N10 power FET(code 264-816); the 4MHzceramic resonator (656-186);small plastic case (508-914)and the low current, 3V to 16VDC buzzer (2245-001) all camefrom the above source. Apartfrom the power FET, most ofcomponent suppliers should be

with DAVID BARRINGTON

Some Component Suppliers for EPE OnlineConstructional Articles

able to supply similar/identicaldevices.

For those readers who wanta ready-programmed PIC16F84(the C84 is no longer produced),one is available from MagentaElectronics for the inclusiveprice of 5.90 UK Pounds(overseas readers add 1 UKPound for postage). For thosewho wish to program their ownPICs, the software can bedownloaded Free from the EPEOnline Library atwww.epemag.com

The printed circuit board isavailable from the EPE OnlineStore (code 7000244) atwww.epemag.com . Finally,you must read the Warning

notes and installation advicebefore commencing thisproject.

QWL LoudspeakerSystem

As far as the woodworkingrequirements for the QWLLoudspeaker System areconcerned, these will have to beobtained from your local timbermerchant or large DIYsuperstore. Also, as indicated inthe article, the square meter ofTerylene damping material maybe purchased from thedressmaking department of yourlocal store.

Turning now to theloudspeakers and crossoverunits. These were chosen by thedesigner after a visit to SouthCoast Speakers Ltd ofSouthampton, UK, and are ofNorwegian origin. Contactingthem, they offered the following(VAT inclusive) pricing for theSEAS speakers and their owncrossovers, in kit form or readyassembled:

Driver unit set (two P17REXpolypropylene bass units andtwo H457 (25TFF) dometweeters) 147.88 UK Pounds(UKP) plus 5.49 UKP post andpacking, total 153.37 UKP.Crossover kit (pair) 39.08 UKPplus 2.49 UKP p&p = 41.57UKP. Asssembled crossover45.08 UKP plus 2.49 UKP p&p= 47.57 UKP. Full, all inclusivekit 192.45 UKP; assembled198.45 UKP. They can alsosupply the ancillary items, suchas the black speaker fixingscrews, damping material etc.To spread the cost, single driveunits and crossovers can alsobe purchased.

Page 68: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1003

For further details andorders contact: South CoastSpeakers Ltd, Dept EPE/ETI, 58Wilton Road, Southampton,Hants, SO15 5SZ, UK. Tel: +44(0) 1703-703221 or Fax: +44 (0)1703-778221. Payments shouldbe made payable to SouthCoast Speakers Ltd.

Micro Power SupplyNot too many problems

should be experienced whengathering together the parts forthe Micro Power Supply project.

The LP2950 +5V voltageregulator was chosen, inpreference to the standard78L05, because it has improvedregulation, draws much lesssupply current, and will operatewith a very low differentialbetween input and outputvoltages; ideal for batterypowered circuits. If your usualsupplier is unable to supply thespecified regulator, it is

currently listed by Electromail(code 648-567 or 411-826), andby Maplin (code AV35Q).

Regarding the “switchedcapacitor” voltage converter,the one used in the prototype ismarked as an IS7660, but afternumerous catalog searches onlyMaplin had it listed (codeYY75S). It would appear thatthe most popular version is theone with prefix letters ICL(7660) and should be availablefrom most good componentsuppliers. It is certainly stockedby Electromail (code 651-490).

The small single-sidedprinted circuit board is availablefrom the EPE Online Store(code 7000243) atwww.epemag.com

Mains Cable DetectorApart from the case, all

components required to buildthe Mains Cable Detectorshould be readily available, off-

the-shelf items. Most of ourcomponents advertisers stockthe high impedance crystalearpiece.

Unfortunately, the two-piececase, with battery compartment,used in the model would appearto be one originally purchasedfrom Greenweld (code CS4330)and may no longer be available.You could try contacting thenew owners by Fax on +44 (0)1992-613020 or by E-mail:[email protected] . In themeantime, the original casemeasured roughly 120mm x60mm x 32mm and, no doubt,other component suppliersshould be able to offer asuitable alternative.

The multi-project printedcircuit board is available fromthe EPE Online Store (code7000932). Being a “multi-project” PCB, it will, of course,have numerous unused holesand pads, so don't forget todouble-check your wiring as youprogress with construction.

6KRS7DON

Page 69: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1004

WIN A DIGITALMULTIMETER

The DMT-1010 is a 3 1/2 digitpocket-sized LCD multi-meterwhich measures a.c. and d.c.voltage, d.c. current, and re-sistance. It can also testdiodes and bipolar transistors.

Every month we will give aDMT-1010 Digital Multimeterto the author of the bestReadout letter.

LETTER OF THEMONTH

PICK OF THE PICSDear EPE,

May I begin by thanking youfor the PIC Tutorial series. Afterusing it for only three months Ihave managed to connect a16C84 to a 6402 UART and haveeffected MIDI program changesand made a sustain/soft pedal. Iwas able to do this latter item by“lifting” the two switch routines ofTUT11 and adding bits of otherTutorials, adapting them to dowhat I want.

I suspect I am not on my ownwhen I say that working throughthe Tutorials “parrot-fashion” isboring. Many years ago I learnedBasic by pinching routines out ofone program and lifting bits (nopun intended) of another and Iam learning PIC assembly lan-guage the same way, referring

back to your Tutorials when Ineed to sort out exactly how aparticular chunk of code works,usually in order to make it worka different way. With Basic ittook me about three years be-fore I was any good, but wasable to adapt many gamesalong the way. I’m sure PICswill take just as long.

The advent of the newPIC16F87x series is exciting as,with more memory and morepins, these devices seem evenbetter for inexperienced would-be programmers such as my-self. With that in mind, I amwriting to ask if there is anychance of a PIC Tutorial Mk2.To provide a set of routines thatcan be mixed and matched toproduce the result the aspiringprogrammer wants but is notable to do on their own withoutconsiderable help, which youprovide in copious notes, aswith the original series.

To date all of my needs areto do with MIDI. I would like tohave routines that will: show mehow to write to the 16F877 US-ART and how to configure it toadd MIDI start/stop bits; how towrite a first-in-first-out bufferwith storage for 20 to 40 8-bitbytes and write to the USART oran 8-bit port for external serial-izing (preferably a “load it intothe buffer and forget it” arrange-ment which leaves the proces-sor free for number crunchingelsewhere); how to read the US-ART; how to write a routine toclock MIDI data out of an ordi-nary 16C84 pin (a la MIDI Sus-tain Pedal, Feb ’99), I can’t sortout how it works; a neat routine

calling data from STORE1,STORE2, STORE3 etc. wouldbe much better for hackers likeme – these routines should en-able me to make a MIDI mixer,with the PIC running at 20MHz Ishould be able to do a lot of ma-nipulation of input data bytesand exotic features such asMIDI mapping, layering and ve-locity changing should all be-come possible; how to read theADCs, allowing me to add pitchblend and variable modulation.

When searching the Inter-net, countless programs can befound for the 16C5x processor,usually in MPASM, whilst yourPIC Toolkit Mk2 will solve thislatter problem for me some helpwith conversion between PICswould be welcome. Similarly,PIC BASIC compilers are nowavailable as freebies and theone I’ve got (but cannot try untilI build Toolkit Mk2) looks useful.I would welcome a discussionarticle, together with a fewdemo programs (to pinch thebits I like).

Doubtless other readers willhave their own needs and ideas;can they be encouraged to sub-mit them with the promise of themost popular being dealt with ina Mk2 Tutorial along the linesrequested. Whilst I have listed agreat number of wants, I don’tthink I’m on my own and sus-pect I speak for many who arestruggling to write their ownstuff and using your Tutorials asa bible and guide. Many thanksfor a great mag, I don’t carewhat you call it, just keep up thequality.

John Becker addresses some of the general points readers have raised. Haveyou anything interesting to say? Email us at [email protected]!

Page 70: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1005

Derek Johnsonvia the Net

You are indeed using theTutorials as I expected – select-ing routines and modifying themto meet your own needs. One ofthe purposes of us publishingany project software, whetheron page or on disk, is to let oth-ers share the code and selectsections or just gain ideas forother designs. This too, ofcourse, is what people do withthe electronic circuits as well –select and modify for other func-tions. No-one is cheating by do-ing so, it’s using common senseand cuts down on the wastedeffort of “re-inventing wheels”each time!

Tutorial-wise, myPIC16F87x Mini Tutorial is inthis current issue, of course. Init I highlight a fair number ofpoints about using the new PICfamily, with particular emphasison the PIC16F877 (as used inthe Data Logger of Aug/Sept’99). The article does not at-tempt to cover all aspects of us-ing ’F87x devices, but givespractical advice based on myexperience with them so far –the implementation of somefunctions proved to problematic,the data sheet not being theeasiest of documents to followin some instances. Hopefullyyou will be saved such puzzle-ment as I encountered fromtime to time!

Regarding MIDI routines, Ican’t offer help since I am not aMIDI user, but other readersmay be able to, and I also plantthe suggestion before RobertPenfold, who does know aboutMIDI (well, Robert?).

Nor am I familiar withPICBASIC compilers – anyonecare to comment on them?

PhizzyBLY CARINGDear EPE,

I would like to place onrecord my deep appreciation ofthe time and effort Alan Win-stanley and Clive “Max” Max-field have put in trying to helpme find the solution to a Phizzy-Bot problem I have. Also to yourEditor and his secretary for theefficient and courteous mannerin which they have handled mycorrespondence.

What a change these daysto find a magazine run by sucha caring crew.

R. TippingBatley, W. Yorks, UK

Thank you Mr. Tipping. Wedo care and try to let it show.

VIRUS FEEDBACKDear EPE,

In Readout Aug ’99, PeteKelly of Australia said that theplural of virus is viruses or viri.Well, according to some VERYgood Virii Creators it is Virii andnot Viri/Viruses. Since virii existbecause of them we should usethe terminology they use. By theway, one virii creator created avirus that infects all .COM filesin the current directory. The viriiwas only 27 bytes long!

Thanks for the great magand keep up the good work. Ifyou publish my letter please cor-rect my spelling (except for Virii,Viri, Viruses).

Ian Galpinvia the Net

You’ve got a point, Ian, but Ifor one have absolutely no re-spect for those malicious van-dals who do write viruses and

shall not take any lessons in En-glish or Latin spelling fromthem. They would appear tohave brains that can achieve aworking program, but it wouldbe far better to use their brainsin a constructive manner, not adestructive one. It is impossibleto conceive what goes throughtheir minds when they create avirus, some of which havecaused untold distress to many,including patients relying fortheir survival on hospital com-puters.

There is no way in which wecan condone this behavior andshould we somehow learn thename and address of a viruscreator, we would have no hesi-tation in reporting it to the Po-lice. The severest of penaltieswould not be too great for suchcriminal idiots.

As requested, we have cor-rected your spelling in non-viralmatters (do we gather from yourE-mail address that you comefrom Zambia?). Thanks for con-tacting us, my anger is not withyou, but with virus writers.

DESCALING REVISITEDDear EPE,

Living in a hard water areawhere the lime factor in the wa-ter had got to the point of beingridiculous, I was prompted tosearch out some means of get-ting rid of or reducing theamount of lime.

I contacted a company sell-ing a commercial waterdescaler, but the price quotedwas disappointing. I then re-membered reading about a wa-ter descaler in one of my backissues of EPE (Oct ’97) thatworked the same way.

I obtained a kit from Ma-genta Electronics, finding it fairlyeasy to build and put together.

5HDGRXW

Page 71: EPE_10-1999

EPE Online, October 1999 - www.epemag.com - 1006

The only difficult part being thewinding of the coil around thecopper pipe in a confined space. Ilost a lot of skin from my knucklesbut succeeded in completing thetask.

I am glad to report that thedevice is working satisfactorily.My wife is especially delighted asto its effect, the periods betweendescaling are longer and the wa-ter feels softer. Magenta Elec-tronics is an excellent company todeal with.

A.J. LewisHarlow, Essex, UK

A couple of years back wehad quite a lot of correspondencein Readout concerning waterdescalers. Good to know that be-tween us, Mark Stuart, Magentaand EPE have provided you witha working product. It is one ofthose areas in which no real sci-entific evidence appears to exist.

PIC TOOLKIT V2.3Last month in Readout, the

introduction of PIC Toolkit Mk2software version V2.2 was an-nounced. Since then I have beenextensively using the program inconnection with probably mymost complex PIC software pro-gram to-date, a Tide Machine(based on a PIC16F873), sched-uled for Spring next year.

As a result, I have also madea few more minor improvementsto Toolkit Mk2, making it eveneasier to use. The latest files,V2.3, were released onto the EPEOnline Library on 8 September’99. Just follow the instructions inthe text files that accompany themain software. Version V2.3 in-corporates all previous changes.The changes are stated near thehead of each .BAS program list-ing, which can be read from DOSEDIT.

As was said last month, Ishall no doubt make further im-provements to Toolkit Mk2’ssoftware in the light of experi-ence – make suggestions if youwish. (But please rememberthat I write such things only inmy spare time!)

NAMING PICSDear EPE,

Regarding Readout Sept ’99in which the question “whatdoes PIC stand for” arose, asfar as I am aware, PIC standsfor Peripheral Interface Con-troller. I have heard people(understandably) calling them allsorts of things, like Pro-grammable Integrated Circuits,Programmable In-Circuit Micro-controllers, and ProgrammableIntegrated Controllers.

The Peripheral InterfaceController definition can befound on some Arizona Mi-crochip promotional literature,which is at -www.jpixton.dircon.co.uk/pic/history.html

This also raises anotherpoint: mostly in your mag PICsare referred to as PIC microcon-trollers, which is a bit confusing. . . Peripheral Interface Con-troller Microcontroller. It is a bitlike when people say “my PINnumber . . .” which means “mypersonal identification numbernumber”!!

Joseph Birr-Pixtonvia the Net

Thanks Joseph! However,as a personal reaction, your pre-ferred definition doesn’t reallycall up in my mind the sophisti-cation of what a PIC can actu-ally do. The added term“microcontroller” is somehow far

more evocative. We also feelobliged to include this wordwhen referring to PICs in orderto clarify to readers who maynot be familiar with the type ofdevice that they are. In itself theterm PIC is only meaningful tothose who already use them.

As surprising as it mayseem to some readers, thereare others who do not yet knowabout PICs. For the sake ofthose who are perhaps readingEPE for the first time, we haveto spell out definitions in variousways somewhere near the be-ginning of an article. The abbre-viation LED is an example, weusually spell it out at least oncein an article as light emittingdiode for sake of anyone whohas not yet come across it.There is sometimes more to ed-ucational publishing than meetsthe casual eye!

5HDGRXW