epe_04-1999

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

Upload: ipse-lute

Post on 28-Jan-2016

220 views

Category:

Documents


1 download

DESCRIPTION

practical electronics magazine

TRANSCRIPT

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

9ROXPH,VVXH

$SULO

EPE Online, February 1999 - www.epemag.com - 383Copyright © 1999 Wimborne Publishing Ltd andMaxfield & Montrose Interactive Inc

EPE Online, April 1999 - www.epemag.com - 382

PROJECTS AND CIRCUITS

PhizzyB COMPUTERS - Part 6 - by Clive Maxfield and Alvin Brown Routines to program the PhizzyBot with collision detection and avoidance

PIC16F87x Microcontrollers - by John BeckerMicrochip’s new EEPROM PICs have even more to offer than the ‘84s 431

Circuit Surgery - by Alan WinstanleySolid State Relays; Photovoltaic Relays; Electret Microphones - the plot thickens 457

REGULARS AND SERVICES

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

478

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

465

READOUT - John Becker addresses general points arising. 471

EDITORIAL 464

SERIES AND FEATURES

Modular Circuit Design CD-ROM - by Robert PenfoldSoftware to help hobbyist designers achieve their circuit goals

428

Net Work - The Internet Page - surfed by Alan WinstanleyFreeserve support costs less; Freeserve sans CD; BT Click goes FREE; .... and more!

462

New Technology Update - by Ian Poole Micro-electromechanical systems offer computer security solutions

426

Voice Record/Playback Module - by Robert PenfoldLess cuddly that a Firby, but more useful!

402Versatile Event Counter by John Becker Count and time music beats, rowing rates, clock ticks and more

Ingenuity Unlimited - hosted by Alan Winstanley Audio Limiter; IRE Remote Control Tester; Video Amplifier

416

PhizzyB COMPUTERS - 6 by Alan Winstanley It’s time to add feelers to the PhizzyBot’s guidance control

411

Ironing Board Saver - by Robert HuntSave energy with this safety add-on

MAX761 D.C to D.C Converter - by Andy Flind How to squeeze the max out of your batteries 436

INTERFACE - by Robert Penfold AD8300 serial digital to analog converter - PC controlled 454

DATA-NET Review - by Robert Penfold A ten CD-ROM library of semiconductor data is out to the test 451

394

419

440

Mechanical Radio - by Bart Trepak - Wrist power provides a renewable radio 384

EPE Online, April 1999 - www.epemag.com - 383

PIC TOOLKIT MK2Microchip's new PIC16F87x series of

EEPROM microcontrollers offer greaterprogram capacity and more facilities than thefamiliar PIC16x84 series. The latter, though,will still find a plethora of uses in less-demanding circuits where the greatersophistication of the '87s is not required. Thereare roles for both families.

Consequently, the PIC16x84 Toolkit ofJuly '98 has been upgraded to make itcompatible with both the '84 and the '87. Theprinted circuit board has been redesigned toaccept the 18-pin '84s and the 28/40-pin '87s.The power supply control has been redesignedto remove the need for a regulated12V/14VPSU between 5V and 20V (at around 10mA).

the Mk2 will run from any DC supply of

Additionally, the controlling software hasbeen considerably enhanced in a number ofways, offering more functions than the Mk1version.

o) The Mk2 has the same basic options asthe Mk1:

o) Disassemble PIC to TASM .OBJ

o) Disassemble PIC to MPASM .HEX

o) Translate TASM .ASM to MPASM .ASM

o) Translate MPASM .ASM to TASM .ASM

o) Configure PIC

o) Program PIC with TASM .OBJ

o) Program PIC with MPASM .HEX

o) Translate MPASM .HEX to TASM .OBJ

o) Translate TASM .OBJ to MPASM .HEX

It also has the following additional options:

o) Assemble TASM .ASM to .OBJ (totallyreplacing the need for a TASM sharewareassembler)

disassemble) from its selected portestablished.

o) Load/read data to/from the PIC's internalEEPROM data memory

This software is considerably moresophisticated than the Mk1 version and issupplied as a suite of four chained programswhich call each other as required without theuser's intervention. It can be run in QBasic,

QuickBASIC, or as a stand-alone (.EXE) program withoutany need for a Basic controller.

The software can also control Toolkit Mk1 withoutmodification to either. Information on using it with the PICTutorial (March to May '98) and the PIC Tutor (CD-ROM)is provided in the text

VERSATILE AM/FM REMOTE CONTROLSYSTEM

Remote control systems are increasingly popular, andthe introduction of pre-tuned radio modules and theirsteadily falling prices has made radio a viable alternativeto infrared. The advantage of radio is the ability of thesignal to pass through objects and walls. Its range is alsoimpressive, 100 meters or more (in free space) beingtypical.

No license is required in the UK, providing the radiomodules operate on the 418MHz waveband, and there area number of conditions, one of which is that setting up andtuning is carried out by a DTI approved company. Hence ifthe module is purchased from such a company the homeconstructor can enjoy the benefits of radio remote control.

The article will describe how to use the radio modulesin a similar way to the infrared system, which appeared inthe November and December '98 issues of EPE Online.We will examine both AM and FM systems, and beginwith a brief outline of the difference between these.

MIDI “HAND BELLS”This project was primarily designed with children in

mind, and was actually produced in response to a requestfrom a reader who required the gadget for a group ofhandicapped children. However, it is capable of providinghours of fun for “children” of all ages! It could be regardedas a modern equivalent to a set of hand bells. It is really aform of MIDI interface, and is incapable of making anysound without the aid of a MIDI equipped synthesizer,sound sampler, or other instrument.

The output of the interface connects to the MIDI inputof the instrument, which is set to produce a bell sound orany other sound you like. Up to 11 pushbutton switchescan be connected to the input of the interface. Thegeneral idea is for each player to control one or twopushbutton switches. By operating the switches in thecorrect sequence and with the correct timing the desiredtune can be produced. In other words, the melody isplayed in much the same way that it would be producedby traditional hand bell players.

EPE Online, April 1999 - www.epemag.com - 384

Every now and then, an in-vention is made which is so sim-ple and obvious that many peo-ple's reaction on hearing about itfor the first time is “why didn't Ithink of it myself?”

This was certainly the au-thor's reaction when he first heardabout the Clockwork Radio whichhas since gone on to make its in-ventor, Trevor Bayliss, a greatdeal of money, as well as improv-ing the life of many people in theThird World.

The brilliance of any inven-tion is in the initial leap of imagi-nation, which results in a newproduct rather than the initialmethod of its implementation orthe evolution of a concept. Hav-ing watched a documentary onthe Clockwork Radio on TV a

teries. It was time to have an-other look at the design to see ifit could be made simpler andcheaper...

CART BEFOREHORSE

The basic concept behindthe Clockwork Radio is shown inthe block diagram in Fig.1a. Inessence, the mechanical energyproduced by turning a handle is

Build a battery-less portable radio – it’srevolutionary!v

0(&+$1,&$/ 5$',2 E\ %$57 75(3$.

year or so ago, which traced thedevelopment of the radio fromits initial idea to its eventualproduction, the author thought itwas a great idea and deter-mined to buy one as soon asthey became available.

Recently, thumbing throughone of those “New Inventions”booklets, which seem to arriveevery now and again, the authorwas delighted tosee a ClockworkRadio listed. Onchecking theprice, however,he soon changedhis mind 60 UKPounds seemedto be an exces-sive price to payto save a fewpounds on bat-

5>5B7ICD?B5

3?9<<<54C@B9>7

5>5B7ICD?B5

5<5333DB931<

75>5B1D?B

75>5B1D?B BBB1114449???

9===555333888111>>>999333111<<<999>>>@@@EEEDDD

222???333;444999111777BBB111===???6663<?3;G?B; BBB111444999?

< ; =5381>9 1< ?

1

2

Fig.1. Comparison of the two energy genera-tion methods.

stored in a spring. This is fed toa generator, which converts thestored mechanical energy intothe electrical energy required topower the radio.

The amount of energywhich needs to be stored de-pends, of course, on the amountof power required by the radioand the length of time for whichit is required to play, and thiswill determine the size and so-phistication of the spring.

Interestingly, by changingthe order of the blocks in Fig.1ato that shown in Fig.1b, the en-ergy can be stored electrically.This requires no development of

EPE Online, April 1999 - www.epemag.com - 385

costly mechanical componentsas the components are avail-able off the shelf, and this de-sign therefore lends itself morereadily to home construction.

An electrical storagemeans, of course, some kind ofrechargeable cell, but here wecome up against a problem.Anyone who has ever charged aNiCad battery will know thateven with a relatively large cur-rent, a battery will need to be oncharge for a good few hours tobe of use. Consequently, manyhours of turning the handle of asmall hand-powered generatorwould be required to charge thebattery, which is clearly unac-ceptable.

Batteries are efficient instoring a lot of electrical energyin a small physical size but be-cause the energy storage de-pends on a chemical reactionwhich takes time to occur, abattery can only accept acharge relatively slowly. A ca-pacitor, however, does not suf-fer from this limitation, and itcan be charged almost instantlyif a large enough charging cur-rent is available.

The energy storage capac-ity is, however, much smaller

compared to a battery of thesame physical size. But, howmuch energy do we actuallyneed to store? To answer thisquestion, we need to know thepower consumption of the radioand the length of time for whichwe want it to play.

The power consumption ofa radio tuner can be made quitesmall, so that the main factorsgoverning this will be the audioamplifier and its loudspeaker.We therefore need to know howloud we want the radio to playand, inevitably, the answer willbe as loud as possible for aslong as possible.

HOW LONG IS APIECE OF STRING?

(Twice as long as from themiddle to the end. Ed.) It is per-haps better to start by determin-ing how much energy can bestored and then seeing what canbe done with it. The energystored in a capacitor is given byE = CV2/2 Joules, where C isthe capacitance in Farads and Vis the voltage to which it ischarged.

The capacitance valuesnormally encountered in elec-

tronic circuits are measured inmicrofarads, but large values ofcapacitance are now available inrelatively small volumes and areused in memory back-up applica-tions in computers. A one Farad(1F) capacitor (5V working volt-age), for example, is only 45mmdiameter x 20mm high, which is aslightly larger volume than that ofa C-size battery and costs aboutthe same.

From the above formula, theenergy stored by such a capacitorcharged to 3V, say, would be 4¬¬¬5Joules. Unfortunately, not all ofthis energy would be available for

&RQVWUXFWLRQDO3URMHFW

R

S

U

R

S

U

DB"">#) $

3!

! ^

F3!! "& `

3"

$' `

DB!">#) $

FB!

![

B!

!=

B"

$'[

=!

43

=?D?B3$

!6

B$

"["

3#

$ 'P

4"

!>$!$(

4$

!>$!$(

B#

"["

<C!

3BICD1<

51B@9535

4!

!>$!$(

4#

!>$!$(

[

Q

[

Q

[

Q

[

Q

<!

=

<!C55 D5HD

DE>9>7

Fig.2. Complete circuit diagram for the Mechanical Radio.

COMPONENTSResistors

R1 1MR2 47kR3, R4 2k2 (2 off)

See also theSHOP TALK Page!

All 0.25W 5% carbon film (or better)

CapacitorsC1 100n ceramic discC2 470p ceramic discC3 4u7 radial electrolytic, 16VC4 1 Farad tagged-can elect. 5VVC1 10-260p tuning capacitor

SemiconductorsD1 to D4 1N4148 signal diodes (4 off)TR1, TR2 2N3904 npn transistors (2 off)

Miscel laneousLS1 crystal earpieceMO1 high torque 9V motor (see text)L1 ferrite rod aerial (see text)

Printed circuit boards availablefrom the EPE Online Store at(www.epemag.com ) codes7000226A & 7000226B; gearwheels (16 teeth, 42/10 teeth, and60 teeth); 2mm diameter spindle;3.5 mm jack socket; knob for VC1;plastic case, 100mm x 77mm x41 mm; connecting wire, solder ...

$24Approx. CostGuidance Only

Potent iometerVR1 1k miniature horizontal preset

EPE Online, April 1999 - www.epemag.com - 386

powering the circuit, because allelectronic circuits need a certainminimum voltage supply to op-erate.

As current is taken from thecapacitor to power the radio thevoltage will fall, and once it hasfallen below a certain level op-eration will cease, despite therestill being a certain amount ofenergy left in the capacitor.

To keep the arithmetic sim-ple, let us assume that our cir-cuit will work down to 1¬¬¬5V, atwhich point the (unrecoverable)energy still left in the capacitorwould be 1¬¬¬125 Joules. A 1F ca-pacitor would thus store around3¬¬¬4 Joules of recoverable en-ergy. An energy expenditure ofone Joule is equivalent to apower of one watt flowing forone second, so that if we wantour radio to operate for, say, 15minutes (900 seconds) the aver-age power taken by the radioshould not exceed 3x 1000/900).

¬¬¬78mW (3¬¬¬4

This power is, of course,very low for a radio fitted with aloudspeaker but more than suf-ficient for a personal radio driv-ing an earpiece. The circuit tobe described presently draws acurrent of only 0and will work down to 1

¬¬¬2mA at 1¬¬¬75V¬¬¬5V, so

that a very respectable playingtime of about one hour can beachieved if the capacitor is ini-tially charged to 3V.

Loudspeaker operationwould be possible for shortertimes, especially if an efficientaudio power amplifier was usedand the capacitor (or capacitors)charged to a higher initial volt-age, although the author has notinvestigated this.

RADIO CIRCUITWith the demise of the

ZN414 radio receiver integrated

circuit, which would have beenideal for this application, we haveto “re-invent the wheel” to make asimple AM radio, and the circuitshown in Fig.2 is one which wouldnot have been out of place in thepages of this magazine in the1960s!

This circuit has the advan-tage of not only being simple tomake and using readily availablecomponents, but it also givesquite good results, although theaudio quality is not hi-fi.

The signal picked up by theaerial L1 is tuned by capacitor C1and applied to the base of transis-tor TR1, which functions as an RF(radio frequency) amplifier and adetector. The input impedance ofthis stage is high so that thetuned circuit is only lightly loaded,resulting in good selectivity.

High gain is achieved by theuse of regenerative (positive)feedback by feeding some of theamplified signal back to the inputvia the small winding on L1, theamount of feedback being set bypreset potentiometer VR1 to alevel just below that which wouldcause the transistor to oscillate.

The transistor then exhibits avery high gain resulting in maxi-mum sensitivity of the receiver. Ashort explanation of the regenera-tive receiver is given later.

The amplified signal is de-tected in the collector of TR1 withthe residual RF signal being re-moved by capacitor C2. The re-sulting audio signal is further am-plified by TR2 and used to drivethe high impedance crystal ear-piece, LS1. The volume is notear-splitting, of course, and re-duces with time as the supplyvoltage falls, but it is more thanadequate for personal listening,even at a low supply voltage.

Transistor TR1 is biased al-most to cut-off and TR2 has a rel-atively high impedance load re-

sistor so that the total currentconsumption of the circuit iswell below 1mA.

The power supply for thecircuit consists of the hand-cranked generator (M1) togetherwith the one-Farad capacitor(C4) and a bridge rectifier (D1to D4).

CAPACITOR CHARG -ING

So far, we have discussedthe radio circuit and how it canbe powered by the chargestored in the capacitor, but wemust now turn our attention onhow this capacitor may becharged.

As most readers will know,when the spindle of a motor isturned, a voltage will appear atits terminals, so a standard per-manent magnet motor has beenused as the power generator inthis design.

When used in the generatormode, the output of a motor isproportional to its speed. Theactual voltage developed at theterminals at a given rotationalspeed will depend on thestrength of the internal magneticfield and the number of turns inthe armature coils and not allmotors will be the same in thisrespect. (Note that specifica-tions for motors being used asgenerators are not quoted bymanufacturers and their outputvoltage and power varies fromdevice to device.)

Motors intended for highervoltage operation (i.e. 6V as op-posed to say 1¬¬¬5V) will probablyhave more turns. Those with ahigher torque will have astronger internal magnetic fieldso that to generate a reasonableoutput without having to turn thespindle at impossible speeds, ahigh torque, high voltage motor

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 387

is required. A 9V motor waschosen, as this was not too bigphysically.

Although the output of sucha motor is DC, the polarity ofthe output will depend on thedirection in which the spindle isrotated. To avoid having tospecify the direction of rotationor to make some mechanicaldevice to prevent the spindlebeing rotated the wrong way, abridge rectifier has been in-cluded to ensure that the outputalways has the correct polarity.

This does mean, however,that the output will be reducedby two diode forward voltagedrops instead of one (one diodewould be required anyway toprevent the capacitor from dis-charging through the coil) but itmakes the mechanical arrange-ment much simpler.

GETTING INTO GEARNo matter what kind of han-

dle was attached to the motorspindle, it was found impossibleto turn it fast enough to obtainan output great enough to over-come the diode voltage dropslet alone charge a capacitor, sothe use of gears was unavoid-able. Ready-made gear trainsare available, but these tend tobe very expensive unless scrapor surplus ones can be found,and these will then probably notbe easy to connect to the motor,so it was decided to make oneusing available gear wheels.

Experiment showed that toobtain a suitable final speed, aratio of about 1:15 was required.However, although gear wheelswith 16 teeth and a diameter of9mm are available, the drivingwheel would need to have 240(15 x 16) teeth, resulting in awheel of around 135mm in di-ameter. This would be biggerthan the rest of the radio and

&RQVWUXFWLRQDO3URMHFW

contained a concentric 10-toothed wheel, for example, andthis was in turn driven by a 50-toothed wheel (28mm diame-ter), this would give a furtherspeed reduction of a factor offive giving an overall speed ra-tio of 1:15 in a much more man-ageable size.

The final gear design uses16, 42/10, and 60 toothed gearwheels to achieve this, as thesewere readily available.

Note that since we are get-ting a speed increase, thetorque is proportionally lower ateach stage or, to put it anotherway, the force required to turnthe first wheel will be 15 timeslarger than that required to turnthe motor spindle directly. Thisis unlikely to tax even the weak-est reader in this case.

It should be noted, though,that the simple plastic gearwheels used in this design aremerely pushed onto the spindleand rely on a tight fit rather thana more robust method of fixing.Any misalignment of thewheels, which is likely to in-

!&D55D8

)]]

!$$]]

$( D55D8

"']]

%&]] 1@@B?H

! D55D8

!%>B@=

!%>B@=

%>B@=

!&D55D8

)]]

"$ D55D8

!#%]]

% D55D8

"(]]

>B@=

>B @=

Fig.3. Gear trains with1:15 ratio.

B#

B$

B!

B

"

3

!

FB!

DB"

DB!

3#

3"

=?D?B

4! 4"

4# 4$

U

U

R

R

S

S

D?<!2?DD?=

D? <! D?@

D? F3!

D? <! 35>DB5 D1@

D? F3!

D? <C!

UR

S

">>>#) $

DB1 C9CD?B

@9 ?EDC

Q[

Q[

Q[

Q[

D? 3$

D? 3$

Fig.4. Component and (approximately) full size tracklayouts for the PCBs.

obviously unacceptable.

It is, though, also possibleto get this ratio by using morestages as shown in Fig.3 so thatif the 16-toothed wheel wasdriven by a one having 48 teeth,this larger wheel would rotatethree times slower and have adiameter of 27mm. If this also

EPE Online, April 1999 - www.epemag.com - 388

crease the torque required toturn them, could result in thewheel slipping on the spindlerather than turning. This is es-pecially true of the largest wheelso that the gear train should beconstructed carefully.

MECHANICAL CON -STRUCTION

The biggest problem in con-structing this project is likely tobe with the mechanical partrather than the electronics, andthe following instructions shouldtherefore be followed closely.

The whole project, includingthe gear train, has been built ontwo printed circuit boards(PCBs), which have been de-signed to perform not only anelectrical function but a me-chanical one as well. This sim-plifies construction consider-ably, and because of this theiruse is mandatory unless otherarrangements for mounting thegear wheels are made.

These boards are availablefrom the EPE Online Store(code 7000226A/B) atwww.epemag.com

The first thing to do is todrill out the four holes in thecorners of PCB 7000226B to3mm.

Next place this board overPCB 7000226A, one centimeter(10mm) from the edge asshown in Fig.5 and drill corre-sponding holes in 7000226A us-ing 7000226B as a template.Once this has been done, thetwo boards may be secured to-gether with nuts and bolts. Theholes for the gear spindles aredrilled through both boards si-multaneously. This method willensure that the holes are drilledin the correct position and thatthey will also be correctlyaligned.

The spindles are 2mm di-ameter, so a 2mm drill shouldbe used for these holes (A). Themotor spindle (hole D) has alarger diameter, but since thisshaft will be supported by themotor bearings rather than theholes in the PCB, the diameterof the hole for this is not too im-portant and a 3mm drill may beused here to give sufficientclearance.

The position and size of thetwo holes (C) for fixing the mo-tor is critical, and these shouldbe drilled using a 2¬¬¬5mm drill.

ELECTRONIC CON-STRUCTION

Once the mechanical as-sembly has been completed,the two boards should be sepa-rated and the circuit assembledon board 7000226A followingthe layout given in Fig.4.

All of the components, ex-

cluding the storage and tuningcapacitors and the aerial, aremounted on this board and careshould be taken to ensure thatpolarized components are in-serted correctly. Pay particularattention to the transistors asthe pinouts for the 2N3904 differfrom the more usual format inthat the emitter and collectorconnections are reversed (seeFig.4).

The one-Farad capacitor(C4), which is not mounted onthe board but connected to it byshort leads, is also polarizedand the negative terminal ismarked by two stripes. This ter-minal is also connected to themetal plate at the base of thecomponent.

Construction should beginwith the lowest profile compo-nents such as diodes and resis-tors, progressing to the largerones with the motor being

&RQVWUXFWLRQDO3URMHFW

=19> @32

4B9<<DG?#]]@9<?D8?<5C D8B?E78 2?D82?1B4CEC9>7 D85

C=1<<5B@32 1C 1D5=@<1D5

=19> @32>EDC 1>42?<DC

1 ---"""]]]]491=5D5B

2 1>44 - #]]491=5D5B

3 % ] 491=5D5B

3<1=@ 2?D8 2?1B4C

D?75D85BEC9>7 DG???>EDC 1>4 2?<DC 256 B54B9<<9>7 D85 ?D85B 8?<5C

! ]]

1 1

222 222

333

4

Fig.5. PCB drilling details for the mechanical mountings.

EPE Online, April 1999 - www.epemag.com - 389

mounted last. This should besecured to the PCB by meansof the two fixing screws andconnected to the appropriatepoints on the board by shortlengths of wire.

The small capacitor wiredacross the motor terminals maybe left in place or removed aspreferred, as it performs nofunction in the circuit operation.

TUNING COMPO-NENTS

The prototype used a smallferrite rod aerial (50mm x10mm diameter) with 70 turnsof 28 s.w.g. wire and a tap at 10turns, together with a 10-260pFtuning capacitor as these wereto hand. These items may notbe available from your usualcomponent supplier, but it is,however, perfectly acceptableto use other values/sizes andmany suppliers list ready-woundferrite aerials and matching tun-ing capacitors for small radiocircuits.

Some windings may nothave a tap for connecting the

aerial, but instead consist of twoseparate windings, one largerthan the other. If this is thecase, both windings should beconnected in series to form onecontinuous tapped winding andit is important to ensure that thephase of both windings is cor-rect (i.e. the end of the smallerwinding is connected to the startof the other).

If this cannot be deter-mined, simply connect the twowindings together and adjustVR1 until the circuit oscillates(see later) and if this does nothappen with any setting of thepreset, reverse the connectionsof one of the coils.

The size of ferrite rods mayvary from supplier to supplier,but any size can be used pro-vided it will fit the box. Themounting is left to the ingenuityof the constructor, and as longas the components are con-nected to the appropriate pointson the circuit board there shouldnot be any problem. Leadsshould be kept as short as pos-sible.

If the coil needs to be handwound, it is probably best to

start with more turns than arerequired so that these can beremoved to obtain the requiredinductance to enable the re-quired stations to be receivedwith the tuning capacitor used.

Many tuning capacitorshave one plate connected to thespindle and, to prevent handcapacitance effects, this termi-nal should be connected to theVR1 end of the coil (negativerail).

EARPIECEThe earpiece, which must

be a high impedance crystaltype, is normally available fittedwith a 3¬¬¬5mm jack plug so thatthe output of the radio should befitted with a suitable socket, apanel mounted type being pre-ferred. Alternatively, as there isno real advantage in having anearpiece that can be discon-nected, the plug could be cut offand the wires soldered acrossresistor R3.

Note that only a crystal ear-piece should be used, becausemagnetic earpieces and head-phones have too low animpedance to work in this cir-cuit.

FINAL MECHANICSWhen the electronic assem-

bly work has been completed,the final mechanical assemblycan begin. With the motormounted on the PCB, the small16-tooth wheel should bemounted onto the motor spin-dle. This is really designed to fita 2mm-diameter spindle, andalthough the motor spindle issomewhat larger than this it canstill be forced onto it providing atight fit.

The best method of mount-ing the gear wheels onto spin-dles is to position them carefully

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 390

in a vice and then tighten itslowly until the wheel is cor-rectly positioned, as shown inFig.6.

If the spindle protrudes fromthe other side of the wheel, apiece of wood with a 3mm or4mm hole drilled in it should beplaced beneath the wheel tosupport it while the vice isclosed.

Next, cut a 1cm piece off a2mm-diameter spindle with ahacksaw and mount the 42/10wheel onto this as describedabove. The rest of the 2mm-diameter shaft, which shouldmeasure a little over 6cm,should be bent into the shape ofa handle according to the di-mensions shown in Fig.7. This

can easily be done by hand ifthe spindle is firmly clamped atthe appropriate point in a vice.

The handle should bepassed through the appropriatehole in the small piece of PCBmaterial before the large 60-tooth wheel is mounted on it, asit will not be possible to pass thebent spindle through the holeonce the wheel has beenmounted.

Once this has been done,

the gears may be assembled asshown in Fig.7 and the gap be-tween the boards adjusted toabout 5mm by means of thenuts and bolts, which shouldthen be tightened securely.Check that the handle can beturned easily and, if necessary,a drop of oil should be appliedto the spindles to ensure this.

If the handle does not turneasily or the spindle slips on thegear wheel, it is probably due tothe two boards not being paral-lel in which case the spacingnuts on the four bolts should beadjusted accordingly.

WIND-UPWhen construction is com-

plete, connect a voltmeter to theterminals of capacitor C4 and,turning the handle, the voltageshould rise slowly. Continue todo this until the voltage readingis 3V, which should take about30 seconds depending how fastthe spindle is turned.

With VR1 turned fully clock-wise, connect the earpiece andtune in a station. Adjust VR1(turning it anti-clockwise) to in-crease the volume until the cir-cuit begins to oscillate. This will

&RQVWUXFWLRQDO3URMHFW

@9535 ?6 G??4G9D8 $]] 8?<5

C@9>4<5

751BG855<

F935

Fig.6. Mounting gear wheelonto spindle.

%]]

751BG855<C

"]] 491=5D5BC@9>4<5C

C@139>7>EDC

2?<D$ ?66

=?D?BC@9>4<5

=?D?B69H9>72?<DC

=?D?B

=19> @323?=@?>5>DC945

81>4<5

!%]]

"%]]

"%]]

=?D?B<514CC?<45B54D?

@32

81>4<549=5>C9?>C

Fig.7. Mechanical assembly.

EPE Online, April 1999 - www.epemag.com - 391

be heard as an increase in thedistortion accompanied by abuzzing sound reminiscent of amotor boat.

Back off this setting slightlyand use VC1 to tune to otherstations and check that thisdoes not occur at any other set-tings, re-adjusting VR1 if itdoes.

The setting up is now com-plete and the radio is ready tomount in a box. The prototypewas built into a 100mm x 77mmx 41mm ABS box, which con-tains slots to support a printedcircuit board.

A suitable slot must bemade in the box to enable thehandle to be mounted on thelarge wheel first and the com-pleted assembly fitted into thebox.

The gear/motor assemblyshould be mounted securely, asshould the tuning capacitor andferrite aerial to prevent themfrom rattling about inside, espe-cially as these components aremounted off the board. The ex-act method of mounting theunits inside the box is not criti-cal.

In use, the radio will requirewinding for around 30 secondsto give an initial supply of about3V and a playing time of aboutone hour. The initial voltage canbe increased by turning the han-dle for longer periods, oneminute giving about 4V. Al-though this will give longer op-eration, it could also cause thecircuit to oscillate, requiring are-adjustment of VR1, unlessthe circuit was originally set upat 4V.

Do not allow the capacitorto become charged above itsrated working voltage (5V).

OTHER USESFor those who do not want

to construct a radio, but mayhave other uses for this device,the PCB has been designed sothat the storage capacitor canalso be mounted on the boardnext to the motor. By cutting offthe radio section, a kind of“mechanical battery” can beconstructed enabling all sorts ofother gadgets to be powered, solong as a supply of 3V or 4V issufficient, and not too much cur-rent is required.

The circuit can easily supplya current of a few hundred mil-liamps, although not for verylong, of course. It will, for exam-ple, power a small DC motor forabout 10 seconds and would beideal for circuits which requirevery low power or are used foronly very short periods. Afterall, this “battery” can always berecharged in 30 seconds or so,which is a good deal faster thanany NiCad!

REGENERATIVE RE-CEIVERS

All radio receivers, from thehumble crystal set to the mostsophisticated types, make useof a tuned circuit to select thefrequency or station required bythe listener from all of thosewhich are being transmitted atany given time.

The tuned circuit consists ofan inductor L1 and capacitor C1connected in parallel, as shownin Fig.8. The signal is picked upby the aerial connected to thetuned circuit. The circuit pre-sents a low impedance to thesignal at all frequencies exceptthe one to which it is tuned.Thus all frequencies are effec-

tively shorted to earth exceptthe one which is required.

In the simple crystal setshown, the RF (radio frequency)signal, which is tuned in, is de-tected using the diode and this,together with capacitor C2, re-covers the audio signal, which isthen heard in the headphones.

The waveforms for an am-plitude modulated (AM) signal,which would be seen at variouspoints in the circuit on an oscil-loscope, are illustrated in Fig.9.Frequency modulated (FM) sig-nals require different techniquesand would not be detected bythis circuit.

This circuit is just about us-able if a long aerial and a good

&RQVWUXFWLRQDO3URMHFW

<!3!

1 4! 2

3"

3Q [

8514

@8?>5C

Fig.8. A simple crystal radio.

B5359F54B6 C97>1<G9D8 1E49?=?4E<1D9?>

C97>1< 6?<<?G999>745D53D9?> 3"B5=?F54

B53?F5B54 1E4 ?1D 8514@8?>5C 3" 9> @<135

1

2

3

Fig.9. Example waveformsproduced with Fig.8.

EPE Online, April 1999 - www.epemag.com - 392

earth are provided. With a goodset of high sensitivity head-phones a strong local stationwill probably be picked up. Thisarrangement was fine in theearly days of radio when onlyone or two stations were trans-mitting and the listener was pre-pared to put up an aerial sev-eral tens of meters long, but it ishardly suitable for use as aportable set.

PORTABILITYFor a portable set, a much

smaller aerial (and no earth) isrequired and the resultingweaker signal means that con-siderable amplification of thesignal is required before it isstrong enough to be applied to adetector, let alone drive eventhe most sensitive of head-phones or loudspeakers.

One stage of amplificationwould not normally be sufficientto produce a signal largeenough to be detected by adiode so that many stageswould need to be cascaded to

obtain the required gain. A sta-ble high gain wide band ampli-fier is very difficult to make asthere will always be a frequencywhere stray coupling betweenthe input and output will begreat enough and in the correctphase to cause the circuit to os-cillate.

This could be overcome bycascading nar-row band ampli-fiers, each withits own tuned cir-cuit adjusted forthe frequency ofinterest to thelistener as shownin Fig.10. Thisarrangement,however, is notused for a varietyof reasons, notleast of whichbeing the diffi-culty of keeping all the tunedcircuits in step while the tuningcapacitor is varied to select dif-ferent stations.

Such a circuit would requirethe use of high quality 3- or 4-

gang tuning capacitors andmost commercial receiverstherefore use a neat trick to getaround this.

SUPERHETThe trick is to mix the in-

coming signal with one gener-ated inside the receiver (calledthe local oscillator) which pro-duces a sum and difference fre-quency.

By making the local oscilla-tor “track” the incoming fre-quency, a constant differencefrequency will be generated irre-spective of the frequency beingtuned in. This frequency isknown as the intermediate fre-quency or IF and all amplifica-

&RQVWUXFWLRQDO3URMHFWB61=@

3!

<!

B61=@45D53D?B

B61=@

3"

1E49?1=@

Q [

Fig.10. Simplified TRF (tuned radio frequency) receiver.96 1=@<9695B

3!

?C39<<1D?B

=9H5B

<!

B6 1=@

3"

45D53D?B1E49?1=@

Q [

Fig.11. Simplified superhet receiver.

45D53D?B

Q [

3! 3"

B61=@

<!

B513D9???>

3?>DB < 1E49? 1=@

Fig.13. Simplified regenerative receiver.

tion is then carried out at thisfixed frequency with specialtransformers (IF transformers)forming the tuned circuit foreach stage.

This arrangement is known

<3 39B333E9DDDG9D8

B575>5B1D9?>

6?B 89785B 719>

1>4 25D 5B

C5<5 D9F9DI

<3 39B3E9DDDG9D8?ED

B57775>5B1D9?>

<?G 19> 1>4 @??B

C5<53 9F9DI

6B5AE5>3I

?ED@ED

F?<D175

6! 6"

Fig.12. Response of singletuned circuit with andwithout regeneration.

EPE Online, April 1999 - www.epemag.com - 393

as a super heterodyne (or su-perhet) receiver and gives ex-cellent performance. A circuitexample is shown in Fig.11.

A basic problem with thecircuit of Fig.8 is not only thelack of sensitivity which pre-vents weaker stations from be-ing received, but also the lowselectivity which often results intwo or more strong stations be-ing received at once.

The graph in Fig.12 showsthe response of a single tunedcircuit to signals of various fre-quencies and it will be seen thattwo adjacent stations(frequencies f1 and f2) are soclose together that both will ap-pear at almost the same level atthe detector.

What is required is a re-sponse similar to the dottedcurve, which would mean thatfrequency f2 would be at amuch lower level compared to

f1 (the required station) andwould therefore not be heard.

FEEDBACKThe “flatness” of the re-

sponse curve of a tuned circuitis caused by the losses in theinductor and capacitor. Theselosses can be “made up” in anoscillator circuit by amplifyingand feeding back a portion ofthe signal to keep a tuned cir-cuit oscillating instead of thesignal simply decaying away.They can also be replaced in areceiver tuned circuit by thesame technique, which will havethe effect of sharpening the re-sponse curve (i.e. improving theselectivity).

To be successful, the fedback signal must be in phasewith the original so that it willadd to, rather than subtractfrom, the resulting output (inother words positive feedback

sometimes called regenerativefeedback). However, since weare trying to make an amplifierand not an oscillator, its levelmust be carefully controlled sothat the amount of signal fedback is just below that requiredto initiate/sustain oscillation.

At this point, the gain of thestage will also be at a maxi-mum, giving a high sensitivityeven from a single stage. Bysuitably biasing the transistoralmost to cut-off, the circuit caneven be made to amplify onehalf-cycle of the RF signal morethan the other so that the stagewill also effectively rectify thesignal, making a separate de-tector stage unnecessary. Thisapproach is shown in Fig.13.

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 394

The days when gadgets capa-ble of understanding what we sayor able talk back to us were in therealms of science fiction are nowwell and truly behind us. This arti-cle is being dictated into a PC us-ing (more or less) normal speech,and when checking the final piecefor errors the computer will beinstructed to read the text back.

It is not only in the computerworld that this sort of voice inter-face is starting to emerge. Allmanner of electronic gadgets thatcan understand simple com-mands and (or) talk back to usare becoming available.

The device featured here is ageneral-purpose voice recordingand playback module that canhandle up to 16 seconds ofspeech. It can be used as a com-plete project in its own right, and

the unit, such as a “warning maximum temperature ex-ceeded” or “red alert this isnot a drill” if your sense of hu-mor gets the better of you!

A big advantage of this sys-tem is that you can use anywords you like, and you are notrestricted to very brief mes-sages. When the module is acti-vated the message can eitherbe played back just once, or itcan be repeated for as long aspower is applied to the module,as preferred.

The basic recording andplayback circuit is designed tooperate from a supply potentialof about 5V, but an optionalvoltage regulator enables thecircuit to operate over a supplyvoltage range of about 7V to15V. The module has a built-inelectret microphone insert andwill directly drive a small loud-speaker having an impedance

Your very own personal “voice box”. Will digitallyrecord up to 16 seconds of sound.

92,&( 5(&25'3/$<%$&.02'8/(

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

it then operates as a simplemessaging system.

In order to record a mes-sage you simply press a button,say a short message such as“taken the cat to the vet, back atabout 4-30” and then releasethe button. Your message canthen be played back as manytimes as required simply bypressing a second pushbuttonswitch. New messages can berecorded over existing ones asand when required.

RED ALERTAnother way of using the

unit is as an alternative to anLED (light-emitting diode) indi-cator or a low-power audioalarm generator circuit. Whenused in this way you must firstrecord a suitable message into

LS1

Address Inputs

LS1

MicrophonePreamplifier

High GainAmplifier

AutomaticGain Control

5-Pole LowPass Filter

AnalogTransceivers

InternalClock

TimingCircuit

5-Pole LowPass Filter

BridgeAmplifier

Non-volatile128k Cell

AddressBuffer/Dec.

Fig.1. Simplified block schematic diagram for the ISD1416 voice chip.

EPE Online, April 1999 - www.epemag.com - 395

rating of 16 ohms or more.

Current consumption of themodule is insignificant when it isin the standby mode, but thenon-volatile memory retains itscontents even when the moduleis switched off. This avoids theneed for any form of batteryback-up circuit.

A unit of this type couldeasily be very complex andlarge, but by using a dedicatedintegrated circuit the componentcount of this circuit is kept to aminimum. The speech quality ofmany “talking” circuits leaves alot to be desired, but in this casethe quality is very good due tothe use of a recorded voicerather than speech synthesistechniques. In fact the quality issurprisingly good, and is limitedmainly by the quality of the mi-crophone and loudspeaker usedrather than the recording andplayback circuit.

Although this module isquite simple, in most cases itwill require a certain amount oftechnical knowledge in order touse it properly. Consequently, itcannot really be regarded as abeginner's project.

SYSTEM OPERATIONThis project is based on the

ISD1416 “ChipCorder” inte-grated circuit from ISD. It is anextremely complex chip thatprovides all the active circuitryneeded for this application. Theinternal arrangement of this chipis shown in the simplified blockdiagram form of Fig 1.

The output level from anelectret microphone is ex-tremely small, and a largeamount of amplification isneeded in order to bring the sig-nal to a level that will drive theanalogue-to-digital converterproperly. A low noise preampli-fier followed by a high gain am-

plifier provides this amplifica-tion.

It is likely that the inputlevel will vary enormously de-pending on factors such as theparticular microphone used, thedistance from the user to themicrophone, and the loudnessof the user's voice. The inputstages of the device thereforeincorporate a simple but effec-tive AGC (automatic gain con-trol) action that prevents over-loading and the extreme distor-tion this would produce.

ACTIVE FILTERThe next stage in the main

signal path is a 5-pole lowpassfilter. In common with other digi-tal recordings systems, this oneuses a system of sampling theinput signal at regular intervals.

The sampled values arestored in memory, and thenplayed back through a digital-to-analogue converter during play-back. This converts the storedvalues back to the original sam-ple voltages, and recreates theoriginal signal.

One slight problem with anysampling system is that any in-put signals close to the sam-pling frequency produce a verysevere form of distortion knownas ”aliasing” distortion. In thiscase, the sampling frequency isjust eight kilohertz (8kHz),

which is well within the audiorange. This makes it important tohave a very effective filter to at-tenuate input signals at more thanabout one-third to one-half of thesampling frequency.

This is the purpose of the 5-pole active lowpass filter at theinput of the analogue-to-digitalconverter. With a sampling fre-quency of 8kHz, the maximumsignal frequency that can be han-dled by the system is only about3kHz or 4kHz, but this is perfectlyadequate for good results withspeech signals.

The ISD1416 data sheet isvery vague about the analog-to-digital and digital-to-analog con-verters, which are simply referredto as “analog transceivers”, butthe audio quality of the devicewould suggest that these have aresolution of at least 8-bits. TheEEPROM has a capacity of 128kilobytes, which together with thesampling rate of 8kHz gives amaximum message duration of16 seconds.

Typically, the memory retainsits contents for 100 years and hasa lifetime of one hundred thou-sand record cycles. Some of theaddress inputs are accessible, butin normal operation it is not nec-essary to take direct control of thememory. The internal control cir-cuits automatically start playbackat the beginning of the sampleand halt it at the end.

It is not necessary to use thefull 16 seconds of message time,and messages can have any du-ration up to the 16-second maxi-mum available. The device hasinternal clock oscillator and timingcircuits that provide suitable con-trol signals to the converters,memory, etc.

OUTPUTOn the output side of the con-

verter stage there is another 5-

&RQVWUXFWLRQDO3URMHFW

$

$

$

$

$

$

12 &211(&7,21

12 &211(&7,21

$

$

12 &211(&7,21

',*,7$/ 9

$1$/2*8(9

63($.(5

66

66

',*,7$/ 9

5(&25'

(;7(51$/ &/2&.

5(&25' /('

3/$<('*( 6(16,67,9(

3/$</(9(/ 6(16,7,9(

12 &211(&7,21

$1$/2*8(287387

$1/2*8( ,1387

$*&

0,&533+21(5()

0,&523+21(

$1$/2*8(9

63($.(5 ²

CC

CC

,6'3

Fig.2. Pinout details for theISD1416 speech recorder chip.

EPE Online, April 1999 - www.epemag.com - 396

pole lowpass filter and a smallaudio power amplifier. Any sam-pling method of recording in-evitably results in a steppedoutput waveform as the signaljumps from one sample level tothe next.

This effectively provides anoutput signal that is modulatedwith the sampling frequency. Inthis case the sampling fre-quency is well within the audiorange, and could produce aclearly audible tone on the out-put. The lowpass filter at theoutput smoothes the signal toremove the stepping, and in do-ing so it also removes any audi-ble breakthrough of the clocksignal.

The power amplifier at theoutput of the device is a bridgecircuit that can directly drive aloudspeaker that has animpedance of 16 ohms or more.Using a bridge circuit enables areasonable output power to beobtained despite the fact thatthe supply potential is only 5Vand the loudspeaker is a highimpedance type.

The ISD1416 also includesa substantial amount of controllogic that enables the recordingand playback functions to becontrolled by just two pushbut-ton switches. These control cir-cuits also govern such things aswhether the device operates inthe one-shot mode or playsback samples continuously.

PINOUTSPinout details for the

ISD1416, which is contained ina standard 28-pin DIL encapsu-lation, is shown in Fig.2. Thereare separate supply pins for theanalogue and digital circuits, butin normal use these are fedfrom a common supply.

Pins designated A0 to A7are the address inputs, but in

many applications these can sim-ply be connected to the 0V supplyrail and otherwise ignored. If thetwo most significant bits (A6 andA7) are high, the address inputscontrol the operating mode of thedevice.

Address input A3 is one ofthe most useful, and controlswhether the chip operates insingle-shot mode or loops contin-uously. This input is taken high inorder to set the device into thecontinuous loop mode.

There is provision for an ex-ternal clock circuit, and the clocksignal can be applied to pin 26.This facility is not normally re-quired, and pin 26 is then con-nected to the 0V supply rail.

RECORD/PLAYBACKRecording and playback are

controlled via three inputs, one ofwhich is used to produce recordcycles (pin 27). Like the othercontrol inputs, this pin is normallyheld high. However, it must betaken low and kept low while themessage is recorded.

An open collector output atpin 25 is switched on during this

period, and can be used to op-erate an LED indicator whichconfirms that the recording cy-cle is proceeding normally. Ifthe recording has not beencompleted by the end of the 16-second maximum recording pe-riod, the LED will switch off toindicate that the recording hasfinished.

Pin 23 and pin 24 controlplayback, and in most applica-tions it is the edge sensitive in-put at pin 24 that is utilized.Taking this input low, even mo-mentarily, results in the com-plete message being playedback. When using the level sen-sitive input at pin 23 the mes-sage is only played back whilethe input is held low, and themessage will be truncated if thisinput is returned to the highstate prematurely.

On the audio side of thingsthere are differential inputs atpin 17 and pin 18. Differentialinputs can help to ease prob-lems with stray pick up of noise,but in most applications therewill be no long microphone ca-bles and this will be purely aca-demic.

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 397

A resistor and capacitor net-work connected to pin 19 con-trols the decay time of the AGCcircuit. The output of the pream-plifier and the input of the am-plifier stage are available atpins 20 and 21 respectively, andan external capacitive couplingis required here. Four pins ofthe device have no internal con-nections.

CIRCUIT OPERATIONThe full circuit diagram for

the Voice Record/PlaybackModule appears in Fig.3. Inpractical applications not all ofthe components and linksshown in the circuit diagram willbe required. We will deal firstwith the components that MUSTalways be included.

The microphone MIC1 iscapacitively coupled to the in-puts of the voice chip IC1 byway of capacitors C6 and C7.Unlike most types of micro-phone, the electret variety has a

&RQVWUXFWLRQDO3URMHFW

built in preamplifier that requiresa power source.

Modern electret micro-phones usually have just twoterminals, and require an exter-nal load resistor for the pream-plifier stage, as shown in ofFig.4a. The preamplifier is usu-ally a simple JFET (junctionfield-effect transistor) circuit thatwill operate from a low supply

potential and draws little supplycurrent. In most cases the cir-cuit will operate at supply poten-tials as low as one volt or so,and with a supply current of lessthan 100 microamps.

INPUT CIRCUITThe input circuit used here

may look a little unusual, but it

,&,6'3

,&/

&

µ

&

&

Q

&

Q

&

QQQ

/

Ω

5

N

5

N

5

N

5

N

5

N

5

N

5

N

5

N

5

0

&

Q

&

Q

&

Q

5

N

'

5('

/.

/.

/.

6 6&

µ

287 ,1

&20

9

9 729

9

/. /,1.

5(&25' 3/$<%$&.

D

N

0,&

Fig.3. Complete circuit diagram for the Voice Record/Playback Module.

5 5

5

)(7

$03

)(7

$03

(/(&75(7

0,&55523+21(

,16( 7

(/(&75(7

0,&55523+21(

,16( 7

9

287387 222888777333888777

9 9

& &

&

– –

9

Fig.4. (left) Normal method of using an electret microphoneinsert, and (right) producing differential output signals.

EPE Online, April 1999 - www.epemag.com - 398

uses the method recommendedin the data sheet for theISD1416. This produces differ-ential output signals using themethod of connection shown inFig.4b.

Resistor R9 and capacitorC8 form a decoupling networkin the supply to the microphonecircuit, see Fig.3. This avoidsproblems with feedback throughthe supply lines, and digitalnoise being coupled into the au-dio path via the supply.

The 0V supply for the mi-crophone circuit is obtainedfrom pin 25 of IC1, which resultsin the microphone circuit beingswitched off except when arecording is being made. Thismaintains the very low standbysupply current of less than a mi-croamp.

Diode D1 is the Recordingindicator LED and R6 is its cur-rent limiter resistor. Incidentally,this LED also flashes briefly atthe end of each playback cycle.

Capacitor C5 and resistorR7 couple the output of the mi-crophone preamplifier to the in-put of the amplifier stage. TheC-R timing network for the AGCcircuit is comprised of C4 andR5. It is necessary to use afairly long time constant here inorder to avoid rapid changes ingain and consequent distortion.

Because the output ampli-fier is a bridge circuit it is notnecessary to use a coupling ca-pacitor in series with loud-speaker LS1. Under standbyconditions both outputs areabout half the supply potential,giving 0V across the loud-speaker.

In operation the outputs pro-vide anti-phase signals (i.e. asone output goes more positivethe other goes negative by anidentical amount). This gives amaximum output voltage that is

twice as high as using a single-ended output stage, and in the-ory the peak-to-peak outputvoltage can be double the sup-ply potential.

In terms of output power, abridge circuit gives up to fourtimes the output of an equiva-lent single-ended circuit. Al-though the circuit only operatesfrom a 5V supply, using a highimpedance (about 64 ohms)loudspeaker provides adequatevolume for most purposes.

If the unit will be used in anoisy environment it would bebetter to use a 16 ohmimpedance loudspeaker, but acomponent of this impedance isunlikely to be available. Usingtwo 8 ohm impedance loud-speakers connected in series isprobably the best option. Notethat using a loudspeaker hav -ing an impedance of less than16 ohms could damage IC1.

SUPPLY NEEDSThe ISD1416 is designed to

operate from a 5V supply, andvoltage regulator IC2 plus ca-pacitor C9 are unnecessary if asupply of about 4¬¬¬5 to 5¬¬¬5V isavailable. If the unit is to be bat-tery powered, three AA cells ina holder provide a nominal 4¬¬¬5Vsupply and seem to give goodresults. Due to the very low qui-escent current consumption ofno more than 10cally just 0

PA (and typi-¬¬¬5PA) it is unneces-

sary to use an on/off switch ifthe unit is used in a stand-aloneapplication.

If the module is used in-stead of an LED indicator andhas to operate from a supply ofabout 7V to 15V, it must bepowered via IC2, and both IC2and C9 must be included. Notethat the standby current con-sumption of the circuit will be up

to a few milliamps if IC2 is in-cluded, due to the current con-sumption of IC2 itself. This fac-tor should not be importantwhen the module is used inplace of an LED indicator, be-cause it should be switched offfor the majority of the time.

Link LK1 is included if theunit must operate in the modewhere it loops continuously, re-peating the message for as longas power is applied to the cir-

&RQVWUXFWLRQDO3URMHFW

COMPONENTSResistors

R1 10MR2, R3, R4 100k (3 off)R5 470kR6, R9 1k (2 off)R7 4k7R8, R10 10k (2 off)

See also theSHOP TALK Page!

All 0.25W 5% carbon fi lm

CapacitorsC1, C9 100n disc ceramic (2 off)C2 1n polyesterC3 470n polyesterC4 4u7 radial electrolytic, 50VC5 100n polyesterC6, C7 330n polyester (2 off)C8 200u radial electrolytic, 10V

SemiconductorsD1 red panel LEDIC1 ISD1416P voice record/playbackIC2 78L05 +5V 100mA voltage regulator

Miscel laneousS1, S2 pushbutton switch, push-to- make, release-to-break (2 off)MIC1 electret microphoneLS1 moving coil loudspeaker (16 ohms or more -- see text)

Printed circuit board availablefrom the EPE Online store, code7000225 (www.epemag.com );28-pin DIL socket; multistrandconnecting wire, solder pins,solder, etc. Some components are notrequired depending on the mode ofoperation (see text for more details).

$40Approx. CostGuidance Only

EPE Online, April 1999 - www.epemag.com - 399

cuit. For single-shot operationinclude link LK2 instead. One orother of these link-wires mustbe included, but obviously notboth .

If the module is used as astand-alone device for handlingmessages, both switch S1 and

S2 should be included. S1 isoperated while a message isrecorded, and S2 is pressedbriefly in order to play backmessages.

These switches could beincluded if the unit is used inplace of an LED indicator, but

they are not really needed. Acrocodile clip lead or virtuallyany short piece of wire can beused to connect the appropriatetwo pins on the circuit boardwhile your message is recorded.The same method can be usedto trigger the unit to check thatyour message has beenrecorded properly.

LED INDICATORWhere the unit is used in

place of an LED indicator, it isclearly necessary to have thecircuit trigger automaticallywhen it is powered-up. One wayof achieving this is to includecapacitor C3 and resistor R1.

Capacitor C3 keeps pin 24of IC1 low for several millisec-onds after power-up, and thistriggers it into a playback cycle.The message will, of course, beplayed back repeatedly if linkLK1 is included. Resistor R1discharges C3 when the poweris removed so that the unit issoon ready to trigger againwhen power is restored.

Access to the level sensi-tive “play” input at pin 23 is pro-vided, or link LK3 can be in-cluded so that this input is per-manently held low. On the faceof it this provides anothermeans of automatically trigger-ing the unit when it is powered-up, but this does not alwaysseem to have the desired effect,and the author would recom-mend using R1 and C3 whereautomatic triggering is required.

CONSTRUCTIONThe component layout and

(approximately) actual size cop-per pattern for the printed circuitboard (PCB) are shown in Fig.5.This PCB is available from theEPE Online Store (code7000225) at www.epemag.com

&RQVWUXFWLRQDO3URMHFW

5

5

5

5

5

&

&

&

&

&

&

555

5

5

&

&&&

/./.

/.

,&

9 7299

9

0,&

/6

N D6 6

225

,1 287

&20

'

Fig.5. Voice Record/Playback Module printed circuit boardcomponent layout, wiring and (approximately) \full-size

copper foil master pattern.

EPE Online, April 1999 - www.epemag.com - 400

The board is fairly straight-forward to construct, workingfrom the smallest to largestcomponent, but the ISD1416Pis a CMOS device and is notparticularly cheap. It is thereforeessential to adhere to the stan-dard anti-static handling precau-tions.

You must use a holder forthe “voice” chip IC1, but do notplug it into its socket until thecircuit board is otherwise com-plete. Try to touch the pins aslittle as possible, and keep thedevice away from any obvioussources of static charges suchas computer monitors and tele-vision sets.

The electret microphonemust be connected with theright polarity if it is to function

well. The lead that connects tothe metal case of the insert isusually the negative supply ter-minal, but where possible thispoint should be checked usingthe manufacturers or retailersliterature.

OPERATING CHOICEAs pointed out previously,

some of the components andlink-wires will not be required,and which ones that have to beleft out depends on your preciseapplication. The following ex-amples should help to clarifymatters.

Stand-alone Messaging Sys -tem

Omit IC2, C4, C9, link LK1,

link LK3, and R1. Power the unitfrom a 4¬¬5V battery and use the0V and 5V supply inputs.

Indicator L.E.D. Replacementfor 5V Supply

Omit IC2, C9, and link LK3.Include pushbutton switches S1and S2 temporarily while themodule is programmed andchecked, or improvise withpieces of wire. For one-shot op-eration include link LK2 andomit link LK1. For continuouslooping omit link LK2 and in-clude link LK1. Use the 0V and5V supply inputs.

Indicator L.E.D. Replacementfor 7V to 15V Supply

Omit link LK3. Includeswitches S1 and S2 temporarilywhile the module is pro-grammed and checked, or im-provise with pieces of wire. Forone-shot operation include linkLK2 and omit link LK1. For con-tinuous looping omit link LK2and include link LK1. Use the0V and 7V to 15V supply inputs.

CASING-UPIf the unit is constructed as

a stand-alone messaging sys-tem, it will obviously have to befitted in its own case and virtu-ally any small to medium sizecase should accommodate ev-erything. A grille is required forthe loudspeaker, and there arevarious ways of producing this.

The standard approach is tomake a large round cutout thatis slightly smaller than the diam-eter of the loudspeaker. A pieceof speaker cloth or fret is thenglued in place behind thecutout. A simple alternative is todrill a matrix of holes about fouror five millimeters in diameter,but this needs to be done verycarefully if a neat appearance isto be obtained.

&RQVWUXFWLRQDO3URMHFW

E

F

H

E

F

H

/('

/('

9

9 9

9

5D 5D

5E

5E

9

9 9

9

75D 75D

92,&(

02'8/(

92,&(

02'8/(

,17(*5$7('

&,5&8,7

,17(*5$7('

&,5&8,7

D

F

E

G

Fig.6. Two examples of using the module in place of an LED.

EPE Online, April 1999 - www.epemag.com - 401

Miniature loudspeakers in-variably lack any provision forscrew fixing, leaving little alterna-tive to gluing them in place. Onlyapply the adhesive to the frontrim of the loudspeaker, takingcare not to smear any over thediaphragm. Any good qualitygeneral-purpose adhesive shoulddo the job quite well.

Building the unit into a largerproject will require some carefulplanning, as space has to befound for both the circuit boardand the loudspeaker. This willnormally necessitate using asomewhat larger case than wouldotherwise be required. The noteson mounting the loudspeaker pro-vided previously also apply here.

It might be possible to addthe module into an existing pro-ject, but this is dependent onthere being sufficient space avail-able in the case. There must alsobe sufficient front panel space forthe loudspeaker. It will be neces-sary to partially dismantle the pro-ject so that the cutout for theloudspeaker and mounting holesfor the circuit board can be addedwithout damaging any of the origi-nal components.

If there is not enough spaceavailable to add the module intoan existing project, it might bebetter to construct it as an exter-nal add-on rather than re-housingthe project in a larger case. Atwin cable plus suitable connec-tors will then be needed to con-nect the two units together.

LINKING-UPIn order to use the module as

part of a larger project, it is es-sential to have a certain amountof technical knowledge. It is notpossible to provide detailed con-nection information for a widerange of projects here, and thisproject is aimed at those whohave some experience of elec-

tronic design and know whatthey are doing. In most cases acertain amount of experimenta-tion will be needed in order toget things working well.

If the main project operatesfrom a 5V supply it might bepossible to use an output of theproject to control the module viapin 23 or pin 24 of IC1. In mostcases it will be easier to simplyconnect it in place of an LEDindicator, making sure that it isconnected with the correct sup-ply polarity. The ISD1416P willprobably be destroyed if thesupply is connected with thewrong polarity.

The current consumption ofthe module is likely to be some-what higher than that of an LED(and can be as high as 30mA).There is no point in trying to usethis module with outputs thatcan only supply a few mil-liamps.

Sometimes, LEDs aredriven from a switching transis-tor, as shown in Fig.6a. Thistype of stage can usually pro-vide quite high output currents,and it should control the modulewithout any problems. If neces-sary the base resistor (Ra) canbe reduced in value slightly, butthis will not normally be neces-sary.

Of course, the moduleshould be driven direct from thecollector of the transistor, as inFig.6b, and current limiter resis-tor Rb should be omitted. If theLED is driven from the output ofan integrated circuit via a cur-rent limiter resistor (Fig.6c), itwill usually be possible to drivethe voice module direct fromthe output of the integrated cir-cuit, as in Fig.6d.

There are likely to be prob-lems if the output is specificallydesigned to drive an LED, andthere is a built-in series resistoror current regulator circuit. Di-

rect control of the voice moduleis then unlikely to work, and aswitching stage will have to beadded.

TESTING, TESTING,1-2-3

Once the project has beencompleted and all the wiring hasbeen thoroughly checked, it istime to power-up the circuitboard and record your mes-sage. Pressing switch S1 orwiring pin 27 of IC1 to the 0Vsupply rail will force the moduleinto a record cycle, and LED D1should light up to indicate thatrecording has commenced. IfD1 fails to light, disconnect thepower at once and recheck thecircuit board.

Assuming all is well, speakyour message clearly and in areasonably loud voice. Electretmicrophone inserts are not usu-ally very sensitive, so you willprobably have to be withinabout 300mm of the micro-phone in order to obtain goodresults.

Release S1 or remove thewire link as soon as you havecompleted your message, whichmust be no longer than 16 sec-onds in duration. D1 should thenswitch off.

In order to play back yourrecording, either press switchS2 briefly, or remove and re-connect the supply, as appropri-ate. If the volume is very lowand the signal is distorted, it islikely that the microphone inserthas the wrong polarity. Recon-necting it with the correct polar-ity and recording your messageagain should rectify the prob-lem.

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 402

Some weeks ago a readerrang the author at EPE:

I would like to be able to es-tablish the beat rate of variousmusical tracks on CDs. I havemade many enquiries but withoutsuccess, apart from one companywho suggested it could cost about5,000 UK Pounds to develop asuitable circuit. Can you help?

The above is the gist of amuch lengthier conversion inwhich the caller (a note of hisname has been lost sorry dearCaller!) put forward other situa-tions that could benefit from beatcounting keyboard typing rates,for example; rowing rates for an-

sorts of events. The results aredisplayed on an alphanumericliquid crystal display (LCD).

There are three ways of in-putting the events via built-inmicrophone, via a jack-pluggedconnection to other electronic cir-cuits, and via a panel mountedswitch.

Four modes are included:

Mode 1 displays the timeelapsed since monitoring be-gan; the elapsed time atwhich the last event was de-tected; the total eventscounted; the average rate atwhich the events have beenoccurring, selectable forcounts per second, countsper minute and counts perhour (CPS, CPM and CPH,respectively).

Mode 2 is a frequency counter,principally for monitoring anexternal electronically gener-ated frequency of 0V/+5Vamplitude, up to about20kHz.

Mode 3 counts the elapsed

Time flies and you can count it (or them) and muchelse that takes your fancy.

9(56$7,/( (9(17 &2817(5

E\ -2+1 %(&.(5

other; object countingpassed a point, and so on.

An immediate reactionby the author was that some-thing could be written in BA-SIC in about a dozen linesthat would display the rate atwhich keyboard keys werepressed. Such a programwould satisfy the caller's de-sire to count beat rates justhit a key at each beat while lis-tening to the music.

This constructional articleshows how BASIC can indeeddo the job, but also takes theidea a lot further, presenting aPIC-microcontrolled design thatwill monitor the timing of all

Listing 1‘EVENT.BAS 04DEC98 EVENT AND RATE COUNTERSCREEN 9: COLOR 11, 1: CLSLOCATE 6, 31: PRINT “EPE KEY RATE COUNTER”LOCATE 9, 22: COLOR 14PRINT “R RESET (ANY OTHER KEY FOR COUNT TRIG)”LOCATE 12, 14: COLOR 11PRINT “START LAST COUNT”; TAB(44);PRINT “C/sec C/min C/hour”COLOR 15: LOCATE 14, 14: PRINT TIME$B = INT(TIMER): GOTO wait2

waitit: z$ = INKEY$: IF z$ = “” THEN GOTO waititwait2: n = INT(TIMER): t$ = TIME$: LOCATE 14, 14IF z$ = “r” THEN PRINT t$: c = 0: b = n: s = 0t = n – b: IF t > 0 THEN s = c / tm = s * 60: h = m * 60LOCATE 14, 24: PRINT t$; TAB (33);PRINT RIGHT$(“ “ + STR$(c), 6); TAB(43);PRINT LEFT$(STR$(s) + “ “,8); TAB(53);PRINT LEFT$(STR$(m) + “ “,8); TAB(63);PRINT LEFT$(STR$(h) + “ “,8)C = c + 1; GOTO waitit

EPE Online, April 1999 - www.epemag.com - 403

time between pairs ofevents and is probably ofbest use with events thatare longer than about a sec-ond apart.

Mode 4 offers selection of mi-crophone or external signalsourcing for use by Modes 1to 3.

BASIC EVENTSFirst though, let's briefly

present and discuss the BASICprogram that offers the simplestanswer to the caller's query.

In fact, by the time the au-thor had put in a bit of screencosmetics, the program endedup a bit longer than a dozenlines, but not a lot. It is shown in

Listing 1 and can be used withQBasic or QuickBASIC.

In the program, the key-press rate is displayed as threeaverages, counts per second,counts per minute and countsper hour. Type in the listing,save it as any name you like(EVENT.BAS, perhaps) and runit. (It's also available with thePIC software see later.)

Using BASIC's secondstimer, the time in seconds (b) atwhich the program is started (orreset) is noted. Each time akey-press is received, time (n)of its receipt is noted and acounter (c) incremented. Sub-tracting b from n gives the timet elapsed so far. The count isnow divided by t to give the av-

erage rate of key-presses persecond (s).

This value is then multipliedby 60 to give the count rate perminute, and this in turn is multi-plied by 60 to give the count rateper hour. Following calculation,the answers are displayed in tab-ulated positions on screen.

Pressing key r (not capital R)resets the counter and startingtime. Any other key could benominated as the Reset key in-stead of r. When monitoring asuccession of events (such asmusical beats), the programshould be reset by pressing r intime with the beat.

The program continues indef-initely until the CTRL and BREAKkeys are jointly pressed. Exit from

&RQVWUXFWLRQDO3URMHFW

R

S

U

2!)F

B"! [

93#'(< %

333(!!! ```

'

C! ?>?66

3!

""P

3?=

9>

3#! ^

B2"

?C3"3<; ?ED

H!

#"'&(

=8j!%

7>4

=1>E1<

49?BBB222'

3<; &

#

$

%

%

)

!!!

!

"

#

93"@93!&3($

?C3!3<; 9>

=3<B

3"

! ^

!&

$

?ED

B!! [

B#! [

3$! ^

F5

D?3;9BBB111$

9>DB2

BBB2!

B111

!

"

#

!$

!!!'

(

"

#

&

'

(

!

93!Q<=#%(

3%$^'

B$!=

B(! [

3?>DB1CD

3?>DB1CD

4&

B!!! [

B! ! [

B)! [

7>4

!$

$

&

%

4'

BBBC

5

G

!

B5C5D

1>4

=935HD@5B9?4 =?45

B%! [

>3 H"<34

=?4E<5

F5

>>>333

!!!

!

"

#

'

(

)

444#

$

%

"

!

"

FB!" [

#

FB"! [

DB!

23%$)

B&$' [

93!R<=#%(

C%

C" C# C$

"

#

!

%

&(

'

$

291C

F

B'

$['

FB#

! [

3&

! `

3)

""P

4!!!

!>$ $(Q [

=93 !

>>>333

5HD 3<;B!"

![

C;!

1@@B?H %%F

C55 D5HD

Fig.1. Complete circuit diagram for the Versatile Event Counter.

EPE Online, April 1999 - www.epemag.com - 404

BASIC in the normal way (ALT,F, X).

There you are, kind Caller an answer for free. But even theenhanced electronic version isnot going to set your wallet backvery much, about 25 quid (forthe benefit of overseas devo-tees, a quid is English slang forone pound Sterling what di-versities you learn through EPEOnline!).

(Which reminds the authorof a time when he was in Egypt:the “driver” of a horse-drawncab he had hired believed thatthe term lubbly-jubbly was En-glish for money what cruel“Dell Boy”-type tourist hadtaught him that?)

(Perhaps we should explainthat Dell-boy was a lovablerogue who frequently used theterm in a long-running British TVcomedy series. Ed.)

However, we digress onwith the story ... the design for amore sophisticated bit of elec-tronics counting gadgetry.

COUNTER CIRCUITIn Fig.1 is shown the com-

plete circuit diagram for the PICEvent Counter. Some of you reg-ular readers may now be puzzled

cuit before somewhere? haven't we seen that same cir-

Quite right you have(almost), as part of the PIC TapeMeasure in EPE online Novem-ber '98. Unashamedly, it is almostidentical. And why not? The func-tions of both designs are verysimilar amplifysound pulses,calculate delaysbetween themand display theresults on anLCD screen.

The previ-ously requiredultrasonic trans-mitter has beendropped, ofcourse, the soft-ware has beenmodified and afew componentshave beenchanged, but

otherwise the circuits are twins.So much so, in fact, that thesame printed circuit board isused for both circuits. Here's aclassic example of how design-ers can benefit from PIC micro-controllers.

An electret microphone(MIC1) is used to detect audiosignals, such as the ticks of aclock, or the snap of fingers, orother intermittent sound events.It is biased to the 5V power linevia resistor R7 and panel-mounted potentiometer VR3.The latter is used (somewhatunconventionally) as a simpleinput signal amplitude control(its configuration here savedmaking significant changes tothe existing PCB for a moreconventional level control to beplaced somewhere within thefollowing amplifier chain).

Between them, opampsIC1a and IC1b amplify the inputsignal that enters capacitor C3.Capacitor C6 across IC1a re-stricts upper frequencies to min-imize general background noisepicked up by the microphone. (Itis a component not used in theTape Measure.)

&RQVWUXFWLRQDO3URMHFW

Front panel display window and function buttons;Mode 1 shown.

Prototype PCB mounted “below” the display module.

EPE Online, April 1999 - www.epemag.com - 405

INDIVIDUAL EVENTSThe aim has been to allow

lower amplitude and lower fre-quency transient audio signalsto be picked up and detected asindividual events. Constantlower frequencies (e.g. 50Hz)are attenuated by using a low-ish value for capacitor C5.

From IC1b, the amplifiedsignal is rectified by diode D1and fed into capacitor C9.These two components replacecapacitor C6 and resistor R7that were in the same positions

&RQVWUXFWLRQDO3URMHFW

in the Tape Measure.

Because C9 replaces R7, itis connected to the positive rail,rather than more conventionallyto the 0V rail; the effect is thesame allowing the rectifiedmultiple pulses from IC1b to be“combined” into a longer pulse.This allows, for example, a briefaudio “pip” (a short burst of anaudio frequency) to be con-verted to a single voltagechange on C9.

Preset potentiometer VR1feeds the voltage across C9 totransistor TR1. Nominally, the

quiescent (stand-by/no-signal)output from IC1b is about 2¬¬5V(half the supply line voltage).VR1 sets the initial bias pro-vided by this voltage to thebase (b) of TR1 to about 0¬¬55V.Signal voltages across C9 thatcause the bias to rise to about0¬¬6V turn on TR1 and cause itscollector (c) to fall from the nor-mal condition of +5V to 0V.

Pin RB7 of the PIC micro-controller, IC2, is connected tothe collector of TR1 and thesoftware has been written to re-spond to and count the 5V/0Vchanges in voltage, using thecount values for subsequentcalculations.

The results of calculationsare output to the alphanumericLCD module, X2. This is used in4-bit mode (see the LCD articlesin the EPE Online Library atwww.epemag.com for moredetails on this). Preset VR2 isused to set to the LCD contrast.

Power is supplied by a 9VPP3 battery, B1, and isswitched on by S1. RegulatorIC3 reduces and stabilizes thevoltage to +5V (the maximumthat the LCD can accept). Cur-rent consumption is about 7mA.

The PIC is operated at3¬¬¬2768MHz, as set by crystal X1in conjunction with capacitorsC7 and C8.

Switches S2 to S4 haveseveral functions, which are ac-tivated by the software whenthey are pressed. In Mode 1(see earlier), switch S2 (Period)steps the display through thethree counting periods (CPS,CPM and CPH), on a 3-step re-peating cycle. In this mode, S4(Reset) resets the count andtiming start values to zero.

Switch S3 (Mode), on a 4-step repeating cycle, steps theprogram through Modes 1 to 4.The latter offers microphone

B

!!

B

!

B

)

3"

3$

B#

B"

B

! B

$

3

%

B

%

B

&

3#

3&

B

(

B

'

H!3'

3(

93" 93!

93#

3!

FB!

9>?ED

3?=

FB"

DB!

US

R

H" <34 =?4E<5!

!

!$

!$

B5C5D =?45 ?>?66@5B9?4=1>E1<

C" C!C#C$C%

4!

3)

FFF5

B54

2<13;

D?

21DD5BI2!

" '

=93 !

FB#

C;!

B

!"

Fig.2. PCB component layout, interwiring and (approximately)full size copper foil master for the Versatile Event Counter.

EPE Online, April 1999 - www.epemag.com - 406

use (MIC) or external signal in-put (EXT/S5). “External” meansthat signal pulses can be inputfrom an external signal genera-tor via socket SK1 and resistorR12, or they can be triggered

manually by switch S5.

The MIC and External sig-nals are routed to different pinsof the PIC and it is the softwarethat selects which pin is to betaken as the signal source thisavoids having to use achangeover switch to select thesource.

When the MIC/External op-tion is offered (Mode 4), press-ing the Reset switch (S4) alter-nates between the two options.

SOFTWAREThe program for the PIC

microcontroller has been writtenin TASM. The software(including that for the BASICprogram in Listing 1) is avail-able via the EPE Online Libraryat www.epemag.com . (Pre-programmed PICs are avail-able. For further details see thismonth's Shop Talk page.)

The software is too long(around 960 commands) andcomplex to discuss in this arti-cle, but a lot of comments areincluded in the source code list-ing that will help PIC-

programming readers under-stand some of what it does.

Essentially, the Mode 1 rou-tine of the PIC software per-forms the same operation as theBASIC program in Listing 1, butfar more commands are re-quired.

Of passing interest may bethe fact that this program wasnot written from scratch. It isheavily based on (lifted from!)the author's software for PIC-Agoras (Bike Computer, EPEApril/May '97). Many of thoseroutines, which include suchfunctions as timing, multiplica-tion, division, binary-to-decimalconversion and LCD display,required little modification tomake them usable for thisEvent Counter.

CONSTRUCTIONDetails of the printed circuit

board component and track lay-outs are shown in Fig.2. Thisboard is available from the EPEOnline Store, code 7000207. Asstated earlier, this PCB is identi-cal to that for the PIC TapeMeasure.

&RQVWUXFWLRQDO3URMHFW

COMPONENTSResistors

R1, R5, R8 to R11 10k (6 off)R2, R3 100k (2 off)R4 1MR6 470kR7 4k7R12 1k

See also theSHOP TALK Page!

All 0.25W 5% carbon film or better

CapacitorsC1, C9 22u radial elect. 16V (2 off)C2 to C4 100n ceramic disc, 0.2in spacing (3 off)C5 4n7 polystyreneC6 100p polystyreneC7, C8 10p polystyrene (2 off)

SemiconductorsD1 1N4148 signal diodeTR1 BC549 npn transistorIC1 LM358 dual opampIC2 PIC16C84 (or PIC16F84) pre-programmed microcontroller (see text)IC3 78L05 +5V 100mA voltage regulator

Miscel laneousS1 miniature s.p.s.t. toggle switchS2 to S5 miniature push-to-make switches (4 off)SK1 plastic 3.5mm mono jack socketMIC1 miniature electret microphoneX1 3.2768MHz crystalX2 16-character 2-line alphanumeric LCDB1 9V PP3 battery and clip

Printed circuit board availablefrom the EPE Online Store, code7000207 (www.epemag.com );plastic case, size 120mm x 64mmx 40mm; 8-pin DIL socket; 18-pinDIL socket; nuts and bolts, M3 x12mm (for LCD mounting) (2 off);connecting wire, solder, etc.

$40Approx. CostGuidance Only

Potent iometersVR1 20k min. cermet preset, roundVR2 10k min. cermet preset, roundVR3 100k rotary, linear

PCB folded back to reveal the LCD modulebolted behind the display window.

(Wires disconnected

EPE Online, April 1999 - www.epemag.com - 407

Note, though, that a trackcut is needed on the PCB, asshown in Fig.2. Because the re-sistor feeding to MIC1 (R7) is acomponent that was not re-quired with the Tape Measure, aplace on the PCB had to befound for it (without redesigningthe PCB). The logical position isthat shown, making use of twoexisting pads. However, one ofthe pads was previously usedfor connection of one side of theultrasonic transmitter to the PIC.It is this connection that needsto be cut as shown.

Even though the PIC pininvolved can be set in softwareto high impedance, it was feltthat there might be a smallamount noise emanating fromthe pin which would be ad-versely amplified via the micro-phone routing. Hence the pin'sisolation by a track cut.

It is suggested that assem-bly of the components is pur-sued in order of size upwards.Sockets should be used for bothIC1 and IC2 (note that a wirelink sits under the socket for IC2 make it first!).

Capacitor C6 (another com-ponent not required for the TapeMeasure) has to be soldered onthe track-side of the PCB acrossthe pads for resistor R4.

Connections to the LCD canbe either via short strandedwires (insulated) or by rigid (un-insulated) solid wires. In eithercase, note that the LCD and thePCB are mounted back-to-back“double-decker” fashion, withthe LCD screen and the PCBcomponent side facing outwardsin opposite directions.

If using rigid connections,use wire of about 1mm diameter(resistor cut-offs might be OK ifthey are long enough). Solderone end of each wire into theLCD terminal pads, with the

long end protruding below theLCD. Trim all the long ends tothe same length and then pa-tiently and with the aid of asmall screwdriver or thin-nosedpliers, push each wire into therespective PCB holes fromthe track side.

It will help if one outer wireis soldered first, then the outerwire at the other end, ensuringthat the spacing between theLCD and the PCB is even, atabout 12mm or so. Then solderthe intermediate wires.

It is advisable to insert alength of card between the LCDand the PCB (taping it in posi-tion) to prevent contact betweenboth items. Also cover theswitch tags with insulating tapeto prevent them connecting withthe PCB tracks.

Do double-check your com-plete assembly for correctnessbefore connecting power.

ENCLOSUREFitting all the components

into the suggested plastic caseis a bit of an exercise in com-pactness. But as you can seefrom the photos, it can be doneand with a bit to spare.

You will see that it is intothe base of the case that theLCD is mounted and that theswitches are mounted alongsideit. The precise positioning willdepend of the size of the LCDmodule, a factor that seems tovary between manufacturersand availability from the suppli-ers.

You must also ensure thatyou leave room for the PP3-sizebattery at one end and the po-tentiometer in the side of thebox. There is plenty of space,however, for mounting the jacksocket in the other end of thebox, but you must allow space

for the microphone to pokethrough a hole in the same end.

Study the photographs,measure your components, planand mark out their positions,and then drill the necessaryholes. The slot for the LCD isalso achieved by drilling mak-ing a perimeter of holes withinthe proposed slot area and thenfiling down the rough edges untilsmooth and to the correct di-mensions.

Bolt the LCD into its slot(the author just used two boltsrather than the four allowed bythe LCD module). Then wire upthe remaining components asshown in Fig.2. Note that resis-tor R12 is mounted on the tagsof socket SK1 this donepurely for physical convenienceas there is no provision for theresistor to be mounted on thePCB.

With IC1 and IC2 omitted,switch on the power and checkthat there is +5V (within a fewper cent) on the output of IC3. Ifthere is not then there is either ashort circuit on the board (0Voutput) or IC3 is incorrectly in-serted (much greater than 5Voutput) provided that the con-nections back to the battery arecorrect, of course!

Assuming all's well, switchoff and insert IC1 and IC2.Switch on again and observethe LCD.

At first you may not seeanything on the LCD adjustthe contrast control VR2 until adisplay similar to that in the sec-ond photo is seen. This is thedefault screen that will alwaysappear when first powering up.

Turn the exterior poten-tiometer (VR3) fully anti-clockwise (minimum signalgain). Now, with a meter(preferably digital) set to readabout 5V DC, monitor the volt-

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 408

age at the base of TR1 and ad-just preset VR1 until the readingis about 0¬¬55V, which is typicallyjust below the turn-on point for asmall-signal silicon transistorsuch as the BC549 used here.

This bias voltage sets thesensitivity of TR1 to signals ar-riving from IC1b and may beadjusted slightly later in the lightof experience (individual tran-sistors may exhibit slightly dif-ferent characteristics).

Let's now step you throughwhat's what of the unit's fullworkings.

OPERATIONThere are five groups of in-

formation shown on the screenyou should be looking at imme-diately after switching on (asalready shown in the secondphoto). At this time the unit is inMode 1 and by default it is themicrophone signal routing thatis being monitored.

At the top left is shown thetime elapsed following the unit'sresponse to the first signal pulsereceived. It is formatted asHH:MM:SS (hours, minutes,seconds). Make some noisenear the microphone (click yourfingers or something!) and youshould see this display startcounting (use VR3 to increasethe signal level if necessary).

The bottom left displayshows the time (also asHH:MM:SS) at which the lastdetected pulse was received intermittently click again a fewtimes and it should change itsreading accordingly.

The top right display showsthe number of pulses that havebeen received so far (to fivedigits).

At the bottom right, the dis-play shows the average numberof pulses that have been occur-

ring in each second since youstarted the unit counting, to thenearest two places of decimals.

Sandwiched between thetop left and top right values willbe seen the single letter S. Thisindicates that the unit is set forthe counts per second range.

Briefly press switch S2(Period) and observe that the Schanges to M, indicating countsper minute, again to two deci-mal places. A further press ofS2 will show H for counts perhour, this time as an integervalue (no decimal places).Pressing S2 again will return thedisplay to S for seconds. Notethat S2 will only be respondedto after the first count pulse fol-lowing reset has been received.

Periodically click your fin-gers while observing the countperiod displays.

Having returned to S, brieflypress switch S4 (Reset) and re-main silent all values shouldbe seen to read as zero. Clickagain to start it all off again.

MODE 2To enter Mode 2 from Mode

1 (and it can only be enteredfrom Mode 1), press switch S3(Mode). The screen shouldchange to show “00000 Hz” onthe top line and “FREQUENCY”on the bottom line. Thisis the frequency count-ing mode and is in-tended principally foruse when an externalsquare wave signal isbeing fed in via SK1(see later). You may getit to respond to finger

clicks and othernoises but the valuesdisplayed will not bemeaningful.

In Mode 2, thestatus of the PIC'schosen input pin(RB6 or RB7) is re-

peatedly monitored for periodsof one second. At the end ofeach period, the number ofpulses counted during that timeis displayed on the top line.

When set for External input,the maximum rate of meaning-ful input is about 20kHz. Fre-quencies much greater than20kHz can be input but, be-cause of the limits imposed bythe rate at which signal levelchanges can be responded toby the software, the displayedanswers will be incorrect. Theycould well be sub-harmonicrates since one or more pulsesarriving may be overlooked dur-ing sampling. There is no wayfor the software to detect what ithas missed!

MODE 3When in Mode 2, pressing

S3 (Mode) sets the program anddisplay into Mode 3. All that isseen on screen when first en-tered is “0000.00 SECS” on thefirst line, and “PULSE” on thesecond. Click fingers in front ofthe microphone the displaywill now show the number ofseconds, to two decimal places(hundredths of a second), be-tween entering Mode 3 and yourfinger click. Click again and theperiod between your first and

&RQVWUXFWLRQDO3URMHFW

Typical screen display in Mode 2.

Typical screen display in Mode 3.

EPE Online, April 1999 - www.epemag.com - 409

second clicks will be shown.

The rate at which you canobserve changes of count is thedetermining factor in this mode you will probably find thataround five events a second isabout the maximum your eyes/brain will register clearly.

The slowest rate at whichtwo events can be timed andcorrectly shown is 9999.99 sec-onds.

MODE 4From Mode 3, Mode 4 is

entered by again pressing S3(Mode). It is from this mode thatthe signal route is selected either microphone or external.

At this moment you shouldsee the words “SOURCE MIC”displayed. Press S4 (Reset) todisplay “SOURCE EXT/S5”. Re-peated pressing of S4 cyclesthe routing message betweenthe two options. End up nowwith the EXT/S5 messageshown.

Having set the signal rout-ing from this mode, the routingwill be applied for each ofModes 1 to 3. Mode 4 is exited

by pressing S3 (Mode) again.Press it now.

This action will return you toMode 1. You now have two op-tions for triggering the unit, ei-ther by an external signal viaSK1, or by pressing switch S2.The microphone routing is nowinactive, and you can be asnoisy as you like (family/neigh-bors permitting!).

Repeatedly pressing switchS5 (Manual) causes the unit'scounting and display to respondas they did when you finger-clicked in MIC mode. This isuseful for counting such eventsas the beat rate of music, theidea that prompted the designof this Event Counter.

The rate of switch responseis limited by the rate at whichyou can push it (although a soft-ware limit of 100Hz applies inMode 1 switch bounce problems).

helping to prevent

As with the MIC routing,Mode 1 offers selection of thesame three periods by use ofS2 (CPS, CPM and CPH).

To check the response tosignals fed in via SK1, plug in asignal generator. It should be

set for 0V/5V square wave out-put at about 2Hz or so (thoughit's not critical just lets you ob-serve a bit better than a fastrate would).

Note that resistor R12,which is in series with the exter-nal signal and the PIC, allowssignals a bit greater than +5V tobe input. It's probably bestthough to keep them belowabout +15V to avoid possibledistress to the PIC. (In this ap-plication, the voltage actuallyreaching pin RB6 of the PICmust not exceed +5V.)Negative voltage signalsmust NOT be input. You arelikely to find that the PIC willrespond to signal pulse levelsdown to a minimum of about3¬¬¬5V.

While the signal generatoris plugged in, also check out theunit's response to it from Mode2 and Mode 3.

Should you press S5(Manual) while an external sig-nal is connected, no damagecan occur because of the pres-ence of R12 (but the PIC's re-sponse to the conflicting signalsources will suffer, of course).Note that the act of changingmodes (S3) resets all timing/event counters to zero.

IN USEThe prototype Event

Counter has been found to beextremely responsive to someastonishingly low level audio(via MIC) signal sources. Suchsources have included theonce-per-second (1Hz) ticks ofa small “carriage” clock, and thethree-per-second (3Hz) tick-tocks of EPE Editor Mike Ken-ward's period mantel clock(nicely wooden and 1930's ish). The 10 meters distantsound of Wife's “Dinner NOW!” war-cry has also been

&RQVWUXFWLRQDO3URMHFW

EPE Virtual Scope display showing 3Hz clock ticksand TR1 response.

EPE Online, April 1999 - www.epemag.com - 410

“observed” (undesirably duringtiming tests, as it happens!).

ED'S CLOCKThe 3Hz clock proved an

interesting subject. Originally,Mode 1 and Mode 2 were pro-grammed for sampling at a rateof 25Hz (the rate the author nor-mally uses for PICs performingHH:MM:SS counting), whileMode 3 was set for 100Hz (toreadily obtain the 1/100ths of asecond accuracy required).

It was a pre-requisite of thisdesign that it should respond toMike's 3Hz clock. “How useful”,he'd said, “if it could havehelped in setting the clock's tim-ing accuracy when newly ac-quired”. (By newly is meantChristmas present time a coupleof years ago we staff shalldeny it had any connection withWimborne Market!)

Anyway, first tests of EventCounter and 3Hz Clock showedthat a correct response was ob-served in Mode 3 but not inMode 1. Quick thinking on au-thor's part and a few minutes ofreprogramming for everything tobe sampled at 100Hz cured theproblem up to a point. Thepoint was raised by the tick-tock: the tocks were louder thanthe ticks (see photo of computerscreen display).

The answer now was in thesetting of level control VR3,carefully adjusting the level tobe enough for the ticks to beresponded to correctly without

the amplification being satu-rated by the tocks. Success wasachieved (and the author'shonor remained untarnished!).

Be aware that in the earlyminutes of obtaining repetitivepulse averages with somethingsuch as a clock, the averagesmay appear to change a bit er-ratically. This is due to the limi-tations of the multiplying anddividing routines in the software,which have only one byte inwhich to store fractions. The av-erages will “settle down” as theminutes and count valuesprogress.

EVENT HORIZONThere must be innumerable

situations in which you couldfind use for this design (“subjectonly to your imagination” is theusual if overworked expres-sion when a really versatile de-sign is published).

One option that comes tomind is using two or more exter-nal sensors (e.g. pressure padsor opto-transmitter/receivers)interfaced to the unit via an ORgate race timing, for example.

So, it's over to you now, tobeat the clock and get yourcomponents purchase order inthe post before this evening'scollection! Or are you doingthings the ”modern” way, via theNet? It offers 24-hour shoppingand has very high security fora start, you can order the PCBright now via the EPE OnlineStore at our web site:

www.epemag.com . Throughthe same address you can alsoget to our Library and download(free) the software.

Do make sure you read thismonth's Shop Talk page wherewe tell you more about compo-nent sourcing (including whereto get the pre-programmed PICmicrocontroller).

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 411

In last month’s PhizzyB con-struction article we introduced theconcept of the PhizzyBot, which isa very simple motorized platformthat transforms a PhizzyB into asimple buggy. This month weshow how easy it is to add a se-ries of detector “feelers” to thePhizzyBot platform (plus theinterrupt-driven switch modulefrom the Feb ’99 construction arti-cle). This means that, along witha suitable program (described inthe associated PhizzyB tutorialfeature elsewhere in this issue),the PhizzyBot can now be em-powered with movement, collisiondetection, and obstacle avoid-ance routines.

that controls the direction ofeach motor. By driving, revers-ing, or stopping either motor,the PhizzyBot can be made toadvance, reverse, turn or spin ineither direction.

However, since there is no“feedback” in the system at thisstage, your average fearlessPhizzyBot will travel blindly untilit collides with something, afterwhich it will be forced to astandstill.

The system to be describednow is intended to demonstratefurther principles of computercontrol, in this instance usingmicroswitches as limit detectorsin conjunction with a computerprogram that forces a suitableresponse from the motors whena collision is sensed.

The simplest way of incor-porating collision detection issimply to add an array of mi-croswitches around the periph-ery of the chassis. These arehooked to an interface board,which connects directly to aPhizzyB input port.

Wheelie feelies give the PhizzyBot a sense of touch(and a sense of humor?)

3KL]]\% &20387(56 E\ $ODQ :LQVWDQOH\

&RQVWUXFWLRQ3KL]]\%RW )HHOHUV

GETTING SWITCHED ONThis penultimate construc-

tional article describes the addi-tion of six microswitches to thePhizzyBot motorized platform.The switches are used as sim-ple mechanical collision detec-tors. As explained in the tutorial,it is possible to use up to eightmicroswitches and alter the pro-gram accordingly, but the au-thors felt that six were enough,and besides, it was raining atthe time and they didn’t fancy atrip to their parts store!

The PhizzyBot hardwareconsists of two DC gearmotorsand a simple relay driver board

3 >?>3

>?D EC54

D? !&G1I@9> 85145B

?> 9>D5BBE@D 2?1B4

CD5555<?@5B1D9>7

<5F B 25>41CB5AE9B54

Fig.1. A typical microswitch.

EPE Online, April 1999 - www.epemag.com - 412

If the PhizzyBot strikes anobstacle, the corresponding mi-croswitch will close and send aninterrupt signal to the PhizzyBcomputer. The program canthen respond by stopping themotors (perhaps for a timed pe-riod) and then reverse or moveoff in another direction. The tu-torial article describes the pro-gramming technique in full, butnow let’s look at the hardwareaspects required to give yourPhizzyBot some “whiskers”!

As was previously noted, itis the interrupt-driven switchmodule (Feb ‘99) that is used tointerface the “whiskers” to thePhizzyB computer, and this willbe connected to input port$F012 by a ribbon cable. Theoutput port $F032 is used tocontrol the DC gearmotors via asimple driver board, as de-scribed last month.

You will recall that the inter-rupt board includes a 16-pinheader, which, effectively, is aset of solder pins in parallel withthe eight keypad push-switches

S0 to S7. The microswitchesare added in parallel to the ex-isting keypad using the 16-pinheader, to which their connec-tions are soldered.

The prototype system usedmicroswitches which had 2¬¬5in(60mm) steel levers that couldeasily be bent to shape as re-quired. Because they have avery low mass, it proved quitesimple to stick the switchesaround the edge of the Phizzy-Bot platform merely by usingdouble-sided adhesive foampads. The steel levers werethen bent outwards so that theywould protrude and act as“antennae”.

ASSEMBLY DETAILSConstruction is very easy,

but there are one or two me-chanical points to bear in mind.Assuming that you have builtthe PhizzyBot platform success-fully last month, the interrupt-driven board should now be lo-cated on the platform where itcan “reach” input port $F012

using a 20-way ribbon cablefolded as required.

Unless you decide to makeup a new IDC lead, the length ofany made-up cable that you haveavailable will determine wherethe interrupt-driven board can befitted, so check this carefully.Then fix the input board to theplatform using printed circuitboard (PCB) stand-off hardware(see photos).

Take care not to damage thewiring on the underside of the ex-pansion board – over time theauthor sprayed several generouscoats of aerosol lacquer onto thisexpansion board in order to helpsecure it and protect the wiringfrom harm. The switchboard wasmounted at the front of thePhizzyBot in the prototype by us-ing 10mm threaded pillars withM3 panhead screws.

The next stage is to solder apair of leads to each of the sixmicroswitches. The two rearswitches (numbered 2 and 3) willrequire a connecting lead up to12in (300mm) long, the wires forthe remaining switches should beof corresponding length. It is farbetter to use six different coloredwires in order to color-code the

&RQVWUXFWLRQDO3URMHFW

6B?>D

B51BG8555< CG9>7C

E>45B>5551D8G85>

B5F BC9>7

C"

9@"

9@! 9@$C! C$

9@#

C#

C C%

9@ 9@%

Fig.2. Layout and orientation of the sixmicroswitches on the underside of the

PhizzyB platform.

Rear view of the platform showingmicroswitches positioned in relation to the

other components.

EPE Online, April 1999 - www.epemag.com - 413

microswitches, which will helpwith the interwiring enormously.Be quite generous with thelengths of wire at this stage anddon’t be afraid to waste a little.

An example of a typical mi-croswitch is illustrated in Fig.1.They have three terminals, usu-ally marked “n.o.” (normallyopen), “n.c.” (normally closed)and “C” (common).

You may need an ohmme-ter or continuity buzzer to deter-mine which terminal is which.For our purposes we are inter-ested in the common andnormally-open terminals (whichwill therefore close togetherwhen the PhizzyBot hits an ob-stacle). Check the types used inyour particular case, then soldersuitable lengths of general-purpose hook-up wire to them,and then proceed to stick themaround the edge of the platform.

No circuit diagram was con-sidered necessary this month,so Fig.2 shows how theswitches were organized on theprototype, noting that the hingesof the levers were positioned asdepicted in the diagram.

In fact the switches werelocated where it was thoughtthey would best act as “feelers”,enabling the PhizzyBot to detect

an obstruction at the front or rear.Since the prototype’s wheels pro-trude from the sides, the levers ofthese microswitches (numbered 1and 4) were bent outwards so thatthey will be tripped by “passing”objects. The feelers were alsocurved to help prevent themsnagging on any obstructions(though this didn’t always quitework).

It should be pointed out thatthe design also relies on the factthat the rear wheel (of the modelaircraft type specified in thePhizzyBot’s constructional details)will swing back underneath thePhizzyBot as soon as the platformreverses, which means that therear wheel is then tucked neatlyout of the way. This leaves therear switches S2 and S3 clear todetect collisions when the Phizzy-Bot reverses.

Be prepared for some trialand error, and you might alsoconsider adding “feeler” wires tothe microswitches to extend thelevers even further, noting thatthe object is simply to demon-strate the principles and there isplenty of scope for you to impro-vise and experiment.

At this stage it is worthdouble-checking before proceed-ing any further, to ensure thateach pair of wires does short to-

gether when the correspondingmicroswitch is closed: use yourohmmeter to confirm this.

ONWARDSThe six pairs of microswitch

wires can now be soldered tothe 16-way pin header. Eachswitch should be hooked to thecorresponding pins (see Fig.4 ofthe Feb ’99 PhizzyB construc-tional article for further details),so switch S0 should be wired toIP0, S1 to IP1 and so forth (andyou will now see why color cod-ing the wiring is a good idea!).

Since the pins on theheader are quite tightly packed,then rather than wrap the wiresaround them, it was found bestto employ a “re-flow” solderingtechnique – each pin should begenerously tinned with the sol-dering iron, and the bared endof the hook-up wire should betinned as well. Then simplytouch the hook-up wire to thepin and melt the solder togetherto form a joint.

It is also an extremely goodidea to use short lengths of PVCsleeving to eliminate the possi-bility of short circuits: a 1in(25mm) length should be placedover the wire before solderingthe joint and slid back over the

&RQVWUXFWLRQDO3URMHFW

Interrupt-driven module connected to thePhizzyB input port.

Microswitch leads connected to the interfaceboard.

EPE Online, April 1999 - www.epemag.com - 414

solder when all joints are com-plete. The result will be a loomof 12 wires, which on the proto-type were contained in an offcutof poly spiral wrapping.

Adhesive tie-wrap baseshelp to route the wiring on theunderside of the PhizzyBot plat-form. This should be routed toavoid impeding the movementof any microswitch levers. Withall the interwiring complete,connect the interrupt-drivenboard to the PhizzyB using anIDC lead.

The prototype PhizzyBotwas entirely self-propelled byusing a 9V Nickel-Cadmiumbattery to power the PhizzyB atthe DC inlet socket (see pho-tos), giving 20 to 30 minutes ofoperation (the twelve 7-segmentdisplays when illuminated forma major drain on the battery!).

You may prefer simply totest the design using the mainsadapter, but the PhizzyBot isquite a hyperactive little fellow,and when scampering aroundthe floor it will create a passableimpression of a double reef knotin the power supply cable in notime at all! (Fortunately at timeslike this the on-board memory

&RQVWUXFWLRQDO3URMHFW

back-up battery will prevent lossof the program when the mainpower is temporarily inter-rupted.)

BEFORE SWITCHINGON

Ensure that the DC motorcontroller and interrupt boardsare both hooked up to the main

PhizzyB with ribbon cables, andswitch the DC motor supply off(to save your ears from thenoise as much as anything!).

Then download the mainPhizzyBot program (described inthe corresponding tutorial arti-cle) from your PhizzyB Simula-tor and press the Run key. Vari-ous segments in the LED bar-graph on $F030 will illuminateto reflect the state of the motorcontroller and by clicking vari-ous microswitches this willcause the bargraph display toupdate, which corresponds to achange in direction of thePhizzyBot platform.

A blank bargraph indicatesthat the PhizzyBot is stationaryat that time but, because ofsome built-in time delay rou-tines, the PhizzyBot may eruptinto life without warning severalseconds later. It is worth waitingto see what happens! (Don’tworry, it’s all part of Max andAlvin’s sense of humor.)

The final stage is a roadtest – so clear the decks, switchon the separate on-board motorsupply, and prepare to be daz-zled! The PhizzyBot will happily

%

999@@@

!

'

&

$

#

"

!% !&

" h (G1IC9<

85145B

! "

D? @89JJI2

6 !"

" G1I3?>>53D?B

>?D EC54

DDD???

=93B?CG9D385C

C C%

Fig.3. Interconnections to the interrupt-drivenswitch module.

The ribbon cable for the motor controllerneeds folding to prevent it interfering

with the microswitch.

COMPONENTS

See also theSHOP TALK Page!

Miscel laneousS0 to S5 long-lever microswitcheswith solder terminals (6 off)

General-purpose multistrandconnecting wire (preferably in sixdifferent colors); PVC sleeving;PCB standoffs; adhesive; tiewraps; solder, etc. Optional 9V Ni-CAD rechargeablebattery with connector clip; lead topower the PhizzyB (standalonemode only)

$12Approx. CostGuidance Only(Excluding Batteries)

EPE Online, April 1999 - www.epemag.com - 415

gallivant around on the floor un-til it bumps into an obstruction,at which time it will behave in anumber of ways, sometimesseeming to stop and think aboutit before zooming off in anotherdirection or spinning around atquite a dizzying speed!

As explained in the mainarticle, it may be necessary foryou to adjust the timing of thedelays in the action sequencesto meet individual preferences.

The system should operatequite reliably and, if the interruptdriven board is known to func-tion successfully, hopefully

there is littlepossibility ofusers experienc-ing any prob-lems. If any mal-function is per-ceived, try reset-ting the powersupply or usingthe RST key,then run the pro-gram again.

Unfortu-nately, DC elec-tric motors andrelay coils areprobably the

worst imaginable electricalloads in terms of noise andspikes, and if readers notice anysigns of misbehavior or erraticoperation, try to isolate thecause. Does the PhizzyBot re-spond correctly if, say, the re-lays are powered but the DCmotors are disconnected?

The problem could perhapsbe electrical interference fromthe motors, and since the de-sign is unscreened, it may beworth re-routing any “noisy”wiring away from sensitive sig-nal wires. Also it may perhapshelp to add further suppressors

in the form of 100nF polyestercapacitors soldered directlyacross the motors.

NEXT MONTHIn next month’s article, we

wrap up the practical aspects ofthe PhizzyB hardware construc-tion by incorporating a series oflight-dependent resistors on theinput port, so that our friendlyPhizzyBot can be attracted tolight (hence a “MothBot”) or in-deed repelled by it (a“RoachBot”).

Max and Alvin will there-after outline further ideas whichwill hopefully encouragePhizzyB owners to developmore practical applications forthemselves – perhaps using thePhizzyBot to follow a white lineor a buried metallic stripe forexample, as the PhizzyB hard-ware is quite capable of beingincorporated into complex oper-ations including robotics ormechatronics, for example.

But remember that thePhizzyBot is designed todemonstrate basic principles,and you are all encouraged toimprovise and experiment foryourselves.

&RQVWUXFWLRQDO3URMHFW

Interrupt-driven board in situ.

EPE Online, April 1998 - www.epemag.com - 416

A circuit was required to limitthe level of audio applied to anFM radio transmitter. The circuitdiagram of Fig. 1 meets theserequirements and it could be used

in many areas besides the in-tended one, particularly in limit-ing the signal applied to an au-dio power amplifier, protectingthose valuable tweeters!

The design is based aroundan LM13700 OperationalTransconductance Amplifier(OTA) IC1. These devices areunlike conventional opamps inthat they are current driven and

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.

Audio Limiter Climb the Peaks

E

F

H

///,0,7(9(/

$8',2 ,1 $8',2 287

/,0,7

9

555Ω

5N

5N

5N

5N

5N

50

95N

5N

5N

5N

Ω

&Q

&Q

D

D

N

N'1

'1

,&D7/

,&E7/

,&F7/

,&G7/

5N

5N

5N

50

,&/0

'/('

D

N

,17(51$/72 ,&

9

²9

6. 6.

Fig.1. Circuit diagram for the Audio Limiter. Note the “split” power supply.

EPE Online, April 1998 - www.epemag.com - 417

have a bias input which can beused to control the gain. Thetwo transistors shown in the cir-cuit diagram are internal to theLM13700 package.

Under normal operatingconditions the output of IC2dwill be sitting at the positive rail,biasing IC1 (OTA) via resistorR5. IC2a and IC2b form a peakdetector which stores the peakvalue of the audio for a shorttime based around the timeconstant of R9/C4. When thepeak level of the audio exceedsa particular level D2 will be for-ward biased.

With IC2d having a gain of100 its output quickly swingsnegative reducing the bias tothe OTA thereby reducing itsgain and holding the audio atthe desired level. IC2c is a sim-ple comparator used to showwhen limiting is occurring.

To set up the circuit, applythe maximum input signal, thenwith a voltmeter on the output of

IR Remote Control Sen -sor Simple Checker

The simple circuit of Fig. 2is designed to test commonhandheld remote controls asused in televisions, stereo sys-

tems and other equipment,and is based around a photo-sensitive transistor switch(TR1). The infra-red emitteron the remote control ispointed directly towards TR1from a distance of about5cms.

Each button on the remotecontrol can then be pressed inturn; the ultra-bright LED Dlshould light to indicate correctoperation. If each of the but-tons on the remote control ap-pears to be working properly,then the fault (if any) may liein the equipment set itself.

Mark McGuinnessClondalkin, Dublin, Ireland

,QJHQXLW\8QOLPLWHG

R

S

U

S

U

B"

![

DB"26I%"

B!

! :

DB!

9B

@8?D?

DB1>C9CD?B

4!

B54 <54

F

)F

Q

[

Fig.2. IR Remote ControlChecker circuit.

E

F

H

E

F

H E

F

H

E

F

H

&9

µ&9

µ&µ

&9

µ &Q

&S

&S

&9

µ

5N

5N

5 Ω

5N

95N

95N

5N

5N

5 Ω

5N

5Ω 5

Ω

/ +µ

/ +µ

75%&

75%&

75%&

75%&

9

9

9

9,'(2,1387

9,'(2287387

999,,,'''(((222222888777333888777

P9 7293($.723($.120,1$/ ,1387

93.723.

7555777555

7

Fig.3. Circuit diagram for a Video Amplifier with 3-way Splitter. Only the first amplifier is shown,the other two being identical.

IC2d adjust VR1 until the volt-age just hits the positive rail(around 13¬¬8V).

Duncan BoydBlackburn, West Lothian, UK

EPE Online, April 1998 - www.epemag.com - 418

Video Amplifier A 3-way Split

The circuit design of Fig. 3was requested by a friend whowanted to split the video signaloutput from a games console sothat when he and his friendsplayed multi-player games, theycould use more than one moni-tor. The circuit accepts a stan-dard 1V peak-to-peak into 75ohm composite video signal in-put (200mV to 2V max.), whichit then amplifies and splits threeways to produce 1V pk-pk oneach of three outputs.

The console video signal isapplied across control poten-tiometer VR1 and fed into thecircuit via transistor TR1 whichacts as an emitter follower.Control VR2 is used to set thebase voltage to 1¬¬¬55V on tran-sistor TR2 and the video signalis then pre-amplified by TR2 togive a voltage of 2¬¬¬7V pk-pk atthe junction of capacitor C3 andresistor R8. This is then attenu-ated by R8 to produce 380mVpk-pk.

The resulting signal is splitthree ways so that 160mV is

supplied to the bases of transistorsTR3 to TR5, each amplifier havingan input impedance of 75 ohms.The signals are then amplified upto 1V pk-pk, and fed to the videooutputs via TR6, TR7 and TR8,each acting as emitter followers.(Only the first amplifier circuit(TR3/TR6) is shown in full, theother two are completely identical.)

The inductors L1 to L4 improvethe gain of the amplifiers at highfrequencies, using the “Shunt peak-ing coil” technique. This helps toamplify the color information con-tained in the video waveform,which would otherwise tend to beattenuated.

Capacitors C6 and C9 and cor-responding devices help to removespikes which appear in the frontporch and peak white area of thewaveform. Users may well find thatthey need to either increase or de-crease the values shown when fi-nally testing the circuit.

A +12V/+20V mains powersupply is suggested separately (seeFig. 4) although it is possible toconstruct a 12V only version of thiscircuit. It will then be necessary todelete components C5, R8 andVR2 from the present circuit. Then

change R4 to 47k and R5 to8k2, and finally change R6 to390 ohms.

The value of capacitor C4should be a minimum of1,000PF, although the circuitwill function well without C4 orL1. However, the minimum in-put voltage will then be reducedto approximately 500mV. En-sure that electrolytic capacitorsall have adequate voltage rat-ings.

Laurence CurnowCuxton, Rochester, Kent, UK

,QJHQXLW\8QOLPLWHG

)6$

E

F H

212))

9 $&0$,16

'&287387

6D

6E

/

1

9

9

9

9 5069$

7

&9

µ&9

µ&9

µ&Q

&Q

,&/&3

,1 287

&20

9P$

9

)6$

)6$

'72 '1

D

D

D

D

N

N

N

N–

5N

5N

5N

5 :

Ω.

5N

'/('

+($76,1.7+(50$/ 5$7,1*&:0,1,080$79 506

75%&

95N

,&7/&/3

N

D

5()

9

9P$

(

Fig.4. Suggested circuit diagram for a suitable power supply for the Video Amplifier. Note aheatsink is needed for the voltage regulator IC1.

EPE Online, April 1999 - www.epemag.com - 419

Over-consumption of powerand damage to the environmentare two concerns of great interestto many people today. To thosenot so involved with “green” ef-forts, the following project will ap-peal on safety aspects.

The author has noted fromdiscussions with many of hisfriends who do the majority of theclothes ironing in their house-holds that at some time everyoneaccidentally leaves the iron on,seemingly no matter what pres-ence of mind they normally enjoy.For instance, a mother may sud-denly have to leave what she isdoing to investigate an unex-plained noise.

HOW IT WORKSThe original design concept

is for a device which may beattached to an ironing board,into which the clothes iron isplugged, and which senses theuse of the iron by vibration. Anadded benefit is that you nowhave an ironing board with abuilt-in extension lead!

The idea could be adaptedto control any mains powereddevice, which creates someform of vibration when in use.

When the clothes iron is tobe put to use, the unit's On but-ton is pressed and the iron stayson for around 1¬¬¬5 minutes or aslong as vibration is detected onthe ironing board. When thetime-out period arrives, beforedisconnecting the power, the“Saver” unit emits a beep toneto warn the user, or reassurehim or her, that the iron hasbeen disconnected should he orshe have forgotten to switch itoff after use.

The purpose of the beeptone is to prevent the user tryingto work with a cold iron, whichwould obviously become a nui-sance, thus preventing the unitfrom being “approved” by theuser, and thus defeat the pur-pose of its construction. At anytime a “Mains On” neon will in-dicate whether power is on oroff.

CIRCUIT DESCRIP-TION

The full circuit diagram forthe Ironing Board Saver is

Save energy with this environmentally friendlyironing-board add-on.

,521,1* %2$5' 6$9(5 E\ 52%(57 +817

This Ironing Board Saver pro-ject was envisioned to preventclothes irons being left on acci-dentally, thus saving electricityand reducing the risk of a possi-ble fire.

Note that the circuitshown in this article wasdesigned for use with a UKmains power supply(240V, 50 Hz). If yourcountry employs a differ-ent supply, you will needto consult a qualified elec-trician in order to modifythe circuit accordingly.

EPE Online, April 1999 - www.epemag.com - 420

shown in Fig.1. The circuitpower supply and mains relaycontact switching arrangementis also included.

The particular type of in-verting buffer, IC1, used here isa special type called a Schmitttrigger. This means that the de-vice has a built in hysteresisrange of input voltages so that itswitches over at, say 70 percent of supply rail but switchesback at say 30 per cent.

This can best be understoodwith the illustration of a thermo-stat in an electric fire, when itreaches the required tempera-ture, say, 20C, and switches offit doesn't come on again untilthe room temperature hasdropped to, say, 17“loop” is called hysteresis.

C. This 3C

Hysteresis is used in thisproject to enable the reliableuse of varying voltages con-

nected to logic gates, as logicgates do not work well withpoorly defined input levels un-less designed to handle them,such as the Schmitt trigger.Otherwise, oscillation aroundthe switchover point occurswhich makes the output spendtime halfway between logicalstates, which can cause failureof the gate due to power devel-oped at the junction atswitchover.

BUZZERWhile on the subject of

these gates, we'll start with thewarning buzzer part of the cir-cuit formed by IC1e/IC1f, R8and piezoelectric transducerWD1. The piezo buzzer circuitcan best be understood if youlook at Fig.2.

Imagine point A is low,causing point B to be high,

which causes point C to be lowtoo. However, resistor R8 passescurrent from point B (high) to oneside of the piezo crystal WD1whose other side is low (point C).As piezo crystals are basically20nF capacitors, gradually thecrystal charges, causing the volt-age at point A to rise.

At a certain point the first in-verter will switch over, so point Bbecomes low, point C thus be-comes high, causing WD1 togradually discharge through R8 topoint B (low). When WD1 has

&RQVWUXFWLRQDO3URMHFW

5/$

0(5&85<6:,7&+

2))

E

F

H

& µ

&

µ

,&D%(

,&G%(

,&F%(

,&H%(

,&I%(

75036$

,&E%(

5N

5N

5N

5N

50

5N

5

N

5N

5N

5

N

'

1

'1

'

1

'

1

'

1

'''

111

'''

111

'1

'1

D

D

N

N

N

NNN N

N

N

D

N

N

D

D

D

DDD DDD

D

N

&Q

6

6

6

:'

9

9

&

µ

9 9

9

9

9

5/$

5/$

5/$

12

12

12

3

3

)6P$7% 7%

7%

/3

6.

/

(

1

7

9

9

Fig.1. Complete circuit diagram of the Ironing Board Saver.

,&H%(

,&I%(

5

:'

$

%

&

Fig.2. Simplified piezobuzzer oscillator circuit.

EPE Online, April 1999 - www.epemag.com - 421

sufficiently discharged it beginsto charge in the opposite direc-tion and eventually the voltageat point A becomes low again,switching B to high and C to lowand so the whole cycle repeatsitself.

If you wish, you could alterthe frequency of the tone by al-tering the value of resistor R8.

The frequency can beroughly calculated by workingout the time constant of R8 andWD1, multiplying this by two,and dividing one by the result:

Frequency = 0¬¬¬5 / (R8 x WD1)Hz

POWER CONTROLTurning now to the power

supply/relay stage of the circuit,the relay, RLA, controls both thecurrent to the appliance beingcontrolled, and the power to thecircuit itself. However, the push-to-make switch S3 momentarilysupplies power to the circuitwhen pressed, and the circuitsubsequently operates the re-lay.

To avoid passing appliancecurrent through switch S3(which would have to be 13Arated if this were the case) therelay alone connects power tothe output socket SK1. Hence

C4 decays to a point where TR1no longer holds the relay RLAon, so power is finally discon-nected.

You may wonder how it isthat capacitor C4 can dischargeto a point which switches overIC1d and yet still holds transis-tor TR1 on. Well, IC1d willswitch over at a voltage equiva-lent to two thirds of the supplyvoltage, but TR1 will switch offonly when the gain of the tran-sistor does not amplify the cur-rent enough to hold the relay onany longer.

As relays demand muchmore current to switch on thanthey need to stay on, then resis-tor R9 needs to pass much lesscurrent after the relay is en-gaged. Therefore, it will stay onfor a few seconds after IC1dhas switched over.

If you wish to alter the timeit takes for the power to discon-nect after the time expires, re-duce the value of resistor R10to discharge capacitor C4 morerapidly. To alter the main timeperiod, adjust the value of C3.The time will be around 1¬¬¬5 min-utes per 100PF.

Pushswitch S2 operates viaresistor R7 as an “Off” button.Pressing S2 charges up C3within half a second, thus caus-ing time expiry, and so the unitswitches off.

VIBRATION SENSORThe vibration sensor switch

S1 is supplied basically as ametal can of approximately9¬¬¬5mm length and 8¬¬¬2mm diam-eter. Only one connection is al-ready provided, you have to sol-der another lead onto the can(see Fig.3). Its predicted life isin the order of millions of opera-tions, especially if used in lowcurrent situations like this.

&RQVWUXFWLRQDO3URMHFW

0(7$/

%2'<

6,,,111*/(

&(175(

3

Fig.3. Wiring of S1, thevibration sensor.

the relay must have three nor-mally open (n.o.) contacts. This isso that both poles of the mainssupply are disconnected from thesocket when it is switched off byRLA2 and RLA3, and the thirdcontact (RLA1) is for power to theelectronics.

Fuse FS1 is rated at 250mAquick blow and supplies current tothe control circuit only, the mainssocket SK1 is fused via the fusein the mains plug.

POWER TIMEROnce power has been applied

to the circuit, the timer formed byresistor R6, capacitor C3, andIC1c operates the relay via diodeD8, resistor R9 and Darlingtontransistor TR1. Once C3 has be-come charged to around twothirds of the supply voltage(around one minute) IC1cswitches over, no longer operat-ing TR1 directly. (TR1 is still held“on” at this point by capacitor C4 see later.) From this point, thepiezo buzzer WD1 starts to sounddue to the oscillator no longer be-ing blocked off by diode D10.

After about a further threeseconds, the charge in capacitorC4 decays to a point which nolonger holds the output of IC1dlow, so it blocks off the oscillatorvia diode D9 and hence the warn-ing sound ceases. After anothercouple of seconds the charge in

&

,&D%(

,&E%(

5

5

%$ '

&

Fig.4. Simplified monostabletimer circuit.

EPE Online, April 1999 - www.epemag.com - 422

The timer circuit, IC1a/IC1b,is constantly being reset by sig-nals from the vibration sensor,S1. Capacitor C1 serves to ab-sorb any very short signals andthe circuit around IC1a/IC1b isagain simplified to aid explana-tion, see Fig.4.

This stage of the circuit ba-sically serves as a pulsestretcher so that momentary sig-nals from the vibration switchS1 are lengthened to a timelong enough to discharge thetiming capacitor C3, via resistorR5 and diode D7. IC1a andIC1b are connected in a monos-table fashion with an on time ofaround half a second.

Referring to Fig.4, once anegative going pulse from S1arrives at point A, point B goeshigh, initially putting point Chigh (via capacitor C2) causingpoint D to go low. As C2charges, the voltage at point Cdrops via resistor R4 until IC1boutput goes high again, bringingpoint A high via resistor R2which puts point B low, dis-charging C2.

In the actual circuit, two ad-ditional components, resistor R3and diode D6, enable capacitorC2 to discharge far more rapidlythan it charges, ensuring thatthe next trigger pulse at point Aresults in just as long an outputpulse from the circuit.

POWER SUPPLYThe power supply circuit

after mains transformer T1 is aconventional full-wave rectifierformed by D1 to D4 withsmoothing by C5. Neon lampLP1 serves to indicate to theuser that power is on.

There are no requirementsfor regulation as the circuit doesnot draw a widely varying cur-rent, and it is insensitive to mi-

&RQVWUXFWLRQDO3URMHFW

nor fluctuations in supply railvoltage.

CONSTRUCTIONMost of the components for

the Ironing Board Saver aremounted on a small printed cir-cuit board (PCB). The excep-tions being the mains trans-former, relay, switches and out-put socket. This board is avail-able from the EPE Online Store(code 7000224) atwww.epemag.com

The board component lay-out and (approximately) full-sizecopper foil master are shown inFig.5. Assemblyof the PCB isstraightforward,but IC1 is staticsensitive so takethe usual precau-tions when han-dling it. Note thatthe buffered ver-sion of the 40106must be used(suffix BE notUBE).

The only dif-ficult componentto fit is the vibra-tion sensor,which must havea wire lead sol-dered to its metalbody. Be carefulnot to apply heatany longer thannecessary.

After mount-ing and solderingall componentsin position, at-tach flying wiresto the PCB forthe relay coil,piezo buzzer andswitch S2. Attachthe two outerwires from the

transformer secondary, whichwill output 12V between them (ifthe transformer is 6V-0V-6V thecenter tap wire should beclipped short and be fully insu-lated) and fit the PCB into thecase.

Flying leads from the PCBcan now be fitted to the relay,buzzer and S2. When attachingleads to the piezo element, youcan solder wires directly to theelement if required but youmust be careful to apply as littleheat as possible so as not todestroy the junction between the

COMPONENTS

See also theSHOP TALK Page!

Printed circuit board available from the EPE Online Store,code 7000224 (www.epemag.com ); case, size and style tochoice; 14-pin DIL socket; multistrand connecting wire; 13Amains-rated cable; mains lead, with fused plug; strain-reliefgrommet for cable entry; crimp terminals for relay; plasticsleeving; tie wraps; nuts and bolts; solder, etc.

$43Approx. CostGuidance Only (excluding case)

SemiconductorsD1 to D4D5 to D11TR1IC1

1N4001 1A 50V rectifier diodes (4 off)1N4148 signal diodes (7 off)MPSA14 npn darlington transistor40106BE Hex Schmitt trigger inverter

Miscel laneousS1S2S3T1

LP1W D 1RLA

TB1FS1

mercury vibration sensormains-rated push-to-make switch (red)push-to-make switch (black)230V mains transformer, with 0V-12V (or 6V-0V-6V) 250mA secondarymains neon indicator, panel mounting3V to 30V wire-ended piezoelectric sounder3-pole mains relay, with 12V DC 110 ohm coil and 13A 230V AC contacts (normally open)3-way mains terminal block, with fuseholder230V 250mA 20mm glass fuse, quick blow

All 0.25W 5% carbon fi lm

1k (2 off)100k (3 off)10k (2 off)

R4R6R8

470k1M22k

ResistorsR1, R7R2, R9, R10R3, R5

100n ceramic disc4u7 radial elect. 25V100u radial elect. 25V

C4C5

22u radial elect. 25V470 radial elect. 25V

CapacitorsC1C2C3

EPE Online, April 1999 - www.epemag.com - 423

two plates. The piezo elementcan be glued to the case, awayfrom all mains wiring.

MAINS WIRINGFor connecting mains

wiring, carefully follow the inter-wiring diagram Fig.6, double-checking as you go along. Also,make sure you keep to the fol-lowing safety notes below.

Safety Aspects

When wiring the unit it is

necessary to fuse the mainstransformer separately from thesupply to the output socket SK1.All wiring which carries thecurrent to the output socketvia the relay must be 13Arated, including the earthwiring, so that no overheatingcould be experienced should aunit taking this much current beused.

Ensure that all exposedmetal (e.g. bolts etc.) is earthbonded, and that the cable exit-ing from the enclosure is firmly

gripped by a strain relief grom-met. It is necessary to sleeve orinsulate all mains connec -tions even though they are en-closed within the box.

In the prototype unit, rubbercovers were fitted over the con-nections to neon LP1 and S3,and the relay terminals wereterminated with insulatedcrimps. Take care also that allmains wiring (whether high cur-rent or not) is mains rated. Ifthis is not the case then the in-sulation could in time breakdown and cause serious prob-lems.

If there is any danger of theiron touching the mains flexleading out of the unit, youshould use heat resistant cable,or cotton covered if you canclamp it securely in the case.

A safety note on earthbonding: Do not effect this in a“daisy chain fashion,” becauseone fault in the chain and theearthing fails at every subse-quent point. It would also intro-duce hazardous potentials in theevent of a fault current, as thelength of the chain would gener-ate a certain amount of voltagedrop.

Instead of this, wire all earthconductors back to a commonpoint excepting the continuityconductor between the input ca-ble and output socket. Remem-ber that this conductor MUSTbe rated at or above the ca -pacity of the mains incominglead.

Note that mains wiring tothe relay should not have anyexposed metal showing, sosleeve all connections or useall-insulated crimp terminals. Itis most important that the termi-nal block TB1, if used, must bea mains rated one, preferablyan approved type. Differentpoles of the mains should al-ways be separated by a certain

&RQVWUXFWLRQDO3URMHFW

F

E

H

75

N N N

N

N

N

N

N

N

N

N

D D D

D

D

D

D

D

D

D

D

'

'

'

'

'

'

'

'

'

'

'

5 5

5

5

5

5

5

5

5

5

&

&

&

&

& 6

726 725/$&2,/72:'

Fig.5. Approximately full size PCB layout for theIroning Board Saver.

EPE Online, April 1999 - www.epemag.com - 424

creepage and clearance gap of3mm as well as a standoff fromthe base of 3mm normal ter-minal blocks do not always sat-isfy this requirement. The termi-nal block used in the prototypealso provide a fuse (FS1) forthe live connection. Note thatthe piezo element must bemains isolated from earth.

RELAYWhen selecting the relay,

as well as ensuring the contactscan switch 13A at 230V AC, en-sure that the coil is well insu-lated from the contacts and thatthe contact gap is 3mm orgreater. These are requirementsfor disconnecting mains current.

The relay should have a coilresistance of at least 100 ohmsat 12V DC. This is to limit theamount of current drawn by thewhole circuit as the relay is themajor consumer of current!

Note that the operate andrelease times are totally unim-portant in this application youwon't need to specify a moreexpensive relay simply for thesake of speed of operation. Ifsourcing a three-pole relay be-comes difficult, you could use

&RQVWUXFWLRQDO3URMHFW

7

99

9

6 62)) 21 /3

9

(

72 3&%

72 3&%

72 3&%

72 3&%

555/$$$

/ / /

5

5/$

&2,/

5/$

6.

1

/

(

127( ,168/$7(7+( &211(&7,216

72 6/3$1' 5/$

7%

)6

1

(

/

675$,1

5(/,()

%86+

9 $&

:'

Fig.6. Interwiring of the PCB to all othercomponents. All earth leads must

connect back to TB1.

EPE Online, April 1999 - www.epemag.com - 425

two separate relays so long asthe coil resistance of the twocombined does not draw morethan 120mA or so altogether.

INSTALLATION ANDOPERATION

Various methods of attach-ing the box to the ironing boardinclude the use of adhesive TY-wrap bases (as in the prototype)or pipe clips so that it can bedetached when desired.

Mount the unit as close asreasonable to the part of the

board where the iron is oftenlaid to rest. Orientation does notmatter as far as the vibrationsensor is concerned, but theswitches should be accessible.

Instructing the user of theironing board (once he or she ishappy with it being attached!) isvery straightforward. Simplyplug the unit into the wall, andthe clothes iron into the unit.Press the On button and wait asusual until the iron is hot.

If you hear a beep, it meansthe unit will soon go off unlessyou tap it or use the iron. Ob-serve the neon lamp to see if

the iron is still on. To switch off,press and hold the Off buttonuntil the lamp goes out.

After the unit has been inuse for some time, you may findthat the timing settings are notquite to the satisfaction of theuser. Remember that you canalter the component values!

Happy ironing!

&RQVWUXFWLRQDO3URMHFW

EPE Online, April 1999 - www.epemag.com - 426

The development of micro-electromechanical systems(MEMS) is progressing rapidlynow. Over the past few years ithas been seen that they havecome from being a laboratorycuriosity to a reality where manyideas are being developed forreal applications.

These machines are sub-miniature mechanical devicesmade from silicon. They aremanufactured using techniquesused for semiconductor manu-facture. As a result they can bemade exceedingly small, allow-ing them to be used for applica-tions that could not be con-ceived for small devices madeby more traditional means. Theycan easily be made in largequantities. Although the initialdevelopment costs may behigh, once these have been ac-counted for the actual incre-mental cost of the individualmachines is relatively low.

MEMS LOCKA novel application has

been developed at the SandiaNational Laboratories in Albu-querque, New Mexico, USA. Ituses a MEMS as a combinationlock. Not only is it of interestbecause of the MEMS technol-ogy, but it is also the first knownmechanical device to be usedas a computer firewall to pre-vent unwanted hackers fromentering a computer system.Normally software firewalls areused, but hackers who are usingever more sophisticated meth-ods can often manipulate them.This mechanical device cannot

be manipulated in the sameway.

There is only one chance ina million of choosing the rightcode to enter. If the wrong codeis chosen then the lock has tobe mechanically reset beforethe system can be accessedagain. In the case of many soft-ware firewalls, repeated at-tempts can be made to accessthe system and it is only a mat-ter of persistence before accessis gained. There is normally nota complete reset as in the caseof the mechanical device.

There are plenty of storiesof people breaking into com-puter systems like those of theFBI, CIA and so forth. Whilstthese stories hit the headlines,and these sites probably attracta lot of interest from amateurhackers, the danger is no lessfor other sites, where more pro-fessional organizations mayhave an interest. This meansthat it is exceedingly importantfor any computer that has linksto the outside world to be wellprotected from invasion fromexternal hackers.

In addressing this problem,Sandia looked at ways of im-proving the current levels of se-curity. It is a fact that mechani-cal systems are far harder tobreak than software ones. Ac-cordingly a decision was madeto adopt a mechanical solutionto devise a system that wouldprevent unauthorized entry intocomputer systems.

The system took only threemonths from initial concept tothe final design. Using ideasbased around those used in

weapon safety locks, the devel-opment team was able to de-sign a system that was verysimple. In fact its very simplicitymakes it easy to analyze andensure that there are no weak-nesses that could be exploitedby hackers.

CONSTRUCTIONThe prototype consists of a

total of six code wheels, eachless than 300across

Pm (micrometers) see photo. These are

driven by a series of combs thatare electrostatically operated,turning the electrical impulsesinto mechanical movement. Thedesign exploits all the availablelevels of polysilicon in Sandia'sSUMMiT process. Three func-tional layers of polysilicon aloneare needed to create the fail-safe discrimination capability ofthe design.

The whole lock can be fabri-cated onto a small chip andwould typically measure about 5x 10mm. It could then bemounted into the computer re-quiring the security function anddriven electrically by pulses de-rived from the interface.

The device can be unlockedonly when the correct code isentered. The lock translates thedigital information that entersthe lock into an angular rotationof the gears. To achieve its per-formance the design requiresthree individual levels of gearteeth where the teeth approachthe mesh point from oppositedirections, unlike conventionalgears that approach from thesame direction. This means that

Ian Poole investigates the use of micro-electromechanical systems in computerapplications.

EPE Online, April 1999 - www.epemag.com - 427

the device is specifically de-signed so that the gear teeth willinterfere and the device will lockup if the wrong code entered.

Control of the lock can onlybe gained from the secure side.It is possible for the system con-troller to enter a new code aswell as resetting the lock when ithas been incorrectly accessedand locked up.

SUMMiTOne of the keys to the suc-

cess of the MEMS lock is thefabrication process that was de-vised at Sandia. The MEMS are

linkages to be fabricated so thatthey can be used to connectvarious actuators to othermechanisms. In this way it canbe seen that the addition of fur-ther layers enables muchgreater flexibility to be obtained.

The Sandia SUMMiT pro-cess creates devices by succes-sively setting down a film, thenplacing a pattern onto the filmusing photolithography, andthen etching the material in linewith the pattern to give the re-quired shape. By repeating theprocess with alternate layers ofsilicon oxide and polysilicon it ispossible to create the compli-cated shapes such as those re-quired for the lock.

At the end of the processthe silicon oxide is chemicallyremoved. Once this has beendone only the much strongerpolysilicon remains, giving therequired shapes for the ma-chine. By designing the correctboundaries between the polysili-con and silicon oxide it is possi-ble to end up with wheels onhubs that can move.

A mask is required for eachstage in the process. The SUM-MiT process requires a total ofeleven different masks. Thismeans that the complexity ofthe fabrication process is aboutthe same as that required for afairly simple CMOS IC. How-ever the SUMMiT process over-comes the problems of residualfilm stress that appear in manymicromachine processes andthis is one reason why its intro-duction is a significant step for-ward.

Although the realization ofthe process required much de-velopment effort it has nowbeen satisfactorily introduced. Itis relatively straightforward anduses the same basic conceptsas integrated circuits. Thismeans that once a process has

been set up the incrementalcosts for these micromachinesis very small.

In view of this many moreideas for these machines willundoubtedly be found in thenext few years and they willstart to appear in many every-day applications. It means thatwhat was only a laboratory cu-riosity a few years ago will be-come an everyday fact in a fewyears time.

1HZWHFKQRORJ\8SGDWHV

Part of the code lock. Photocourtesy of Sandia NationalLaboratories intelligent mi-

cromachine initiative

made from polycrystalline sili-con or polysilicon for short. Thismaterial is widely used in ICfabrication processes, and it isactually stronger than steel,making it ideal for mechanicalstructures.

The number of layers thatare used governs the complex-ity of the machines that can beachieved. A process that con-tains a ground plane (i.e. thebase plane for the structure)and one mechanical level iscalled a two level process andcan be used to fabricate a struc-ture such as a comb drive. Athree level process is requiredfor a gear on a hub. The addi-tion of a further layer enables

EPE Online, April 1999 - www.epemag.com - 428

This educational software isfirmly based on the series of arti-cles that appeared in EPE be-tween November '95 and August'96 under the title Teach-In '96 A Guide to Modular Circuit Design(this was the hard-copy version ofthe magazine, Ed.) It is not actu-ally a program, but a set of HTMLfiles. In effect it is an Internet siteon a CD-ROM.

It should work with any PCthat is equipped with an Internetbrowser, but note that no browseris included on the CD-ROM. Thisshould not be a major problem,since browser software is widelyavailable free of charge, eithervia the Internet or on the coverdisks of computer magazines. Ifyou are using a modern operatingsystem you may well find that abrowser is included.

As the accompanying textpoints out, in the real world it isnot always possible to compart-mentalize things quite a simplyas this, and (say) an input mod-ule could be used as a signalprocessing stage. In generalthough, designs produced usingthis system consist of an inputmodule, an output module, and(possibly) one or two signal pro-cessing stages in between.

A reasonable range of mod-ules is provided, including sim-ple sensors, amplifiers, triggers,timers, an audio mixer, relaydrivers, and so on. Most of themodules are what would bebroadly termed analogue cir-cuits, but there are also a fairnumber of digital modules.These include such things assimple bistable latches, J-K flip/

flops, andCMOS monos-tables. Usingthe modules itshould be possi-ble to producecircuits thatcover a widerange of appli-cations.

When youare familiar withthe general con-cepts of thesoftware, thenext step is toprogress to theexample de-

signs. There are about a dozenof these covering such things asa Reaction Tester, a Flood Alertcircuit, and a Temperature

Robert “test drives” a new software CD-ROMpackage.

02'8/$5 &,5&8,7 '(6,*1 &'B520E\ 52%(57 3(1)2/'

STARTING POINTIn order to use the software

you locate the “Start” file andthen use the browser to run it. Itis then a matter of navigatingyour way around the “site” byclicking on the highlighted linkwords. The initial page (Fig.1)has links to sections that givegeneral advice on using the sys-tem, and a more detailed intro-duction to the system.

As its name suggests, thissoftware teaches the user aboutcircuit design using a modularapproach. Three types of mod-ule are available, and these areinput, output, and signal pro-cessing modules.

Fig.1. Start screen page.

Fig.2. Contents screen listingpage.

EPE Online, April 1999 - www.epemag.com - 429

Warning system.

Clicking on the highlightedtext for the design you requirebrings up a page that provides abrief description of the systemas a whole, and each of themodules. There are then links tothe circuit for each module to-gether with a more detailed de-

ROLLING YOUR OWNOnce you have looked

through some of the design ex-amples, it is time to try yourhand at designing a circuit fromthe supplied modules. The sec-tion called “Realizing your De-sign” gives some general adviceon how to proceed, but fromhere onwards you are largelyleft to your own devices.

Suppose you wanted to pro-duce a circuit that switched onan LED each time sound wasdetected. There is more thanone way of seeking the appro-

priate modules for the job, butprobably the best one is to goto the “Contents” page (Fig.2)and look through the variousinput and output modules.From here there are links tothe sections dealing with thesound input module (Fig.3)and LEDs (Fig.4).

You then have to considerwhether or not a signal pro-

cessing stage is required, whichin this case it probably would be.Looking at the processing mod-ules for a suitable amplifier showsnothing really suitable, but a sec-ond look at the output modulesshows that various driver mod-ules are available, including aLED driver type. This looks wellsuited to our example application.

After drawing up the com-plete circuit by joining togetherthe appropriate two modules, it istime to either simulate or buildthe circuit to see how it performs.If you decide to build the circuit,which is almost certainly the bestapproach, there is a data section(Fig.5) which gives semiconduc-tor pinout details and otheruseful data.

6SHFLDO5HYLHZ

Fig.4. LED screen page.

Fig.3. One of the Sound Input module

scription of each one, plus a linkto the complete circuit.

Unfortunately, most linksare to general sections dealingwith a range of sensors, signalprocessors, or whatever, whichcan be a bit confusing at first.The descriptions are also ratherbrief, but do cover the most im-portant aspects of each module.Users are encouraged to experi-ment with the designs, andwhere appropriate there is ad-vice on how to alter the charac-teristics of the modules.

EPE Online, April 1999 - www.epemag.com - 430

One drawback of this soft-ware is that it is not interactive,and does not have any form ofbuilt-in circuit simulator. If youwish to take the simulation routeit will be necessary to obtain aseparate circuit simulator, whichis likely to be quite expensive. Itshould not be too difficult to testdesigns using either approach,since designs produced usingthis software will be reasonablysimple.

It should, however, providejust the right level of informationfor those wishing to buildGCSE-level high school pro-jects, for example, encouragingsome research in order to comeup with the final design, ratherthan giving away too much in-stant assistance with a ready-made circuit diagram. In thisrespect, it will be a welcome ad-dition to many school resourcesand to hobbyists who want tomove on from just copying pub-lished designs.

STABILITYDuring the review period

there were no signs of instabilitywith this software, and no miss-ing links were discovered. It

does not require a powerful PC,and it should run reasonably wellon any PC that can handle HTMLfiles.

Obviously, a CD-ROM driveis required, and there is a poten-tial problem here for some users.The review software was suppliedon CDR rather than a pressedCD, and some of the older CD-ROM drives can have difficultiesreading CDRs. It seems to besome of the CDR formats thatcause the problems, rather thanthe CDR media itself. (We believethis problem has now been solved Ed.) It would obviously bepointless to include a largeprinted manual with software ofthis type, but there is a usefultwo-page leaflet to help newusers get things underway.

BOTTOM LINEThis software is very simple

when compared to most of thecompetition. It does not coversuch a wide range of topics as thepopular Electronic Principles pro-gram for example, and it does nothave the built-in circuit simulatorof Crocodile Clips. On the otherhand, it costs much less than ei-

ther of these.

Modular Circuit Design cer-tainly provides a good introduc-tion to circuit design. It is wellsuited to complete beginnersprovided they are guided by atutor, and should also be usableby those who have gained someexperience at project buildingand wish to progress to some-thing more than cloning pub-lished designs.

Prices for the Modular Cir-cuit Design CD-ROM are as fol-lows: Sample version 12 USDollars (plus S&H), Full version32 US Dollars (plus S&H). Bothversions are available from theEPE Online Store atwww.epemag.com

6SHFLDO5HYLHZ

EPE Online, April 1999 - www.epemag.com - 431

Thousands of you have be-come familiar with the PIC familyof microcontrollers. Over the lastthree years we have publishedmany designs that use them. Theprincipal members of the familythat have been used in the de-signs are the PIC16C84 andPIC16F84. Our PIC Tutorial se-

PIC16C73/74/76/77 devices).

Importantly, not only dothey have greater capacity thanthe '84s, they offer more facili-ties that make them ideal candi-dates for use in many sophisti-cated designs for which the '84scould not readily provide com-plete control solutions.

Of particular importance aretheir several on-chip analog-to-digital converters (ADCs), andtheir communications optionsbased upon internal USART(Universal Synchronous Asyn-chronous Receiver Transmitter)protocols.

It is worth noting, however,that the 'F87s cannot be usedwith the PIC Tutorial printed cir-cuit board, or with the PIC16x84 Toolkit programmer (July'98). Methods by which theycan be programmed are dis-cussed later.

Microchip’s new EEPROM microcontrollers havegreater capacity and much more to offer than thefamiliar PIC16x84s.

3,&)[ 0,&52&21752//(56

E\ -2+1 %(&.(5

ries of March to May '98 (in theprinted version of EPE) wasbased upon them. (This series isnow available on CD-ROM visitour web site for more details:www.epemag.com ).

FAMILY ADDITIONArizona Microchip, the manu-

facturers of the PICdevices, have nowintroduced a newrange to the family,the PIC16F87x se-ries. In many re-spects, these newdevices can be re-garded as greatlyenhanced versionsof the '84s (morespecifically, theyare CMOS Flashversions of theexisting

=3<BF @@D8F

B1 1>>>

B1!1 !

B1$DDD 333;;;999

B1%1>$CC

7>4

?C3!3<;9>

?C3"333<;?ED

B3 D!?C? !

B3!D!?C93333@"

B " 3@!

B3#C3;C3<

BBB111#111>>>#FFFBBB555666

" "

BBB222'@@@7774

& 3

%

$

# =

"

BBB222!

9>D

F5

7>4

333'BHHH4D

& D 3;

BBB% CCC444?

$ 9C41

!

"

#

$

%

&

'

(

)

!!!

!

"

#

$

"""(

!!!%

&

'

(

)

"""

!

"

#

$

%

&

'

Fig.1. Pinout details for the PIC16F873/876microcontrollers.

o) High-performance RISC CPUo) 35 single word (14-bit) instructions (identical to PIC16x84)o) All single cycle instructions except for program branches which are two cycleo) Operating speed: DC to 20MHz DC to 200ns instruction cycle (PIC16x84 max speed10MHz, 400ns)o) Up to 8K x 14 words Flash Program memory Up to 368 x 8 bytes Data Memory (RAM) Up to 256 bytes EEPROM Data Memory (PIC16x84 1K, 36, 64, respectively)o) Pinouts compatible to the PIC16C73/74/76/77o) Up to 14 internal/external interrupt sources(4 for 'x84)o) Eight level deep hardware stacko) Direct, indirect, and relative addressingo) Power-on-Reset (POR)o) Power-up t imer (PWRT)o) Oscillator start-up timer (OST)o) Watchdog timer (WDT) with on-chip RC oscillatoro) Programmable code protectiono) Power saving Sleep modeo) Selectable oscillator options (as for 'x84)o) Low-power, high-speed, CMOS Flash/EEPROM technologyo) In-circuit 2-pin 5V serial programmingo) 3-pin 12V/14V serial programmingo) In-circuit Debugging via two pinso) Processor read/write access to program memoryo) Operating voltage range 2.0V to 5.5V ('x84 2V to 6V)o) Sink/source current 25mAo) Power consumption, <2mA typical @ 5V 4MHz, 20uA typical @ 3V 32kHz, <1uA typical standby ('x84<2mA, 60uA, 26uA, respectively)

Table 1.Core features.

EPE Online, April 1999 - www.epemag.com - 432

CORE FEATURESThere are currently four de-

vices in the 'F87x series:PIC16F873, PIC16F874,PIC16F876 and PIC16F877.Their core features are shown inTable 1. The features that areimprovements on the '84s arehighlighted in bold.

Their peripheral features (ofwhich none except for Timer0are included in the '84s) areshown in Table 2, whilst specifickey features for the individualdevices are shown in Table 3.

Pinouts on the standardplastic dual-in-line (DPIP)packages are given in Fig.1(surface mount variations arealso manufactured).

PORT FUNCTIONSThe following is a summary

of the ports available on the'F87x devices.

PORTA. This is a 6-bit wide(on the '84 this port is 5-bit) bi-directional port for which any ofthe pins may be individually setas inputs or outputs (as with the'84). Unlike the '84, however,this port has the extremely use-ful additional feature of havingfive pins that may be configuredas analog-to-digital inputs. Twoof the pins may also be used asreference voltage inputs, al-though not at the same timethat they are used as ADC pins.

PORTB. As with the '84,this is an 8-bit wide bi-directional port for which any ofthe pins may be individually setas inputs or outputs, and withthe option of biasing the inputshigh via internal pull-ups. Incommon with the '84, two ofthem (RB6 and RB7) can alsobe used as the Data and Clockpins when downloading programdata to the device. However, anadditional feature has been

given to pin RB3, allowing it tobe used to set the '87x devicesfor on-board low voltage pro-gramming (see later).

PORTC. This port is notavailable on the '84. It is an 8-bit wide bi-directional port forwhich any of the pins may beindividually set as inputs or out-puts. Several peripheral func-tions are multiplexed withthis port, as outlined in Table 4.They will be describedseparately.

PORTD. Only the 40-pin'F87x devices have this portavailable ('F874 and 'F877). It isan 8-bit bi-directional port andall its pins have Schmitt triggerinputs. It can be configured asan 8-bit wide Parallel SlavePort when interfacing to a mi-croprocessor bus.

PORTE. Only the 40-pin'F87x devices have this portavailable ('F874 and 'F877). Itonly has three pins but each isbi-directional and has a Schmitttrigger input. All pins can beused as analogue-to-digital in-puts. They can also be config-ured as control inputs when Par-allel Slave Port mode has beenconfigured for PORTD.

SERIAL PERIPH-ERAL INTERFACE(SPI)

The SPI mode allows eightbits of data to be synchronouslytransmitted and received simul-taneously. Typically, three pinsare used during communication,Serial Data Out (SDO), SerialData In (SDI), Serial Clock(SCK). A fourth pin, Slave Se-lect (SS), may be used when inSlave Mode operation.

Various control bits can beconfigured to allow the followingto be specified:

o) Master Mode (SCK asclock output)

o) Slave Mode (SCK as clockinput)

o) Clock polarity (idle state ofSCK)

o) Data input sample phase(middle or end of data outputtime)

o) Clock edge (output data onrising/falling edge of SCK)

o) Clock rate (Master Modeonly)

o) Slave Select Mode (SlaveMode only)

When used in Master Mode,the device can initiate data trans-fer at any time since it controlsthe SCK. The Master also deter-mines when the Slave (a secondprocessor) is to broadcast data.

The SPI clock rate is user-programmable for the Master andcan be set for Fosc/4, Fosc/16,Fosc/64 or Timer2 output/2, soallowing a maximum bit clock fre-quency (at 20MHz) of 5¬¬¬0MHz.

In Slave Mode, the data istransmitted and received as theexternal clock pulses appear onSCK. When in Sleep mode, theSlave can transmit and receivedata, although when a byte is re-ceived the device will wake upfrom Sleep.

To emulate 2-wire communi-cation, the SDO pin can con-nected to the SDI pin. When theSDO pin needs to operate as areceiver, the SDO pin can beconfigured as an input, whichdisables transmissionsfrom the SDO.

USARTThe Universal Synchronous

Asynchronous Receiver Transmit-ter is one of the two serial I/Omodules. The USART (which isalso known as a Serial Communi-cations Interface or SCI can be

6SHFLDO5HYLHZ

EPE Online, April 1999 - www.epemag.com - 433

configured as a full duplexasynchronous system that cancommunicate with peripheraldevices such as CRT terminalsand PCs. It may also be config-ured as a half duplex syn-chronous system that can com-municate with peripheral de-vices such as A/D or D/Ainterface circuits, serialEEPROMs, etc.

The USART can be config-ured in the following modes:

o) Asynchronous (full duplex)

o) Synchronous duplex)

Master (half

o) Synchronous Slave (halfduplex)

It also has a multi-processorcommunication capability using9-bit address detection.

There is a dedicated 8-bitbaud rate generator that sup-ports both the asynchronousand synchronous modes of theUSART. The baud rate is soft-ware controllable, between19¬¬¬53 kbaud and 5000 kbaudat a crystal oscillator rateof 20MHz when insynchronous mode.

In asynchronous mode, theUSART uses standard non-return-to-zero (NRZ) format(one start bit, eight or nine databits and one stop bit). The mostcommon data format is eightbits. The USART transmits andreceives the LSB first.

Whilst the USART's trans-mitter and receiver are function-ally independent, they use thesame format and baud rate.Parity is not supported inhardware but can be imple-mented in software.

The asynchronous moduleconsists of the followingelements:

o) Baud Rate Generator

o) Sampling Circuit

o) Asynchronous Transmitter

o) Asynchronous Receiver

ADC MODULEThe analog-to-digital con-

verter module has five inputsfor the 28-pin devices ('F873,'F876) and eight inputs for theothers ('F874, 'F877).

The selected analog inputcharges an internal sample and

hold capacitor, the output ofwhich is the input to the con-verter. The converter then gener-ates a 10-bit digital equivalent ofthis analogue level via succes-sive approximation. The conver-sion result is stored in a 16-bitregister, which may be instructedto justify it left or right, with theextra bits set as zeros.

Accuracy of the conversion isdependent on the capacitor beingallowed to fully charge to the in-put channel voltage level. Theimpedance of the external sourceand that of the internal samplingswitch directly affect the chargeacquisition time and must betaken into account when design-ing the analogue source circuit.The maximum recommended in-put source impedance is 10k:.Sampling rates can be selectedunder software control. At a crys-tal oscillator rate of 20MHz, theminimum recommended sam-pling time is 1¬¬¬6Ps.

A unique feature of the ADCis that it is able to operate whilethe device is in Sleep Mode.

Voltage reference can be in-ternally set at VDD and VSS levels,or at user-selected external levels

6SHFLDO5HYLHZ

o) Timer0: 8-bit t imer/counter with 8-bit prescalero) Timer1: 16-bit t imer/counter with prescaler, can be incremented during Sleep via external crystal/clocko) Timer2: 8-bit t imer/counter with 8-bit period register, prescaler and postscalero) Two Capture, Compare, PWM (pulse width modulation) modules Capture is 16-bit, max resolution 12.5ns Compare is 16-bit, max resolution 200ns. PWM resolution is 10-bito) 10-bit multichannel ADC (analog-to-digital) convertero) Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave)o) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detectiono) Parallel Slave Port (PSP) 8-bits wide, with external ~RD, ~WR, and ~CS controls (40/44-pin only)o) Brown-out detection circuitry for Brown-out Reset (BOR)

(PIC16x84 only has Timer0 -- al l other features specif ic to 'F87x)

Table 2. Peripheral features. =3<BF@@D8F

B1 1>

B1!1>!

B1$D 3;9

B1%1>$CC

7>4

?C3!3<;9>

?C3" <;?ED

B3 D!?C?D!3;9

B3!D!?C933@"

B333"33@!

B3#C3;C3<

B1#1>#FB56

B1"1>"FB56

B2'@74

B2&@73

B2%

B2$

B2#@7=

B2"

B2!

B2 9>D

F5

F5

7>4

HHH

' B 4D

BBB333&D3;

% CCC444?

$ 9C41

!

"

#

$

%

&

'

(

)

!

"

#

$

%

!!!&

'

(

)

"

"(

"""!

"

#

$

%

&

'

")

#

#!

#"

##

#$

#%

#&

#'

#(

#)

$

B5"3C1>'

B5!GB1>&

B5 B41>%

B4'@C@'

B4&@C@&

B4%@C@%

$ $

BBB444#@@@CCC@@@#

" "

BBB444 @@@CCC@@@

! !

Fig.2. Pinout details for thePIC16F874/877 microcontrollers.

EPE Online, April 1999 - www.epemag.com - 434

set via pins RA2 and RA3. Thereference source for each inputcan be individually selected forinternal or external. Users arecautioned that the conversionaccuracy degrades as the exter-nally applied VREF diverges fromVDD. Minimum differentialbetween VREF+ and VREF is 2V.Quantization error istypically 1 LSB.

CAPTURE, COM-PARE, AND PWM

Each Capture/Compare/PWM module contains a 16-bitregister, which can operate as a16-bit Capture register, as a 16-bit Compare register, or as aPWM (pulse width modulation)master/slave DutyCycle register.

In Capture mode, the 16-bitvalue of the TMR1 register iscaptured when an event occurson pin RC2/CCP1, which setsan interrupt flag. An event canbe defined as occurring on:

o) Every falling edge

o) Every rising edge

o) Every 4th rising edge

o) Every 16th rising edge

In Compare mode, the 16-bit register Capture is constantlycompared against the TMR1value. When a match occurs aninterrupt flag it set and(depending on a pre-selectedcontrol code) the RC2/CCP1pin is:

o) Driven high

o) Driven low

o) Remains unchanged

In PWM mode, theRC2/CCP1 pin produces aPWM output of up to 10-bit res-olution. The PWM period andduty cycle can be set throughsoftware.

PRIMARY CONFIGU-RATION

The four 'F87x deviceshave a different primary config-uration word (initialization pat-tern) to the PIC16x84 devices.This means that, even withhardware permitting, the config-uration associated with theTASM SEND and PIC Toolkitprograms (their Mode 1) cannotbe used to fully configure the'F87x devices.

These two EPE-publishedprograms have been written toprovide the same common con-figuration data (oscillator type,WDT, Power-Up Timer) to bits0-3 of the configuration register,but the remaining bits (4-13) arenot accessible to the user.

In the 'F87x devices, how-ever, bits 4-13 are variouslyused for configuring Code Pro-tect, Brown-out Reset, Low Volt-age Programming enable, EEP-ROM data memory code pro-tect, Flash Program MemoryWrite enable, In-circuit Debug-ger mode.

LOW VOLTAGE PRO -GRAMMING

PIC16F87x devices can beserially programmed while inthe end application circuit (ascan the '84s), by means of threeconnections (plus ground). Inter-estingly, the 'F87x devices canalso be programmed using twoconnections (plus ground)while in a low voltage program-ming (LVP) mode.

At first sight, this seems tobe an exciting option no morerequirement for a 12V to 14Vprogramming supply (VIHH) onthe ~MCLR pin. Regrettably,this is not the case. An 'F87xdevice has to be configured to

accept the LVP mode and thisconfiguration can only be donewhen the chip's programmingvoltage is at the usual VIHH level.

Once the LVP option hasbeen configured, though, futureon-board re-programming can bedone at the VDD level. In thismode, the RB3/PGM pin is dedi-cated to the programming func-tion and ceases to be a generalpurpose I/O pin. A VDD of +5V(10%) is applied to the ~MCLRpin (as it is for normal runningmode with a supply of 5V) duringlow voltage programming, whichis set by software outputting logic1 to the RB3/PGM pin.

The LVP bit can only be pro-grammed when programming isentered with VIHH on ~MCLR; itcannot be programmed when pro-gramming is entered withRB3/PGM. If the LVP option hasnot been enabled, only the highvoltage programming mode canbe used to program the device.

PROGRAMMINGHARDWARE

PIC16F87x devices can beprogrammed via Microchip's suiteof programming hardwareand software (contact Microchipfor more details).

Additionally, a Mk2 version ofthe EPE PIC Toolkit is in prepara-tion. It will allow all currentPIC16F87x and PIC16x84 de-vices to be programmed. TheMk2 version will also include soft-ware that assembles (compiles)the source codes (written inTASM or MPASM formats) to be-come object codes for sending tothese devices via the same pro-gram. This program will removethe need for using TASM itself asthe assembler for the '84 devices(we have no intention of upgrad-ing TASM or its SEND programfor the 'F87x devices).

6SHFLDO5HYLHZ

EPE Online, April 1999 - www.epemag.com - 435

Watch our pages for thepublication date of Toolkit Mk2.

An example of one of thePIC16F87x devices in use isalso in preparation. It is a DataLogger that makes use of thedevice's ADC and serial com-munications facilities, and intro-duces the use of a Microchipserial EEPROM memory de-vice. Again, watch these pages!

PIC16F87X AVAIL -ABILITY

All good suppliers of PICmicrocontrollers should bestocking the PIC16F87x de-vices, including RS, Farnell,Magenta and Maplin (other sup-pliers are invited to advise usthat they are doing so as well we will publicize the factthrough our news pages).

You will be interested toknow that three data sheets are

available from Microchip, theirweb site, and their latest CD-ROM. The data sheet for thePIC16F87x microcontrollers(200 pages of it (1¬¬¬34Mb), butexcluding serial program-ming data) is available asdata sheet DS30292A.General details of serialprogramming for all PICmicrocontrollers are givenin the In-Circuit Serial Pro-gramming Guide (datasheet DS30277B). LVPprogramming for the 'F87xdevices is detailed in thePIC16F87x ProgrammingSpecification (data sheetDS39025 but not yet onthe web site at the timeof writing, mid-Jan).

Arizona MicrochipTechnology can be con-tacted at Microchip House,505 Eskdale Road, Win-nersh Triangle, Woking, BerksRG41 5TU, UK. Tel: +44 (0)

118-921-5858. Fax: +44 (0) 118-921-5835. Web:www.microchip.com . Mailaddresses for Microchip agentsworld-wide are also accessiblevia this web site.

ACKNOWLEDGE -MENT

We express our gratitude toArizona Technologies Ltd (a sub-division of Arizona Microchip) fortheir helpful co-operation in con-nection with our introduction toand use of the PIC16F87x micro-controllers and associated serialEEPROM devices.

MICROCHIP C-ROMWe heartily recommend that

anyone interested in PIC micro-controllers should obtain Mi-crochip's CD-ROM. It contains a“snap-shot” of Microchip's website and takes you to the com-plete selection of PIC microcon-trollers (including the 'F87x), plusnon-volatile memory devices, se-rial EEPROMs, Keeloq code hop-ping devices and a full-line ofdevelopment tools.

6SHFLDO5HYLHZ

PIC16F873 PIC16F874 PIC16F876 PIC16F877

Operating FrequencyResets (and Delays)

Flash Program Memory(14-bit words)

DC-20MHzPOR, BOR

( P W R T , O S T )

DC-20MHzPOR, BOR

( P W R T , O S T )

DC-20MHzPOR, BOR

( P W R T , O S T )

DC-20MHzPOR, BOR

( P W R T , O S T )

4K 4K 8K 4K

Data Memory (Bytes) 192 192 368 368

EEPROM Data Memory 128 128 256 256

Interrupts 13 14 13 14

I/O Ports A,B,C A,B,C,D,E A,B,C A,B,C,D,E

Timers 3 3 3 3

Capture, Compare, andPWM Modules

2 2 2 2

Serial CommsMSSP

USARTMSSP

USARTMSSP

USARTMSSP

USART

Parallel Comms --- PSP --- PSP

10-bit ADC 3 inputs 8 inputs 3 inputs 8 inputs

Instructions

Pins

35 35 35 35

28 40 28 40

Table 3. Device-specific key features.

EPE Online, April 1999 - www.epemag.com - 436

Consider the following designproblem. A circuit is to be batterypowered, preferably from a 9Vsource. It will drive six ultra-brightLEDs, connected in series on theend of a two-core connectinglead.

To be sure of overcomingtheir collective forward voltagedrop, a supply of at least six voltsis required, plus an additionalthree volts as "overhead" for theiroperating circuit since brilliance isto be accurately controlled. Thisrules out direct supply from a 9Vbattery as these normally deterio-rate to about 6V before replace-ment.

As the LEDs are to be oper-ated with a maximum current of40mA a charge-pump step-upconverter is not practical, whichleaves just two possibilities. Ei-ther a switch-mode converter isemployed, or the battery supplymust be increased to 12V.

SWITCHED-ON ICNot so long ago, the design of

switch-mode converter circuitswas considered to be somethingof a black art, usually avoided byhobbyists. The introduction ofsimple, integrated circuit, switch-mode regulators is rapidly chang-ing this however, and the MaximMAX761 is a fine example ofthese integrated circuits (ICs).

ers using this IC is very simpleand anyone designing their owncircuits, especially where bat-tery power is intended, wouldbenefit from an understandingof its capabilities.

IN BRIEFA brief description of the

operation of the switch-modestep-up converter is as follows.In simple terms, an electronicswitch is used to connect thesupply voltage across an induc-tor so that a rapidly rising cur-rent flows through it. When thiscurrent reaches a suitable valuethe switch is opened. Current inan inductor has a tendency tokeep flowing and will generate ahigh voltage in order to do so,as demonstrated by the sparksproduced when mechanical con-tacts are used to break current

Squeezing the most out of your batteries could notbe easier if you use the MAX761 step-up voltageconverter.

0$;'& 72 '&&219(57(5

E\ $1'< )/,1'

It can provide an outputvoltage between 5V and 16¬¬¬5Vfrom an input extending to be-low 3V, and output currents inexcess of 150mA are possible.High speed switching allows theuse of small inductors and de-coupling capacitors. It can oper-ate from as little as 100PA ofquiescent current and also con-tains a low supply voltage de-tecting circuit which makes itideal for battery-powered appli-cations.

Although advertised as a12V device, the output voltagecan in fact be adjusted to anyvalue between 5V and 16¬¬¬5Vwith just two external resistors.The design of step-up convert-

Q

4!C55 D5HD

<29 <H93!"

#

$

3!! P

F

'

62

C84> B56

7>4=1H'&!

3#! ^

%

&

!

3"! ^

9>@ED

"F D? &F

F<2? (

<!!( 8P

F

3%##P

3$! ^

!"F! ]16B?=%F ( 566

% ]]]1114???G>D? "%F

" D 25<?G "F

?ED@ED[

Fig.1. Pin connection details and basic bootstrapped operationfor the Maxim MAX761 step-up voltage converter.

EPE Online, April 1999 - www.epemag.com - 437

flowing in an inductive circuit.

In the case of a switch-mode converter, this current isdiverted through a diode into areservoir capacitor, and re-peated operation of the elec-tronic switch can produce anoutput voltage that is higherthan that of the input. A controlcircuit is normally provided toensure that current flow in theinductor does not rise to a valuehigh enough to damage theswitch, and to adjust switch fre-quency and “on” times toachieve the desired output volt-age over a range of input volt-ages and output load currents.

INSIDE DATAAlthough switch-mode cir-

cuits are complex, most of thedesign work is covered by theinternal circuit of the MAX761.The best way to understand theoperation of this device is prob-ably through some practical ex-amples.

The data sheet refers fre-quently to two “modes” of oper-ation, “bootstrapped” and “non-bootstrapped”. In practice, allthis means is that in boot-strapped mode the IC takes itsinternal power from the circuitoutput, whilst in non-bootstrapped operation power istaken in the conventional man-ner from the positivesupply input.

There are two advantagesto bootstrapped use. One is thatthe internal power switch, aMOSFET device, receives ahigher gate drive voltage andcan therefore switch morerapidly, improving efficiencywith low supply voltages andhigh output currents.

The other is that in thismode the voltage-setting feed-back input can be simply con-

nected to V supply for a fixed12V output, eliminating the twovoltage-setting resistors. Thisoption is not possible in the non-bootstrapped mode. An alterna-tive version of the device, theMAX762, produces a 15V out-put in this configuration.

The data sheet recom-mends the use of bootstrappedoperation for supply voltagesbelow 4V and up to 6V forhigher output currents. At highersupply voltages non-bootstrapped operation canmarginally improve efficiency,although the simple fixed 12Voutput option may make boot-strapping preferable.

OPERATION BOOT-STRAPS

The basic bootstrapped cir-cuit is shown in Fig.1, whichalso shows the pin arrangementfor the MAX761 DC/DC con-verter IC. Positive supply for pin8 is taken from the output. The“low battery” (LB) and“shutdown” (SHDN) inputs, pin 2and pin 4, are not used and aredisabled by connection toground (V). The voltage sensingfeedback (FB) connection at pin3 is also grounded, causing theinternal sensing circuit to takeits reference from pin 8 andgenerate a fixed 12V output.

Decoupling capacitors areprovided at input and output.The data sheet suggests 33PFat both input and output, but inpractice some improvementwas obtained from the use of100PF for C1 at the input. Somedesigns might also benefit fromthe use of a larger value of C5at the output. For simplicitythese capacitors are only shownin this example, though theyshould be included in all circuitsusing this device.

The internal reference volt-age is nominally 1¬¬5V and ap-pears at pin 5 (REF), though it isusually not necessary to do any-thing with this pin excepting theprovision of a 100nF decouplingcapacitor as shown. The internalelectronic switch operatesthrough pin 7 (LX) to connect oneend of the inductor L1 to ground,following each switch turn-off cur-rent flows through diode D1 intoC5 to produce the output.

On test this circuit managedto produce up to 100mA of 12Voutput from a 5V supply with anefficiency of 80 per cent. It main-tained 50mA down to an input of2¬¬¬5V and 20mA to below 2V,though it would not always startup reliably with these suppliesand loads.

The data sheet states that thevalue of inductor L1 can be se-lected from L(PH) = 5 x V, whereV is the maximum expected sup-ply voltage. This is about as sim-ple as inductor selection for aswitch-mode circuit can get, andsince the IC also shows an amaz-ing tolerance for incorrect values,design is very easy even when awide range of supply voltage andoutput current is expected.

Diode D1 MUST be a high-speed type due to the switchingfrequency of the circuit. “1N400X”series types will NOT work withthe 761. The data sheet suggestsa Schottky device, the 1N5817.Testing for this article was carriedout using a UF4002, which is ahigh-speed version of the1N4002.

A bootstrapped circuit usingexternal feedback resistors R1and R2 to set the output to 9V isgiven in Fig.2. Apart from the useof these resistors the circuit is thesame as that of Fig.1. (Input andoutput decoupling capacitors notshown.)

6SHFLDO)HDWXUH

EPE Online, April 1999 - www.epemag.com - 438

The resistors are calculatedfrom the simple formula:

R2 = R1 x (( Vout/Vref) – 1)

… remembering that Vref has anominal value of 1¬¬5V. Thevalue of resistor R2 can be any-where between 10k (kilohms)and 250k, bearing in mind thatthe higher the values of thesetwo resistors, the lower the cur-rent loss through them.

With a supply of 6V, thiscircuit produced up to 150mAwith an efficiency of 87 percent, whilst 100mA was avail-able with a 4¬¬¬5V input. Thiswould allow three or four AAcells to become a cost-effectivealternative to the ubiquitousPP3. A current of 30mA wasmaintained to below 2V, sug-gesting the possibility of low-power 9V circuitry operatingfrom just two cells or a singlelithium cell.

An example of a non-bootstrapped 12V circuit isshown in Fig.3. With an input of9V, this generated 12V out at upto 200mA with an efficiencyaround 90 per cent. Althoughdesigned for higher supply volt-ages, it still managed 50mA ofoutput from a 4V supply, so itcould find plenty of uses.

LIFE EXTENDERA Battery-life Extender, which

takes the output of a 9V battery,such as a PP3, and maintains aconstant 9V as the actual batterysupply voltage gradually drops offis shown in Fig.4. There are tworeasons for doing this, one beingthat the battery can deterioratefurther than usual before replace-ment is necessary, whilst theother is that the circuit receivesfull supply for the entire life of thebattery.

Low battery indication is pro-vided in this example by feedingpart of the supply voltage to LB1(pin 2) through the potential divid-ing resistors R1 and R2, for com-parison with the 1¬¬¬5V internal ref-erence. Resistor R2 can be any-where from 10k up to 500k, whilstR1 can be calculated from theformula shown in the diagram,again remembering that Vref is1¬¬¬5V.

The values shown cause LEDD1 to light at about 6V. The inputLB1 has a built-in hysteresis of20mV to help prevent jitter.

The output of the low batterydetector, LB0 (pin 1), is an open-drain capable of sinking 5mA so itcan be used for directly driving alow-power LED as shown in Fig.4.

If it is to be used to control alogic input a pull-up resistorfrom LB0 to positive supply maybe required.

SHUTDOWNNo mention of the shutdown

(SHDN) input, pin 4, has been

6SHFLDO)HDWXUH

F

)F

?ED@ED

=1H'&!

B56G85B5 F

DB9@

- !%F

B! - B" hF FB56

FB56

F

7>4

&

$C84>

<29"

B"## [

B56

%

3#! ^

B%&([

4!"]1 <54B54

9>@ED

B!!=

&F D? )F

'

<2?!

B#"["

[

Q

F<H

(

93! #62

[Q

4!C55D5HD

B$## [

<!$' 8P

F

%F!"F

?ED@ED

=19> %F

?ED@ED

3?>DB?<

F

Q

[

4!7>4

<29

&

"

$C84>

B56

%

3#

! ^

#62

=1H'&!

93"

9>

3?=

'( %

93!

F

9>@ED

'B!

! [

Q [4"

?ED %F&

<H

(

F

[Q

4!

<!

C55 D5HD

!( 8P

Fig.4. Circuit diagram for a 9V battery life ex-tender, with low battery warning.

Fig.5. Circuit diagram for a 5V/12V switch-able supply from a 5V input.

F

)F

?ED@ED

=1H'&!$C84>

7>4

&

F

B56

3#!

B"

&([

%

'

<29

<2?>3

"

!

9>@ED

"F D? &F

F<H

(

B!## [

93! #62

[Q

4!C55D5HD

<!!(8P

Fig.2. Bootstrapped opera-tion with a 9V output.

F

!"F

?ED@ED

=1H'&!<29

7>4

&

F

$C84>

B56

3#! ^

B"$'[

%

(

F

<2?>3

"

!

9>@ED

$F D? !"F B!## [

93! #62

'

<H

[Q

4!

<!

C55 D5HD

$' 8P

Fig.3. Non-bootstrappedoperation, 12V output

from 9V input.

EPE Online, April 1999 - www.epemag.com - 439

made so far. Quite simply, ifthis input is low (Ve) the 761operates normally, whilst if it ishigh (+Ve) operation ceases. Inthe shutdown state the MAX761IC is stated to draw about 5PAof quiescent current, and thesupply voltage will, of course,continue to appear at the out-put, less the forward drop ofdiode D1.

A possible use for this fea-ture is shown in outline by Fig.5,a 5V/12V switchable supply cir-cuit. Here a regulated supply of5¬¬¬6V is produced by placing adiode in the “ground” (common)path of the 5V regulator IC1.The forward voltage drop ofdiode D2 compensates toprovide a main logic supplyrail of +5V.

Meanwhile, resistor R1holds the SHDN input of IC2high so IC2 does not operate,and the forward voltage drop ofD3 results in an auxiliary supplyof +5V. If the “control” input isnow grounded however, IC2 willbegin to operate and theauxiliary supply will rise toalmost 12V.

6SHFLDO)HDWXUH

Some decoupling capacitorsare, of course, required in apractical circuit, but this easilycontrolled dual-voltage supplycan be created with very fewcomponents and a single low-voltage supply, and could proveuseful in the design of logiccircuits which require a switch-able 5V/12V supply for pro-gramming purposes.

IN CONCLUSIONThe circuits shown here

were all bench-tested by the au-thor to obtain practical data onthe MAX761's performance. TheIC appears to be commendablyrobust, as the usual untidybreadboard construction, poorhandling procedures and occa-sional incorrect connectioncaused no damage.

Internal switching appearsvery efficient as, despite inputcurrents up to 500mA, it neverbecame noticeably warm. Underheavily loaded conditions itsometimes failed to start, andwhen overloading causes it todrop out of regulation drasticreduction of the load is some-

times necessary to bring it backin. When forced out of regula-tion in this manner it can gener-ate a lot of RF noise, right intothe VHF spectrum.

It should be rememberedthat switch mode circuits arefairly noisy in this respect any-way, so their main use is inlogic circuits, anything to dowith radio reception is probablynot a good idea. To minimizeradiation a toroidal or pot-coreinductor could be used, thoughtesting for this article was car-ried out with miniature ferritebobbin-type inductors.

With these notes in mind,the MAX761 DC/DC voltageconverter will hopefully becomea useful device in the workshopof many amateur designers.

SOURCEThe MAX761 5V to 12V DC/

DC converter chip should nowbe widely stocked by advertis-ers and will be priced around 4UK Pounds each. The authorobtained his from Maplin(www.maplin.co.uk ) codeNR61R.

EPE Online, April 1999 - www.epemag.com - 440

In this month’s constructionalarticle, Alan Winstanley describeshow to add a number of mi-croswitches around the peripheryof the PhizzyBot. For our part inthis tutorial, we are going to dis-cuss how to program the Phizzy-Bot to use these microswitches todetect collisions (say with a wallor a household pet) and performwhatever actions we deem to beappropriate. (Note that vaporizinghamster-type obstructions withindustrial-strength lasers is NOTan appropriate response!).

As part of this exercise, we’llbe employing some rather cun-ning programming tricks that willmake you squeal with delight (sodon’t read this article in a publicplace, because we cannot be heldresponsible for the outcome)!

ADDING SWITCHESNote that we are going to be

using the interrupt-driven inputswitch device we created in Part4 of this series (Feb ‘99), and thatthis device will be connected tothe PhizzyB’s input port at ad-dress $F012. Now, as discussedin Alan’s constructional article, weare going to physically mount sixmicroswitches to the PhizzyBot asshown in Fig.1.

only six microswitches? Afterall, the input port could supporteight switches if we so desired.If you’ve been conditioned toassume that everything to dowith computers is complex, theanswer to our poser shouldprove to be refreshingly simple,because there is no reasonwhatsoever.

We could indeed have usedeight microswitches, but we de-cided that six would do the job(plus we only had six mi-croswitches in our treasurechest of parts and it was rainingand neither of us wished to trekout to the local electronicsstore).

SKELETON PROGRAMOK, as for last month, the

first thing we’re going to do is tocreate a skeleton (framework)program, which we’ll develop aswe go along. Invoke yourPhizzyB Simulator, activate theassembler, and enter the pro-gram shown in Listing 1.

Before you do anythingelse, save this skeleton programas eeexp1.asm. Now considerthe Constant Declarations sec-tion at the beginning of the pro-gram. The SWITCHES label will

Hi there. As you will recall, last month in a crescendo of excitement we created a simple CD motorcontroller output device. Next we mounted the PhizzyB on a base with two DC motors, thereby taking afirst step towards a simple robot, the PhizzyBot.Then we performed some simple experiments to test our ability to control the PhizzyBot’s motors. Thisincluded the creation of a timing subroutine that allowed us to execute actions for fixed duration'sspecified in tenths of a second. Cool! But wait, there’s more . . .

3KL]]\% &20387(56

3DUW 3KL]]\%RW&ROOLVLRQ 'HWHFWLRQE\ &OLYH ´ 0D[µ 0D[ILHOG DQG $OYLQ %URZQ

For reasons that are a bittoo involved to go into here,computer guys and gals oftenstart numbering things fromzero, and our microswitches areno exception. (The reasons fornumbering things in this mannerare discussed in excruciatingdetail in our book BebopBYTES Back.)

These switches are going tobe connected to the 16-pinheader on the interrupt-drivenswitch device, such that Switch0 ultimately drives bit IP0 of theinput port, Switch 1 drives bitIP1, and so forth.

One point you might bepondering is why did we use

Front

Top-downview

23

14

5 0

Fig.1. Locations of themicroswitches.

EPE Online, April 1999 - www.epemag.com - 441

be used to associate ourinterrupt-driven switch device(which is now wired to the mi-croswitches) with the input portat address $F012.

As per last month, we’re go-ing to use the PhizzyB’s on-board 8-bit LED bargraph dis-play to indicate the value we’redriving to the motors. Thus, weequate the MGRAPH label to theaddress of this output port,which is $F030.

Similarly, we’re going toconnect the 8-bit LED bargraphdisplay we created in Part 2(Dec ’98) to the output port ataddress $F031, and then usethis to display the current valuein the timer. Thus, we equatethe TGRAPH label to the addressof this output port.

Next we’re going to connect

our motor controller board fromPart 5 (Mar ’99) to the outputport at address $F032. Hencethe MCONTROL declaration.

Moving on, the DELCONSTlabel is assigned a value of $0C(12 in decimal), which is used topersuade our timing subroutineto loop around for 1/10 of a sec-ond (we determined the value ofDELCONST by trial and error aswe discussed in last month’stutorial).

Finally, the way in which weuse the FOREVER, NOMORE,GOGOGO, and EEEKSTOP labelswill become apparent as we pro-ceed (although their namesshould be somewhat suggestiveof their function).

At the end of the programwe reserve three 1-byte mem-ory locations called GOFLAG,

TVALUE, and TEMPSW, plus a 2-byte value called TEMPX. This 2-byte value is of particular interestin that we assign it an initial valueof $0000. The way in which thisinitialization works is discussed inmore detail in Chapter 12 of Be-bop BYTES Back and also in Ap-pendix D of The Official Bebop-uter Microprocessor Databook(this appendix is provided freewith the PhizzyB Simulator –check the simulator’s online helpfor more details)

INDIVIDUAL MOTORCONTROL CON-STANTS

What! More constants? Wellyes, we’re afraid so, but these lit-tle rascals are going to make ourlives one heck of a lot easier, letme tell you. For example, a bi-nary value of 00001010 doesn’timmediately convey a lot of infor-mation to the casual reader,whilst a constant label calledFORWARD (which we can associ-ate with the 00001010 value)gives us a pretty good clue as towhat’s going on.

From last month’s article weknow that output port bits OP1and OP0 are used to control thePhizzyBot’s left-hand motor,whilst bits OP3 and OP2 are usedto control the right-hand motor(Table 1). (Remember that, in thiscontext, the terms ‘‘left’’ and‘‘right’’ refer to your perspective ifyou were to shrink yourself downand position yourself atop of thePhizzyBot looking towards itsfront end.)

Note that if the control bitsassociated with a motor are atboth at 1, this will also cause thatmotor to stop, but we aren’t par-ticularly concerned with this. Weonly need one stop condition permotor, and we’ve chosen to usethe case where both control bits

&RQVWUXFWLRQDO3URMHFW

Listing 1### Start of Constant DeclarationsSWITCHES: .EQU $F012 # Switch input deviceMGRAPH: .EQU $F030 # Motor bargraph displayTGRAPH: .EQU $F031 # Timer bargraph displayMCONTROL: .EQU $F032 # Motor controller board #DELCONST: .EQU $0C # Delay constant valueFOREVER: .EQU $00 # Do it forever codeNOMORE: .EQU $FF # End-of-sequence codeGOGOGO: .EQU $01 # "Let's go" codeEEEKSTOP: .EQU $00 # "Let's stop" code### End of Constant Declarations

### Start of Main Program Body .ORG $4000 # Start of program### End of Main Program Body

### Start of Interrupt Service Routines### End of Interrupt Service Routines

### Start of Subroutines### End of Subroutines

### Start of Temp Locations and Data ValuesGOFLAG: .BYTE # Flag (0=stop, 1=go)TVALUE: .BYTE # Main timer tempvalueTEMPSW: .BYTE # Copy of switchesTEMPX: .2BYTE $0000 # Temp index register### End of Temp Locations and End of Program .END

EPE Online, April 1999 - www.epemag.com - 442

are 0. Based on this, we need toadd six more constant declara-tions to our program as shownin Listing 2a (append these tothe bottom of the existing decla-rations).

COMBINED MOTORCONTROL CON-STANTS

If we only account for onestop condition for each motor asdiscussed above, then eachmotor has three possible statesit can be in. As we have twomotors, this gives us a total of 3× 3 = 9 different possibilities.Four of these cover the caseswhere both motors are activesimultaneously (Fig.2).

The next four cases to con-

sider are those in which only asingle motor is active (Fig.3). Inthis case the PhizzyBot can turnleft or right, and also reverse tothe left or right.

The final case, of course, iswhere both motors are inactive(we won’t bother illustrating thiscase). We can add these ninecases to our constant declara-tions as shown in Listing 2b.

The vertical bar character(‘‘|’’) in the center of the listing isused to indicate a logical OR op-eration. We haven’t seen this sortof thing before, but in fact con-stant declarations can employsimple logical and arithmetic op-erations between numerical val-ues and/or previously declaredconstant declarations.

For example, we previously

assigned the labels RREVERSEand LFORWARD with values of00000100 and 00000010, re-spectively. The logical operatorin the constant declarations be-haves in a similar manner to thePhizzyB’s OR instruction (whichwas introduced in Part 2). Thus,our new SPIN_CW (spin clock-wise) label from Listing 2b willend up being assigned a valueof 00000100 ORed with00000010, which will be re-solved as 00000110.

There are several points tonote here. First, constant decla-rations are only used by the as-sembler to perform its machina-tions. These declarations don’taffect the size of the finalmachine-code program, sothere’s no overhead involved inusing them.

Obviously we could havesimply used a SPIN_CW .EQU%00000110 statement to assigna value to our SPIN_CW labeldirectly (and similarly for ourother labels). However, thiswould have obliged us to per-form the OR operations manu-ally, which would be a pain inthe neck and prone to error.Given a choice, we always pre-fer to make the assembler dothe bulk of the ‘‘grunt work’’,thereby leaving us free to do theconceptual thinking.

One very important point isthat these new labels MUST ap-pear AFTER our other labels,because an expression formingpart of a constant declarationcan only make use of constantlabels that have already beendeclared. Otherwise, it would bepossible to generate expres-sions in which label ‘‘A’’ wasused to define label ‘‘B’’, whichwas in turn used to define label‘‘A’’, which would result in noend of confusion. (This is dis-cussed in more detail in Chapter12 of Bebop BYTES Back and

&RQVWUXFWLRQDO3URMHFW

MicroswitchNumber

012345

6 (Dummy)

Binary Valuefrom Switches

Result inIndex Register

$0000 (0)$0001 (1)$0002 (2)$0003 (3)$0004 (4)$0005 (5)$0006 (6)

00000001000000100000010000001000000100000010000001000000

Listing 2aLSTOP: .EQU %00000000 # Left motor stop codeLREVERSE: .EQU %00000001 # Left motor reverse codeLFORWARD: .EQU %00000010 # Left motor forward codeRSTOP: .EQU %00000000 # Right motor stop codeRREVERSE: .EQU %00000100 # Right motor reverse codeRFORWARD: .EQU %00001000 # Right motor forward code

Listing 2bSTOP: .EQU LSTOP | RSTOP # All stopFORWARD: .EQU LFORWARD | RFORWARD # Go forwardREVERSE: .EQU LREVERSE | RREVERSE # ReverseSPIN_CW: .EQU LFORWARD | RREVERSE # Spin clockwiseSPIN_ACW: .EQU LREVERSE | RFORWARD # Spin anticlock -wiseTURN_L: .EQU LSTOP | RFORWARD # Turn leftTURN_R: .EQU LFORWARD | RSTOP # Turn rightBACK_L: .EQU LSTOP | RREVERSE # Reverse leftBACK_R: .EQU LREVERSE | RSTOP # Reverse right

EPE Online, April 1999 - www.epemag.com - 443

in Appendix D of The OfficialBeboputer Databook.)

ACTION SEQUENCESNow let’s pause for a mo-

ment to ponder exactly what wewant to be able to do. If thePhizzyBot wanders into some-thing causing one of its mi-croswitches to be activated,then we want to be able tocause the little rascal to executea specific sequence of actions(for example, ‘‘Stop, reverse,turn right, go forward again . ..’’).

In order to do this we re-quire a method by which we canspecify such a sequence of ac-tions in our PhizzyBot controlprogram. Furthermore, remem-bering that there could well be adifferent sequence associatedwith each microswitch, we wantthis method to be easy to readand modify, thereby facilitatingour ability to experiment withdifferent sequences.

&RQVWUXFWLRQDO3URMHFW

The absolute worst casewould be for us to have to spec-ify such a sequence as a collec-tion of binary values. For exam-ple: 00000000 (stop), 00000101(wait for 0¬¬5 seconds),00000101 (reverse), 00001010(for 1¬¬0 second), 00001001 (spinanticlockwise), 00000111 (for0¬¬7 seconds), 00001010 (go for-ward), and so forth.

Note that, as per our discus-sions from last month, we’re as-suming that the delays arespecified in tenths of a second.For example, 00000101 = 5,which means 5 times 0¬¬¬1 sec-onds = 0¬¬¬5 seconds.)

At the other end of thespectrum, it would be great tobe able to actually specify acommand sequence as a stringof characters in natural lan-guage format, such as ‘‘Stopand pause for 0¬¬¬5 seconds, thenreverse for one second, thenspin anticlockwise for 0¬¬¬7 sec-

onds, then start to go forwardagain’’.

Unfortunately, natural lan-guages contain ambiguities andlogical inadequacies, so we’llneed to use something a littlemore formalized. However, wemight be able to get quite closeto our ideal case with relativelylittle effort.

Consider the statementsshown in Listing 3 (and whileyou’re considering them, insertthem into your program just af-ter the temporary locations atthe bottom of the program).

The syntax we’ve decidedto use is to commence each se-quence of actions with a label.For example, the label ACTSW0stands for ‘‘The actions associ-ated with Switch 0’’. This label isthen followed by a series ofbytes, which are organized aspairs consisting of an action fol-lowed by a delay (specified intenths of a second). The assem-bler will of course replace theaction code labels like STOP,REVERSE, and SPIN_ACW withtheir binary equivalents00000000, 00000101,00001001, respectively.

As we will soon discover,we’re going to organize themain body of the program suchthat an action code of 11111111causes the PhizzyBot to stopand wait for another interrupt tooccur (for example, a pet tobump into one of the switches).

Furthermore, we’re going towrite the program such thatspecifying a delay of 0 actuallymeans ‘‘do this action forever’’(or at least until the PhizzyBotbumps into something causing anew interrupt to occur). This ex-plains the two constant labelsNOMORE and FOREVER, whichwe declared in our skeletonprogram, and which we seeappearing in Listing 3.

Left = ForwardRight = Forward

(a) GoForwards

(b) GoBackwards

Left = ReverseRight = Reverse

(c) SpinClockwise

Left = ForwardRight = Reverse

(d) SpinAnticlockwise

Left = ReverseRight = Forward

Fig.2. Cases where both motors are active.

(a) TurnRight

Left = ForwardRight = Stop

(b) TurnLeft

Left = StopRight = Forward

(c) ReverseLeft

Left = StopRight = Reverse

(d) ReverseRight

Left = ReverseRight = Stop

Fig.3. Cases where only one motor is active.

EPE Online, April 1999 - www.epemag.com - 444

Note the ASTART label atthe end of the action se-quences. We’re going to usethis to define what the Phizzy-Bot will do when the programfirst starts running. As you cansee, our example program sim-ply instructs the PhizzyBot tostart rolling forward, and to keepon doing so until it bumps intosomething.

However, once you’ve gotthis first version of the programworking, you could easily mod-ify this sequence to do some-thing more interesting, such asspinning round three times be-fore heading off into the greatunknown.

Also note that we’ve onlyassigned actions to the twoswitches on the front of thePhizzyBot (Switch 0 and Switch5). This assumes that thePhizzyBot will roll forward until itbumps into something, at whichpoint it will reverse, spin oneway or the other, and start goingforward again. If any of theother switches are triggered, thePhizzyBot will stop dead in itstracks ... unless you assign yourown action sequences to theseswitches of course ...

A CUNNING PLOYOne thing we’re going to

need to know is the start ad-

dress of each of the action se-quences we just created above.But these start addresses arefairly fluid. For example, if weinsert additional actions into theACTSW0 sequence (or deletesome actions), then this willchange the start addresses ofall of the other action se-quences.

What’s needed is a cunningploy, and we are nothing if notmasters of the cunning ploy! Toillustrate what we mean, perusethe statements in Listing 4(while you’re adding them to theprogram just after the action se-quences).

DON’T PANIC if this doesn’tappear immediately obvious ona first viewing. Consider labelADRSW0, which is used to re-serve a 2-byte value in thePhizzyB’s memory. As we dis-cussed earlier (in the context ofthe TEMPX label), it is possibleto instruct the assembler to ini-tialize the contents of memorylocations reserved in this way.In this case, we’re assigning thelabel ACTSW0 to our 2-bytevalue. Our cunning ploy is thatthe assembler will automaticallyreplace this assignment with theactual address of ACTSW0.

The end result is that weknow that the 2-byte valuewe’ve called ADRSW0 will con-

tain the start address of actionsequence ACTSW0. Similarly,the 2-byte value we’ve calledADRSW1 will contain the startaddress of action sequenceACTSW1, and so forth.

The clever bit is that when-ever we modify anything, thevalues associated with all of thelabels will automatically be up-dated when we re-assemble theprogram.

DELAY SUBROUTINESOK, we’re almost ready to

create the main body of our pro-gram, but before we do we needto create a couple of utility rou-tines. First we need to add thetimer routines shown in Listing 5(add these just after the ‘‘start ofsubroutines’’ comment in theskeleton program).

These two routines are al-most identical to the ones wedeveloped last month, so wewon’t spend too much time onthem here. Suffice it to say thatwe can load the accumulatorwith the required delay(specified in tenths of a second)and then call the TIMER routine.In turn, this routine will repeat-edly call the ONETENTH routine,which is designed to take onetenth of a second to execute.

Every time it goes aroundthe loop, the TIMER routine willdisplay the current count on the8-bit LED display connected tothe output port at address$F031. This routine will termi-nate when it has ‘‘timed-out’’ orif it discovers that the contentsof the GOFLAG location havebeen set to zero. As we dis-cussed last month, the contentsof GOFLAG are modified by aninterrupt service routine asshown in the next section.

&RQVWUXFWLRQDO3URMHFW

Listing 3ACTSW0: .BYTE STOP, 5 # Stop for 5/10 sec .BYTE REVERSE, 10 # Reverse for 1 sec .BYTE SPIN_ACW, 7 # Spin ACW for 7/10 .BYTE FORWARD, FOREVERACTSW1: .BYTE NOMORE # No actionsACTSW2: .BYTE NOMORE # No actionsACTSW3: .BYTE NOMORE # No actionsACTSW4: .BYTE NOMORE # No actionsACTSW5: .BYTE STOP, 5 # Stop for 5/10 sec .BYTE REVERSE, 10 # Reverse for 1 sec .BYTE SPIN_CW, 7 # Spin CW for 7/10 .BYTE FORWARD, FOREVERASTART: .BYTE FORWARD, FOREVER

EPE Online, April 1999 - www.epemag.com - 445

INTERRUPTROUTINE

Now we need to add theGETSW interrupt service routineshown in Listing 6 (add this justafter the ‘‘start of interrupt ser-vice routines’’ comment in theskeleton program).

As we will see in the mainbody of the program, this rou-tine is called when one of thePhizzyB’s microswitches is trig-gered. The first thing this rou-tine does is to use a PUSHA(push accumulator) instructionto copy whatever is currently inthe accumulator onto the stack.

Next we load the value fromthe input port connected to themicroswitches. As we knowfrom Parts 4 and 5, the way this

input device is constructedmeans that a closed (activated)switch returns a logic 0, while allof the other switches returnlogic 1s. However, we’d preferthis to be the other way around,so we use an XOR $FF state-ment to invert all of the bits inthe accumulator (swap the 0sfor 1s and vice versa), then westore this value into our TEMPSWlocation (which stands for‘‘temporary switch’’).

As soon as we’ve safelysquirreled the value from theswitches away, we load the ac-cumulator with the EEEKSTOPcode (which we previously as-signed a value of zero) andstore this into our GOFLAG loca-tion (this will be used to termi-nate the TIMER subroutine).

Last but not least, we use aPOPA (pop accumulator) instruc-tion to retrieve our original accu-mulator value from the stack,then we return to wherever wewere in the program when thisinterrupt service routine wascalled.

THIS ISN’TCOMPLICATED!

Take a deep breath, count toten slowly, and breathe out. Thisreally isn’t as complicated as youmight think. Although we seem tohave covered a lot of ground, ourprogram thus far is really rathersimple. In fact all it actually con-tains at this stage is two timersubroutines (14 instructions) andone interrupt service routine(eight instructions). The rest ofthe program consists of constantdeclarations (a lot of labels) andthe action sequences (lists of la-bels). All we have to do now is tocreate the main program.

MAIN PROGRAMBODY

The main program body isshown in listing 7 (enter this justafter the ‘‘Start of main programbody’’ comment in your skeletonprogram). As we’ll see, this iswhere all of the really cunningstuff takes place.

The easiest way to under-stand what’s happening is to‘‘walk through’’ the code one in-struction at a time. First we use aBLDSP to load the stack pointerwith an address of $4FFF, thenwe use a BLDIV to load the inter-rupt vector with the start addressof our GETSW interrupt serviceroutine (remember that the as-sembler will automatically substi-tute the GETSW label with its cor-responding address in thePhizzyB’s memory).

&RQVWUXFWLRQDO3URMHFW

Listing 4ADRSW0: .2BYTE ACTSW0 # Address of SW0 actionsADRSW1: .2BYTE ACTSW1 # Address of SW1 actionsADRSW2: .2BYTE ACTSW2 # Address of SW2 actionsADRSW3: .2BYTE ACTSW3 # Address of SW3 actionsADRSW4: .2BYTE ACTSW4 # Address of SW4 actionsADRSW5: .2BYTE ACTSW5 # Address of SW5 actionsADRSTR: .2BYTE ASTART # Address of initial acts

Listing 5#== Start of "Main Timer" RoutineTIMER: STA [TVALUE] # Store originalcountTLOOPA: JSR [ONETENTH] # Call 1/10 Sec loop LDA [GOFLAG] # Load flag JZ [TRETURN] # Jump if flag=0 LDA [TVALUE] # Load count value DECA # Decrement it STA [TVALUE] # Store it STA [TGRAPH] # Store it to LEDs JNZ [TLOOPA] # Loop again if !=0TRETURN: RTS # Exit subroutine#== End of "Main Timer" Routine

#== Start of "1/10 Second" RoutineONETENTH: LDA DELCONST # Load count valueOTLOOPA: DECA # Decrement it JNZ [OTLOOPA] # Loop again if !=0OTRETURN: RTS # Exit subroutine#== End of "1/10 Second" Routine

EPE Online, April 1999 - www.epemag.com - 446

We want the PhizzyBot tostart off by performing whateveraction sequence it finds at theASTART label, but we reallydon’t want to do a lot of workcreating any special ‘‘start up’’code. To get around this we usea trick, which is based on thefact that we know the PhizzyBotonly has six microswitches(numbered 0 to 5). What we dois to load the accumulator with abinary value of 01000000,which corresponds to a seventh,dummy microswitch, and thenstore this value away into ourTEMPSW location. (Rememberthat TEMPSW is where ourGETSW interrupt service routinestores the value from the inputswitch device.)

WHICH SWITCH?Now we arrive at the GET-

SEQ label (short for ‘‘get se-quence’’), which is where themain program loop really starts.In the future this will be thepoint in the program where we’llend up after a microswitch hasjust been activated. Thus, as faras the program is concerned, itneeds to work out which switchwas triggered and it has no cluethat we’ve pre-loaded theTEMPSW location with a dummyvalue.

The first instruction at GET-SEQ is a BLDX, which is used toload the index register with

zero. Next we load the accumu-lator with the contents ofTEMPSW, which our program as-sumes is the value from the in-put switch device. Now we entera sub-loop, in which we use aRORC (“rotate right throughcarry”) to rotate the contents ofthe accumulator one bit to theright, thereby causing the least-significant (LS) bit to ‘‘fall off theend’’ into the carry flag.

The JC (“jump if carry”) in-struction is used to test the con-tents of the carry flag. If this flagcontains 1 we’ve found the mi-croswitch that was activatedand we jump to label GSCONT,otherwise we use an INCX toincrement the index register andthen jump back to the GSLOOPlabel.

The end result of this loop isthat by the time we reach theGSCONT label, the index registercontains a number correspond-ing to the decimal value of themicroswitch that was activated(Table 2).

The first thing we do atGSCONT is to use a BSTX in-struction to store the contents ofthe index register into our 2-byte temporary location TEMPX.In a moment we’re going to usethis value to point to one of ourADRSW0, ADRSW1, ADRSW2 . . .labels.

The problem is that each ofthese fields occupies two bytes,

so we really want to multiplywhatever value is in TEMPX bytwo. In order to do this we loadthe accumulator with the least-significant byte of this value,shift it one bit to the left, andstore it away again. (The factthat shifting a binary value onebit left is equivalent to multiply-ing it by two was discussed inthe bonus article accompanyingPart 3 of this series.)

WHAT ADDRESS?So we now find ourselves at

the GETACT label, at which pointwe use a BLDX to reload the in-dex register with the new valuein TEMPX. Remember that weoriginally loaded the TEMPSWlocation with a binary value of01000000. From Table 2 weknow that this will have beenconverted into a value of $0006in the index register (6 in deci-mal), and we’ve just multipliedthis by 2, so the index registernow contains $000C (12 in deci-mal).

Now consider the LDA[ADRSW0,X] statement, whichloads the accumulator using theindexed addressing mode.What this means is that the con-tents of the index register($000C in this case) are addedto the address of the ADRSW0label, and the accumulator isloaded with the contents of thememory location at the resultingaddress.

By some strange quirk offate, this resulting address isthat of the ADRSTR label, whichitself contains the start addressof the ASTART action sequence. . . Phew!

So the accumulator nowcontains the most-significant(MS) byte of the address of theASTART action sequence, whichwe immediately store in the MS

&RQVWUXFWLRQDO3URMHFW

Listing 6#== Start of "Get Switch" RoutineGETSW: PUSHA # Copy ACC to stack LDA [SWITCHES] # Read value on switches XOR $FF # Invert 0s to 1s etc. STA [TEMPSW] # Store to temp location LDA EEEKSTOP # Load ACC with stopcode STA [GOFLAG] # Set flag to stop POPA # Copy ACC from stack RTI # Exit routine#== End of "Get Switch" Routine

EPE Online, April 1999 - www.epemag.com - 447

Listing 7 .ORG $4000 # Set prog origin BLDSP $4FFF # Load stack pointer BLDIV GETSW # Load I-vector SETIM # Enable interrupts LDA %01000000 # Load dummy switch STA [TEMPSW] # Store to temp#== Work out which microswitch was activatedGETSEQ: BLDX $0000 # Load index reg = 0 LDA [TEMPSW] # Retrieve temp valueGSLOOP: RORC # Rotate right 1 bit JC [GSCONT] # Jump if carry = 1 INCX # Else inc X reg JMP [GSLOOP] # Jump back & repeat#== Get start address of appropriate action sequenceGSCONT: BSTX [TEMPX] # Store index reg LDA [TEMPX+1] # Load LS temp index SHL # Shift left (x2) STA [TEMPX+1] # Store it againGETACT: BLDX [TEMPX] # Load X reg with # addr of addr LDA [ADRSW0,X] # MS addr of action STA [TEMPX] # Store to MS temp X LDA [ADRSW0+1,X] # LS addr of action STA [TEMPX+1] # Store to LS temp X BLDX [TEMPX] # Load X reg with # addr of dataGOOD2GO: LDA GOGOGO # Load “go” code STA [GOFLAG] # Store it to Flag#== Get the next action in the sequenceNEXTACT: LDA [0,X] # Get next action JN [ALLSTOP] # If N=1 then stop STA [MGRAPH] # Store to LEDS STA [MCONTROL] # & motor controller INCX # Inc index register LDA [0,X] # Get delay value JZ [JUSTDOIT] # If 0 do forever INCX # Inc index register JSR [TIMER] # Call timer routine LDA [GOFLAG] # Load go flag JNZ [NEXTACT] # If !=0 get next act JMP [GETSEQ] # ... else get new # sequenceALLSTOP: LDA STOP # Load stop code STA [MGRAPH] # Store to LEDS STA [MCONTROL] # & motor controllerJUSTDOIT: HALT # Wait for interrupt JMP [GETSEQ] # Get new sequence

&RQVWUXFWLRQDO3URMHFW

byte of the 2-byte temporaryvalue TEMPX. Now we use asecond indexed-mode LDA toload the accumulator with theLS byte of the address of theASTART action sequence, andstore this to the LS byte ofTEMPX.

Next we use a BLDX instruc-tion to load the value in TEMPXinto the index register. We knowthat this is a little convoluted,but the end result is that the in-dex register ends up containingthe address of the ASTART la-bel, which is the first byte in ourstartup action sequence.

A TAP-DANCINGFOOL

Let’s quickly summarizewhat we’ve done to make surethat we’re all still tap-dancing tothe same drumbeat. First of allwe arranged for the index regis-ter to contain a value corre-sponding to whichever switchwas loaded (0 = switch 0, 1 =switch 1, and so forth).

We then saved this value toTEMPX, multiplied it by two, andreloaded it into the index regis-ter. Next we used the contentsof the index register to providean offset from the base addressof the ADRSW0 label (in the caseof our dummy switch, this offsetallowed us to locate the addressof the ADRSTR label). We nextloaded the two bytes at ADRSTRinto TEMPX and then loaded thisvalue back into the index regis-ter, which leaves the index reg-ister containing the address ofthe ASTART action sequence.

PERFORM THEACTIONS

So now we’re at theGOOD2GO label, at which pointwe load the accumulator with

the GOGOGO code, save it to theGOFLAG location, and proceedto the NEXTACT label to startexecuting the action sequence.

The first thing we do atNEXTACT is to load the accumu-lator with the first action in thesequence. Once again we’re

using the indexed addressingmode. However, this time weknow that the index registercontains the full address of thefirst action, so we use an LDA[0,X] instruction, which willadd the contents of the indexregister to 0 to give us the tar-get address.

EPE Online, April 1999 - www.epemag.com - 448

&RQVWUXFWLRQDO3URMHFW

The JN (“jump if negative”)instruction tests to see if themost significant bit of this actionis 1 (corresponding to a NOMOREcode). In this case we wouldjump to the ALLSTOP label andstop the motors. Otherwise westore this action to the LED bar-graph display at address $F030and also to the motor controller.

Now we use an INCX to in-crement the contents of the in-dex register, then we load theaccumulator with the delayvalue associated with this ac-tion. The JZ (“jump if zero”) in-struction is used to test if thedelay value is zero(corresponding to a FOREVERcode).

In this case we would jumpto the JUSTDOIT label, whichcontains a HALT instruction.This means that the PhizzyBotwill continue to perform this lastaction until the universe ends oruntil a microswitch is activatedthereby triggering an interrupt(whichever comes first).

Alternatively, if the delayvalue is non-zero, we use anINCX to increment the indexregister to point to the next ac-tion, then we call our timer sub-routine to wait for the requireddelay. When we return from thetimer subroutine we check thestatus of the GOFLAG.

A non-zero value means

that we’re still in GOGOGO mode,in which case we jump back toNEXTACT to get the next action.Otherwise we know that an in-terrupt must have occurred, inwhich case we jump to GETSEQto find out which switch was ac-tivated and do the whole thingall over again.

LET’S GO!OK, let’s be honest and ad-

mit that the main body of thisprogram is non-trivial, and it re-quires a bit of ‘‘lateral thinking’’to wrap our brains around itscunning machinations. But ifyou read through it a few timesyou should be able to seewhat’s happening. Also, don’tforget that all of the instructionsand addressing modes are dis-cussed in excruciating detail inAppendix A of The Official Be-boputer Microprocessor Data-book.

Once you’ve entered theentire program, assemble it togenerate the corresponding ee-exp1.ram file. Before we loadthis program into the PhizzyBot,it’s worth taking the time to testit on the PhizzyB Simulator.Power up the simulator and usethe Memory – > Load RAMcommand to load eeexp1.ramfile into its memory.

Click the simulator’s Runbutton and note that both the

onboard LED bargraph displayat address $F030 and the exter-nal output device at address$F032 (corresponding to themotor controller device) showvalues of 00001010, whichequates to both motors drivingforward (this is what we speci-fied in our ASTART sequence).

Now enter a value of11111110 into the binary field ofthe input device at address$F011 and click the Set buttonto present this value to the inputport (this value corresponds tomicroswitch 0 being activated).Next click the simulator’s IRQ(interrupt request) button, andobserve the resulting ACTSW0sequence being executed (noteespecially the output device ataddress $F031 reflecting thecurrent value in the timer sub-routine).

When you’re ready, use thePBLink utility to download theprogram to the PhizzyBot andset it running. The Bot shouldstart rolling forwards until one ofits front microswitches hitssomething, at which point itshould perform the appropriateaction sequence (stop, reverse,spin) and start rolling forwardsagain.

FINE TUNINGAs fate would have it, the

delays in our action sequenceswere arrived at in a fairly arbi-trary manner. This is becauseyour PhizzyBot may have differ-ent sized wheels and be geareddifferent to ours. Thus, you aregoing to have to modify the de-lays associated with the actionsequences to ensure that yourPhizzyBot does what you want.For example, if you want theBot to spin 90 degrees, you aregoing to have to fine-tune thedelay associated with the spinaction until your PhizzyBot per-

MicroswitchNumber

012345

6 (Dummy)

Binary Valuefrom Switches

Result inIndex Register

$0000 (0)$0001 (1)$0002 (2)$0003 (3)$0004 (4)$0005 (5)$0006 (6)

00000001000000100000010000001000000100000010000001000000

Table 2. Evaluating the number of the triggered switch

EPE Online, April 1999 - www.epemag.com - 449

&RQVWUXFWLRQDO3URMHFW

forms as required.

Also, don’t forget that youcan modify the start-up se-quence to do something moreinteresting, like spinning aroundthree times before heading offinto the great unknown.

Finally, remember that weonly specified useful action se-quences for microswitches 0and 5. If any of the otherswitches are triggered, their ac-tion sequences cause thePhizzyBot to stop and wait foryou to do something. Of coursethere’s nothing to stop you frommodifying these action se-

quences to do something moreinteresting. . . .

NEXT MONTHNext month we’ll show you

a trick that will allow you to re-place delay values with unitslike inches and degrees. Thiswill allow us to specify actionsequences along the lines of‘‘Go forward for 10 inches andthen spin clockwise for 45 de-grees. . . .’’

And, we’ll be adding a lightsensor to the PhizzyBot, whichwill allow us to tailor its behavior

to be that of a ‘‘RoachBot’’(avoids the light) or a ‘‘MothBot’’(loves the light).

PhizzyB SMORGASBORD - Useful Tools

Don’t forget that thePhizzyB Simulator comesequipped with a smorgasbord oftools, which can be in-credibly useful whenyou are debugging aprogram or simply try-ing to understand ex-actly what your code isdoing.

First of all, whenyou assemble a pro-gram you can use theassembler’s Window ->View Listing File com-mand to show the con-tents of the list file,which you can subse-quently print out. Thelist file contains youroriginal source codealongside the resultingmachine code(including the addresses of thememory locations containingeach byte of machine code).The list file is invaluable whenused in conjunction with theother tools referenced below.

The CPU Register Dis -play

Use the simulator’s Display-> CPU Registers command toinvoke the CPU Register dis-play (Fig.A).

This display shows the cur-

rent contents of the PhizzyB’sinternal registers whilst you arestepping through a program oneinstruction at a time. (Note thatthe contents of the status regis-ter are displayed as five individ-ual I, O, N, Z, and C flags.)

The Memory Walker Dis -play

Use the Display -> MemoryWalker command to invoke thesimulator’s “memory walker”display (Fig.B).

The memory walker displaycan be used to examine (andedit!) the contents of thePhizzyB’s memory locations.Amongst other things, the tool-bar icons at the top of this dis-play allow you to quickly bouncearound between the RAM,ROM, and input/output ports.Whilst stepping through a pro-gram, two chevron charactersappear in the “Step” column toindicate the address you arecurrently at. (Note that the ad-dress of the chevrons in Fig.B.reflects the value of the Pro-

Fig.A. The CPU Register display.

EPE Online, April 1999 - www.epemag.com - 450

&RQVWUXFWLRQDO3URMHFW

gram Counter shown in Fig.A.)

More importantly, you canuse the breakpoint toolbar icon(the one with the hand) to spec-ify one or more “breakpoints,”which will appear in the BP col-umn. When you click the simu-lator’s Run button, it will racethrough the program until itreaches the next breakpoint, atwhich time it will automatically

return the simulator into its Stepmode. This allows you toquickly and easily run throughuninteresting portions of a pro-gram (such as a timing loop) soas to focus on specific areas ofinterest.

The Messaging Subsys -tem

Use the sim-ulator’s Display -> Message Sys-tem command toinvoke the simu-lator’s messag-ing subsystem(Fig.C.)

If this dis-play is active,then wheneveryou click thesimulator’s Stepbutton to stepthrough an in-struction, themessaging sub-system will dis-play all of themicro-actionscomprising that

instruction. The left-most text(in black) describes the mainactions (Get Opcode, DecodeOpcode, Execute Opcode, andso forth). Messages indentedone level to the right (shown inBlue) indicate sub-actions, suchas incrementing the contents ofthe program counter. Finally,messages indented two levelsto the right (shown in Red) offeradditional comments and expla-nations.

All for one and one forall

Each of the tools describedhere can be used in isolation,but they are most effectivewhen used in conjunction witheach other. For example, youcan use the Memory Walker toset a breakpoint and run to it.Then you can use both thememory walker to examine thecontents of the PhizzyB’s mem-ory and the CPU Register dis-play to examine the PhizzyB’sregisters as you step throughthe program. And when youreach an area where you needyet more information aboutwhat’s going on, you can acti-vate the messaging subsystem.

The authors use all three ofthese tools regularly, as will youonce you come to appreciatejust how useful they can be.Note that all three of these dis-plays are documented in thesimulator’s online help. Alsonote that the memory walkerand CPU register displays (andthe use of the list file) are dis-cussed in the PhizzyB UserManual Volume 1, which is pro-vided FREE on the PhizzyBSimulator CD – see the simula-tor’s online help for more de-tails.

Fig.B. The Memory Walker display.

Fig.C. The Messaging Subsystem display.

EPE Online, April 1999 - www.epemag.com - 451

While it would be an exag-geration to say that the days ofconventional semiconductor databooks “are numbered,” computer-ized versions seem to be steadilytaking over.

Computerized data is avail-able from two main sources,which are the Internet and CD-ROMs. I do not know if the Inter-net contains data sheets for everyavailable semiconductor, but datafor most devices seems to beavailable if you search long andhard enough.

The CD-ROM approach ispotentially much quicker and eas-ier, and many component manu-facturers now make their dataavailable in this form. Also, someof the major component retailerssupply data sheets on CD-ROMfor the main semiconductors thatthey have available. No doubt

which is needed to view thedata sheets that are all in AdobePDF format.

This now seems to be theaccepted format for electroniccomponent data sheets. Ofcourse, if you already haveAdobe Acrobat Reader installedon your PC, and provided it is areasonably up-to-date version,only the database program hasto be loaded.

Installation is basically justa matter of finding the appropri-ate Setup programs on the CD-ROM and then going throughthe usual Windows-style instal-lation processes. The servicepack on the single floppy disk isthen installed, and this bringseverything completely up-to-date.

With what is presumably inexcess of six gigabytes of dataon the CD-ROMs there is noquestion of installing the dataon to the hard disk drive of thePC. You find the data sheet yourequire using the database andsearch engine, and then read itfrom the appropriate CD-ROMusing the Adobe Acrobat readerprogram.

SEARCH ENGINEThe search engine is very

simple to use, and it is just amatter of providing it with a textstring. This can be either a com-plete type number, or just partof one. The recommended ap-proach is to supply only the ba-sic part number, omitting any

A ten CD-ROM library with a vast repertoire of usefuldata is put to the test.

'$7$1(7 5(9,(: E\ 52%(57 3(1)2/'

many readers will have tried theofferings from Farnell, RSand Maplin.

GIGA-DATAI suppose that the ideal data

source would consist of a set ofCD-ROMs containing all thesemiconductor data availableon the Internet. This is, more orless, what the DATA-NET pack-age sets out to be. It consists of10 CD-ROMs and a singlefloppy disk.

There is no proper manualsupplied in the package, just asingle-sided A4 sheet. However,this software is quite easy to setup and use, so the minimalistdocumentation is perfectly ade-quate. The usual “readme” fileon one of the CD-ROMs aug-ments it.

Two programsare needed in orderto access the data,and these are to befound on disk num-ber 10. The firstprogram is adatabase of all thedevices for whichdata is availableand a search en-gine to make iteasy to find thedata you require.The second pro-gram is Adobe Ac-robat Reader,The Data-Net 10 CD-ROM and “floppy”

disk collection.

EPE Online, April 1999 - www.epemag.com - 452

manufacturers prefix, orany suffix.

By using this method youare supplied with a list of all theavailable data sheets for thedevice you are interested in.This might not provide you withany additional data, but somemanufacturer's data is more in-formative than others, and thismaximizes your chances offinding the required information.

One slight snag with thisapproach is that any devicenumbers that contain a givensearch string will be included,which can sometimes produce along list of devices, most ofwhich are of no relevance. Forexample, using “109” as thesearch string will not just pro-duce a listing for the BC109transistor, but will also throw upother devices that have “109” intheir type number, such as theCMOS 40109B level shifter.

This is not usually a majorproblem and “741” for example,only produces a list of 741 oper-

ational amplifiers. Occasionallythough, it is necessary to refinethe search with an additionalprefix or suffix in order keepthings manageable. Entering“351” for the LF351N for exam-ple, brings up a long list of de-vices which have “351” in theirtype number.

This shows up a minor flawin the search engine, which issimply the small size of the win-dow in which it operates. Thetype numbers have to bescrolled out of sight in order tobring the vertical scrollbar intothe visible part of the window.This can result in a lot of jug-gling with the two scrollbars inorder to find the device you re-quire. A larger and resizablewindow would be better.

IN PRACTICEIt is fine having a search

engine and CD-ROMs full ofdata, but do the two work to-gether efficiently? Obviously it

is not possible to check that ev-erything listed by the search en-gine carries through to the correctdata sheet, but in my tests every-thing went smoothly.

You just double click on theentry for which data is required,insert the requested CD-ROMinto the CD-ROM drive, and thenwait while Adobe Acrobat Readerruns and the appropriate datasheet is displayed. If your PC hasmore than one CD-ROM driveyou can select the drive that isused by DATA-NET.

Most PC screens are inca-pable of displaying full pages ofdata with adequate clarity, butAdobe Acrobat Reader makes iteasy to zoom in and scroll aroundthe selected page. The quality isusually very good, but this is ob-viously dependent on the systembeing fed with a good scan of theoriginal data sheet.

Provided your PC is equippedwith a suitable printer, high qual-ity hard copy can be produced. Infact with a suitable laser or inkjet

6SHFLDO5HYLHZ

The initial screen of the search engine. A typenumber (or part of one) is entered in the box,and clicking the Search button then producesa list of matches. Selecting an entry and click-ing on the Form button brings up a request forthe appropriate CD-ROM, after which AdobeAcrobat Reader is run automatically and thedata sheet is displayed.

Using partial type numbers will sometimesbring up a large list of matches. In this case

there are too many to display at once, but it isnecessary to use the horizontal scrollbar in

order to access the vertical scrollbar (which isout of the display area to the right).

EPE Online, April 1999 - www.epemag.com - 453

printer the quality of mostprinted-out data sheets is re-markably good.

The amount of data variesfrom one data sheet to another,but all the information madeavailable by the manufacturerseems to be included. As a fewexamples, there are nine pagesfor the CD40109B, seven forthe BC109, and eight for theLF351N operational amplifier.The data is mostly facts, fig-ures, and graphs, but there areapplications circuits for somecomponents, especially for themore specialized integrated cir-cuits.

CONCLUSIONOn the face of it, DATA-

NET has little to offer that is notavailable on the CD-ROMsavailable from some of the ma-jor electronic component retail-ers. It does have a definite ad-vantage though, which is that itis far more comprehensive, andit includes data for many minorsemiconductors such as transis-tors and diodes, which are notincluded in many other datasources.

It also includes a far widerrange of integrated circuits, al-though non-professional usersshould bear in mind that they

may find it impossible to obtainmany of these. There do seem tobe some omissions from the data,and the entire Holtek rangeseems to be absent for example.

Obsolete devices are not in-cluded, which will not worry circuitdesigners, but it makes the pack-age less useful to service engi-neers. It is easy to search for dataif you already have a type num-ber, but the search facilities donot let you search for devices of aparticular type, such as widebandwidth operational amplifiersor analogue multipliers.

Although DATA-NET has afew limitations, it still provides theuser with a vast amount of datafor the money, and it is easy totrack down the data sheet for anydevice in its “repertoire”. It is sup-plied with 16 and 32-bit versionsof Adobe Acrobat Reader, and itshould therefore work with practi-cally any PC running Windows3.1 or later. Of course, the PCmust be equipped with a CD-ROM drive and a hard disk drive.Only 10 megabytes of hard diskspace are required.

DATA-NET is handled in theUK by Dannell Electronics Ltd,Unit 15, Enterprise Court, LakeRoad, Braintree, Essex, CM73QS, UK (Tel +44 (0) 1376-347415, Fax +44 (0) 1376-550019, [email protected] )[r]. Itshould also be available for pur-chase on-line atwww.dannell.co.uk . The cost is39.00 UK Pounds includingpostage and VAT. Updates con-sisting of five CDs should beavailable for less than 20 UKPounds at approximately six-month intervals.

6SHFLDO5HYLHZ

The Adobe Acrobat Reader program uses PDF files that canhandle high quality graphics as well as text. A good display isneeded in order to make the best use of them, or they will pro-

duce high quality hard copy via a suitable printer.

EPE Online, April 1999 - www.epemag.com - 454

ROBERT PENFOLD

AD8300 Serial Digital to Analog Converter

In recent years a lot of “oldfavorites” have disappearedfrom the semiconductor market.Many of the popular analog todigital and digital to analog con-verters from Ferranti are recentadditions to this growing list.Several circuits in this seriesover the years have featuredFerranti chips, and their con-verters often represent the sim-plest solution to a problem. Onthe other hand, they require aparallel interface, which canmake life difficult where severalconverters are required.

The use of serial analog todigital converters has been cov-ered in several previous Inter-face articles, and but so far wehave not considered the subjectof serial digital to analog con-verters. Whereas a device suchas the Ferranti ZN426E requiresan eight-line interface and of-fers only eight-bit resolution, aserial converter typically re-quires just three connectingwires and provides 12 or even16-bit resolution.

The main drawback of serialconverters is that the softwareside of things becomes muchmore convoluted. Somethingthat requires just a single line ofBASIC or machine code whenusing a parallel converter oftenrequires dozens of programlines when using a serial chip.Overall though, serial convert-ers represent a genuine stepforward rather than just anenforced replacement for“golden oldie” chips that are nolonger available.

The AD8300The circuit of Fig.1 is for a

simple 12-bit digital to analogconverter that utilizes the Ana-log Devices AD8300 serial con-verter chip, and connects to aPC printer port. The AD8300 isactually the only componentused in the circuit! This chip willoperate over a supply voltagerange of 2¬¬¬7 to 5¬¬¬5 volts, but it

of obtaining a +5 volt supplyfrom a PC have been coveredin several previous Interfacearticles. A highly stable voltagereference is included in theAD8300, and this ensures accu-rate operation despite anychanges in the supply voltage. Italso permits operation over awide temperature range of 40to +65 decrees Celsius. Theoutput voltage is 0¬¬¬5 millivoltsper bit, giving a maximum out-put potential of 2¬¬¬0475 volts.

There are five control inputson the AD8300, but in normaloperation only three of theseare required. The Clear (CLR)input at pin 6 is a sort of resetinput that is pulsed low to resetthe DAC register to zero. If thisfacility is not required the Clearinput is simply tied to the +5volt supply rail. The Chip select(~CS) input at pin 2 disablesshift register operation when itis taken high. This input is nor-mally taken to the 0V rail so thatthe shift register is permanentlyenabled.

The other three inputs areused to clock data into the chip,bit-by-bit, and then load it intothe DAC register. The clockingprocess is quite simple, and it isjust a matter of placing the dataon pin 4 and then producing apulse on pin 3. Data is latchedinto the shift register on thepositive going edge of theclock pulse.

This process must be re-peated for all 12 bits, startingwith the most significant bit andworking through to the least sig-nificant bit. Note that most serialinterfaces operate the oppositeway round with the least signifi-cant bit being transmitted first.Once all 12 bits have been

Fig.1. The circuit diagram forthe serial DAC. The output po-

tential is 0¬¬¬5mV per bit.

Fig.2. Connection details for thePC printer port.

must be operated from a stan-dard 5-volt supply if compatibil-ity with standard 5-volt logic cir-cuits is required, as it is in thiscase. The current consumptionis only about two milliamps.

The PC printer ports do nothave a supply output, but ways

EPE Online, April 1999 - www.epemag.com - 455

latched into the serial register, alow pulse on pin 5 loads thisdata into the DAC register andthe appropriate output voltage isgenerated by the chip.

Details of the connectionsto the PC printer port are pro-vided in Fig.2. These connec-tions are made via a 25-waymale D-connector. The con-verter is driven from the leastsignificant data outputs, but withappropriate software the circuitshould be usable with any threelatching outputs. Although aform of serial interfacing is usedhere, an ordinary parallel portprovides the control lines. Con-sequently the connecting cableshould be no more than a fewmeters long. The AD8300 is aMOS device and it thereforerequires the normal anti-statichandling precautions.

SoftwareThe first GW BASIC pro-

gram in Listing 1 demonstratesthe writing of 12-bit data to theconverter. An integer from 0 to4095 is entered at the prompt,and the program then outputsthis value to the converter. Atline 20 the base address of theprinter port is assigned to thevariable called “PORT”. This isthe address used to write datato the printer port, and it is nor-mally &H378 for port 1 (LPT1),or &H278 for port 2 (LPT2). Itcan sometimes be &H3BC, andif necessary trial and errormust be used to find theright address.

The value to be written tothe converter is input at line 50.Next the program must gener-ate a clock pulse on data lineD2, having first set output D0 toone if appropriate. Bitwise AND-ing is used to set variable “B” to1 or 0, depending on the state

Listing 1

10 REM SERIAL DAC PROGRAM (12-BIT)20 PORT=&H27830 C=240 D=650 INPUT A60 OUT PORT,670 B=A AND 204880 IF B=2048 THEN E=C+1 ELSE E=C90 IF B=2048 THEN F=D+1 ELSE F=D100 OUT PORT,E110 OUT PORT,F120 B=A AND 1024130 IF B=1024 THEN E=C+1 ELSE E=C140 IF B=1024 THEN F=D+1 ELSE F=D150 OUT PORT,E160 OUT PORT,F170 B=A AND 512180 IF B=512 THEN E=C+1 ELSE E=C190 IF B=512 THEN F=D+1 ELSE F=D200 OUT PORT,E210 OUT PORT,F220 B=A AND 256230 IF B=256 THEN E=C+1 ELSE E=C240 IF B=256 THEN F=D+1 ELSE F=D250 OUT PORT,E260 OUT PORT,F270 B=A AND 128280 IF B=128 THEN E=C+1 ELSE E=C290 IF B=128 THEN F=D+1 ELSE F=D300 OUT PORT,E310 OUT PORT,F320 B=A AND 64330 IF B=64 THEN E=C+1 ELSE E=C340 IF B=64 THEN F=D+1 ELSE F=D350 OUT PORT,E360 OUT PORT,F370 B=A AND 32380 IF B=32 THEN E=C+1 ELSE E=C390 IF B=32 THEN F=D+1 ELSE F=D400 OUT PORT,E410 OUT PORT,F420 B=A AND 16430 IF B=16 THEN E=C+1 ELSE E=C440 IF B=16 THEN F=D+1 ELSE F=D450 OUT PORT,E460 OUT PORT,F470 B=A AND 8480 IF B=8 THEN E=C+1 ELSE E=C490 IF B=8 THEN F=D+1 ELSE F=D500 OUT PORT,E510 OUT PORT,F520 B=A AND 4530 IF B=4 THEN E=C+1 ELSE E=C540 IF B=4 THEN F=D+1 ELSE F=D550 OUT PORT,E560 OUT PORT,F570 B=A AND 2580 IF B=2 THEN E=C+1 ELSE E=C590 IF B=2 THEN F=D+1 ELSE F=D600 OUT PORT,E610 OUT PORT,F620 B=A AND 1630 IF B=1 THEN E=C+1 ELSE E=C640 IF B=1 THEN F=D+1 ELSE F=D650 OUT PORT,E660 OUT PORT,F670 OUT PORT,4680 OUT PORT,6690 GOTO 50

,QWHU)$&(

Listing 2

10 REM SERIAL DAC PROGRAM (8-BIT)20 PORT=&H27830 C=240 D=650 INPUT A60 OUT PORT,670 B=A AND 12880 IF B=128 THEN E=C+1 ELSE E=C90 IF B=128 THEN F=D+1 ELSE F=D100 OUT PORT,E110 OUT PORT,F120 B=A AND 64130 IF B=64 THEN E=C+1 ELSE E=C140 IF B=64 THEN F=D+1 ELSE F=D150 OUT PORT,E160 OUT PORT,F170 B=A AND 32180 IF B=32 THEN E=C+1 ELSE E=C190 IF B=32 THEN F=D+1 ELSE F=D200 OUT PORT,E210 OUT PORT,F220 B=A AND 16230 IF B=16 THEN E=C+1 ELSE E=C240 IF B=16 THEN F=D+1 ELSE F=D250 OUT PORT,E260 OUT PORT,F270 B=A AND 8280 IF B=8 THEN E=C+1 ELSE E=C290 IF B=8 THEN F=D+1 ELSE F=D300 OUT PORT,E310 OUT PORT,F320 B=A AND 4330 IF B=4 THEN E=C+1 ELSE E=C340 IF B=4 THEN F=D+1 ELSE F=D350 OUT PORT,E360 OUT PORT,F370 B=A AND 2380 IF B=2 THEN E=C+1 ELSE E=C390 IF B=2 THEN F=D+1 ELSE F=D400 OUT PORT,E410 OUT PORT,F420 B=A AND 1430 IF B=1 THEN E=C+1 ELSE E=C440 IF B=1 THEN F=D+1 ELSE F=D450 OUT PORT,E460 OUT PORT,F470 GOSUB 540480 GOSUB 540490 GOSUB 540500 GOSUB 540510 OUT PORT,4520 OUT PORT,6530 GOTO 50540 OUT PORT,2550 OUT PORT,6560 RETURN

EPE Online, April 1999 - www.epemag.com - 456

,QWHU)$&(

of the most significant bit. If B isat 1, 1 is added to variables Eand F, which are then written, inturn, to the printer port. Thisgenerates the clock pulsewith D0 being set to 1 whereappropriate.

The same general processis repeated for the other 11 bits,and then a pulse is generatedon output D1 at lines 670 and680. The purpose of this pulseis to latch the data into the con-verter's DAC register, and theappropriate output voltageshould then appear at its output.The program then loops back tothe beginning so that a newvalue can be entered if desired.Use the normal Control-Break

potential of 2¬¬04 volts.

Clearly the software neededto drive serial DACs is relativelycumbersome, but the fact thatthey can operate with just threecontrol lines is a great assetwhen trying to make the most ofa PC printer port. This alsomakes them attractive for usewith PIC processors. The soft-ware side of things is actuallysomewhat simpler with PICs asthey have bit level instructionsthat make it easier to generatethe correct control signals.

combination of keys to breakout of the program.

The same program can beused if only eight-bit operationis required, but the maximumoutput voltage will be a mere127¬¬5 millivolts. It is better if theeight bits of data are shifted intothe most significant bits of theDAC register, and this isachieved using the program inListing 2. This operates muchas before, but only on eight bitsof data. Four dummy bits set atzero are then written to the con-verter, moving the original eightbits of data into bits four to 11 ofthe DAC register. This gives anoutput voltage of eight millivoltsper bit and a maximum output

EPE Online, April 1999 - www.epemag.com - 457

Solid state relaysOne reader is building a

powerful model boat, but has afew problems deciding the bestway to control the two motors:

I have to power a modelboat that will use two motorsrated as 6V 10A. The electronicspeed control is no problemsince I've already made severaltypes of controller all suitable forthe model. However, I need adouble-pole relay for each mo-tor.

I can find relays suitable fora 6V supply but no more than8A current rating. I've foundsome relays which could copewith up to 15A but they are allphysically too big and, what isworse, they require no less than12V d.c. to operate! I've heardthat so called “solid state relays”can deal with heavy currents butI don't know how to use them orhow to insert such componentsin a circuit. Could you help witha solution?

Many thanks from Fer-nando Bentes de Jesus , Por-tugal.

I thumbed through someheavyweight catalogues and thenearest I managed was a singlepole 6V 10A PCB relay (Maplin,www.maplin.co.uk , codeJM66W) but most “power re-lays” are designed for 12V auto-motive or 24V process controluse. Relay ratings were de-

scribed in the December '98edition of Circuit Surgery.

Alternatives to ordinaryelectromagnetic relays includesolid-state relays (SSRs),which are all-electronic switch-ing devices that incorporatean opto-isolator or other de-vice for safety: the idea is tokeep the sensitive signal wellaway from the load. Your re-quirement for double-pole op-eration could be a problemthough, because SSRs don'texactly come cheap and theyare inherently “single-pole”devices. Some types includezero-voltage switching for ACpower control circuits to elimi-nate noise on the AC supply(they only switch on at zerovolts or off at zero current).Manufacturers of SSRs in-clude Crydom(www.crydom.com ) and In-ternational Rectifier(www.irf.com ).

Solid-state relays are es-pecially useful where controlsignals (e.g. digital outputsfrom a microcontroller) are to

be interfaced with externalheavy AC or DC loads. Theystart with small dual-in-linetypes capable of handling ahundred milliamps, all the wayup to large chassis-mountingdevices, which will carry 125A!They usually use an opto-emitter in place of a relay “coil”and a MOSFET or thyristor forthe relay “contacts”.

The most common specifi-cations to look for include loadvoltage (equivalent to the “relaycontact voltage”), since the out-put is switched by a semicon-ductor power device, this ratingstates the maximum load volt-age permitted. An SSR may ei-ther be current or voltage-controlled, depending on itstype. A control voltage (“relaycoil voltage”) can be anythingfrom 3V to 15V or so, whilst atypical control current will be 2-5mA, say.

Also of interest, of course,is the load current: a tiny DILSSR will handle maybe 70-100mA but large chassis-mounting versions will cope with25-100A or more. Instead of arelay contact resistance, an “on-state” resistance of a few tensof ohms might be typical. Justfor interest, the dielectricstrength (also called the isola-tion rating) indicates how effec-tive such devices really are atseparating the load from thesignal before the device fails. Avalue of 2,500V to 5,000V istypical, which is the maximuminput/output potential of thesolid state relay. The insulationresistance indicates the samething, only expressed in ohms(say 109 ohms).

These devices offer manyadvantages over ordinary elec-tromechanical relays: they have

Our monthly round-up of readers’ queries andcomments starts with an in-depth examination ofsolid-state relays, plus DC motor control, electretmicrophone FETs, and more!

by ALAN WINSTANLEY

C97>1<

9>@ED<54

<?14

?ED@EDDD

=?C65

Q

[

Fig.1. A photovoltaicMOSFET-type of

solid-state relay in adual-in-line package.

EPE Online, April 1999 - www.epemag.com - 458

no moving parts, so there areno contacts to arc or “soot” orgenerate interference, they aresmaller than a comparable re-lay, and are more power effi-cient as well. Problems of back-EMF in the relay coil are alsoeliminated, although someSSRs may need EMF protectionon their output instead, to pro-tect them from inductive loads.

Photovoltaic relaysSo a solid state relay

sounds ideal for the job butthere are still a few more con-siderations (not least of which iscost). There are several typesof SSR one is a photovoltaicrelay which has a MOSFET out-put. They start at 4 to 5 UKPounds each, and the“photovoltaic” label comes fromthe fact that they have a light-sensitive voltage source inside(a series of on-chip photovoltaiccells) which produces a voltagewhen light shines on it (the Pho-tovoltaic Effect). The light isemitted by a separate input LED(Fig.1), hence the opto-

a thyristor (SCR) or a triac toswitch AC power loads. Thesemay include extra functionssuch as zero-crossing switchingand dv/dt transient protection. Ifyou don't see “MOSFET” men-tioned in the description, the de-vice is probably this latter thyris-tor variety. I hesitate to specu-late on the effects of using sucha device on a continuous DCload instead, though.

I did indeed manage to lo-cate a MOSFET type solid staterelay that will technically fit thebill, but the price may rule it out.The International Rectifier 1-DCSeries are DC output relays withMOSFET outputs. The D1D12(e.g. Farnell Part No. 280-276)is rated at 12A DC. They areprovided in bolt-down packages,and data sheets are availablefrom the IR web site (look forSeries 1DC data). However, thistype works in a slightly differentway: they are actuallytransformer-coupled internally,so the input signal powers a50kHz oscillator which is currentlimited and functions over arange of 31

¬¬¬5V to 32V DC at¬¬¬6mA to 28mA.

I am afraid the really badnews is the price they aresome 35 UK Pounds each +VAT, but there is probably noneater self-contained alternativeto a relay. There are some use-ful “H-bridge” motor controllerchips available (e.g. Allegro's2953 is a complete pulse-widthmodulation motor controller),but I am not sure that the needfor 10A will be met with a fullyintegrated device, as the largestof these tend only to handle acouple of amps. Fig.2 showshow an H-bridge is configured:the motor can be made to re-verse simply by switching overdiagonally-opposed transistors,which swaps the polarity of themotor voltage.

isolation. The photo-voltagegenerates a control signal,which turns on the output tran-sistors and completes the circuitto the load, which can be any-thing from DC to RF.

Catalogues sometimeshighlight this type of SSR bycalling them Photovoltaic MOS-FET solid-state relays. They canusually be used for AC or DCloads, but they may already in-clude protection diodes on theoutput so check the data first. Insome of their photovoltaic re-lays, the manufacturer Interna-tional Rectifier uses a single-chip power IC dubbed aBOSFET (a bi-directional MOS-FET) for the output drivers,which enables both AC and DCloads to be switched by the solidstate relay.

MOSFET-type solid-staterelays in a dual-in line style arerestricted to a lower power level(say from 100mA to a fewamps). Larger ones are panel-mounted in a bolt-down pack-age which can carry muchhigher currents.

A second type of SSR uses

&LUFXLW6XUJHU\

R

S

U

R

SSS

U

R

U

R

S

U

3?>DB?<<5B

F

B"

!% :

B#

"' :

B$

"' :

DB!6==D'!'

DB#6==D&!'

FC

B!

!% :

=?D?B

DB"6==D'!'

DB$6==D&!'

=

Fig.2. `H' bridge motor driver capable of controlling the direc-tion of the DC motor (2¬¬¬5A maximum) courtesy Zetex.

EPE Online, April 1999 - www.epemag.com - 459

The best compromise isprobably a motor driver chipcoupled to external power tran-sistors. You could try using saythe SGS-Thomson L292(Farnell 407-550), which is a 2Acontroller, and add externalpower transistors to supplyhigher currents. An applicationcircuit is shown in Fig.3, whichgives the general idea, but hasnot been proven by us, and themaker's device notes must beconsulted for more information.It is suggested that the circuitcould deliver up to 8A or so withthe 15A 125W TO-3 power tran-sistors shown.

Electret microphones

the plot thickens...In the February '99 issue I

described the basic constructionof an electret microphone,showing how a typical miniaturecapsule consists of a metalliseddisc “diaphragm”, which formsone side of an air-spaced ca-pacitor of a few picofarads invalue. The other capacitor“plate” was welded directly to

the terminal of a mysteriousJFET transistor and trying totrack down the actual “K596”type used in my example wassomewhat of a marathon. Aftersome detective work on the In-ternet, I was still not much wiserabout the identity of that “K596”transistor, but I found likely-looking alternatives suggestedby semiconductor web sites.

Last month, aided by regu-lar reader/contributor BarryTaylor , we concluded that thetransistor must be a 2SK596though its data eluded us still. Iam extremely grateful to BobSchoomaker of Woodside,New York, USA whom I know isan avid reader of EPE. He E-mailed me with further interest-ing background information asfollows, which will be of interestespecially to those who dealwith Asian transistors:

I was just reading your Feb'99 Circuit Surgery column, anddug out my “spares” box, as Iremembered cannibalising sev-eral old electret mics from bothPanasonic and Murata. All hadthe same construction as shown

in your Fig.2 (page 135), minuswhat appears to be a resistor onthe PCB, although they all usedthe 2SK50 JFET which is listedin the Towers' InternationalMOS Power and Other FET Se-lector Update Number 1, 1994.

The convention for labellingmost Asian semiconductors us-ing the EIAJ system (ElectronicIndustry Association of Japan) isto drop the 2S, and mark thepart with only K50 (K N-channel, J P-channel). Unfortu-nately, the 2SK596 was notlisted in Towers'. However, itwas listed in a Japanese publi-cation similar to the Towers'book, whose only English coverlettering says: '95 The FETManual No. 4 \- CQ Publishing(ISBN4-7898-4324-6), availablein the USA from MCM Electron-ics(www.mcmelectronics.com )and there is also a standardBJT version, part number 81-1205, same price (ISBN 4-7898-4321-1). Both are very handy inan area where in my view Tow-ers' is weak.

&LUFXLW6XUJHU\

R

S

U

R

S

U

R

S

U

R

S

U

=

B&

!%[

B"

%! :

B!

%! :

3!

$'^

3###

$'^

B

""[

'

)

%

!"

3"

!%^

!! $ ! (

93!<")"

3#

$' P?>. #"""FFF

?66,

!#

F9

&

B'

!:

# !$"

B(

!:

4"

3$

"" ^

DB!24G%"1

B%

! :

4!

4!DDD?4$

$161C 49?45C

B&

F

! :

DB"24G%"1

DB#24G%!1

4# 4$ DB$24G%!1

FC

Q

[

Q

Q

[

[

Q

[

=?D?B

!

!%

Fig.3. A high power motor controller suitable for 8A DC motors, with external power transistor bridge courtesy SGS-Thomson.

EPE Online, April 1999 - www.epemag.com - 460

&LUFXLW6XUJHU\

The 2SK596 depletionmode JFET is listed in the “Use”column specifically for use as a“C-mic” (condenser micro-phone). Other specs are as fol-lows:

(Vds = 5V): Vgd = 20V; Pd= 100mW; Idss = 0¬¬1mA min/0¬¬8mA max; Vgs off = 1¬¬5V

¬

¬ ¬

¬

max for 11

PA; Gm = 0¬4mS min/

Crss = 0¬2mS max; Ciss = 3¬5pF typ;

¬65pF typ.

With regard to the availabil-ity of the 2SK596, I could findonly one distributor with stock; acompany in Russell, Pennsylva-nia called B&D Enterprises In-ternational (www.bdent.com ),which is the credit card/mail or-der arm of Ten-Four Ltd, a ma-jor Asian semiconductor im-porter and distributor in the US.I called B&D who said the2SK596 was a proprietarySanyo part discontinued in1991. This was confirmed bySanyo Corporation in the US,adding that before the 2SK596was discontinued, it had beensupplanted by the newer2SK1578, which is a direct re-placement with improved noiseand other specs. It will remain acurrent production part for theforeseeable future. Data for allcurrent-production Sanyo de-vices is available at:www.semic.sanyo.co.jp/en-glish/index-e.html .

After further examination ofThe FET Manual, it seems thatthe 2SK595 and 2SK597 bothhave identical specs to the2SK596. The only difference isthe pin-out which for the2SK595 is GSD; for the 2SK596is DGS; and for the 2SK597 isGDS.

Just thumbing through themanual, I was surprised by thenumber of devices specificallylisted for use as “C-mic” (23 ad-

ditional). I suspect any of themwill work quite satisfactorily, as allhave very close parameters.More importantly, while at anotherRadio Shack (Tandy stores in theUK, which were recently sold offto Carphone Warehouse ARW),I spotted some blister-pack stylesfor the electret capsules. Uponexamination I noticed to my sur-prise that they had the 2SK596JFET you encountered, but with-out the resistor, just as I found inthe mics containing the 2SK50.

Bob Schoomaker confirmssomething which many readersmay not be aware of, namely thepractice of omitting the “2S” inAsian device type markings, al-though this can sometimes createeven more confusion: for in-stance I have a bag full of(European) BC548C transistorswhich are marked as “C548C”.Only with experience are youlikely to know whether a devicetype number commences with a“B” or whether it's likely to be anAsian “2S” type.

The microphone manufac-turer probably picked the 2SK596because it had the desiredpinouts, so that the transistorcould be orientated inside thecapsule in a particular direction.The example of the elusive FETalso proves the value of havingaccess to appropriate data books,and again with experience youwill soon know where to look onthe World Wide Web for informa-tion. My Net Work A-Z index con-tains every URL that I have linkedto ever since that column began(check the EPE web site for thisatwww.epemag.wimborne.co.uk ,Ed.), and is a good starting pointfor Internet users embarking onsome electronics-related re-search. Once again, my thanks toour readers for providing the ex-tra input.

Endangered SpeciesThe Internet is also useful

for tracking down any pockets ofodd, obsolete devices, or atleast finding out the current sta-tus of an obscure semiconduc-tor chip, as prompted by thisenquiry:

I was wondering whetheryou could find out whether ornot the General InstrumentSPO256-AL2 speech synthesisIC is available anywhere oreven still in production. It ismentioned in an old roboticsbook (published in 1987) Ibought from a car boot sale Iwas intrigued by this particularcircuit because it allows a PC orC64 to talk! Also, the SPO256-AL2's sister IC, the CTS256-AL2, converts ASCII intospeech. Many thanks for any-thing you can do. Joseph Birr-Pixton .

Some research on Usenetand Web sites revealed that theSP0256-AL was produced byGeneral Instruments very manyyears ago, but I gather that GIsold off their chip manufacturingdivision to Arizona Microchipand the SP0256 has long sincebitten the dust. An attractiverange of voice synthesis chips ismanufactured by InformationStorage Devices Inc (ISD) andis retailed by Maplin and others.Try www.isd.com for details.

The question of obsoletechips is quite a pertinent one,and sudden chip deletionscause at lot of headaches forourselves as well as our read-ers. If a chip is listed in a cata-logue and possibly included ona catalogue CD then it seemsreasonable to assume that itshould be readily available fromthat supplier. Savvy designersknow only too well, though, thatcatalogues cannot always be

EPE Online, April 1999 - www.epemag.com - 461

&LUFXLW6XUJHU\

relied on and they may try toseek confirmation from themanufacturer to determine thelikely availability.

To be fair, catalogues them-selves have a long shelf life andit is quite common to find thatdevices have been withdrawn(overnight, sometimes, whenremaining stocks just vanish)after a catalogue has gone topress. I have found it to be un-realistic to expect that just be-cause a chip is listed in a cata-logue, it is always still availablein a reasonable quantity. It may

have been delisted, or there mayonly be a handful left, and a di-rect substitution may not be pos-sible.

I noticed that National Semi-conductor list devices on theirweb site which they have discon-tinued or which are likely to bediscontinued in the future: lookfor the Obsolete Products Listingat www.national.com . It's a400K text file which some engi-neers and buyers may find handy.(Some hobbyists will be dismayedto learn that National finallydrowned the useful LM1830N

fluid level detector in December1998; remember the funLM3909 LED flasher/oscillatorand the handy LM3911 temper-ature controller? They wereboth ditched as far back as April1995. I hope the indispensableLM3914N bargraph driverdoesn't suffer the same fate.)

EPE Online, April 1999 - www.epemag.com - 462

FREESERVE SUPPORTCOSTS LESS

Barely a day goes by in theUK without the name“Freeserve” being mentioned(www.freeserve.com ), and thisattractive free Internet accessoperation is now set to be spunoff into a separate company.Many existing users wouldargue that Freeserve is everybit as good as their existing ISP,and about one million users aresaid to have signed up in just afew months. (If Internet accessstatistics are to be believed,there are now over six millionInternet users in the UK alone.)

Judging by your E-mails,most Freeserve users appear tobe completely happy, althoughthere have been a number ofothers who reportedly suffereddifficulties in trying to sign upusing the Freeserve CD.Problems include unwelcomealterations to softwareconfigurations, which irkedsome experienced users,conflicts with other software orsystem crashes during theregistration process. Anotherbone of contention was theprice of support calls at 1 UKPound a minute, but these haverecently been slashed to 50p,which is welcome news.

FREESERVE SANS CDThe Freeserve FAQ Page

advises that it is not possible tosign up to their service withoutusing the Freeserve CD-ROM,although nothing which prohibitstrying to do this is mentioned in

Freeserve's Acceptable UsePolicy (AUP), and Freeserveare also investigating whetheron-line sign-up can beaccommodated for the future. Ifyou want to sign up the E-mailclient on your Apple Macincidentally, you have to use aWindows PC and then transferthe login details over. Freeserveusers must access the serviceevery 30 days to maintain theiraccount, but dormant accountsare easily re-activated by theirusers.

In the February issue Ipointed to an independent website which published details ofhow to obtain a Freeserveaccount without the need to usethe Freeserve CD.Unfortunately the web site inquestion was temporarilywithdrawn soon after publicationof the last Net Work column.The co-maintainers of the website tell me that their popularinstructions for connecting toFreeserve without the use of theCD have now been relocated toa more appropriate URL, and itsauthors have decided togeneralize their previouslyTurnpike-specific instructions sothat people using software otherthan Turnpike can connect toFreeserve without destroyingtheir local setups. (Turnpike isan E-mail and newsgroup clientmarketed by Demon Internetwhich also supports other UKISPs including Freeserve). Mythanks to Wm and Colin Pricefor keeping me posted about thenew URL, which iswww.seesaw.freeserve.co.uk/fs/fs-sans-cd.htm .

BT CLICK GOES FREEIf you have a Windows

95/98 PC and all you seek isweb browser access plus E-mail, then British Telecom'snew “ClickFree”(www.btclickfree.co.uk ) mightbe the simple way of getting offthe ground. It appears to havenone of the potential sign-upproblems reported by a numberof Freeserve users, andinterestingly BT claims it is theUK's only free service thatdoesn't require registration. Itlooks to be an excellent startingpoint for beginners. BTClickfree has also linked withValue Direct, which aims tooffer cut-price electrical goodsfor Internet shoppers.

Unfortunately the launch ofBT's original “Click+”(www.btclick.com ) Internetaccess service coincided withthat of Freeserve. BT Clickcharged local call rates plus 1pper minute, which, comparedagainst Freeserve, appeared tobe doomed from the start. Ihave now tried BT's latestoffering, BT ClickFree, which isa new free access service forwhich you only pay for the localrate phone call. The idea is thatusers can fire up a web browsersimply at the click of a discretedesktop icon. Telephonesupport costs 50p per minute.

If you do not already havean existing Internet connection,then a CD ROM is available(Freefone 0800 731 7887). BTClickfree also offers the user“free-mail” (Talk21) which iscurrently an on-line mailbox

By Alan Winstanley

SURFING THE INTERNET

EPE Online, April 1999 - www.epemag.com - 463

service allied to Excite mail (theClickfree portal site is hosted byExcite UK). Presently E-mailsmust be composed whenconnected to the web-basedTalk21 mail server, but a POP3upgrade is promised, whichmeans that offline mailcomposition and reading will bepossible. (Excite.com hasalready done the same.) The BTClickfree mail service alsomakes it simple to attach files toE-mails. Don't forget that youcan put your modem phonenumber on a “BT Friends &Family” list to attract furtherdiscount.

So how good is it? I foundthe BT Clickfree sign-up wasvery smooth and extremelyrapid, in the sense that thedownload is a tiny 70kB“setup.exe” file which can befetched from the web siteprovided that you have anexisting connection. This quicklyinstalled to create an icon thatlaunches your own pre-installedbrowser. During set-up, I tried tojump from the Clickfree page tocreate an E-mail address butthis was very problematic, withlengthy delays that I eventuallycircumvented by hopping overdirect to the Talk21 web site(www.talk21.com ). It was soonset up, though. A single icon on

the desktop is double clickedand this dials in and launchesthe browser, and you canaccess other online servicestoo.

CHECKING OUT ATTESCO

Talking of shopping,Britain's largest supermarketchain has commissioned BT toproduce TescoNet(www.tesco.net ), a freeInternet access whose primaryrequirement is the ownership ofa Tesco loyalty Clubcard. Thisnecessitates a visit to yournearest Tesco store, and if youdon't already have an existingconnection to sign up, then aTescoNet CD-ROM wasscheduled to launch onFebruary 22nd. This is anotherfree access service with 50p perminute telephone support. Itruns on Windows 95/98 andTesco say that Windows 3.1and Mac are supported too,along with single channel ISDN.Customers' own homepages(10MB) are provided andTescoNet supports up to fivePOP3 mailboxes, permitting off-line E-mail composition. POP3mail allows you to usually fetchmail even if you have dialed inusing another Internet provider,

or you have moved location(e.g. you may be at work ratherthan at home, noting thatcommercial use of TescoNet isprohibited).

Registration is performed bylogging on to http://register.tesco.net andanswering a few minorquestions (have your Clubcardready). Browsing aroundTescoNet's new web site, I wasimpressed by the amount ofmaterial aimed at Internetbeginners, and the overallpresentation was clear andconcise. Although it wasn'tpossible to try TescoNet's CD-ROM or custom software, it wasquite feasible to accessTescoNet using another dialer.Setup was straightforward andinvolved configuring the rightaddresses and passwords, andthe system then ran trouble-free. The necessary setupinformation is found in theTescoNet FAQ, which should beprinted off via their web site.

As always, I have gatheredtogether a number of linkswhich I think will be of interestto Net Work readers and theseare published on the Net Workpage of the EPE web site atwww.epemag.wimborne.co.uk. I welcome pointers fromreaders for electronics orInternet-related links. These canbe sent by E-mail [email protected] ,and all contributions areacknowledged.

1HW:RUN

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

IF ALL ELSE FAILS …There’s an old engineering joke that says “If all else fails, read the instructions!”

Unfortunately, this is becoming an increasing problem for us at EPE and EPE Online, withpeople asking questions about projects that are clearly covered in the article.

It seems that the ease with which people can e-mail us is part of the cause. There is anincreasing perception that penning a quick e-mail and setting it racing across the internet iseasy and costs little, and you will get a quick reply back. Problem solved with minimum effort!Sad to relate, however, that the reply may simply say “Please read the article” or “Please readShoptalk”

GIVE US STRENGTH!The shear quantity of email we receive may surprise you (sometimes more than 100

messages a day), and each one takes time to answer. You can only imagine our surprise anddelight to receive a message saying something like “Are the PIC code files for project xyz stillavailable in the EPE Online Library?” Well Duh! Would it have exhausted the writer of this littlegem to actually visit the library and look for himself? So it may not surprise you to hear that ourresponse was a one word email saying “Yes!”

And then there was the reader who sent an email saying “I’m thinking about buying thePhizzyB Simulator CD. Can you tell me how to install it when I get it?” Is it just us, or is theresomething not quite right here?

IN A PICKLEIf you are building a PIC project and simply buy a ready programmed chip for it then there is

rarely a problem most of the PIC projects are, after all, fairly simple in terms of construction. If,however, you are programming your own chip and get into a PICkle (sorry, we couldn't resist it)then make sure you know how to use the programmer you have, and that you follow theinstructions supplied with it, or with the article from which you built it. For instance, you mustinitialize the chip with the correct configuration before doing anything else.

Whilst we try to be as helpful as we can, we are increasingly finding our time taken up withsomewhat obvious queries; unfortunately it's time we don't have and it's time that is beingwasted because we have already supplied the information. We know it is not always easy whenyou are learning something new like PIC programming or, when your project refuses to work,and we do not want to put off the genuine queries from readers. Just check that you have readeverything and tried to sort it out yourself before you leap into action on the keyboard, please.

Not only will you have the satisfaction of knowing that you have solved the problem, you willalso have gained some knowledge and experience along the way and that, surely, is part ofwhat our hobby is all about.

EPE Online, April 1999 - www.epemag.com - 464

EPE Online, April 1999 - www.epemag.com - 465

The race is on to market anerasable optical disc which issmall enough to use in a pocketrecorder that also plays low costpre-recorded discs. Hard discscannot be pre-recorded bypressing. Existing optical discsare either too large or havesuch limited capacity that heavycompression is needed for use-ful playing times.

New standards recently setfor the Digital Versatile Disc,and new developments inSony's Mini Disc, clear the wayfor tiny discs with at least twicethe capacity of today's 12cmCDs. But consumers cannotexpect a single standard.

Conventional 12cm CDscan store around 75 minutes ofuncompressed stereo sound. An8cm CD can hold only 20 min-utes. Sony's Mini Disc is a64mm disc in a protectivecaddy which records 74 min-utes, but only by using heavycompression that throws away80 per cent of the data.

A 12cm DVD can hold atleast 4¬¬¬7GB, which is enough fora full-length movie. There arenow three different varieties ofDVD, which can make erasablerecordings. DVD-RAM is backedby Hitachi, Toshiba, and Pana-sonic, while Philips and Sonyprefer DVD+RW, and Pioneerproposes DVDRW. All three relyon phase change technology;the disc is coated with material,which switches between amor-phous and crystalline state, andthus different reflectivity, whenheated by a laser beam. All

three disc types are embossedwith a groove which guides thelaser over the blank duringrecording. They vary in the waythey record data in and along-side this groove, and are largelyincompatible.

STANDARD SETTINGAt a recent meeting (Oct/

Nov '98) in Barcelona, the DVDForum set the standard for 8cmversions of DVD. The smalldiscs will record at least 1¬¬¬4GB,and as much as 5¬¬¬3GB if it is

MINI OPTICAL CDBarry Fox highlights the next generation of read-write CDs small enough for the

pocket.

A ROUNDUP OF THE LATEST EVERYDAY NEWSFROM THE WORLD OF ELECTRONICS

SLAUGHTERED LAPTOPSIt's become lap-top murder most horrid but Barry

Fox detects a solution.Two US companies have developed gadgets, which protect trav-

elers from a problem they only recognize when they find their laptopPC modems have been destroyed by hotel phones.

Modern hotels often use digital switchboards to route and billcalls. Some convert the digital pulses into analog signals before theygo to bedroom phones, but others send digital code to room phones,which have built-in converters. The plugs and sockets are the samebut, if a conventional analog modem is plugged into a digital line, itwill not work and the higher current, up to 0¬¬¬5A, quickly burns out or“fries” the modem.

Analog phones should be marked “Complies with Part 68, FCCRules”, but some are wrongly labeled. Passive fuses and trips maynot work fast enough to protect a modem.

American Power Conversion (of West Kinston, Ri) has devel-oped the SurgeArrest, a $40 connector which plugs between a laptopand its mains adapter, and between the phone line and modem. Themains adapter provides power for sensor circuitry inside the connec-tor. As soon as this detects current of more than 140mA on thephone line it lights a warning lamp and at 200mA breaks the connec-tion to the modem. APC will start selling the device in Europe duringthis year.

Konexx (of San Diego, Ca) goes one stage further with its new$200 AutoSet adapter. This exploits the fact that all phones, whetherdigital or analogue, send an analogue signal to the handset. The Au-toset plugs between the main body of the phone and the handset,and relies on the digital-to-analog converter inside the digital phoneto provide a safe working connection for a conventional analog mo-dem.

Because the level of the analog signal flowing between thephone and handset can vary considerably between different phonetypes, the battery-powered AutoSet self-adjusts to a level that letsthe modem operate normally.

EPE Online, April 1999 - www.epemag.com - 466

of the infrared laser normallyallows.

Japanese company TDKmakes blank media for what-ever recording systems peoplewant to use. The company cur-rently sells blank CDs, MiniDiscs, and DVDs, and is readyto mass produce the new minia-ture formats as soon as hard-ware to use them is available.Jean-Paul Eekhout, TDK Eu-rope's Product Manager, seesno prospect of the industry set-tling on one standard for porta-bles because the gap betweenphase change and magneto-optical technology is too wide.“We already see a trend fromCD to DVD, and we are devel-oping improved MDs. By 2001there will no longer be singlesystems for audio and video.”

Whereas previous video E-mail systems have only workedif the recipient has matchingsoftware to decode the soundand picture file, V-Mail bundlesmatching Player software withthe message and packages it asan executable (EXE) file. Therecipient then just clicks on themessage, which unpacks itselfand plays sound and pictures.

The player software workswith any version of Windows(3.x, 95, 98, NT) or IBM's OS/2,and even runs on old 486 pro-cessors. The pictures display ina small window of the screen,while the sound comes out ofthe PC's speakers.

“V-Mail will replace E-mail infour or five years” predicts HughBrogan, Chief ExecutiveOfficer of Philips PC Peripher-als Division.

1(:6

double-sided and each side hastwo recording layers. So aportable recorder will be able torecord several hours of videoor many hours of hi-fisurround sound.

Sony sees 8cm DVD as aserious threat to its existing MiniDisc audio recording system,which has a capacity of only200MB so must compress audioby a factor of five to squeeze 74minutes of stereo on the 64mmdisc. Sony has now joined withFujitsu to develop GigaMO, ahigh density version of MDbased on laboratory work doneby Sony in 1991 called ThermalEclipse Recording.

Unlike phase change DVD,Mini Disc is a magneto-opticalsystem. The disc is coated witha terbium ferrite cobalt mix.Heat from a laser makes thecoating temporarily lose allmagnetism. As the coatingcools it picks up magnetismfrom a surrounding field whichis switched to create a magneticpattern of spots which changethe polarization of readout light.

CORE CAPACITYThermal eclipse can in-

crease the capacity of amagneto-optical disc by a factorof six. The disc coating is madesensitive only to the hot centralcore of the laser beam. So arelatively thick beam recordssmall spots.

To allow equally precisereadout, the disc has a passivetop-coat, which covers a lowerlayer that stores the magnetism.The central core of the readoutbeam heats fine spots in the toplayer which then “sucks” mag-netic information from the lowerlayer. So the beam “sees” onlyvery fine spots of magnetism,effectively focussing moretightly than the long wavelength

V-MAILED E-MAILPictures speak a thou -sand words could V-mail replace E-mail?

Barry Fox investigatesthe prediction.

Electronic mail is getting anew look. Philips will soonlaunch the $99 Videogram or V-Mail kit. A simple color videocamera with built-in microphoneplugs into the USB (universalserial bus) socket of a Windows98 PC. Videogram Creator soft-ware then lets the user click onan icon, talk to the camera andhit Escape to stop recording.

Clicking on Send then com-presses the conventional AVI(Video for Windows format file)recording by a factor of 100, sothat a one minute sound andvideo message can be storedon a standard 1¬¬¬4MB floppydisk. The compressed fileis then sent as an ordinary E-mail message.

AMBIDEX-TROUS PCS

Multitasking takes on abroader meaning for PCuse Barry Fox reports.

Philips has now secured ap-proval from the US FederalCommunications Commissionto sell Ambi, a wireless homenetwork system which lets a sin-gle PC run two different applica-tions at the same time, withtheir different images simultane-ously displayed on the PC moni-tor screen and a conventionalTV set in another room. Ambi,which will go on sale in the USduring this year for around$600, relies on spread spectrumtechnology, similar to that de-veloped for secure military com-munications and now used bydigital cellphones in the US.The data is spread over a 1MHz

EPE Online, April 1999 - www.epemag.com - 467

loops are then cut with enzymesto create “sticky” ends, whichare then re-joined to explore ev-ery possible combination. Dyesare then used to expose thepatterns formed.

Check sequences areadded to expose errors, in amanner analogous to error cor-rection in a digital bit stream.NEC is proving the system withtraditional problems, like thebest routes a travelling sales-man should take to cover anumber of cities, without evervisiting the same city twice.

NEC acknowledges that theinvention builds on proposalsmade by Leonard Adelman ofthe University of Southern Cali-fornia in 1994, but makes thetechnique commercially viable.Although DNA computing isslow, taking hours per step in-stead of microseconds, a verylarge number of strands can betreated at the same time tocreate a massive parallelprocessor.

want to donate their IT equip-ment, as well as the people whowant to get hold of it, will knowwho to contact.

Copies of the handbook areavailable through the DTI publi-cation orderline (quoting refer-ence URN 98/979) Tel: +44 (0)870-1502-500, Fax: +44 (0)870-1502-333.

1(:6

band at 2¬¬4GHz.

A transceiver plugs into thePC and sends a 4Mbps datastream to a matching unit,which is connected to the TV.The TV's unit can also sendback data entered into an in-frared keyboard. The two-wayradio line reaches 50m, so onemember of the family can word-process or work on a spread-sheet while using the PCscreen, while others play com-puter games or surf the Internetusing the TV screen in anotherroom. The video sent to the TVis converted from the VGAcomputer standard to NTSCTV format.

The PC can multitask online, so that two people can surfthe Internet at the same time,using the same phone connec-tion to the same ServiceProvider. Ambi encrypts andlabels the data sent on the radiolink so that neighbors with simi-lar hardware cannot tap in.

The same 2¬¬¬4GHz fre-quency band is available in Eu-rope for wireless networking, butAmbi cannot be sold until eachcountry has approved thespread spectrum signal forlocal use.

RE-HOMING 5M PCs”Around five million items of

old IT equipment are thrownaway in the UK each year”, sosaid Dr Kim Howells, the UK'sCompetition and Consumer Af-fairs Minister, when recentlylaunching Unwanted ComputerEquipment: a Guide to Re-useat a workshop on environmentalresearch and development atthe DTI in London.

The handbook provides ad-vice and help to businesses whowant to find a good home fortheir old computer equipment.Markets for refurbished comput-ers include schools, libraries,community centers, charitiesand households. The handbookcontains a directory of UK refur-bishers, so that businesses who

DNA COMPUTERBy Barry Fox

NEC's Research Institute inPrinceton, New Jersey, haspatented (USP 5 804 373) auniversal computer, as origi-nally proposed by British scien-tist Alan Turing, that uses DNAstrands instead of tape to storethe program. NEC's re-searchers, Allan Schweitzer andWarren Smith, used circularloops of DNA, with groups of 20molecules sequenced to repre-sent letters of the alphabet. The

PIC BASICA free PIC Basic compiler

has been released by LeadingEdge Technology Ltd. LET hasreleased this program to en-courage the use of PIC16Cxxseries microcontrollers alongwith their range of low-cost ICE(In-Circuit Emulators), PICProgrammers and otherrelated products.

The Basic compiler sup-ports PIC54/55/56/57/71/84, thecode produced is “stand-alone”and no run-time modules arerequired. It can be downloadedfrom LET's web site: http://let.cambs.net . LET are basedin Malta.

CLIVAN BBSClive Bonner (G3TGF) has

asked us to publicize his Ama-teur Radio Telephone BBS. TheBBS was set up originally toprovide a user-friendly meansof exchanging data, programsand weather pictures. It followsthe success for many years ofthe Amateur Radio WeatherNet, which takes place on3786MHz each morningthroughout the year, usually be-tween 07:30 and 09:30 GMT.

All software included on theBBS is either Shareware or

EPE Online, April 1999 - www.epemag.com - 468

1(:6

Freeware and is for AmateurRadio purposes only, includingSSTV and Weather satellite re-lated programs. The system hasbeen set up to be as simple andquick as possible, operatingwithout “bells and whistles”.

The 24-hour phone numberfor access to the CLIVAN BBSis +44 (0) 1435-830484, 3333.Clive emphasizes the impor-tance of including the last fourdigits in the modem dial-outstring to ensure correct routing.Preferred FTP protocol isZMODEM but other protocolsare available.

Maplin Tailors PCsMaplin Electronics have

come up with a leading solutionto what they say is the mostasked question in the PC retail-ing world: “What system shouldI get?”. Maplin believe that inthis increasingly computer-orientated world, the need tohave systems that meet theconsumer's individual needs iscrucial. Accordingly, they haveawarded Compusys Ltd the“Build to Order” contract for sup-ply of “customer-designed” PCsto all Maplin stores. Prices startat 699.99 UK Pounds.

Staff are on-hand to offerexpert advice to PC buyerswhen selecting from the widerange of options available.“Maplin have long had an ex-ceptional reputation for highlevel technical expertise at thepoint of sale”, said GordonDavies, General Managerof Compusys.

For further information, con-tact any of Maplin's stores na-tionwide (and international), ortheir head office at PO Box 777,Rayleigh, Essex SS6 8LU, UK.Tel: +44 (0) 1702-554000. Fax:+44 (0) 1702-554001. Web:www.maplin.co.uk

Nepcon WebbedOf likely interest to those

who would like to get to theNepcon UK electronics exhibi-tion but cannot, is the new website at www.nepcon.co.uk .

Nepcon UK is the UK'sleading annual event for theelectronics manufacturing in-dustry. The new web site aimsto be the number-one source forindustry information for theelectronics manufacturing com-munity in general. This year'sevent takes place at NEC inBirmingham from 13-15 April.

By filling in a short formover the Web, users can accessthe Product Index all yearround. This is a free referenceservice that informs users by E-mail of any updated products asthey appear on the site. It alsooffers a search facility wherebythe index may be used tolocate potential suppliers byproduct category.

Nepcon UK is organized byReed Electronics Events, whocan be contacted on +44 (0)181-910-7849.

costs around $10k US Dollars),but to give you an insight intothe extent that some manufac-turers are now going to in orderto protect their products.

The heart of the amplifier isthe patented Equibit PCM-to-PWM processing and outputstage, developed by ToccataTechnology, an independentresearch team. Just two ActelFPGAs were used to replacetwo 24-bit DSPs (digital signalprocessors) and two PLDs(programmable logic devices)running at greater than 90MHz.The FPGAs have on-chip pro-gram storage that is not easilycompromised and use farless power than the originalcomponents.

Actel was approached afterToccata decided that the possi-ble piracy of such a high valueproduct and risk of a competitorusing their proprietaryalgorithms simply could notbe tolerated.

“Our antifuse FPGA tech-nology has proven to be a se-cure way for companies likeToccata to protect their valuableintellectual property”, com-mented Andy Biddle, NordicDistrict Manager for ActelEurope.

Actel devices are highly re-sistant to copying because ofthe difficulty in differentiatingbetween a programmed and anunprogrammed antifuse. Nonon-destructive optical methodshave been identified and theonly way developed so far in-volves destructively sectioninga programmed device. This is alaborious high-precision processconsidering that the antifusefeature size is typically 0¬¬¬5Pm orless. This, coupled with the factthat a typical device can containmore than a million antifuses,make these parts extremely dif-ficult to replicate and are

WORLD'S FIRST DIG-ITAL AMPLIFIERTACT Audio recently

launched the first ever direct-drive digital amplifier aimed atthe high end of the hi-fi market.The TACT Millennium achievesits high quality sound perfor-mance using two Actel MX FP-GAs (field programmable gatearrays), whose antifuse technol-ogy has a proven track recordas a piracy deterrent.

We highlight the product notonly for its own sake (which

EPE Online, April 1999 - www.epemag.com - 469

1(:6

¬

likened to security offered bycustom components.

The TACT Millennium issaid to have made a major im-pact on the hi-fi market thanksto the Actel Devices it contains.The amplifier itself benefitsfrom this technology with an ef-ficiency of 96 per cent, a crispand clear output with 150WRMS per channel and a totalharmonic distortion of lessthan 0¬05 percent.

For more information con-tact Actel Europe Ltd., DaneshillHouse, Lutyens Close, Bas-ingstoke, Hants RG24 8AG, UK.Tel: +44 (0) 1256-305600. Fax:+44 (0) 1256-355420. Web:www.actel.com . Tact Audioalso have a web site at:www.tactaudio.com .

MARCONI CEN-TENARY

Radio amateurs recentlycreated a new world-recordwhen they re-enacted the firstever ship-to-shore radio mes-sage. The transmissions werefrom the same locations usedby Guglielmo Marconi himself,namely the South Goodwinlightship and the South Fore-land lighthouse.

Previous achievementrecords were smashed duringthe event, organized by The Na-tional Trust and sponsored byMarconi Communications, whenmore than 5000 messages weresent and received from enthusi-asts all over the world overthe four-day period from 19 to22 December.

One of the operators,Richard Mortimer (GW4BVJ)single-handedly made a total of

2043 contacts in Morse code.To ensure that he broke the pre-vious record, he remained athis Morse key for 24 hours non-stop on the last day.

Norfolk Island, some17,000km in the Southwest Pa-cific Ocean, was the destinationof his furthest link-up withKirsty Smith (VK9NL) and herhusband Jim (VK9NS).

Mike Parton, managing di-rector of Marconi Communica-tions, said “We congratulate theradio operators on their achieve-ment and for their superb re-enactment of Marconi's firstdemonstration that radio couldassist ships at sea”.

SOLAR NIGHT-LIGHTA remarkably low cost solu-

tion to independent outdoorlighting at night is being offeredby Solar Solutions Fountains.Their new Sentinel Solar Pow-ered Light will, they say, be ap-preciated by anyone who “findsthemselves holed up in the shedto twilight and beyond”. TheSentinel provides reliable, pow-erful outdoor fluorescent light-ing, with no need for costly orcomplicated mains wiring, andhas no running costs.

“The beauty of the Sen-tinel,” explains Alex Smith ofSolar Solutions Fountains, “isthat it is so easy to use andlends itself to such a wide vari-ety of use. All you have to do isaffix the solar panel outside yourshed, garage or outhouse, posi-tion the fluorescent tube inside,and connect them with the cablesupplied. The Sentinel willcharge up even in watery winterlight, and is then ready for usewhenever you need it.”

The Sentinel Solar PoweredLight kit comes complete with

an 18W fluorescent light withbuilt-in battery, 5W top-qualitysolar panel, 5m cabling, fixingsfor panel and light, plus easy-to-follow instructions. It costs 98UK Pounds including postageand packing. It is available bymail order from:

Solar Solutions Fountains, 6High Street, Kington, Hereford-shire HR5 3AX, UK. Tel/fax:+44 (0) 1544-230303.

EPE Online, April 1999 - www.epemag.com - 471

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, andresistance. 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 *

APPLE iMACDear EPE,

I was delighted to see twoitems in the January 1999 issuerelating to the Apple iMaccomputer, but I think that youwere very unfair with yourcomments in both pieces. TheInnovations article is verymisleading on several points: itimplies that suitable peripheralsare difficult to find this is simplynot the case. The iMac's USBports are standard PCconnectors. A whole range of lowcost devices including scanners,printers and serial adapters wereavailable to buy in the UK whenthe iMac was launched inSeptember, and many newproducts have come onto themarket since then, includingexternal disk drives.

The iMac does have anexpansion slot, although its useis limited, but since the iMaccomes with an ATI Rage ProTurbo graphics controller and6MB of video RAM, SRS sound,100Mps Ethernet and 56Kmodem built in, it is hard toimagine what a home userwould need to add. The cost ofRAM for the iMac is no differentto any other modern PC and theprice varies greatly at themoment (Dec '98) most iMacsuppliers are including free96MB RAM upgrades. Manypeople have criticised Apple fornot including a floppy drive, butthis does make sense if youconsider that most people buyan additional zip or superdiskdrive for their PC anyway,leaving the floppy redundant.

I do not understand why youhave decided to quote the start-up time as your only measure ofhow fast the iMac is. Sincewhen has this been a usefulmeasure of a computer'scapability? In use, the iMac isblisteringly fast thecombination of the super fastPower PC processor with itshighly efficient Cache memoryand accelerated video hardwaremean the iMac is onlymarginally slower than Apple'stop of the range systemscosting three times as much truly amazing for a homecomputer.

The Net Work article doesprovide a far more roundedpiece on the iMac, until AlanWinstanley chooses not torecommend the machine on

grounds that I feel areunjustified. It is true that AppleMacs are rarely seen in the highstreet but this means thatthere is a thriving mail ordercommunity instead. I see noreason why a “technicallyinexperienced” iMac ownershould have difficulty buyingmail order. I have yet to gainany benefit from sales staff atDixons or PC-World whenbuying computer equipment. Itseems far better to talk to a realexpert in a mail order companyover the telephone.

With regard to the issue ofIBM PC software compatibility,this is no longer a seriousproblem for Apple users.Virtually all of the majorsoftware titles (Microsoft Wordand Excel, Adobe Photoshop,etc) are available for both Macand PC, and they use identicalfile formats files saved on theMac can be opened on the PCand vice-versa.

Easy Open file translationsoftware, often bundled withApple computers performsautomatic translation ofdocuments when the correctapplication isn't available farmore flexible than straightcompatibility. I am notexaggerating by saying that inmany cases, Apple computersare more compatible with PCsthan PCs are. I am regularlyusing my Macintosh computerto unzip, translate and convertPC files for my colleagues touse on their PCs.

For software titles not

John Becker addresses some of the general points readers have raised. Haveyou anything interesting to say? Email us at [email protected]!

EPE Online, April 1999 - www.epemag.com - 472

available for the Mac, a numberof excellent and veryrealistically priced softwareemulators are available that willrun any Windows application.The astonishing speed of theiMac means it is quite capableenough to run Windows 98 atPentium speeds. I currently useVirtual PC to run Windows 95and the Microchip MPLABsoftware and program PICmicrocontrollers without anyproblems on my Mac, a modelfar less well specified than theiMac.

The issue of IBMcompatibility is not nearly asserious as you suggest. Apple'sMacintosh computers (includingthe iMac) run MacOS, currentlyat version 8.5, which is almostuniversally acclaimed as thebest personal computeroperating system available. It isbrilliantly designed from theground up to provide fast, easycomputing. The MacOS andapplications that run on it reallyare a joy to use a far cry fromthe problems of Windows 3.1,95 and 98. Apple computerhardware is also exceedinglywell built there are many ten-year old Macintosh systems inuse today.

If you want an indication ofjust how good Apple Computersand the Macintosh MacOSoperating system is, considerthis: despite the fact that Macusers are in a minority amongWindows users, the fact thatMac hardware and softwareoften isn't available on the high-street, and the fact that Applecomputers have alwayspreviously been moreexpensive than Windowssystems, Apple is still one of thelargest computer companies inthe world, second only tocompanies like Dell andCompaq in terms of numbers of

computers sold, but always ontop and winning awards with thefastest machines, and newestand most innovativetechnologies. It is fantastic thatApple is able to produce theiMac, a fully specified computerat a home computer price.

I find it sad that such abrilliant piece of engineering isknocked back largely on thebasis that it isn't directlycompatible with the majority ofPCs. There are millions ofpeople in the world who knowthat there are problems withWindows 95, millions havingproblems with Windows 98 sowhy are people so keen to stickwith something so universallyknown to perform so poorly?With the iMac, Apple has at lastproduced a very credible,affordable alternative toWindows, and this should beapplauded.

PS. I am a productdesigner/electronic engineerwho uses both Macs and IBM-PCs every day, and I don't workfor Apple!

Roger Colemanvia the Net

Thanks for an extremelyinteresting and different viewpoint of the iMac. Editorially wetry to be impartial and the viewsexpressed by contributors areentirely their own.

PIC TOOLKITANDWINDOWS I/O

The first part of this letter isspecific to Windows 98, but theremainder will be of interest toWindows 95 and 3.1 users aswell.

Dear EPE,

Having just changed myoperating system to Window 98,I found that I could not sendsignals to the PIC Toolkit board(EPE July 98) in a DOS boxunder Windows. I have nowbeen doing some work on theWindows 98 I/O portaccessibility problem.

I have found that if I disableLPT1, then Windows 98 keepstrying to reinstall it and thereseems to be somedisagreement between theBIOS and Windows. I've givenup trying to sort out what ishappening and instead havecome up with a solution thatworks all the time.

I have two parallel ports, thefirst of which came with the PCand is known as LPT1. Thesecond is one that I later addedmyself at a cost of a few poundsand is LPT2. I installed this asnormal and tested it on myprinter.

The trick now is to navigatefrom My Computer to theProperties General tag forLPT2, then tick the box to“Remove from this hardwareprofile.” This frees the port fromWindows, which then ignores itno matter how many times Ireboot. I've not looked intohardware profiles!

Using the now free LPT2port connected to either the PICToolkit board or the EPE PICTutorial board, I find that I canaccess and run the softwarefrom the desktop in a DOS box.

This has brought to lightanother problem. My LPT2 porthas some sort of internal pull-upon its pin 10 which is so strongthat the drive from the PIC inVerify Mode can't drive logic 0

5HDGRXW

EPE Online, April 1999 - www.epemag.com - 473

below about 2V, which givesverify errors of course.

To get over this I have addeda 7404 chip on a small piece ofVeroboard and wired two of itsinverters in series to give a non-inverting drive between the PICpin 13/4053 pin 15 junction andpin 10 of the Centronicsconnector. I didn't need to cut thetrack but just removed two jumperlinks from the board and wiredaccordingly.

As seen by my oscilloscope,the voltage at connector pin 10goes from 0have not had a single Verify error.

¬¬¬1V to 5V and so far I

I really can't thank youenough for the knowledge andexperience gained from your twoprojects and I can only guess atthe number of man-weeks ofeffort invested on your part.

Colin BirtwistleSwanley, Kent, UK

Colin, I am most grateful toyou for this information, as will bea number readers there havebeen quite a few who havecontacted me about theircomputer's inability to correctlyread the data on connector pin10.

In this context, it hassurprised me how many readershave not fully read my commentsabout setting the programvariable VERIFY% = 0 if thecomputer cannot read the pin (it'snear the head of the program andnormally set to VERIFY% = 1,which tells the computer that itshould try to verify/disassemble).

As result, a common resultingproblem is that some of thesereaders have thought their PICwas not being programmed at allbecause the computer wasreporting vast quantities of errorsfound, probably as many as thenumber of bytes sent! In all

cases, it is highly likely(provided everything else isbeing/has been done correctly),that the PIC will have acceptedthe data, and it's just thecomputer that erroneouslyreports otherwise, simplybecause it cannot read pin 10.

To summarize the possiblereasons why the PIC mightappear to be inaccuratelyprogrammed by Toolkit, theyare:

o) PIC omitted/incorrectlyinserted (should be notchdown)/wrong type (16C84and 16F84 only)

o) Power to the board notpresent or not to thevoltage required

o) Printer cable not plugged in

o) Incorrect Port addressselected on computer (re-read my text there arethree possible addresses,hex 378, 278, 3BC)

o) Computer cannot readprinter port as an input (see Colin's letter abovefor possible solution andmy above comment aboutdisabling the verifyingroutine, setting VERIFY%= 0)

o) PCB and/or componentsfaulty in some way

o) A few genuine errors exist

experienced it) try again (I've never

o) PIC has not first beenconfigured as required forapplication (Menu Option 1not run)

o) Failure to disassemble maybe because PIC haspreviously been CodeProtected

I have long suspected thatsome computers might need abuffering chip between theirprinter port and the PIC, and

have been suggesting such tosome readers who have phonedme. It is an option which is wellworth exploring if your computerseems unable to verify/disassemble. With Toolkit Mk2which I am currently preparing(and which is intended for thePICx84 and the new '87xfamily), I have included a bufferas part of the circuit.

5HDGRXW

APPLE PRESSDear EPE,

I must take exception tosome of the remarks in the Jan'99 Net Work column concern-ing the Apple iMac. There arethings I think need to be said,and the press should be sayingthem.

I am an electronics techni-cian in California, and an avidcomputer hobbyist, building myown PCs from parts. I too wouldadvocate avoiding the iMac forthose who like to tinker withtheir systems. However, myreasoning is very different. Iwould also tell these same peo-ple to avoid Compaqs, PackardBells, and any number of otherPC brands.

Why? Because they, likethe iMac, are designed to betaken home, plugged in, and leftalone. Despite the fact thatthese are PC compatible, thatcompatibility is primarily opera-tional. These machines fre-quently contain proprietary com-ponents that make upgrading oradding on peripherals a night-mare. For those who want asimple ``plug-n-play'' solution,the iMac is nearly ideal.

As for the compatibilityproblems, I feel you havegrossly overstated them. Whiletransferring files from Mac to PCcan be problematic, anyone whohas worked in a (supposedly)

EPE Online, April 1999 - www.epemag.com - 474

homogeneous PC environmentwill have experienced the prob-lems that come with the numer-ous incompatible versions ofMicrosoft software.

The standard practice is toforgive any problems caused byMicrosoft's software, and sug-gest buying a new version to fixproblems that shouldn't havebeen in the old version. Also ig-nored is the fact that the newversions always have at least asmany problems as the old ones;they're just different problems.

It's been my experience that90 per cent of “hardware” prob-lems go away when you switchto a non-Microsoft operatingsystem. Apple's current hard-ware is better than anythingavailable in the PC world.

A technically oriented maga-zine such as yours should notbe advocating staying with thestatus quo for convenience rea-sons. The situation would bemuch better if those in the presswere more willing to explorethose alternatives and lessprone to dismiss them out ofhand for problems that oftenamount to “urban myths.

Alan RatcliffLivermore, California, USA

The above and the followingreply have been heavily editedfrom their original lengths forspace reasons. Net Work beingAlan Winstanley's pet addiction,it's he who replies as follows:

If I had the time, I couldwrite many pages of views com-paring the practicalities of Win-tel and Macintosh ownershipand I also know how defensiveand loyal Macintosh owners areconcerning their choice of com-puter equipment.

Like many users stuck on aperpetual upgrade treadmill, I

hardly have a wonderful timerelying for a living on hardwareand applications from Apple'scompetitors, though if nothingelse I am totally spoilt for choiceof plentiful and cheap upgradesand accessories for my PC sys-tem. (I run a Macintosh Power-book too, by the way.)

I have just spent severalhours talking to Apple's repre-sentative about the iMac andalso playing around with aniMac 233, and I can tell you thatif I had the office space I wouldprobably buy one today. I thinkit is a brilliantly executed pieceof (consumer) electronics, whichoozes design flair and it de-serves to be an enormous suc-cess. Apart from my biggestgripes (the lack of removablediskette, the mouse ergonomicsand the lack of tilt/swivel moni-tor), I think that the reliance onthe Internet for file transmissionis a brave move but is onewhich is slightly ahead of itstime.

My Net Work article (whichwas not aimed at gurus) relatedto the launch of an Internet-dependent machine, which wastargeted specifically for homeuse, with the added attractionthat it was said to be easy touse (and implying it would ap-peal to beginners or inexperi-enced users). I felt it was impor-tant that people should beaware of some of the practicaldifferences between the twoplatforms before they buy intoeither path.

Without wishing to spoil Ap-ple's fun, ultimately I outlinedsome of the drawbacks but I didleave it to the reader to decide.The problems are hardly insur-mountable to an experienceduser/buyer but are pretty funda-mental to the beginner lookingfor an easy to use home ma-chine.

Rather than the situationbeing caused by the technicalpress forever “pushing” PCs, Ithink Apple has only itself toblame for the disparity in themarket penetration of its prod-ucts, though I am the first to ac-knowledge that the Mac easilyreigns supreme in professionalmarkets including page make-up and pre-press, graphics andweb creation, as reflected bythe highly specialist softwareavailable for the Mac OS.

Alan Winstanley

LADDERSDear EPE,

With reference to CarleWilde's request in Readout Feb'98 for a Ladder Logic article, Iwould like to refer him to ETIDec '98. This is great articlewhich gives the reader a chanceto experiment.

Tom MullanWoking Surrey

Thanks Tom, as we nowown ETI we can quite happilypass on your recommendation!We have copies of this issue forresale see the EPE/ETI website for more detailswww.epemag.wimborne.co.uk

WINDOWS 98 PORTSDear EPE,

In Readout Feb '98 (HighLanguage), you ask about ac-cessing Windows 98 ports, inthe context of Ken Brown's en-quiry about using Windows pro-gramming languages for EPEparallel port projects.

Windows 95 and 98 are notnearly so different as Windows3.1 and 95 are. Information

5HDGRXW

EPE Online, April 1999 - www.epemag.com - 475

about using MS-DOS/Windowscomputer's parallel port for EPEtype projects is on my web siteat: www.arunet.co.uk/tkboyd/ele1pp.htm

Ken Brown's points addresswhat you are “supposed'' to doin Windows programming. Forthe purpose of EPE-type pro-jects, I do not believe that therewould be significant problemswith the “cheats” inherent in my“quick and dirty” method.

Please consider publishingan E-mail address for Readoutas part of its main page head-ing.

Lastly, congratulations onabsorbing ETI.

Tom Boydvia the Net

You have an interestingweb site, Tom, with some veryuseful links. I spent a couple ofhours browsing through theselinks, and there's a lot of port-related material. Readers arerecommended to take their ownlook.

Curiously, though, I didn'tspot anything relating to whylap-top computers seem lesswilling than desk-tops to allowtheir printer ports to be used forpurposes other than drivingprinters.

We periodically get callsfrom readers who cannot gettheir lap-tops to work with someprojects that are known to workcorrectly with desk-tops. Couldthe lap-top output voltages belower than those expected fromdesk-tops? Could pull-up/downresistors provide a solution?Can anyone provide some an-swers from their own experi-ence with lap-tops?

Readout does not have itsown E-mail address, the general

Editorial address should beused (as given at the top right ofeach month's Editorial page),i.e. edito [email protected]

FUEL FOR THOUGHTDear EPE,

I have just changed my mo-torbike (from an R110RS to aCruiser). All my previous bikeshad fuel gauges yet this newmodel from BMW surprisinglylacks one (except for a low-warning light, which is uselessas you may not be able to find agarage with the range left).

Not to be put off, I removedthe tank and plate expecting tofind a float and rheostat inside(as is the case with their othermodels, even though a gaugemight not be actually fitted tothe display panel. There is onlya small float switch used by thewarning lamp. There appears tobe no float/rheostat assemblyavailable that can be fitted in-side this particular model's tank.

Do you, or any reader, knowof a way of measuring fuelquantity in a metal tank using atransducer from outside (so asnot to have to drill a holethrough the tank which wouldpresent sealing problems), e.g.by pinging the tank with a soundwave. The measurement doesnot have to be linear as thiscould be accomplished using aPIC.

Any suggestions would bewelcomed as I do not want torun out of fuel miles from any-where again!

Stephen H. Alsop JPvia the Net

Again? therein lies a tale(and a trail) I guess! Stephen's

E-mail was addressed to AlanWinstanley, who offers the fol-lowing:

From my industrial experi-ence it can be extremely hard toobtain reliable results, depend-ing on the nature of the fluid be-ing measured. Methods includeultrasonic or laser detection,checking the image reflectedfrom the top of the fluid. Butwith a motorcycle there will ob-viously too much turbulence forsuch a system to work properly.

The old ways are best and Ithink that a float would be theonly feasible way of dampingdown the movement inside thetank. There are several floatsensors available from RS orFarnell, but I really wouldn't liketo offer a circuit due to the haz-ards involved. As for trying todetect the fluid content fromoutside, I really cannot think ofany reliable method.

I find it incredible that nogauge is fitted to your machine.(I'll stick to a mountain bike!)

Alan Winstanley

As a thought from me,could you perhaps put a flowmonitor into the fuel line?Knowing the rate of flow and thepipe diameter, the PIC shouldbe able to calculate the quantityused. Providing you know howmuch fuel you put into your tankeach time (perhaps entering thevalue into the PIC) you shouldbe able to keep track of theminimum quantity remaining.

RS do a range of flow sen-sors, at least one of which is foruse in automotive fuel line ap-plications (part no 256-225,about 70 UK Pounds). Let usknow how you eventually solvethe problem.

5HDGRXW

EPE Online, April 1999 - www.epemag.com - 476

PIC84 EEPROMDATADear EPE,

How can I program thePIC16x84's internal EEPROMdata memory with a messagebefore the program itself isloaded? I understand some PICprogrammers can do it, but yourTASM Send does not seemable to.

Daniel Hicksvia the Net

Yes, TASM Send cannot dothis. However MK2 that is in preparation can!

my new Toolkit

It will both program any mes-sage (or other codes) of one'schoosing into the PIC's EEP-ROM data memory and (withcomputers that can read theirprinter ports) can also readthem back to disk. Toolkit Mk2,is for programming PIC16x84and the new PIC16F87x micro-controllers and is scheduled forthe May issue. And, incidentally,the inclusion of this facility wasprompted by your query (andhalf a weekend to spare)!

ONLINE DILEMMADear EPE,

Now that EPE is availableOnLine via the Net and I canreadily access it, should I nowcancel my printed edition of themag and adopt the Internet ver-sion?

Also, I have noticed thatEPE has been criticised throughReadout for becoming computerorientated. Electronics is purelya hobby for me, but as part ofmy science course in the early'60s I had to learn the character-istics of thermionic valves andtransistors and how to build abetter amplifier. I did not find

this particularly interesting orchallenging.

However, in my opinion, Ibelieve that with the advent ofthe computer and microelectron-ics all this has changed. I be-lieve that EPE should have a bitof everything whilst remaining atthe cutting edge of technologyand innovation.

Colin Watkinvia the Net

EPE Online provides an ex-cellent way for readers allaround the world to gain fastaccess to the magazine and tothe articles in past issues (EPEOnline started with the Novem-ber '98 issue). The Online website also houses a shoppingmall which carries books, CD-ROMs etc. In addition to this,various other information in theform of back up material isavailable free of charge. Onlinerepresents an exciting leap for-ward for EPE and an extra facil-ity for all readers. However,readers should be aware thatthe on-line edition appearsabout ten days after publicationof the printed version and, atpresent, carries no advertising.

If you just want access tothe articles and are not worriedabout the adverts then Online ischeaper than the printed ver-sion. We suggest you “suck itand see”, a free issue (Nov '98)is available so you can get thefeel of it and see if it suits you.

The Net version is preparedand put on-line in America byour friends Max and Alvin (ofPhizzyB infamy!). They are sentour files only when the printededition layouts have been final-ized and sent to our UK printers.M&A then edit the files so thatthe Net edition is tailored toWeb presentation and an inter-national market. In this process

some contents may be slightlychanged, and even some arti-cles may be switched betweeneditions.

Whilst we are aware thatsome readers would prefer usnot to be involved with comput-ers, the majority do seem towelcome the fact that in theirvarious forms computers andallied devices such as micro-controllers have become an in-tegral part of electronics designand construction. I for onewould be totally lost now withouta computer I use one in myworkshop much more than Iever use a multimeter.

ENTITLINGDear EPE,

In your Feb '99 Editorial youasked for title suggestions tosuit the integration with ETI. Ibeg you not use an amorphousinitial-lettered title. Such apseudo name may identify themagazine to those who are fa-miliar with it even them

or it may confuse but it would mean

nothing to the unacquaintedwhom you would wish to attract.

The fatuous use of corpora-tion names comprised of initialshas become fashionable; butapart from a very few such des-ignations, as of the BBC, theyconvey nothing to the majorityof the people.

Besides, historically youramalgamated publication will bederived from more than only PE,EE and ETI (Hobby Electronics.for example?).

I suggest that you need atitle which would associate themagazine with its aspirationsand achievements. Try Func-tional Electronics.

J. H. EastaughChesham, Bucks, UK

5HDGRXW

EPE Online, April 1999 - www.epemag.com - 477

I have to agree that initials-only titles can be confusing tothose who are not already in theknow. Although we refer to our-selves as EPE within the bodyof the magazine, it would be im-prudent of us to substitute thoseletters for the full title on thefront cover. Even as an inde-pendent magazine, ETI stillspelt out their full title under-neath the logo.

Personally, I think it's dan-gerous for any magazine tochange its name in any signifi-cant way without a really goodreason readers become usedto looking for their favouritemagazine by its cover style. Ifchanges are to be made theyshould be done gradually. Ourincorporation of the ETI logohas, we hope, made EPE andETI readers still feel they havea familiar image to draw theirattention to the cover.

You are almost right on thehistorical aspect Hobby Elec-tronics was started by ArgusPress as a “little sister” to ETI,in the same way that IPC Maga-zines had previously started EEas a “little sister” to PE. Thiswas in the great hey-day ofelectronics hobbyist activity(1970s-80s) with several pub-lishers offering comparablemagazines to meet market de-mand.

However, as I understood itwhen it was happening, HobbyElectronics (HE) began to de-cline in popularity and its namewas changed to ElectronicsMonthly (EM) in an attempt togain more readers. It failed inthis and the title was bought byEveryday Electronics and incor-porated on the EE cover. Infact, the title of Hobby Electron-ics was also bought by EE. Con-sequently, our parent company,

Wimborne Publishing, owns sixelectronics magazine titles, ab-breviated to: EE, PE, EPE, HE,EM and ETI (not to mention thetwo massive electronics manu-als and their on-going quarterlysupplements: Electronics Ser-vice Manual (ESM) and TheModern Electronics Manual(MEM).

HAPPY FAMILIESDear EPE,

A wee suggestion for yourtitle I know you are trying tokeep loyal to all the readers ofEE, PE and ETI, but why nottake a simple and practical ap-proach? Your magazine is aboutelectronics so why not have aclear and obvious title that any-one looking for an electronicsmagazine can spot on thecrowded newsagent shelves why not call it Electronics? Itmay be a bit simple but it tellsthe onlooker what is inside!Maybe have a picture of theworld under the title to showthat it is an international maga-zine, but what ever you do, keepit simple.

I would also like to thankAlan Winstanley for his HomePage on the Internet. If youhave not seen it yet, look it up.Being a father of seven childrenI know where he is coming from.

Lee Elvinvia the Net

Thanks for the observationsElvin simplicity has a lot to besaid for it. But I'll bet that sim-plicity is not always a keywordwith a septet in tow! And, yes,Alan's probably a father-figureto many treading the path to-wards electronics knowledge.

ROM VS CATDear EPE,

I fancied a CD-ROM cata-logue from Maplin. I had justadded a CD-ROM drive to mycomputer set-up and was anx-ious to try it out. Cheque sent.Eventually (!) a disk arrived, butthe set-up stalled trying to opena non-existent file. Sent diskback with note of the problem.

They send another CD-ROM. Same problem, so wroteto HQ who had no knowledge ofmy previous correspondence.Sent copies. Eventually got astrange letter, very difficult tounderstand but setting out in-structions using the encloseddisk only they never sent thedisk! “Where's the disk?” Iasked. This came some dayslater with a scribbled compli-ments slip.

It took a long time runningfollowing their instructions usingthe floppy disk containing a fileomitted(?) from the CD-ROM.However, I got a little window,which said it had all been suc-cessfully installed. Play“Freecell” and all would be well.Which I did, but there is no signof the catalogue anywhere. Iwonder where it went?

I then had to re-install Win-dows because I couldn't accessit at all. The re-installed Win-dows didn't work either. So Ihad to format the hard drive, soeverything went.

Re-installed DOS and Win-dows and all is well, except Ilost my letter files so I don'thave a copy of my EPE PrizeWinning Letter (Dec '98), andthere wasn't a copy of EPE tobe had in Newcastle.

I don't know why I bother,but I suppose my generationalways did. I will just have touse the paper catalogue.

5HDGRXW

EPE Online, April 1999 - www.epemag.com - 478

Peter McBeathMorpeth, Northumberland

A somewhat longer Comedyof Errors detailed in Peter's let-ter has been edited!

We knew Maplin's first CD-ROM had been causing prob-lems for a lot of our readers,indeed our own copy gave usproblems too. However, I haveloaded their latest CD onto twomachines without problems andam using it (them) regularly.

We feel sure that a com-pany of Maplin's size, and usu-ally good reputation for the vari-ety, quantity and quality of itsproducts, will take heed of anyfeedback they receive abouttheir CD-ROM and rectify anyproblems before the next edi-tion. It must be said, though,that it is concerning that some-one should have lost datathrough loading it.

Peter also asks:

“How can I do a drawing onthe drawing board which will putit straight on the computerscreen a fine pointer insteadof a mouse? And how can I pro-gram a timer and clock to pro-duce `ship's' bells?''

Well, readers, have you anysuggestions?

BASICDear EPE,

Referring to the letter fromJoseph Zammit (Dec '98), Iwould like to suggest EPE con-tinues to use BASIC as themain programming language fortwo reasons: almost everyoneknows BASIC and if someonewants to use other programminglanguages they can easily trans-late the program. Secondly,QBASIC.EXE is free.

On the other hand, youmentioned Visual Basic in yourreply letter I think it is a goodidea since many people are us-ing Windows and writingWindows-based programs willbecome more popular.

Charles LawHong Kong

Thanks Charles.

YETI BOUND?Dear EPE,

There was a letter publishedin Readout Oct '98 which sug-gested that a serial link betweentwo PICs increased the numberof available I/O lines. I wouldlike to know how this was doneas I have a requirement wheretwo PICs are being used andlinked serially.

Also, re the letter in Read-out March '99 regarding the“mistake” of changing Electron-ics Today International to ETIand that EPE is not easily pro-nounced: how difficult is it toreel off eepy? Akin to ETI beingpronounced like yeti or yehtiwithout the y.

Chris Nealevia the Net

Hi again Chris. I've notdone double-PICing yet andcan't answer you, but suggestyou ask via our Internet ChatZone atwww.epemag.wimborne.co.uk ers out there! lots of knowledgeable read-

Ah yes, the Yeti theabominable snowman, and stillbeing looked for I believe. Butyou don't have to look far for us on any good newsagent'sshelves, or on your door mat ifyou're on subscription, or on theNet if you're Webbed.

5HDGRXW

EPE Online, April 1999 - www.epemag.com - 478

Voice Record/PlaybackModule

Only the ID1416P Chip-Corder “natural voice” inte-grated circuit chip, used in theVoice Record/Playback module,will take some finding locally.

To date, the only outlet wehave found for readers is fromMaplin (code NM47B). At thetime of writing they tell us thatstocks are low, but more are onorder. They also supply a suit-able electret microphone insert,type EM-10B (code QY62S) ortype EM-60B (code FS43W).

The small printed circuitboard is available from the EPEOnline Store (code 7000225).As for the loudspeaker (whichmust be 16 ohms or more), youmay have to opt for a 64 ohmimpedance version if you arelooking for one less than 76mm(3in.) diameter (Maplin Hi-Zrange); depending, of course,on the size of case used. You

may even be contemplatingputting the project into your fa-vorite soft toy your very ownFurbie!

Versatile Event CounterThere should be no prob-

lems finding a suitable electretmicrophone insert for the Versa-tile Event Counter as many sup-pliers, including Maplin(FS43W), seem to stock them.

These omni-directionalelectret “condenser” micro-phones are usually listed as ul-tra or sub-miniature types andeither will do in this circuit. Like-wise, the small plastic box, orone with almost identical(larger) measurements shouldbe readily available.

The vast majority of 2-line16-character LCD modules ap-pear to use the same chipsetline-up and interwiring arrange-ment (but check when purchas-ing), so they should not give

ATTENTION READERS!EPE Online is intended for

a worldwide audience, but weneed your help. If you know oflocal suppliers in your countrywho carry any of the “hard-to-get” components used in ourprojects (as described above),then please email us their con-tact details (name, phone num-ber, postal address, email ad-dress, web address), along withthe part details (type, code, etc.)in question. We will use this in-formation as part of an ongoingShop Talk section on our webpages. Email us at edi-

any sourcing troubles. Youcould try Greenweld, who occa-sionally give discounts on thesedevices. The one in the modeloriginally came from Magentaand they still have stocks.

The printed circuit board forthis project is the same one thatwas used for the PIC Tape Mea-sure published in the November'98 issue of EPE Online. Thisboard is available from the EPEOnline Store, code 7000207.Readers will have to make theirown minor corrections to thePCB to adapt it for the VersatileEvents Counter (see the con-struction article for more de-tails).

For those readers who donot have the facilities to pro-gram their own PIC chips, aready-programmed PIC16C84microcontroller is available fromMagenta Electronics for the allinclusive sum of 5.90 UKPounds (overseas readers add1 UK Pound for postage).

If you do intend to do yourown programming, the software

with DAVID BARRINGTON

Greenweld UK), Webwww.greenweld.co.uk

J&N Factors (UK), Tel +44 (0)11444-881965

Magenta Electronics (UK), Tel+44 (0) 1283-565435, Webwww.magenta2000.co.uk

Maplin (UK), Webwww.maplin.co.uk

Squires (UK), Tel +44 (0) 1243-842424

Suppliers Referenced in this Month’sConstructional Articles

Bull Electrical (UK), Tel +44 (0)1273-203500

EPE Online Store, Webwww.epemag.com

ESR Electronic Components(UK), Tel, +44 (0) 191-251-4363

Farnell (UK), Tel +44 (0) 113-263-6311, Webwww.farnell.com

EPE Online, April 1999 - www.epemag.com - 479

listing can be downloaded fromthe EPE Online Library atwww.epemag.com

Ironing Board SaverA number of components

needed to construct the IroningBoard Saver come into the cat-egory of being “special” andmay be difficult to locate. Butfirst we must endorse all thecomments about the dangers ofworking with mains voltagesand advise readers to take extracare when building this project.

For the mains transformer,the author suggests readers useone of the 250mA miniature,wire-ended, types from Maplin.He suggests the 6V-0V-6V ver-sion (not using the center-tap)code VN14Q.

All the semiconductors, in-cluding the 40106BE Schmittinverter IC, should be widelystocked. When ordering the IC,stress that it must be the“buffered” version; suffix BE.

The biggest problem will bein finding a 3-pole mains ratedrelay that meets all the designrequirements. The only one wecan recommend is manufac-tured by Finder (62 series) andstocked by Farnell, code 606-625. This 3-pole relay has a12V 110 ohm coil, “normal

open” contacts rated at 16A,and has a 3mm gap betweenthe open contacts. If possible,use nylon nuts and bolts to fixthe relay in the case.

All the switches and neonindicator used in the prototypemodel came from Maplin, codesFF96E (square push, black),FF98G (square push, red) andRX82 for the panel mountingneon. The metal cased, singlepin, mercury vibration sensorswitch carries the code UK57.

This just leaves us with themains socket panel, 3-wayfused mains terminal block andthe printed circuit board. Thecircular, panel mounting mainssocket came from Farnell, code107-721 and the terminal blockfrom Maplin, code GU72P.

The single-sided printed cir-cuit board is available from theEPE Online Store, code7000224.

Mechanical RadioTo save some possible

problems regarding componentsourcing, a kit of componentsconsisting of the motor, 1 Faradcapacitor, 2mm spindle andgears is available (mail orderonly) from the author at 7.50 UKPounds including postage (add2 UK Pounds extra for overseas

orders). Send checks, postalorders, or bank drafts to: B.Trepak, 20 The Avenue, Lon-don W13 8PH, UK .

An excellent range of low-voltage motors, gears and gearwheels are also stocked bySquires and Magenta. For theferrite rod aerial, try Bull Electri-cal, J&N Factors, or ESR Elec-tronic Components.

You may need to cut downthe ferrite rod to the requiredsize (50mm x 10mm dia.), ifyou use a small case. Be extracareful here, as ferrite is verybrittle! The author suggests thatsome suppliers list ready-woundferrite aerials and matching tun-ing capacitors we have yet tolocate one. The small 10pF to260pF tuning capacitor is usu-ally found listed as a “transistorradio tuning capacitor” in cata-logues.

The printed circuit board isavailable from the EPE OnlineStore, code 7000226 (A and B).

PhizzyBotThe microswitches for this

part of the PhizzyB series werebought by the author from Far-nell, part number 624-688.Nothing else deserves specialnote.

6KRS7DON