epe_12-1998

71
Volume 1 Issue 2 December 1998

Upload: ipse-lute

Post on 15-Feb-2016

224 views

Category:

Documents


4 download

DESCRIPTION

practical electronics magazine

TRANSCRIPT

Page 1: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 4

Volume 1 Issue 2December 1998

Page 2: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 71

Regular readers of EPEwill probably be aware of theauthor's enthusiasm for the de-sign of “Mind Machines,” asseveral of these have beenpublished in previous issues.Although effective, the designspresented in the past have beenfairly complex to constructwhich may have discouragedsome enthusiasts who wouldotherwise have liked to buildone of these devices.

The main problem hasbeen the method of providinga “program” of output frequen-cies over an adjustable period.The most recent version, in theMarch '96 to April '96 issues ofEPE (the printed edition ofEPE, Ed.) was user-programmable by means of six-teen variable resistors and,whilst effective, it was by no

means cheap or simple to con-struct.

With the arrival of the PICmicrocontroller chip this situa-tion has changed quite dramati-cally. PICs are ideally suited tosuch control tasksand can result in much simplercircuits, since much of the workis carried out by the software.

TAKE YOUR PICIt seemed natural therefore,

that following assimilation ofthe excellent EPE PIC Tutorialseries (March, April and May'98 issues and now availableon CD-ROM) (again, the printededition of EPE, Ed.) the au-thor's first PIC-based designshould be a new Mind Machine,and this project is the result. Ataround half the size and weight

of the 1996 design, it is thefirst capable of operating from asingle PP3 battery. With push-button selection of seven built-in

Seven mind-bending, built-in programs to soothe yourstate of mind. Relax with the power of a PICentertainment machine.

EPE MIND PICKLER by Andy Flind

Q12

PULSEGENERATOR

MICRO-CONTROLLER

PROGRAMMINGSWITCHES AND

CIRCUIT

RESET PIEZOSPEAKER

R-2RNETWORK CONTROL

VOLTAGE

WIDTHCONTROL

INPUT

400Hz

ELECTRONICSWITCH

3 2768MHz CLOCK

INTEGRATORS

INTEGRATORS

AND

AND

AMPLIFIER

AMPLIFIER

380Hz TO398Hz VOLUME

CONTROL

HEADPHONES

EXORCOMBINER

Q13

DIVIDER

OUTPUTS

PULSESHAPING

CURRENTDRIVER

BRILLIANCECONTROL

L.E.D.GLASSES

WARNING NOTICEPhotic stimulation at Alpha

frequencies can cause seizuresin persons suffering fromEpilepsy. For this reason suchpeople MUST NOT try this pro-ject.

A user who is not a knownepileptic, but when using theEPE Mind PICkler begins to ex-perience an odd smell, sound orother unexplained effects,should TURN IT OFF IMMEDI-ATELY and seek professionalmedical advice.

Because of the above pos-sibility, the EPE Mind PICklershould not be used while onyour own.

YOU MUST TREAT THIS UNITWITH DUE RESPECT

Fig.1.BlockDiagram

Page 3: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 72

programs and operating times itis also extremely easy to use,the only other controls beingtwo knobs for Volume and Bril-liance and a Phase switch.

Although the programs arenot user-changeable, cons-tructors wishing to try out theirown programs can do so byre-programming the PIC, sincethe seven session programsare just strings of numbers con-tained in a table (details nextmonth) in the main program. It isnot even necessary to be com-pletely conversant with PICassembly language to do this.

Although still not especiallycheap and simple to build, thisproject represents a hugeimprovement over earlierdesigns and is much easier toget working, since most of thecomplex functions are handledby the PIC.

CIRCUIT DETAILSA broad outline of the EPE

Mind PICkler project's operationis shown in the block diagramof Fig.1. Program and operatingtime selections are communi-cated to the PIC microcontrollerthrough three inputs and ac-knowledged by beeps froma directly driven piezo trans-ducer. Following this a 400Hzsquarewave signal is producedand a variable control voltage iscreated with 7 binary outputsapplied to an R-2R network.

The PIC's clock is tappedto drive a divider, which in turntriggers a pulse generator whichblocks the clock to the dividerthrough an electronic switch.The blocking period is voltagecontrolled by the R-2R networkoutput so, effectively, the sec-ond frequency is controlled bythe PIC.

The two outputs are com-bined with an EXOR circuitto extract their differencefrequency which is processedfor driving light emitting diodes(LEDs) in the glasses. Eachoutput also passes throughtwo integrators which convertthem into relatively pureaudio sinewaves for drivingthe headphones.

The full circuit diagram forthe EPE Mind PICkler is shownin Fig.2. The seven push-buttonswitches S1 to S7 are used toselect one of the seven pro-grams, followed by one of sevensession times.

So that these selectionscan be passed to the PIC, IC1,using only three connectionssome simple diode and resistorlogic converts them to their binaryequivalents, which are appliedto port A bits 2, 3 and 4 (IC1 pins1, 2 and 3). A third press ofany button then sets the programrunning for the selected time.

At any point during operation,pressing Reset switch S8 appliesa brief reset pulse to takethe program back to the start

where it waits for fresh input.Power-up and all button pressesare announced by brief “beeps”from the piezo transducer WD1,driven directly by port A bit 1.

The internal oscillator fre-quency of IC1 is set by crystalX1 to 3⋅2768MHz, which gives aconvenient internal clock fre-quency for other timings re-quired by the circuit. Two audiofrequencies are needed, onefixed and the other differing fromit by the programmed brainwavefrequency.

The first of these is gener-ated directly by the PIC, usingan interrupt routine to generatea 400Hz signal from port A bit 0(IC1 pin 17) whilst the main pro-gram is running. The second isobtained from division of thePIC's oscillator signal, takenfrom “osc out” pin 15 andpassed through the gates ofIC2 to divider IC4 (at clockinput), which reduces it toabout 400Hz.

Port B bit 7, at IC1 pin 13,is used to block the input to IC4until the main program starts.Whilst it is high, IC2a output

Constructional Project

Fig.2. Complete circuit diagram for the EPE Mind PICkler.

Page 4: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 73

(pin 6) is low, so the clock fre-quency does not appear at theoutput of IC2b. Frequency varia-tion is achieved by blocking theclock signal briefly during eachhalf-cycle of the output from Q13of IC4, this time through IC2d.

VOLTAGE CONTROLThe period for which the clock

is blocked is voltage-controlled.To understand the action of thispart of the circuit, it should firstbe assumed that Q12 (IC4 pin 1)has been in the low state forsome time (relatively speaking!).Q12 is the output preceding Q13so it changes state twice foreach change of Q13.

The low output from Q12 isapplied to an input of IC2c, pin13, so the output of this is high.

Applied to an input of IC2d thisallows the clock signal at theother input to pass to IC4.

Meanwhile, capacitor C6 willhave discharged through resistorR21, so the output of comparatorIC3 (pin 6) is high, and this isapplied to the other input of IC2c,pin 12. When Q12 switches tothe high state. IC2c initially hastwo high inputs so the outputgoes low, blocking the clocksignal through IC2d.

However, capacitor C6 nowcommences charging throughR21, increasing the voltage atpin 2 of IC3. When it exceeds thevoltage at pin 3, IC3's output

goes low, causing the output ofIC2c to return to the high stateand allow the clock to passthrough IC2d again.

When Q12 returns to thelow state this is immediatelyapplied to IC2c to maintain itshigh output and C6 commencesdischarging through R21, readyfor the next operation. The pe-riod for which the clock cyclesare blocked depends on thevoltage applied to the non-inverting input of IC3, so a smallvoltage-controlled drop in theoutput frequency from IC4 isobtained.

Note that IC2 and IC4 arethe 74HCxxxx high-speed ver-sions of the CMOS 4093 and4060 devices. Standard typesare close to their operatingfrequency limit at nearly 4MHz,and cannot be guaranteed towork in this circuit. In addition,the 74HC132 pinout (see Fig.3)differs from that of the 4093.

The control voltage is takenfrom an R-2R resistor network,R6 to R19, connected to sevenoutputs from port B of the PIC,which provides digital-to-analogue conversion of binaryvalues on these pins. Each pro-gram is divided into 30 periods,each of which starts with avalue corresponding to one volt-age and ends with one corre-sponding to the next.

The PIC alternates rapidlybetween these two values,gradually dwelling less on thefirst and more on the second asthe end of the period ap-proaches. The result is that thevoltage appears to changesmoothly through each step.The output is reduced to a maxi-mum of just under half thesupply voltage by resistor R20and smoothed by capacitor C5.

Although this is the sameprocedure used in the last MindMachine, there are almost twiceas many values in each pro-gram and many more steps

Constructional Project

Derivation of Formula for Calculating PIC Program Values

The basic frequency of the two audio tones is 400Hz. One oscillator is fixedat this frequency, whilst the other is lowered by having its clock inputstopped for a brief instant each half cycle. The actual length of this instant isthe time it takes for C6 to charge to the same voltage as the control outputfrom the R-2R network R6 to R20. The maximum output from this is 2.48V(127/128 x 2.5V). It varies in steps of 2.5/128 or about 19.5mV.

If the fixed audio tone is 400Hz, the variable one must be 400f Hz, where f isthe required frequency difference. The period for this is 1/(400 - f). Theperiod of the basic 400Hz tone is 1/400 or 0.0025 seconds. Thus, the clockmust be blocked for 1/(400 - f) - 0.0025 seconds per cycle. However, it isactually blocked twice per cycle, so the blocking period t is half this, or0.5/(400 - f) - 0.0025 seconds per cycle.

The control voltage V1 from the R-R2 network is given by V=2.5 x N/128,where N is the decimal value of the binary state of the seven outputsfrom it.

The voltage V2 across C6 is given by V2 = 5 x (1 - e -t/T), where T is thetime constant R21 x C6. Hence, the point where V1 and V2 coincide

is reached when 2.5 x N/128 = 5 x (1 - e -t/T), which can be reduced to

N = 256 x (1 - e -t/T). Of course T is 82k x1n5, which works out at0.000123 seconds.

This gives us N = 256 x (1 - e -(((0.5/400 - f) - 0.00125) / 0.000123) ) - 1, where the '1'being subtracted at the end is used to correct a small but constant errorfound in practical testing.

This can be reduced to N = 256 x (1 - e -(f/(39.36 - (0.0984 x f))) ) - 1, which isslightly easier to use with calculators or spreadsheets.

Page 5: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 74

Constructional Project

BRAINWAVESThe existence of electrical activity at various frequencies in the human brain was discovered many

years ago, almost as soon as the first electronic system capable of amplifying it became available. Thefirst regular waveform recorded, because of its high amplitude, was named Alpha with a frequency spec-trum between of 8Hz and 14Hz. Subsequently other frequencies have been observed and are broadlyclassified into Delta (0⋅5Hz to 4Hz), Theta (4Hz to 8Hz) and Beta (14Hz to 20Hz and above).

During the sixties, experiments were carried out with a master of Zen meditation, where it was discov-ered that during deep meditation very high levels of Alpha activity were generated. This led to further ex-periments in which feedback was used for training subjects to generate this kind of activity at will. The in-tention was to reach states similar to those of advanced meditation, which normally requires many yearsof dedicated training. Thus was born the technique known as EEG (electroencephalograph) biofeedback.

ALL IN THE MINDThe science has advanced a long way since those early days and the states associated with the

other frequencies are now well understood. The low frequencies of Delta are associated mainly with deepsleep (and young babies) and so have little practical application, except perhaps for insomniacs. Theta onthe other hand has been linked with intense creativity and so is of interest to many people wishing to gen-erate artistic inspiration and innovative solutions to problems. Beta is predominant in normal waking con-sciousness.

The original type of biofeedback device is not so common nowadays. They are difficult to build sincethey have to detect low frequency signals with an amplitude of a few microvolts, which generally have tobe separated from several volts of induced “hum” caused by nearby household mains wiring.

They are also relatively difficult to use, since good, noise-free electrical contact must be made withthe head. This usually involves silver electrodes and messy gels.

STIMULATIONBecause of these disadvantages, they have largely been replaced with devices intended to encour-

age production of the desired brain electrical activity. By far the most effective way of doing this isthrough ”visual stimulation” by flashing lights before the user's eyes at the intended frequency.

The next most popular method is ”binaural sound.” At its simplest, this consists of two audio toneshaving a frequency difference equal to the desired brain electrical activity. Played through loudspeakers,these would produce the familiar “beat note” effect, but in this application they are played separately, oneto each ear, through headphones. The user's brain “synthesizes” the beat note internally and this is sup-posed to encourage the desired brain activity.

This is the method used by the EPE Mind PICkler in conjunction with flashing LEDs and there is nodoubt about the effectiveness of the two stimuli when combined in this way. The sound has a pleasant“bell-like” quality. It does have to consist of fairly pure sinewaves as any noise or distortion is subjectivelyfar more intrusive than in most other audio applications.

Other methods of inducing brain activity at specific frequencies include magnetic fields (see the EPEMood Changer -- June '98 issue) (the printed edition of EPE, Ed.) and the passing of tiny electrical cur-rents through the head. You're not going to see a design for this last method in EPE Online, although be-lieve it or not, a couple of instruments using this method are actually on sale in the USA.

It is now generally accepted that the states experienced by users of this type of equipment are“different” from those attained in advanced meditation, though they may form a good starting point forthose wishing to pursue deeper spiritual growth. However it is easy to reach states of deep relaxation,which in turn may help in the control of stress. For this, and simply for recreational use, the EPE MindPICkler is a very useful tool.

Page 6: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 75

ween them so the control actionis much smoother. With precisevoltage regulation and crystalfrequency control the output isvery accurate, and the shortertime constant needed forsmoothing the output makes fora much improved settling timewhen the program commences.

The numerical values corre-sponding to control voltagesand output frequencies, heldwithin the PIC, take into ac-count the exponential nature ofthe charging time of capacitorC6 and the output frequenciesmeasured in the prototype werefound to be within 0⋅1Hz of theirintended values.

INTEGRATEDOUTPUTS

The two output signals initially have square waveforms.The audio outputs should be asclose to pure sinewaves aspossible, so conversion iscarried out by two integrators ineach signal path.

Taking the upper signalpath, which processes the fixed400Hz tone, the first integratoris IC8a which converts the sig-nal into a triangular waveform.The integration response is setby resistor R39 and capacitorC21. C20 and R42 are neces-sary for the stage to operate atthe correct d.c. working pointand, though they do introduce alittle distortion, this is not audi-ble in the output.

Following the Volume con-trol, VR2a, a similar secondintegrator, IC9a, takes thetriangle-wave from IC8a andconverts it into a sinewave. Italso provides sufficient powerto operate Walkman type head-phones.

The signal level should bekept reasonably high here for agood signal-to-noise ratio, sothe output is reduced to anappropriate amplitude by seriesresistor R49 rather than by low-ering the input. A small tendencyto instability under some condi-tions was corrected by theaddition of resistor R47 andcapacitor C25.

The second signal path forprocessing the variable fre-quency output from IC4 isidentical. The sound quality ob-tained from this circuit is greatlysuperior to that of the earlierMind Machine designs.

BRAINWAVESAs in the previous design,

the two squarewave signals arealso combined through two XORstages to extract the brainwavefrequency (see separate panel)and provide phase switching,for flashing the LEDs (mountedin the glasses) either in phasewith the audio signals or inopposite phase to them.

The output from IC6b is an800Hz train of pulses of varyingwidth which, when averagedthrough a simple C-R filter,appear as a triangle wave.Resistor R24 applies d.c. bias-ing to this, so that when passedthrough the Schmitt triggerstage built with IC6c theoutput pulses obtained are onlyabout a quarter of the length ofeach cycle.

Finally, in case the userprograms a very low frequency,C17 and R28 limit the maximumpulse width to prevent overloadof the battery and output LEDs.

The brilliance of the twoLEDs in the glasses is con-trolled by varying their current.A control voltage obtained from

potentiometer VR1 is used byopamp IC7a and transistor TR1to generate a small currentwhich is converted back to avoltage, this time referenced tothe positive supply, by resistorR31. Readers may be inter-ested to learn that the eye, likethe ear, has a logarithmicresponse to intensity, so poten-tiometer VR1 should be a loglaw type. The voltage acrossresistor R31 is used by IC7b,together with transistors TR3and TR4, to generate a largercurrent to drivie the LEDs.

This method results in acurrent which returns to nega-tive supply, which is usefulwhen the audio signals are alsorelative to the negative supplyand sockets for both are fittedto the same metal panel. Insu-lated 3⋅5mm sockets are hard tofind, and for this reason theearlier design had to use 6mmtypes with adapters.

Transistor TR2 turns off theLEDs when switched on byIC6d, so the pulses from IC6dare negative-going to generatethe output flashes.

Constructional Project

14

13

12

11

10

9

8

74HC132

1

2

3

4

5

6

7

+VE

0V

Fig.3. Internal and pinout de-tails for the high-speed74HC132 IC.

Page 7: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 76

Constructional Project

+

+

b

c e

b

c e

b

c e

b

ce

RA2

RA0

1IC

PIC

16F84

OSC

OUT

MCLR

OSC

IN

RA4

RA3

Q12

CLK

VC

C

RST

GND

Q13

CO

MO

N/O

FF

S9

OU

TIN

C9

100

m

C10

100n

C11

100n

C12

470

m

C24

4n7

C25

100n

C26

100

m

C34

100n

C35

100

m

C33

4n7

EX

TE

RN

AL

PO

WE

R

SK1

16 8IC

474HC

4060

IC5

LP2950

2

1

3

6

7

5

4

SK3

HE

AD

PH

ON

ES

R44

10k

R45

10k

R46

470k

R47

10

WR48

10k

R49

47

W

R52

56k

R53

470k

R54

10

WR55

10k

R56

47

W

C18

4700

m

C19

100n

VR

110k

LO

G

BR

ILLIA

NC

E

R30

10k

R29

3k3

R22

100k

S10

C13

100n

13

11

12IC

6a

4070

B

PH

ASE

R2

4k7

R32

1k

TR

1BC

184L

4

OP296

38

1

2

IC7

a

R31

100

W

TR

2BC

184L

69

2P

OIC7

b R33

10k

R34

10k

R35

10k

5 6

7

C14

100

m

C15

100n

R24

39k

R23 k

21

10

98

IC6

b4070BC

110p

C2

10p

R25

100k

R26

47k

C16

10n

1 2

17

S8C

310n

R4

1M

4

R1

4k7S1

R3

4k7

D1

D2

S4

S2

S3

D3

X1

32768

MHz

D1

TO

D9

1N4148D

5

D4

D6

D7

S5

S6

S7

D9

D8

15

1623 1

R5

4k7

7

C27

100n23

TR

3BC214L

TR

4BC184L

R36

10k

R37

1W

GLA

SS

ES

SK2

R38

22

W

IC6

d4070B

IC6c

4070B

R27

1M

C17 n

07

43

6 5

R28

390

k

GN

D

5

RB7

RA1

RB

0

13

186

R13

20k

LS1

C20

100n

4

C6

1.5

n %1

02

R 10k

C5

100

m

VR2a

10k

LO

G

C28

470n

6 5

4

R50

100k

R51

1M

VR

2b

10k

LO

GV

OLU

ME

VO

LU

ME

C29

10n

C30

470n

C31

100n

7

C32

470n

R41

10k

32

93

R 100kR40

10k

R42

1M

C7

100n6

4

C21

10n

C22

470n

C23

100n

1

R43

56k

12

2a

IC 74HC

132

14

R6

TO

R12

20k

RB

2

RB1

8 7

RB5

RB4

RB36

BR

VCC

11

10 912

C4

100n

R14

TO

R19

10k

R21

82k

4 5

11

2

12

6

3

13

IC2

c74H

C132

1

C8

100n

IC2

b74HC

132

IC2

d 23

1C

H4

714

8

109

11

1 2

7a k

a k

a k

a k

a k

a k

a k

a k

a k

+

+

+

+

+

++

++

IC3

3130

+

69

2P

OIC8

bIC

9b

OP279

+

+

IC9

aO

P279

8

OP296

IC8

a

8

RE

SE

T

B1

9V

PP3

PR

OG

RA

MS

ELE

CT

PL2

aa k k

D10

D11

1 2 3

714

Fig.2. Complete circuit diagram for the EPE Mind PICkler.

Page 8: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 77

POWER NEEDSPower for most of the circuit

is 5V supplied by the regulatorIC5. This is a micro-powerequivalent of the well-known78L05 device, featuring verylow operating current anddrop-out voltage which makes itideal for use with battery sup-plies. It is also more accuratethan the standard type.

The output stages for bothaudio and LED glasses aresupplied directly from the 9Vbattery supply, though the LEDstage receives this through re-sistor R38. It also has a verylarge decoupling capacitor,C18, to prevent a faint“popping” sound which other-wise results from the suddendrops in supply voltage causedby LED operation at high bril-liance.

SOFTWAREThe software in the PIC,

IC1, starts by obtaining theuser's choice of program andsession time from the ProgramSelect push-switches, thenwaits until instructed to startrunning the program. Oncestarted, it loads a pair of valuesfrom a table held in the softwareand alternates rapidly betweenthem, placing each in turn onthe first seven bits of port B.

It increases one output pe-riod and decreases the other in255 steps, so a gradual, smoothtransition from the first value tothe second appears to takeplace. Following this, it replacesthe first value with the second,loads a new second value andrepeats the process.

It does this with a total of31 values, an initial one plusone for the end of each of the

30 steps that comprise a pro-gram. When the last value hasbeen used, it goes to an “end”routine where it loops at 3-second intervals, bleeping eachtime, until the user switches offor resets it for the input of newsettings.

All the time the main pro-gram is running interruptschange the state of port A bit 0at a rate of 800 times a second

to generate the 400Hz output.Servicing the interrupt routinetakes only a few microseconds,a tiny fraction of the time spentrunning the main program, so itseffect on this is not apparent.

FLOWCHARTSA flow diagram of the main

program is shown in Fig.4. Fol-lowing switch-on or reset, theprogram sets up the ports for

Constructional Project

COMPONENTSResistors

R1 to R3, R5 4k7 (4 off)R4, R27, R42, R51 1M (4 off)R6 to R13 (20k (8 off)R14 to R20, R30, R33 to R36, R40, R41, R44, R45, R48, R55 10k (18 off)R21 82kR22, R25, R39, R50 100k (4 off)R23 12kR24 39kR26 47kR28 390kR29 3k3R31 100 OhmsR32 1kR37 1 OhmR38 22 OhmsR43, R52 56k (2 off)R46, R53 470k (2 off)R47, R54 10 Ohms (2 off)R49, R56 47 Ohms (2 off)

All 0.6W 1% metal film type

CapacitorsC1, C2 10p resin-coated ceramic (2 off)C3, C16, C21, C29 10n resin-coated ceramic (2 off)C4, C7, C8, C10, C11, C13, C15, C19, C20, C23, C25, C27, C31, C34 100n resin-coated ceramic (14 off)C5, C9, C24, C26, C35 100u radial electrolytic, 16V (5 off)C6 1n5 polystyrene, 1%C12 470u radial electrolytic, 16VC17, C22, C28, C30, C32 470 resin-coated ceramic (5 off)C18 4700u radial electrolytic, 16VC24, C33 4n7 resin-coated ceramic (2 off)

MiscellaneousX1 3.2768MHz crystalS1 to S7 sub-miniature push switch, push-to-make, black (7 off)S8 sub-miniature push switch, push-to-make, redS9, S10 sub-miniature double-pole slide switch (2 off)2.1mm power socket w break contact3.5mm screened mono chassis socket, with matching jack plug for glasses3.5mm screened stereo chassis socket for headphonesWire-ended piezoelectric sounder9V battery (PP3), with clip-in holder

PCB available from the EPE OnlineStore, code 7000214; plastic case, size180mm x 120mm x 40mm; 8-pin DILsocket (4 off); 14-pin DIL socket (2 off);16-pin DIL socket; 18-pin DIL socket;20mm diameter max. plastic knob (2 off);headphones, Walkman-type; glasses(see next month); multi-strand connectingwire, solder, etc.

See also theSHOP TALK Page!

$56Approx. CostGuidance OnlyExcludes case, headphones, & glasses

PotentiometersVR1 10k miniature rotary carbon (log.)VR2 10k dual min. rotary carbon (log.)

SemiconductorsD1 to D9 1N4148 signal diodes (9 off)5mm hyper-bright red LEDs (2 off) (for glasses)TR1, TR2, TR4 BC184L npn silicon transistor (3 off)TR3 BC214L pnp silicon transistorIC1 PIC16C84 or PIC16F84, pre- programmed controller (see text)IC2 74HC132 quad Schmitt NAND gateIC3 3130 CMOS opampIC4 74HC4060 14-stage ripple counterIC5 LP2950 5V voltage regulatorIC6 4070B CMOS quad EXOR gateIC7, IC8 OP296 dual opamp (2 off)IC9 OP279 dual opamp

Page 9: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 78

user input, output bleeps andblocking ofthe clock signal to the vari-able frequency output. It thenwaits for a button to bepressed, and stores theresulting input value in a reg-ister. Valid button pressesand releases are both veri-fied by a 40ms software de-bouncing routine. The sameprocedure is used to obtainthe value for session time,stored in another register.

The program then waitsfor a third button press, fol-lowing which it sets up the

ports for output as required andstarts the interrupt routine forgenerating the 400Hz fixed fre-quency output. The first value iscalled from the table and placedin the register for the secondvalue, this being because the pro-gram then goes to a repeatingsequence where the value in thesecond value register is trans-ferred to the first and a new valueis read from the table and placedin the second. The output routineis then called to perform the ap-parent gradual transition betweenthe two values.

This sequence is repeatedthirty times and each time theregister holding the table valuepointer is checked. When itreaches 31 the program exits thisloop to the final routine, where itstops the interrupts, blocks theclock signal to stop the variableoscillator output, and goes into anendless long loop, bleeping eachtime it goes around.

The flow routine for generat-ing the smooth transition betweenthe two values is shown in Fig.5.It starts by setting two “ratios”,used for the dwell times of thetwo values. It then goes intothree nested loops with two more

Constructional Project

Start

Set up ports for user input

Get program selection

Get session time selection

Wait for start command

Start 400Hz output

Enable variable freq. osc.

Get first value from table

Put in "2nd value" register

Table pointer=31?

Copy "second value" registerinto "first value" register

Get next value from table

Put in "2nd value" register

Call output routine

Stop 400 Hz tone

Stop variable freq. oscillator

Beep at 3-second intervals

yes

no

Set "Ratio 1" to 255,"Ratio 2" to 1, & "Scale" to 41

Copy "Time" into "Tim"

Copy "Scale" to "Scl"

Copy "Firstval" to Port B

Copy "Ratio 1" to "Ratio"

Decrement "Ratio"

Ratio = 0?

Copy "Secval" to Port B

Copy "Ratio 2" to "Ratio

yes

no

Decrement "Ratio"

yes

no

Decrement "Scl"

Ratio = 0?

yes

no

Decrement "Tim"

Scl = 0?

Tim = 0?

yes

no

Increment "Ratio 2"

Decrement "Ratio 1"

Ratio 1 = 0?

yes

no

Page 10: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 79

equential loops at the center,using values derived from theuser's Time input and a Scalevalue which sets the overall run-ning time to the correct value.

The first program value fromthe table is copied to port B,“Ratio1” is copied to “Ratio”,and the first inner loop providesa delay proportional to “Ratio1”.Then the second value iscopied to port B, “Ratio2” iscopied to “Ratio”, and the sec-ond inner loop gives the delayfor “Ratio2”.

These two operations arecarried out for the number oftimes given by “Scale” multipliedby “Time”, so it can be seenthat switching between the twovalues always takes place atthe same speed, just over 2kHz,regardless of the value of“Time”.

Following this, “Ratio2” isincreased by 1, “Ratio1” is de-creased by 1, and the processis repeated. This happens until“Ratio1” reaches zero, whencontrol returns to the main pro-

Constructional Projectgram to update the two valuesfrom the table.

The use of 255 discretesteps for each pair of valuesmeans that even at the slowestrate of change, for a runningtime of 40 minutes, the outputvoltage appears to change atover three steps per second, soa smooth change of output fre-quency is obtained.

This covers the circuit andprogram operation. Next monthwe conclude with the construc-tion and testing of the unit.

Bebop to the Boolean Boogie(An Unconventional Guide to Electronics)By Clive “Max” Maxfield470 pages, $35 US Dollars (plus S&H)

This book gives the "big picture" of digital electronics. This in-depth, highlyreadable, up-to-the-minute guide shows you how electronic devices work andhow they're made. You'll discover how transistors operate, how printed circuitboards are fabricated, and what the innards of memory ICs look like. You'llalso gain a working knowledge of Boolean algebra and Karnaugh maps, andunderstand what Reed-Muller logic is and how it's used. And there's much,MUCH more (including a recipe for a truly great seafood gumbo!). Hundreds of

carefully drawn illustrations clearly show the important points of each topic. The author's tongue-in-cheekBritish humor makes it a delight to read, but this is a REAL technical book, extremely detailed and accu-rate. A great reference for your own shelf, and also an ideal gift for a friend or family member who wantsto understand what it is you do all day....

Available from the EPE Online Store at www.epemag.com

Sticks and stonesAs the need to represent numbers grew, early

man employed readily available materials for thispurpose. The oldest known objects used to repre-sent numbers are bones with notches discoveredin Western Europe. Of special interest is a wolfbone more than 20,000 years old with 55 notches

in groups of five, which was discovered at Veston-ice, Czechoslovakia in 1937.

Also of use were small stones or pebbles, whichcould represent larger numbers than fingers andtoes and have the advantage of being able to eas-ily store intermediate results for later use. Thus, itis no coincidence that the word “calculate” is de-rived from the Latin word for pebble.

Page 11: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 80

Flashing lights for Christmastrees and other festiveornaments have been with usever since electric light bulbsreplaced candles as the primarymeans of lighting up a Christ-mas tree. The original onesused a special lamp whichcontained a bi-metallic strip,which heated up and broke aninternal contact causing thewhole chain to go out. With thecurrent now interrupted, thestrip would cool down causingthe contact to be closed, lightingup the chain again.

This system is still used inmany cheaper light sets but withtechnology being what it is, itwas soon replaced by transis-torized flashers and nowmicroprocessor controlled onesare available which not onlyflash the lights but play a rather“tinny” selection of Christmascarols as well!

FLASHYFlashing lights can be very

attractive and certainly addmovement and interest to thedisplay, which is fine if you wantto hang them in your window toimpress the neighbors or peoplepassing by. But, picture theclassic Christmas scene:

You are sitting in a dark-ened room in your favoritearmchair. In the hearth the log

fire is blazing, the Christmaspresents have been opened,the long lunch/dinner is overand, with a glass of brandy inyour hand, you are watching theQueen's speech which yourecorded earlier.

But you feel tense, a slightheadache, nausea − and youhaven't even taken a sip yet!Was it the turkey? No … thestuffing perhaps … or the extrahelping of mince pies … andthen it hits you …

It's those infernal tree lightsflashing on and off withmonotonous regularity orswitching to some even more

annoying chase pattern. Whatis needed is something moregentle, calming, to help you re-lax and get ready for BoxingDay (the day after ChristmasDay, Ed.) and another chanceto spend some more money atthe sales!

This is not quite how theidea for this project was born,but it should help to avoid thisscenario. The circuit to be de-scribed has been designed notto flash the lights on and off, butto gradually fade them up anddown, providing a more sooth-

Use a PIC to provide sophisticated programs for yourtree lights

FADING CHRISTMAS LIGHTS by Bart Trepak

Note that this project isONLY intended for usewith a 240V 50Hz mainspower supply!

Page 12: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 81

ing, relaxing display with no sud-den changes in brightness,thereby avoiding the “discoeffect”.

Although designed primarilyfor Christmas tree lights, thecircuit could also find uses inexhibition work or at moresedate gatherings (a lightshowat an afternoon tea dance per-haps?) or even as backgroundlighting at a disco. A particularlyeffective display could beobtained by using three differentcolored lights such as red,green, and blue, and projectingthese onto a white wall toproduce a constantly changingcolor or rainbow effect.

PROGRAMThe project is based around

a PIC microcontroller, whichmeans that virtually any pro-gram can be written to vary theintensity of the three channelsof lighting over a period of time.One program has been writtenand is available free or can bepurchased already programmedinto the PIC chip (see later fordetails).

The PIC is used to vary theoutput to three channels of light-ing, each controlled by a triac.The circuit for the FadingChristmas Lights will bedescribed later, after we havelooked at the techniques em-ployed to control the power tothe lights.

MICRO-DIMMINGThe most common tech-

nique used to dim mains lightsusing a triac is called “phase-control”, because the triggerpulse for the triac whichswitches the light is applied atthe same frequency as the

mains but not in phase with it. Putsimply, the trigger pulse isdelayed with respect to the mainswaveform.

Once triggered, the triac thencontinues to conduct until the cur-rent through it is reduced to zero(which occurs at the end of eachmains half-cycle) so that if thetrigger pulse is applied early, nearthe beginning of the half-cycle,then the triac will conduct foralmost the whole time, giving fullbrightness. While if it is delayedand only applied near the end ofeach half-cycle, then the triac willbe off for most of the time, result-ing in a low lamp brightness.Varying the delay between thesetwo extremes will give varyinglevels of brightness.

Conventional light dimmersuse a capacitor and resistor toproduce the delay required and,by making the resistor variable,the amount of delay and hencethe brightness can be manuallycontrolled. In this application wewant the brightness to varyautomatically and we do not wantto have to turn a potentiometer upand down to achieve this. Theconventional way to do this wouldbe to make the delay voltage-controlled and apply a lowfrequency triangular or sine waveto the control input, which wouldcause the delay and hence thebrightness to increase and de-crease in sympathy.

A similar method could beused with a microcontroller but,being a digital device, it is fareasier to produce a delay digitallyrather than using voltage control.Delays in microcontroller circuitsare very easily achieved simplyby loading a counter with a num-ber and then counting down untilzero is reached.

The delay obtained will thendepend on the rate at which the

counting occurs (which isnormally fixed and depends onthe system clock) and thenumber originally loaded into thecounter which can easily bevaried by software. Thus, if thesystem clock is adjusted tocause the counter to be decre-mented every 40us for example,then by loading the counter with250 (decimal), it will reach zeroin 10ms, while if only 10 wereloaded, the delay would be only400us.

ZERO CROSSINGIt is not enough, however,

to simply provide a variabledelay, because to achieve thesame brightness in successivehalf-cycles, the delay mustcause the trigger pulse to occurat the same time in each half-cycle. So it must always start atthe same time by being syn-chronized with mains waveform.

The best reference point touse is the point at which thehalf-cycle starts − that is, themains zero crossing point.

There are many zero crossingdetector circuits available both

Constructional Project

MAINSVOLTAGE

INPUT THRESHOLDVOLTAGE

PIC SUPPLYRAIL

TRUE ZEROCROSSING

WAVEFORMAT PORT RA2

ZEROCROSSING(INTERNALSIGNAL)

0V

0V

0V

-2 5V

-5V

-5V

-5V

325V

-325V

0 + 0

A

A

B

B

Fig.1. Zero crossing pointasymmetry. Pulse A appearstoo early while B too late.Greatly exaggerated for clarity.

Page 13: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 82

in integrated circuit form anddiscrete designs, but again it issimpler to use the microcontroller,especially as this requires onlyone resistor.

The mains waveform is fed toone of the microcontroller inputs(port RA3 in this case) via aresistor, which serves to limit thecurrent to a safe value and theinput port is read. During the posi-tive mains half-cycle this will readhigh and during the negative half-cycle it will read low, so that theinstants at which a low readingchanges to high or a high readingchanges to low will be the zerocrossing point.

This is not strictly true,because the input threshold (thevoltage above which a logic highand below which a logic low isread), which is around half thesupply voltage in CMOS circuits(i.e. 2⋅5V with a 5V supply), doesnot coincide with the mains zerovoltage. This has the effect ofmaking the positive zero crossingappear to occur slightly earlierand the negative slightly laterthan is the case as shown inFig.1, which is greatly exagger-ated for clarity.

This can cause asymmetry inthe delay between positive andnegative half-cycles and othermore serious problems, and oneway around this would be toprovide a +/-2⋅5V supply for themicrocontroller instead of asingle-ended -5 volts. Note that anegative supply is used in thisdesign, because triacs are moresensitive to negative triggering.

A simpler solution, however,is to introduce time delays intothe program so that the crossingsoccur at the correct time, thusensuring that any subsequentdelay will start at the same timewith respect to the true zero-crossing point.

FADE AWAYWe now have a zero-

crossing detector and a delay,albeit in software, so that all wenow need to do is to switch anoutput port which will trigger thetriac at the precise point to giveany brightness required. In orderto make the brightness ramp upand down, we must arrange forthe number which is loaded intothe phase delay counter at eachzero crossing to increase anddecrease periodically. This isdone by storing the number to beloaded in another counter, whichcan be incremented over theperiod we want the brightness ofthe lamp to decrease and thendecremented over the time periodduring which we want the bright-ness to increase.

This will, of course, cause thebrightness to change in steps but,provided we make the steps smallenough, the change in brightnesslevel will appear smooth and con-tinuous. In practice, 32 levels,which corresponds to a 5-bitcounter, would probably be suffi-cient, but this design uses 7 bitsand 120 levels.

Unfortunately, the relationshipbetween the lamp brightness andthe phase delay is very non-linear. This is because the lampbrightness depends on the powerfed to the lamp (which is propor-tional to the area under the sinewave for the period during whichthe triac is conducting) and, inFig.2a, it can clearly be seen thatthe increase in power (shadedarea) caused by advancing thetriggering point around the middleof a half-cycle from t4 to t3 ismuch greater than the increaseachieved by advancing it by thesame amount from t2 to t1 nearthe beginning (or end) of thehalf-cycle.

This means that if thetriggering delay is increased (ordecreased) by equal amountsover a period of time, the lampbrightness will appear to changerelatively slowly and perhapsimperceptibly at first, then fastaround the mid-range of thehalf-cycle and finally slowlyagain as maximum (or minimum)brightness level is approached.To obtain a relatively linearvariation in brightness with time,a correction must therefore beapplied.

APPROXIMATIONIn order to obtain a perfect

brightness versus trigger delaycharacteristic (Fig.2b) wouldprobably require the use of afairly extensive look-up table,but experience shows that thisis not really necessary, and inpractice a simpler approach canbe used.

The first thing to notice is

Constructional Project

0V

TIME

325V

VOLTAGE

t1 t2 t3 t4

ACTUAL

APPROXIMATION

IDEAL

DELAY(PHASEANGLE)

BRIGHTNESS

0 90 180

50%

100%

(A)

(B)

Fig.2. (a) Effect of changingtrigger delay at differentpoints in the halfcycle and(b) lamp brightness versustrigger delay.

Page 14: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 83

that the beginning and end ofevery half-cycle contribute verylittle to the total power, so that iftriggering is restricted to the midrange very little of the bright-ness range of the lamp will belost. There will be no noticeabledecrease in the maximumbrightness which will beachieved, while at the lowestbrightness levels, the lamp ishardly glowing and producingvirtually no light so that thisportion can also be discarded.This immediately gives a largeimprovement in the characteris-tic because, this center portionof the brightness against triggerdelay curve is more linear.

A further improvement canbe obtained by altering thebrightness faster at the extremi-ties of the brightness range,where the brightness changesmore slowly compared with thatat the center, by software.Thus, if the number in the bright-ness register (which rangesbetween 0 and 120 in thisdesign) lies between say 40and 80, the rate of change ismade half of that which occurswhen the number to be loadedinto the phase delay counter is

outside these limits.

The brightness is thereforeincreased or decreased twice asfast at the beginning and the end ofthe half-cycle compared to the rateof change which takes place whenthe brightness is varied around themid-portion. Together, these tech-niques give a visually almost linearvariation in brightness.

Constructional Project

NAME

DIMR

PSET

ZRX

INPUT

DELAY

SUBROUTINE FUNCTION

Dimming routine which decrements PHSCTR and producestrigger pulses when it is zero

Sets new brightness level for each output by increasing ordecreasing the number in the brightness register and changingthe direction of dimming as required. The rate of change ofbrightness is also linearized by the LIN subroutines which arecalled from this subroutine.

Zero crossing subroutine switches off triac trigger outputs andreloads the PHSCTRs from the respective brightness registers(BRGs)

Reads switches and alters the values stored in the NREGs,which determine how often the BRG registers are altered.

Short delay used to ensure that trigger pulses cannot beproduced until after the mains zero crossing.

UP AND DOWNEach of the three channels

has its own brightness counter(BRG1, BRG2 and BRG3), andthese are all varied at the sametime and by the same amountso that they will all remain instep as the brightness ischanged. All that is required toensure that each channel rampsup and down continuously is tomake sure that the channel con-tinues dimming until minimumbrightness is reached (byincreasing the count in therespective brightness register)and then increases the bright-ness (by decreasing the count)until maximum brightness isreached.

The decision on whether toincrease or decrease the countin each brightness register istaken after examining anotherregister called − for want of abetter title − the DimmingDirection Register (DMDR).

COMPONENTSResistors

R1 470 Ohms 0.5WR2, R10, R11 2M2 (3 off)R3 4k7R4 to R6 (2k2 (3 off)R7 to R9 220 Ohms (3 off)RN 10k SIL resistor network

CapacitorsC1 470n Class X, 250V a.c.C2 470u electrolytic, 16VC3 22p ceramicC4 to C6 10n Class X, 250V a.c. (3 off)

SemiconductorsD1 4V7 500mW Zener diodeD2 1N4148 silicon diodeD3 to D5 red LED (3 off)

MiscellaneousL1 to L3 4mH 100W, 240V open toroidal choke (3 off)FS1 2A fuse and panel-mounting mains fuseholderS1, S2 s.p.n.o. push-switch, 250V a.c. with plastic body - see text (2 off)

PCB available from the EPE Online Storeat www.epemag.com code 7000215; fullyinsulated plastic case approximately130mm x 65mm x 43mm; plastic PCBmounting posts (4 off); PCB mountingterminal blocks 2-way (4 off); strain-reliefgrommets (4 off); mains cable;interconnecting wire; solder etc.

TR1 to TR3 2N3903 npn transistor (3 off)CSR1 to CSR3 C206D triac (3 off)IC1 PIC16C54N programmed micro- controller (see Shop Talk)

PotentiometerVR1 10k horizontal skeleton preset

$41Approx. CostGuidance Only

Excludingcase and lights

See also theSHOP TALK

Page!

Page 15: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 84

Only the first three bits ofthis are used (one for eachchannel), with a set bit indicat-ing that the brightness of thecorresponding channel is to in-crease and a zero meaning adecrease.

These bits are then toggledwhen the brightness countreaches a maximum or a mini-mum, which ensures that thebrightness begins to fall as soonas the maximum is reached andrise after the minimum has beenreached. Loading the brightnessand DMDR registers with suit-able initial values then ensuresthe correct relative brightnessof the respective channels asthey are faded.

SPEEDThe speed at which the

brightness ramps up and downis determined by how often thebrightness registers are incre-mented or decremented. This isdone with the aid of another

counter, or rather counters asthere are again three of these,one for each channel, which arecalled NCTR1, NCTR2 andNCTR3.

These counters are loadedwith a number (held in anotherset of registers called NREG1to NREG3) and count off anumber of mains cycles beforechanging the value in the bright-ness registers in the directiondetermined by the DMDRregister. Here again, a largernumber in the NREG will meanthat zero in the correspondingNCTR will be reached after alarger number of mains cyclesresulting in a slower ramp andvice versa.

A simplified flowchart for theprogram is shown in Fig.3a andconsists of the main program(which detects the zerocrossing) and a number of sub-routines (which are called asthey are required). Eachsubroutine performs a single

function such as decrementinga counter and triggering thetriac if required as shown inFig.3b, the simplified flowchartfor the dimming subroutine.

Each subroutine ends with areturn instruction (RETLW),which ensures that after thesubroutine has been executed,the program returns to the lineafter the one from which it wascalled and continues from thispoint. The function of each sub-routine is described in Table 1.

USER CONTROLSThe only input/output lines

required for this unit are there-fore RA3 for the mains signal(from which the zero crossingtiming is derived) and threeoutputs RA0, RA1 and RA2 totrigger the three triacs. The onlycontrols provided are two push-switches connected to portsRB0 and RB1, which are usedto increase or decrease thespeed at which the brightness

Constructional Project

b

c

e bc

e b

c

e

R42k2

C4 TO C610n CLASS X

250V a.c.

C1470n

CLASS X250V a.c.

R22M2

D21N4148

RN8 x 10k

C2470m

SPEEDUP

S1

D14V7

RB3

RB4

RB5

RB6

RB7

OSC1/CLK IN

RB2

RB0

RB1

BRIGHTNESS

C322p

SPEEDDOWN

S2

R34k7

PIC16C54N

IC1

SS

RA0

RA1

RA2

V

V DD MCLRRA3

OSC2/CLK OUT

RTCC

R112M2

R1470W

VR110k

R102M2

2N3903TR3

R9

C206DCSR3

2N3903TR2

CSR2

TR12N3903

R52k2

R7220W 220W 220W

D3

CSR1C206D g g g

C4

R62k2

D4

R8

C206D

C5

D5

C6

L

L1

LP1

TB2/1

TB2/2

LP2

TB3/2

TB3/1

L2

LP3

TB4/2

TB4/1

L3

230Va.c.

MAINS

N

N.C.

16

6

7

8

9

10

11

12

13

414

2

1

3

15

18

17

5

TB1/1

TB1/2

+a

a

k

k

mt1 mt1 mt1

mt2 mt2 mt2

*

* * *

* * *

see text

a a a

k k k

L1 TO L34mH 240V

100W

FS12A

Fig.4. Complete circuit diagram for the Fading Christmas Lights. It is most important that thiscircuit must be housed in a fully insulated plastic case

Page 16: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 85

changes. This is done by read-ing these ports and if either ishigh (switch pressed) incre-menting or decrementing thenumber stored in the NREGregisters. The range of valueswhich the NREGs are allowedto assume is limited to preventvery slow or very fast ramps.

The switches are read in asubroutine called INPUT whichis called once in every cycle,but this would result in the valuein the NREGs changing so fastthat even a short touch of theswitch would cause the con-tents of the register to changefrom minimum to maximum,allowing virtually no controlother than fast and slow. Toslow things down a bit, the sub-routine includes a counter whichonly allows the value of NREGto change once every 20cycles.

OVERVIEWTo summarize therefore, the

brightness of a lamp can becontrolled by the contents of therespective BRG register, whilethe speed and direction of theramp is determined by the con-tents of the respective NREGand bit in the DMDRrespectively. Since all of theseregisters are separate, eachchannel can be varied indepen-dently to produce any kind ofdisplay required.

Thus, by leaving the bits inthe DMDR register cleared, forexample, and reloading thebrightness register with themaximum value each time theminimum is reached, a“sawtooth” brightness patternwill result with the channelfading down to minimum bright-ness at a rate determined bythe contents of its respective

NREG register, and then switch-ing on to full brightness torepeat the process again. Simi-

larly, by leaving the DMDR bitset the output would increase inbrightness. One output could

Constructional Project

Early prototype of the PCB. Some of the components, namely theinductors and capacitors, have been repositioned and a mainsrated terminal block included for the mains input lead.

R11

R4

R5

R6

R10

R7

R8

R9

R1C1

VR1C2

R2

D3

D4

D5

C4

C5

C6

L1

L2

L3

CSR2

CSR1

CSR3

G

G

G

MT2

MT2

MT2

MT1

MT1

MT1

k

k

k

a

a

a

C3

e

e

e

b

b

b

c

c

c

TR1

TR2

TR3

R3

IC1

RN

D1

D2

a

a

k

k

+

TB1

TB2

TB3

TB4

1

1

1

2

2

2

1 2

TOS1

TOS2

215

Fig.5. PCB topside component layout and underside copper foiland master pattern for the Fading Christmas Lights.

Page 17: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 86

also be made to dim while theothers increased in brightnessat different rates.

Note that once the outputbrightness reaches maximum, ifthe DMDR bit remains set, theoutput will stay at this bright-ness and would only change ifeither the contents of the BRGregister were altered or thecorresponding bit in the DMDRwas cleared. The same isof course true for outputs thathave reached minimumbrightness.

It is also possible to makethe outputs remain at someintermediate brightness level byswitching the correspondingDMDR bit high and low eachtime the BRG register is altered.This will in effect cause theoutput to ramp up and down byan amount so small as tobe hardly noticeable as achange in brightness.

Alternatively, the programcould be written in such a waythat the contents of the BRGregister are not altered whenthe brightness is to remain atone level. Using these tech-niques enables the brightnessof one or more channels to be“frozen” if required while otherscontinue to change at differentrates and in different ways.

If there are many settings orpatterns programmed, then alarger number of switches willbe required to select them and,in this case, port B would needto be reconfigured to drive/reada keyboard and the INPUTsubroutine re-written to do this.Perhaps the simplest way ofimplementing other lighting pat-terns would be to define a regis-ter which would store the num-ber of whichever key was lastpressed.

The other patterns would bewritten as subroutines similar tothe PSET subroutine, and thesecould be called from the mainprogram depending on whichnumber was stored in the regis-ter. This is not difficult to do,but it is beyond the scope ofthis article.

CIRCUIT DETAILSHaving discussed the soft-

ware, it is now time to examinethe hardware required to dothis. The full circuit diagram forthe Fading Christmas Lights isgiven in Fig.4.

As with most microcontrollerprojects, the circuit is unremark-able, consisting of thePIC16C54 chip itself plus theusual clock and input port pull-down resistors. The frequencyof the clock circuit is madevariable by means of presetVR1 to enable the circuit to beset up (see later).

As was mentioned earlier,port RA3 is used to input themains waveform for the zero-crossing detector, and it will benoted that two resistors, R10and R11, are used in seriesrather than one. This is be-cause most resistors are ratedat 250 volts, which is too lowfor connecting directly acrossthe mains, which has a peakvoltage of around 325V.

The other three lines of portA are used to drive three tran-sistors (TR1 to TR3), which inturn switch the three triacscontrolling the lamps. Each tran-sistor has a LED in its collectorcircuit, which mimics the mainlamp in brightness (these maybe mounted on a front panel orleft out if not required).

Phase control unfortunatelygenerates large amounts of

radio interference (RFI), whichmust be suppressed if it is notto cause annoyance to nearbyradio listeners, and this is thefunction of the chokes L1 to L3and capacitors C4 to C6 con-nected to the triacs. Thesecomponents MUST be correctlyrated for this application − seethe components list.

The circuit is powereddirectly from the mains (therebeing no good reason why itshould be isolated from thesupply), and a capacitor C1 (aClass X 250V a.c. capacitor) isused as a mains dropper inpreference to a resistor. Thea.c. voltage developed acrossthe Zener diode D1 is rectifiedby D2 and smoothed by C2 toprovide a nominal 4V negativesupply for the PIC. The currentconsumption of the circuitis quite low as the triacs arepulsed rather than d.c. trig-gered.

CONSTRUCTIONIt is important to realize

that all parts of this circuit areat or near mains potential,and under no circumstancesshould earthed equipment beconnected to the printedcircuit board (PCB), norshould the unit be usedwhilst connected to themains supply without beingfully encased in a totallyinsulated plastic box −−− seelater for details of this.

The circuit is built on a smallsingle-sided PCB. The compo-nent layout, together with fullsize copper foil master pattern,is shown in Fig.5. This board isavailable from the EPE Onlinestore (code 7000215) atwww.epemag.com

Constructional Project

Page 18: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 87

None of the components areunusual and should be availablefrom most suppliers. Note that thePIC microcontroller must be pro-grammed for this application, andfor those who do not have the facil-ities to program this device or pre-fer not to, a pre-programmed chipis available from the author − seeShoptalk for details on this and onthe availability of the software.

The pull-down resistors used inthe prototype were from an 8-wayresistor network, which is a singlein-line package with 9 pins, one foreach resistor and a common. The

common connec-tion is marked by adot on the body ofthis component,and care should betaken to ensurethat this is insertedinto the circuit cor-rectly with the dotadjacent to pin 5 ofthe IC

.

TAKE CAREThe only other

components worthyof note are themains dropper ca-pacitor C1 and thesuppressor capaci-tors C4, C5 and C6which must berated at 250 voltsa.c. Class X types,suitable for connec-tion directly acrossthe mains supply.DO NOT betempted to use anordinary 250 voltpolyester type asthese are normallyrated at d.c. andcould break downcausing extensive

damage to the rest of thecircuit.

The triacs should also havea minimum voltage rating of 400volts and have a low trigger cur-rent requirement (i.e. a sensi-tive gate) with a rating of 5mAbeing ideal. The C206D (whichis a 400V device) is best as italso has a low latching currentwhich is important when lowpower loads such as Christmastree lights are to be used.

This triac can be used tocontrol up to 750 watts of light-ing provided it is mounted on aheatsink. Without a heatsink100W would be more realistic,which should in any case bemore than enough for most ap-plications.

Note that the tab of this de-vice is not isolated, so that amica insulating kit will also berequired if a heatsink is to beused. The chokes should alsobe suitably rated to carry thelamp current.

CIRCUIT BOARDAll of the components ex-

cept the two switches and thefuse are mounted on the PCB,

Constructional Project

L

L

L

N

N

N

SPEEDUP

SPEEDDOWN

FS12A FUSE

TEMPORARY100W - 150W LAMP

(FOR TESTING ONLY)

230V a.c.MAINS IN

S1 S2

230V a.c .CHRISTMAS LIGHT CHAINS

OR SPOTLIGHTS(100W MAXIMUM FROM

EAC H OUTPUT)

LIGHT OUTPUTS230V a.c.

FULLY INSULATEDPLASTIC CASE

PRINTEDCIRCUITBOARD

MAINSINPUT

LP1 LP2 LP3

Fig.6. Component layout and interwiring in-side the plastic case. Beware of mains volt-age on the p.c.b and DO NOT earth any partof this circuit.

Page 19: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 88

and construction should follownormal practice with the lowestprofile components such as re-sistors and diodes beingmounted first. It is also a goodidea to fit an 18-pin DIL socketfor the microcontroller ratherthan soldering it directly to thePCB. This is a CMOS deviceand, although quite robust, thereis no point in tempting fate forthe sake of a few cents. Themains connection and connec-tions to the lamps are madeusing screw terminal blockswhich are also soldered ontothe board.

The off board componentswill, of course, be panelmounted and connected to theboard with flying leads. If thecircuit is to be used exclusivelywith Christmas tree lights, thesecan be connected directly to thescrew terminals and strain reliefgrommets used in the case. Ifother lighting arrangements areto be employed, a Bulgin 8-waymains connector (of the typeused in many light chasers)could be used to make theconnections.

The circuit may be mountedin any plastic box of suitablesize, there being many on themarket to choose from rangingfrom the plain functional to themore attractive. The choice isleft to the individual.

The circuit board should bemounted on plastic stand-off pil-lars (the self-adhesive ones areprobably the easiest to use) andsuitable holes should be drilledin the corners of the board forthis.

TESTING TIMEOnce construction is fin-

ished, check that there are nosolder splashes on the board

which could short out adjacenttracks. Do not insert IC1 yet.

The circuit MUST bemounted in a fully enclosedplastic case and no metal partshould pass through the case(except of course for the mainswiring, which must also be insu-lated in the normal way). Thismeans that switches S1 and S2MUST be plastic bodied typesrated for mains insulation − seethe components list.

ON NO ACCOUNTSHOULD ANY OTHER CASEARRANGEMENT BE USEDFOR THIS PROJECT! If youare in any doubt about yourability to build this mains pro-ject safely, then consult aqualified electronics engi-neer.

Remember that this circuitoperates at mains potential, donot use it whilst it is connectedto the mains unless it is fullycased as described above. DONOT EARTH ANY PART OFTHIS CIRCUIT.

TEST LAMPIt is a good idea to connect

a lamp of 100W-150W in serieswith the mains lead (as shownin Fig.6) at this stage to preventloud bangs, blown fuses, andperhaps some smoke shouldthere be a short circuit some-where. (Do not connect anylights to the outputs yet.) Theworst that will then happen isthat the lamp will light indicatingthat there is a fault somewhere.

Carefully check the voltageacross pin 5 (negative) and pin14 of the DIL socket to ensurethat it is at least 3⋅5V and notgreater than 5⋅5V d.c. If all iswell, switch off and insert thechip into its socket. The 100Wlamp in series with the mains

input may now be removed.

Connect suitable loads to theoutput terminal blocks (i.e. 15Wto 100W lamps or three Christ-mas tree light chains) and switchon the mains supply. The lightsshould all come on at differentintensities.

Press switch S1 to increasethe fade speed and adjust VR1for minimum lamp brightnesswhen one of the lamps dims to aminimum. Do not adjust to thepoint where the lamp switches offaltogether as this will tend to spoilthe effect. When the lamps aredimming satisfactorily, press S2and check that the rate of dim-ming slows.

Once this has been done, thecircuit will operate continuously atthe rate set by push-switches S1or S2, and the only thing to do isto experiment with various lightingset ups to obtain the mostpleasing effect. As mentioned,three spotlights in the three pri-mary colors red, green and blueprojected onto a white wall orceiling provides perhaps the mostinteresting display but, as beautyis in the eye of the beholder, youmay have other ideas.

Constructional Project

Page 20: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 89

Last month we described aunit based around a 38kHz mod-ulated system, which offers therange and reliability associatedwith commercial infra-red (IR)control systems. Several set-ups were described, amongstthem a 4-way latching or mo-mentary system, which makes itpossible to transmit two or more“ways” at the same time.

The 15-way system de-scribed now employs a multi-plexing arrangement. Opencollector transistor outputs areprovided at the receiver, to en-able the user to control what-ever is required, either directly,or via relays.

15-WAYTRANSMITTER

The transmitter circuit is thesame as that described lastmonth, except that the data in-puts are encoded in binary fash-ion to provide 15 ways, as

shown in Fig.1.

The circuit diagram illus-trates how 15 push-to-makeswitches are connected to

four points, labeled Data 8 toData 11. This numbering systemconforms with the data inputs(D8 to D11) of the HT12B en-coding device shown in Fig.4(Transmitter system circuit) lastmonth.

Note that the switcheslabeled S1 to S4 in last month'sFig.4 are not required andshould not be confused with theswitches in the 15-way circuit.

One side of all the switchesin Fig.1 is connected to 0V.Each switch is joined to the ap-

Increase your control options with this 15-way codedIR Transmitter and Receiver system.

15-WAY INFRA-RED REMOTE CONTROLby Max Horsey

D2S2

0V

D15S12

S13

S14

S15

D16

S8

D7S7

D9

D11

D13

S9

S10

S11

D1

D4

D3

D5 D6

S3

S4

S5

S6

D8

D10

D12

D14

S1

D17

D19

D21

D18

D20

D22

DATA 11

DATA 10

DATA 9

DATA 8

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

k

D1 TO D221N4148

Fig.1. 15-way switching matrix. Incorporated, with somesimple amendments, to last month's Transmitter

Page 21: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 90

propriate combination of datapoints via a matrix of diodes. Totake one example, if S4 ispressed, then Data 10 goeslow, but the diodes prevent anyother data points from beingaffected.

When Data 10 at theTransmitter (HT12B pin D10)goes low, the equivalent dataoutput at the Receiver shown inFig.2 goes high. We will seelater how a high at pin D10 ismade to activate Output 4at the Receiver.

Returning to Fig.1, if S6 ispressed, then Data 10 goes lowagain, but Data 9 also goes low.Hence pins D10 and D9 both gohigh at the receiver, and thisactivates Output 6. We are ef-fectively counting in binary, withreceiver pins D8 to D11 repre-senting values of 1, 2, 4 and 8respectively. Table 1 illustratesthe principle, in which logic 0 isrepresented by 0V and logic 1 isabout 5V.

15-WAY RECEIVERThe 15-way Receiver and

Decoder circuit diagram is shownin Fig.2. It is similar to the 4-wayreceiver shown last month, ex-cept that the data output pinsfrom IC2 (D8 to D11) are con-nected to the control inputs A, B,C and D on the multiplexer/demul-tiplexer IC4.

This device behaves like arotary switch, the position of theswitch being controlled by thelogic state of inputs A, B, C andD. For example, if A is at logic 1

and the other inputs at logic 0,then the switch will be set to po-sition 1, shown as output X1 inFig.2. In other words pin 1, thecenter pole (moving contact) ofthe imaginary switch inside IC4,connects with pin 8.

If the inputs A, B, C and Dcount up in binary, the pole (pin1) of the switch “moves” throughthe various ways shown as X1,X2, X3 etc. Note that wheninputs A, B, C and D are all atlogic 0, output X0 is active.Hence there are actually 16outputs if this is included.

Constructional Project

bc

e

bc

e

bc

e

+

7

8

9

10

11

12

2

3

4

5

6

1A1

A2

A3

A4

A5

A6

A7

A0

X15

X5

X10

X11

X12

X13

X14

X6

X7

X8

X9

X3

X4

X0

X1

X2

1

2

3

4

5

6

7

8

S2 R347k

V

12

SS

IC44067

A

B

C

D13

14

11

10

OUTIS1U60

GND

CC

TR1BC184L

R210k

18

V

R4SEETEXT

24

DD

V

D9

D8

D10

D11

OSC 2

OSC 1

IC2HT12D

DIN

VT

10

11

12

13

14

15

16

17DD

SS

V

9

IC1 V

V R147k

15EN

X1

6

16

5

4

3

2

23

22

21

20

19

18

17

9

8

7

COM

C1100n

OUT

OUTPUTCIRCUITS

x 16 TR2TO

TR17

D1

TR18BC184L

R22SEETEXT

D2 TO D171N4001

R54k7

INIC378L05

OUTPUTS0 TO 15

COMMONPOSITIVE

ON/OFF

S1

R6 TO R2110k

SEE TEXT

TIP122

C21000m

1

2

3

a

a

k

k

B1(SEE TEXT)

0V

Fig.2. Full circuit diagram for the 15-Way Receiver and Decoder. The insert area(TR2/TR17 isrepeated for each output pin of IC4.

TRANSMITTER RECEIVER

D1111111110

D1011100001

D910011001

D801010101

S1S2S3S4S5S6S7S8etc.

D1100000001

D1000011110

D901100110

D810101010

= 1= 2= 3= 4= 5= 6= 7= 8etc.

Table 1 Relationship between Matrix switches, Transmitter andReceiver Outputs

Page 22: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 91

The outputs X0 to X15 canbe used to drive light emittingdiodes (LEDs) directly (via cur-rent limiting resistors), or anythingrequiring a similar current (up toabout 15mA). If LEDs arerequired they can be wiredacross the pads on the printedcircuit board (PCB) intended forthe base/emitter connections ofthe transistors.

Darlington transis-tors (TR2 to TR17) areshown in the circuit inorder to allow switchingof an amp or more fromeach output. Since onlyone output can be onat any time, a singleseries resistor (R4)can be used instead ofresistors R6 to R21.The latter resistorswere included in casesome outputs are usedfor LEDs, and othersfor buzzers etc. If any

resistor is not required, it may bereplaced with a wire link.

The values of the resistorswill depend on the required use.For example, LED seriesresistors should be around 220Ωon a 4⋅5V supply or 680Ω on 12V.If transistors are employed, in-crease these values by aboutthree to four times.

As in the previous receivercircuits, the regulator IC3 canbe omitted if a 4⋅5V supply isemployed. Components R5,TR18, R22 and D1 may all beomitted if a “code detect” indi-cator is not required.

OPEN COLLECTOROUTPUTS

Each of the Darlingtontransistors TR2 to TR17 arenpn types which turn on whenthe voltage at the base (b)rises. If ordinary transistors areemployed, such as BC108 orBC184L (for small currents) thebase voltage required for turnon will be around 0⋅7V. If Dar-lingtons such as TIP122 areused, the turn on voltage will bearound 1⋅4V. Darlingtons havethe advantage of being able toswitch high currents (an amp ormore) yet still require only a

Constructional Project

DATA 8

DATA 9

DATA 10

DATA 11

0VS1 S2 S3

S4 S5 S6

S7 S8 S9

S10 S11 S12

S13 S14 S15

D2

D10 D8

D4 D1D6

D18

D12

D3 D5

D7

D22

D11D9

D13

D16D14

D20

D15

D21

D19

D17

a

k

a

ka

k

a

k

a

k

a

ka

k

a

k

a

k

a

k

a

k a

k

a

k

a

k

a

k

a

k

a

k

a

k

a

ka

k

a

k

a

k

211

Fig.3. The 15-way Switch Matrix printed circuit board component layout and full size copper foilmaster. The Data lead-off wires link to the Transmitter board (last month) as indicated in Fig.4.

Layout of components on the 15-waySwitch Matrix board. The LEDs belongto the Transmitter PCB.

Page 23: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 92

tiny current at the base.

The collector (c) of eachtransistor is shown uncon-nected (open circuit). It isessential to note that anydevice being powered must beconnected between the chosenopen collector output and thepositive supply line. This isbecause the collector will be“open” when the transistor isturned off, and around 0V whenthe transistor is turned on.

So, if a relay is required,for example, connect one sideof the relay coil to positive andthe other side to the appropriatecollector. Note that the word“positive” in this instancemeans the positive supplyvoltage before the regulatorIC3, i.e. directly to the batteryor other power source.

IC1, IC2 and IC4 all operateon a +5V supply from the outputof the regulator. Hence the tran-sistors interface the 5V supplywith the pre-regulation powersupply, enabling 12V relaysor solenoids to be employed.

If the regulator IC3 isomitted and replaced with a wirelink, the whole circuit may thenbe operated on a 4⋅5V supply.

BACK-EMFPROTECTION

If relays, motors or similarinductive output devices areused, a diode (such as type1N4001) should be connectedacross the output device, withthe cathode (k) of the diode onthe positive side, to protectagainst “reverse surges − backEMF (electromotive force) atswitch-off. (Note that a band orring on the diode body indicatesthe cathode end).

one infra-red controlsystem, you will need a differentcode on the second Transmit-ter/Receiver system. Thiscan be achieved byinserting an extra wire linkacross a pair of pads intendedfor S6, or by soldering in S6 andsetting one or more ways to on.

When the transmitter boardis complete, insert connecting

Constructional Project

COMPONENTS

ResistorsR1 4k7R2 10MR3 to R5 4.7 Ohms (3 off, see text)

See also theSHOP TALK Page!

All 0.25W 5% carbon film or better

CapacitorsC1, C2 100p ceramic disk (2 off)C3 100n ceramic diskC4 470u radial electrolytic, 16V

SemiconductorsD1 to D3 infrared LED (3 off)TR1 TIP122 npn DarlingtonIC1 HT12B coded IR-transmitterIC2 78L05 +5V regulator (see text)

MiscellaneousS5 miniature s.p.d.t toggle switch (see text)S6 6-way DIL s.p.d.t slide switch moduleX1 455kHz ceramic resonator

Printed circuit board (Transmitter)available from the EPE Online store,code 205 (Transmitter); plastic casewith battery compart-ment, 145mm x78mm x 34mm;18-pin DIL socket; battery & holder(see text); wire, solder, etc.

$40Approx. CostGuidance Only

TRANSMITTER

SWITCH MATRIXSemiconductors

D1 to D22 1N4148 signal diodes (22 off)

MiscellaneousS1 to S15 miniature push-to-make switches (15 off)PCB (Matrix) available from the EPEOnline Store, code 211 (Matrix),insulating card to suit.

TRANSMITTERCONSTRUCTION

Switches S1 to S15 and diodesD1 to D22 are mounted on aseparate PCB (the Matrix board)as shown in Fig.3. This board isavailable from the EPE Onlinestore, code 211 (15-Way Matrix) atour Web site www.epemag.com

It may be more convenient toinsert the diodes in the PCB beforethe switches. Ensure that they arefitted the correct way round.

Next, construct the TransmitterPCB as shown last month in Fig.6,but without its switches S1 to S4.Remember to note which options

are required regarding supplyvoltage and whether S5 (on thetransmitter PCB, not the switchesPCB) is required.

As with last month's transmit-ter, the coding switches (S6) willprobably not be required unlessyou wish to frequently change thecode. If you have built more than

Fig.4. Printed circuit boardconnections/amendments tolast month’s Transmitter.

Page 24: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 93

wires as shown in Fig.4 so thatthe matrix switches PCB maybe linked with the transmitterPCB. The two PCBs are placedback-to-back, with an insulatingpiece of plastic or card betweenthem to prevent a short circuit.

RECEIVERCONSTRUCTION

Now construct the 15-wayReceiver board, as shown in

Fig.5. This board is availablefrom the EPE Online PCBstore, code 212 (15-W Rec/Dec) at our Web sitewww.epemag.com

Ensure that the variousoptions have been considered.For example, if a 12V supply willbe used, fit regulator IC3. OmitIC3 and link its In/Out pads onthe board if a 4⋅5V supply is tobe employed.

Consider how many outputsare required, and whether anoutput current of up to about10mA is sufficient, in whichcase Darlington transistors TR2to TR17 are not required.

Resistor R4 is provided incase the current required by alloutputs is the same. For exam-ple, if only a set of LEDs isrequired, a single resistor (R4)can be fitted, and resistors R6to R21 omitted. The current forthe LEDs will then be takendirectly from the outputs of IC4.The pads which are joined tothe outputs from IC4, andintended for R6 to R21, makeconvenient connecting points.

The cathodes (k) of theLEDs may all be connected to0V via a single wire. There willbe a number of spare 0V points

on the PCB. if the transistorsare not employed.

If a variety of currents isrequired then fit a wire link inplace of R4, and fit resistors R6to R21 as required. In the proto-type, a mixture of LEDs andtransistors was used (as seenin the photographs), and sovarious resistor values werefitted. For example, on a 12Vsupply a typical resistor valuefor an LED is 680Ω, and 2k2Ωfor a transistor base. The sug-gested values for a 4⋅5V supplyare 220Ω for the LED and 680Ωfor the transistor base.

One source of confusionmay be the pads labeled“COMMON OUT +VE”. Theseare positive (from the battery orpower supply), and are intendedfor any device which is oper-ated via the transistors.Alternatively, a device which isconnected directly from anyoutput of IC4 must be con-nected to 0V. As stated, a num-ber of pads are available on thePCB which are joined to 0V.

The point made about thecode switches in the Transmit-ter also applies here, and re-member to have exactly thesame arrangement in thereceiver with regard to switch

Constructional Project

COMPONENTS

ResistorsR1, R3 47k (2 off)R2 10kR4, R6 to R21 (see text)R5 4k7R22 680 Ohms for 12V, 220 Ohms for 4.5V

See also theSHOP TALK Page!

All 0.25W 5% carbon film or better

CapacitorsC1 100p ceramic diskC2 1000u axial electrolytic, 16V

SemiconductorsD1 red LEDD2 to D17 1N4001 rectifier diodes (16 off) (see text)TR1, TR18 BC184L npn transistors (2 off)TR2 to TR17 TIP122 npn Darlington transistors (16 off) (see text)IC1 IS1U60 or PIC12043 sensor/receiverIC2 HT12D decoderIC3 78L05 +5V 100mA regulator (see text)IC4 4067 1-to-16 way analog multiplexer

MiscellaneousS1 miniature s.p.s.t toggle switchS2 6-way DIL s.p.s.t slide switch module

PCB (Receiver) is available from theEPE Online store, code 212(15-W Receiver/Decoder); plasticcase with clear lid, 152mm x 113mmx 72mm approx; PCB mountingpillars (4 off); connecting wire,solder, etc.

$62Approx. CostGuidance Only

15-WAY RECEIVER

R6

R7

R8

R9

R10

R11

R12

R13 R14

R15

R16

R17

R18

R19

R20

R21

R22

R5

R1

R2

R3

TR9

TR8

TR7

TR6

TR5

TR4

TR3

TR2

e bc

eb c

eb c

eb c

eb c

eb c

eb c

eb c

eb c

e bc

e bc

e bc

e bc

e

e

e

bc

e b

b

b

c

c

ce bc

IN

COM

OUT

IC3 TR18

TR1

IC1

1 2 3

IC2

IC4

R4

C1

S2

TR10

TR11

TR15

TR12

TR13

TR14

TR16

TR17

C2

+ OUTPUT 9

OUTPUT 10

OUTPUT 11

OUTPUT 12

OUTPUT 13

OUTPUT 15

OUTPUT 14

OUTPUT 8

OUTPUT 7

OUTPUT 6

OUTPUT 5

OUTPUT 4

OUTPUT 3

OUTPUT 2

OUTPUT 1

OUTPUT 0OV

+VE

ON/OFF

POWERSUPPLY

COMMON OUT +VECOMMON OUT +VE

S1

D1a k

Fig.5. Receiver/Decoder printed circuit board componentlayout and wiring.

Page 25: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 94

mode S2 so that the circuitlooks for the correct code.

Begin assembly by solder-ing in the integrated circuit (IC)

sockets, followed by the wirelink and small components. Fitthe optional components asrequired, and take care with

the polarity of electrolyticcapacitors and transistors. Thetransistors are unlikely to re-quire heatsinks.

Fit the delicate IR sensorIC1, either directly to the PCBwith the bulge facing the out-side, or via wires. Remember

that the infra-red beam must beable to “see” the sensor wheninstalled in a case.

Fit the necessary connect-ing leads and insert the ICs.

TESTINGWhen the receiver is turned

on, output X0 (pin 9 of IC4)should be at about 3V to 4V.This should make Output 0active, assuming that no IRsignal is being received. If thisis not the case, check thepower supply connections onIC4 (pins 24 and 12) for areading of 5V (or 4⋅5V if batterypower is used). A 12V readingsuggests a serious problem andthe circuit should be switchedoff immediately before damageto IC1 and IC2 is caused. In thisevent, check the connections toregulator IC3 carefully.

If all is well so far, aim thetransmitter LEDs at the front ofthe receiver module (there is asmall bulge at the front). Placethe two units about a meterapart. See if pressing a button

Constructional Project

The completed Receiver housed in a casewith a transparent lid. A larger case maybe required if “switching” relays are to oc-cupy the same case.

Make sure that the Receiver infra-red sensor, onthe PCB,aligns with the IR lens and the “beam en-try” hole in the side of the case.

Layout of components on the completed Receiver.

Page 26: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 95

on the transmitter causes anyreaction at the receiver.

If TR18 and its associatedcomponents have been fitted,LED D1 will indicate the pres-ence of a correctly coded sig-nal. Otherwise, test the voltageon the VT pin (pin 17) on IC2 ofthe receiver. It should be at 0Vbut change to about 5V when asignal is received.

Should the VT test fail,check that the receiver (IC1) isfitted the correct way round,with its bulge facing the outsideedge of the PCB. Now checkthe voltage on the pins of IC1.Pin 3 should be positive, andpin 2 at 0V.

When a signal is notreceived, pin 1 (the output pin)should be at just under 4V.When a signal is received thisvoltage should fall by about 1V.Note that as the signal is oscil-lating, a voltmeter provides arather approximate guide tovoltage. If an oscilloscope isavailable, it should be possibleto view the encoded signal, in

which case the trace will riseand fall between 4V and 0V.

If this test fails, try sendinga signal from a remote controlunit belonging to a TV or similar.The signal will not be decoded,but you will at least know if IC1is working and hence determineif the fault lies in the transmitteror receiver assembly.

If the output from IC1 isworking, test the signal at theData In (pin 14) of IC2 on thereceiver. It should be at about0V when no signal is received,rising to about 1⋅3V on a volt-meter. An oscilloscope will showthat the signal actually pulses toabout 5V.

Pushing switch S1 on thetransmitter should make pin D8on IC2 of the receiver switch toabout 5V, S2 should switch D9,S4 should switch D10, and S8switch D11. Other switchesshould cause different combina-tions of the outputs from IC2.Check that the voltages onthese outputs are copiedcorrectly to IC4.

Note that Output 0 on thereceiver is only active at switchon, or if the transmitter is innon-latching mode.

If the outputs from IC4 areworking correctly, rememberthat the outputs from thetransistors (if fitted) are eitheropen circuit or at 0V. Normalvoltmeter tests are not possible.Instead, connect the positiveside of the voltmeter to positive(e.g. the “COMMON OUT +VE”point on the PCB) and use thenegative lead of the voltmeteras a probe to test the outputs.

TRANSMITTER TESTSIt is difficult to test the

transmitter (see last month) fullyunless an oscilloscope is avail-able, in which case the codecan be checked at the DOUT (pin17) of IC1. A similar but invertedcode should appear at thecollector of TR1 and (if the IRLEDs are the correct wayround, and the series resistorsare of the correct value) a

Constructional Project

Two halves of the Transmitter case opened-up to reveal the two PCBs and the matrix of holes forthe output “code” switches. Note the cardboard separating the two PCBs in the left-hand photo.

Page 27: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 96

signal will be transmitted. An os-cilloscope will also determine ifthe resonator (X1) is oscillating.

Voltmeter tests are confinedto checking the power supplyacross IC1 (pins 18 and 9). Thisshould be around 3V to 5V.Data pins D8 to D11 should behigh unless an appropriateswitch is pressed, in whichcase the voltage should changeto about 0V. Note that the se-ries diodes will cause a voltagedrop, sometimes preventing theappropriate data pin falling fullyto 0V. This should not present aproblem.

COMMON PROBLEMSTypical mistakes include dry

joints and bridged pads − i.e.adjacent pads accidentallyjoined with solder. Furthermishaps include failing to insert

wire links. For example, do notforget the wire link bridging IC3In/Out pads if a regulator IC is notused. Also check that all the po-larity conscious components arethe correct way round.

TRANSMITTER CASEA number of suitable boxes

are available on the market, manywith battery compartments and asuggested layout is shown in thephotographs. Very careful align-ment is necessary for the holesmade for the switches to projectthrough the case.

Make a photocopy of thePCB layout diagram, fasten it tothe case and drill through theappropriate points.

The IR LEDs should bebent over so that they project thebeam through holes made in theend of the case.

RECEIVER CASEAny suitable case may be

used for the receiver, and asuggested layout is shown inthe photographs. However, if 15relays are required, a muchlarger case may be necessary!

If the IR sensor is mountedon the PCB, take care toposition the PCB opposite asuitable hole drilled in the case,for the IR beam to penetrate.A red filter or red lens maybe fitted over the hole on theinside of the case; this is forcosmetic rather than perfor-mance reasons.

If any relays are required tooperate mains equipment, apiece of insulated PCB materialor plastic sheet must be fixedinto the case to make a sepa-rate compartment for the mainswiring.

Constructional Project

Designus Maximus UnleashedBy Clive “Max” MaxfieldFree CD-ROM, 448 pages, $39.95 US Dollars (plus S&H)

This unabridged and unexpurgated tome contains the definitive collectionof Clive "Max" Maxfield's wildly popular articles published in Electronics DesignNews (EDN) magazine under Max's Designus Maximus column (plus articlesfrom other leading electronics magazines). The 30 chapters cover a smorgas-bord of topics, including design capture, logic synthesis, digital and analog sim-ulation, testing RAMs and ROMs, asynchronous design, reconfigurable andvirtual logic, genetic algorithms, and deep submicron delay effects. The arti-cles in this book appear in their original form, and address the subject matter in

significantly more depth than their magazine counterparts, which were edited for space and style. For yourdelectation and delight, the accompanying CD-ROM contains a logic synthesis tool, a multimedia digitallogic design system, and a demonstration copy of the virtual microcomputer from Bebop BYTES Back (forWindows 95 machines only).

Available from the EPE Online Store at www.epemag.com

Page 28: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 97

In designing this little pro-ject, the aim was to build ahand-held audio generator witha few more features than thosenormally found on the simple“probe” type designs. Injectorsof this sort generally fall intoone of two main categories.

On the one hand there isthe very basic square wavetype. In its discrete form it usu-ally consists of little more than amultivibrator using a couple oftransistors, the output beingtaken from the collector of oneof them.

The frequency might be anominal 1kHz or so. Often thereis no control over the outputlevel and this might be anythingup to 9V peak-to-peak depend-ing on the batteries used.

IN COMPARISONApart from a few specialized

tests requiring a square wave,the shortcomings of this type ofinjector are many. The squarewave contains harmonics − lotsof them. These are fine if you

also want to use the in-jector to pump a signalthrough an RF stageworking at 50MHz! But foraudio circuit testing theycan be a distinct disad-vantage, causingcrosstalk and break-through between stages.

Using one of theseinjectors, while fault-finding in the pre-ampstages of an amplifier, theauthor actually managed

to get a weak but audible outputfrom the speaker, only to findthat the power to the amplifierwas turned off! Confusing in-deed!

Finally, a square wavesource cannot be used in testsfor distortion. Using a squarewave signal source when tryingto trace distortion, such as“clipping”, is completely mindbogglingly difficult if not practi-cally impossible.

The second type of injectoris a little more elegant, produc-ing a sine wave output insteadwith, perhaps, the added refine-ment of an output attenuator. Tokeep things simple, the fre-quency is again usually fixed at(say) 1kHz.

The sine wave might be de-rived from a Wien bridge, twin-Tor phase-shift oscillator. If care-fully designed, all are capable of

A truly pocket-sized instrument, with three switchedranges covering 50Hz to 20KHz

HANDHELD FUNCTION GENERATORby Brian Adkinson

Full size Function Generator fitseasily in the palm of the hand.

SpecificationUseable Frequency Range: From below 50Hz to over 20kHz, in threeoverlapping ranges.

Output Waveforms: (O/P levels measured with fresh batteries fitted).Variable − Sine and Square wave. 0-300mV and 0-3V pk-pk.Fixed −Sine and Square at nominal 500mV pk-pk.Triangle at nominal 1⋅5V pk-pk.

Sine wave Distortion: Better than 5 percent.

Power Source: 3V (2 x N-cells).

Power Consumption: 5mA quiescent, rising to around 50mA at fulloutput into an 8 ohm load.

Page 29: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 98

giving a low distortion output,which is really better than thatneeded for a simple probe typeinjector.

FUNCTIONALDESIGN

It was decided early on inthe development of the Hand-held Function Generator that itshould provide a reasonablequality sine, triangle and squarewave output with continuouscoverage over most of theaudio range. Also included is aswitched and variable outputattenuator.

To further increase its ver-satility, the output is via a smallaudio “power” type IC. With theoutput level set at maximum,this allows the unit to drive lowimpedance loads, such as loud-speakers, directly.

This could prove usefulwhen testing speaker wiring etc.in home and car audio systems.The power available is only afew tens of milliwatts but by se-lecting the square wave output,and adjusting the generator to asuitable frequency, a surpris-ingly loud output can be ob-tained.

Finally, additional fixed out-puts are available from the sine,square and triangle signals. Oneor more of these could be con-nected to the circuit under testas well as say, an oscilloscope,a.c. millivoltmeter or frequencycounter. In fact, where an accu-rate output level or frequency isimportant, connection to one ofthese will be a necessity.

Although the HandheldFunction Generator is fairlycomprehensive in its features −see the Specification panel − itmust be stressed that it has not

been possible to miraculouslysqueeze the quality and featuresof a “full-blown” instrument intosuch a tiny case. There are, ofcourse, a number of trade-offs;for example the output amplitude,and to a lesser extent, frequencyare dependent on supply voltage.

With only 3V available, a reg-ulated supply was considered im-practical. Also, the distortion levelof the sine wave is somewhathigher than that of a“professional” generator. Evenso, the unit should still find use ina number of applications wheremoderate distortion is of littleconsequence, such as in fre-quency response and gain mea-surements in amplifiers, filtersetc. and in general purpose faultfinding.

The additional fixed outputsand neat design of the case allowit to work as a quite useablebench instrument as well. Thegenerator is powered by two in-expensive N-cells which willgive many hours of service undernormal use.

HOW IT WORKSThe main signal generator

section is a Schmitt oscillator.This is a fairly simple circuit andone in which the frequency canbe altered quite easily. TheSchmitt oscillator is an adaptationof the more familiar Schmitt trig-ger circuit (see Fig.1).

In the Schmitt trigger, a signalof slowly varying amplitude isconverted or “cleaned up” intoone with a predictable output am-plitude. Signal levels below theset upper and lower trigger pointsare ignored. When configured us-ing an opamp, the upper andlower trigger threshold points areset by resistors R1 and R2.

The basic circuit exhibits a

large degree of hysterisis or“backlash”, which considerablyimproves noise immunity. Theupper and lower trigger pointsare affected, to a degree, bythe supply voltage and thiswould, ideally, be stabilized.

An inverting Schmitt triggercan be converted to a Schmittoscillator by connecting a resis-tor, R3, from the output back tothe inverting input, and a capac-itor C from this point to ground(0V), as shown in Fig.2. The re-sulting output is a high qualitysquare wave with, additionallyat the inverting input, a“triangular” wave.

The ramp of the trianglewaveform is actually exponen-tial in shape and is produced bythe charge and discharge of ca-

Constructional Project

+

R1

R2

VIN

VOUT

0V

Fig.1. Schmitt trigger circuit.

+

R1

R3

R2

0V

C

SQUAREWAVE OUT

TRIANGLEWAVE OUT

Fig.2. Circuit arrangement forproducing a Schmitt oscillator.

Page 30: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 99

pacitor C through resistor R3 asthe output switches alternatelybetween –Vcc and +Vcc. Assum-ing resistors R1 and R2 are thesame value, say 5k6, then theperiod or frequency is set by thevalues of R3 and C, so the fre-quency will then equal:

1/(2.2 x C x R3) Hz

Again, assuming R1 and R2are the same value, then the am-plitude of the triangular wave willbe roughly two thirds of the differ-ence between -Vcc and +Vcc.

CLIPPINGIn the Handheld Function

Generator it is the triangularwave that is used as the basis forthe sinewave and for this reasona fairly linear ramp is needed inorder to minimize distortion. If re-sistors R1 and R2 are given suit-able values, the trigger level ofthe oscillator can be adjusted toproduce a triangle wave ofsmaller amplitude. This meansthat a smaller and hence morelinear part of the exponentialcurve can be used, with a resul-tant output nearer to a true trian-gle.

The sine wave itself is pro-duced through the simple butrather crude technique of“clipping” the triangle waveform toproduce a more sinusoidal shape.In practice this is done by feedingthe triangle waveform into a pairof signal diodes connected in in-verse parallel, the non-linear con-duction characteristics of thediodes progressively modifyingthe applied waveform.

CIRCUITDESCRIPTION

The full circuit diagram for theHandheld Function Generator is

shown in Fig.3. Resistors R1 andR2 form a potential divider togenerate the 0V rail, necessaryfor the correct operation of IC1.IC1a and its associated compo-nents perform the function of aSchmitt oscillator.

Capacitors C3, C4 and C5set the three frequency ranges A,B, and C. The coverage of theseis approximately: 45Hz to 400Hz;350Hz to 4kHz, and 3⋅5kHz to20kHz respectively.

The upper limit on each rangeis partially limited to that whichcan be comfortably resolved,bearing in mind the small size ofthe scale and control knob. Also,the scale is non-linear and be-comes more cramped towardsthe high frequency end.

On the prototype, the actualupper frequency limit reached onRange C was 33kHz. The exactcoverage of each range will de-pend upon the tolerances of theindividual capacitors used.

The frequency on each rangeis set by control VR1, with resis-tor R3 acting as an end stop lim-iter. This resistor prevents stallingof the oscillator and excessivedistortion when VR1 is set to min-imum resistance. The output onRange C tends to be slightlyhigher than the others, so resistorR7 and capacitor C6 areswitched in to correct this.

Overall, the output amplituderemains substantially flat from40Hz to 15kHz, with a linear roll-off beyond this point. If an accu-rate level is needed, for say fre-quency response tests, then itwould be prudent to connect anA.C. Millivoltmeter or Oscillo-scope to the SK2 output.

As well as providing a smallamount of gain, IC1b buffers thetriangle output at pin 2 of IC1a.

Constructional Project

COMPONENTSResistors

R1, R2, R10 4k7 (3 off)R3, R14 3k3 (2 off)R4 68kR5, R8, R13, R16 10k (4 off)R6 2k2R7 100kR9 15kR11, R12 150k (2 off)R15 680 OhmsR17 10 OhmsR18 1k

See also theSHOP TALK Page!

All 1/8W 5% carbon film

PotentiometersVR1 100k horiz. modular carbon control (see text)VR2 1k vertical modular carbon control (see text)

CapacitorsC1, C2 220u sub-miniature radial electrolytic, 6.3V, 5mm lead spacing, 7mm high (2 off)C3 330n polyester layerC4 33n polyester layerC5 2n2 polyester layerC6 330p plate ceramicC7 470n polyester layerC8 100n polyester layerC9 100p plate ceramicC10 non-polarized (see text for val)

SemiconductorsD1, D2 1N4148 signal diodes (2 off)D3 3mm red flashing LED (see text)IC1 7621DCPA CMOS opampIC2 TDA7052 low-voltage pwr-amp

MiscellaneousS1, S3 3-way double-pole, sub- miniature, PCB-mounting slide switches (2 off)S2 2-way single-pole, sub-min. PCB-mounting slide switchSK1, SK2 3.5mm stereo screened chassis jack sockets (2 off)B1 1.5 N-cell (2 off)

PCB available from the EPE OnlineStore at www.epemag.com (code7000207); miniature sloping-frontcase, size 77mm x 44mm x 28mm(max); probe tip; N-cell PCB batteryclips (2 sets); dual gang shaft forVR1 and VR2 (2 off); miniaturecrocodile clip; multistrand conductingwire; solder, etc.

$33Approx. CostGuidance Only(Excluding battery)

Page 31: EPE_12-1998

EPE Online, December 1998 - www.epemag.com -100

his gain is needed as the trian-gle wave produced is of insuffi-cient amplitude to correctlydrive the triangle to sine waveconverter diodes D1 and D2.These diodes need at least600mV to conduct, although inpractice they will begin to con-duct at below 500mV. The highvalue given to resistor R11 wasfound to give the best shape tothe sine wave.

Capacitor C8 isolates the twodiodes from any d.c. offsets pre-sent at the output of IC1b or inputof IC2. Anything more than a fewhundred millivolts will cause a d.c.bias to be applied to one of thediodes with resultant non-symmetrical clipping. CapacitorC7 prevents any d.c. offsetreaching the input (pin 2) of IC2.(IC2 input is referenced to thenegative line (-V) not 0V).

Resistors R12 and R13form a potential divider to re-duce the input level into IC2 to asuitable value. The actual levelarrived at is designed to causea very “soft” clipping action inIC2 which improves the sinewave shape slightly. This clip-ping action increases marginallyas the battery voltage falls, butis partially offset by the reducedinput level to IC2.

The square wave output isproduced when switch S2 isclosed. This connects resistor

Constructional Project

+

B13V

IC1a7621

IC1b7621 IC2

TDA7052

R510k

R915k

R62k2

R810k

R14k7

R181k

R24k7

R143k3

R1610k

R15680Ω

VR21k

R1310k

C433n

C52n2

C3330n

A B C

S3a S3bRANGE

FREQUENCY

SINE/SQUARE

RANGE

LEVEL

HI-LO

R7100k

C6330p

C8100n

C9100p

R468k

R33k3

VR1100k

2

5

3

61

78

4

C7470n

C10(SEETEXT)

R11150k

R104k7

R12150k

D11N4148

D21N4148

a

ak

k

S2

2 8

3

1

6 5R1710ΩC1

220µ

C2220µ

PROBE TIP

VARIABLEOUTPUT

GROUNDCLIP

ON/OFF

S1a

S1b

L.E.D. 1

V+

SINE/SQUARE

TRIANGLE

SK1

SK2

FIXED OUTPUTSP

P

P

P

P

0V

a

k

(2 x 1.5V)N-CELL

Fig.3. Complete circuit diagram for the Handheld Function Generator.

A 1kHz triangle waveformtaken at IC1b pin 7.

A 1kHz sinewave outputtaken from IC2 pin 8.

5

TDA7052

1

2

3

4

Output 2

N.C.

GNDSubstrate

Output 1

VS

INPUT

GNDSignal

N.C.

6

7

8

Pinouts for the TDA7052.

Page 32: EPE_12-1998

EPE Online, December 1998 - www.epemag.com -101

R10 in parallel with resistorsR11 and R12 and causes IC2to be driven hard into clipping.Earlier attempts at making useof the square wave available onpin 3 of IC1a yielded no betterresults than the simple methodfinally adopted.

OUTPUTA bridge form of output

stage is used by IC2 to gener-ate relatively high power levelsat low supply voltages. Thebridge configuration gives anegligible d.c. offset across theoutput (pins 5 and 8) and in nor-mal applications a couplingcapacitor is not needed.

However, for a signal gen-erator, an output couplingcapacitor is necessary as itisolates the output from any d.c.that might be present in theequipment under test. Also, acapacitor here protects theequipment under test from theearth return path via resistorR17 and control VR2. Note thatthe output pins of IC2 are effec-tively “floating” and neithershould be earthed to the -V rail.

Resistor R17 merely limitsthe available output power, inthe event of a short circuitacross the probe tip, with theattenuator switched out (S1bclosed) and VR2 set to maxi-

mum. Resistors R14 and R15form the potential divider for thefixed 500mV output to socketSK1.

In order to conserve batterylife, a Power On LED (D3) isincluded as a reminder that theunit is switched on. In theprototype a high brightnessflashing LED was used, the onlytype the author has any chanceof noticing!. A standard highbrightness type could be usedinstead if preferred.

COMPONENTSIt is important to use only

the specified components forthis project. The general perfor-mance, and in particular thesine wave purity, will be ad-

Constructional Project

R5

R9 IC1

R6

C3 C4 C5

R8

R7 R1C6

R2

R4

S3

S2

R10C7

R11

R12

C8

IC2R13

R15 R14

R17

C2 C1

VR1

VR2

R18

D1 D2

C9

R3

R16

S1

TO PROBETIP

BATTERY+V

BATTERY-V

+ +

W

W

a k

C10(SEE TEXT)

SK2

TRIANGLEOUTPUT

FIXEDOUTPUTS

TO GROUNDCROC CLIP

a b

p

a b

p p

D3

SK1

Fig.4. Printed circuit board topside component layout (approx.twice full size), together with interwiring connecting leads. Con-nections to SK1 and SK2 should be made from the back of thePCB or the board can be drilled in an unpopulated area andthe wires passed through the holes. The final size (approx.)copper foil master pattern is shown top-right.

213

Component layout on thecompleted circuit board

Page 33: EPE_12-1998

EPE Online, December 1998 - www.epemag.com -102

versely affected if differentresistor values are substitutedfor any of those around IC1aand IC1b or R11, R12.

Some alternative compo-nents may simply not fit on theboard. In particular the elec-trolytics C1 and C2 which mustbe no more than about 7mm indiameter.

Only use the specifiedopamp (a 7621) in the IC1 posi-tion. Although some opamps arequoted as working at a 3V sup-ply, they either work poorly ornot at all below 3V. (Which mustbe allowed for as the batteriesdischarge). The specification onthe ICL7621 indicates a mini-mum supply voltage of +/-1V.

There are a number of alter-native control shafts availablefor the controls used for VR1and VR2. The longer shaft isrecommended as it has aserrated section at the end forbetter grip. Because it isdesigned to go through twopots, to make a stereo control,it is longer than needed andtherefore the excess should becut off flush with the board.

OUTPUT CAPACITORFor normal use, the output

coupling capacitor C10 shouldbe a non-polarized or bi-polartype. A 10uF 50V capacitor wasfitted in the prototype. Thisvalue is more than adequate forfeeding the output of the gener-ator into medium to highimpedance loads. However, todrive a low impedance loadsuch as a loudspeaker, a muchhigher value, say 470uF, wouldnormally be used.

As mentioned in the circuitdescription, a bridge type outputlike the one used in IC2 actuallyneeds no coupling capacitor at

all. When using the generator tocheck out speakers and theirwiring, the effect of a low valuecapacitor is to greatly reducethe lower frequency output.

However, with the level atmaximum and square wave se-lected, fast edged spikes orpulses are generated. Althoughthese are not a true representa-tion of the output of thegenerator, they are still useful inproducing a very loud anddistinctive output.

If there is a requirement touse the generator to test lowimpedance loads without thislow frequency limitation thenC10 can be shorted out. A sep-arate subminiature s.p.s.t.switch could be fitted in thecase opposite the two socketsin order to facilitate this. Toavoid possible damage to IC2or the equipment under test, itwould be important to rememberto return this switch to its“normal” position before usingthe function generator forgeneral test work.

CONSTRUCTIONDue to its compactness,

great care will be needed whenbuilding the Handheld FunctionGenerator. The positions ofswitches S1, S2, S3, presetsVR1 and VR2 require accurateplacing on the printed circuitboard in order to line upcorrectly with the front panelholes and cut outs.

All the components exceptcapacitor C10 and the two out-put sockets SK1 and SK2 aremounted on one small printedcircuit board (PCB) while a sep-arate miniature PCB, containingspring contacts, holds the bat-teries. An (approximately) twice-size component layout, together

with an (approximately) full sizefoil master, is shown in Fig.4.This PCB, including batteryboard, is available from the EPEOnline store atwww.epemag.com (code7000213).

The use of a battery board(Fig.5) was necessary as adouble N-cell battery holdercould not be made to fit into thecase. The outside sections ofeach battery clip will have to bebroken off, otherwise they willnot fit into the battery compart-ment. These are quite brittle andby using fine-nosed pliers asingle bend at the bottom of theclip should break off each “ear”leaving just the contact.

The batteries should stillstay in position as they fit fairlytightly in the case, but any ten-dency for them to pop out of thecontacts can be reduced by tap-ing them together before inser-tion into the holder. Before sol-dering in the four battery con-tacts, the solder lugs should firstbe bent flush with the circuitboard. If this isn't done the caseback will not close properly.

MAKING CONTACTThe slide switches S1, S2,

and S3 are raised off the circuitboard by connector sockets oneach pin. These sockets comeas a 32-way strip, each socketbeing cut off as required using asharp knife.

As the sockets have aninsulating shroud, the minimumpitch between pins is 2⋅54mm.The switches, however, have alead pitch of just 2mm. To over-come this problem, the connec-tor socket fitted to the middle ofeach group of three switch pinsneeds to have its shroud cutaway, as shown in Fig.6.

Constructional Project

Page 34: EPE_12-1998

EPE Online, December 1998 - www.epemag.com -103

Note that while VR2 is astandard vertical preset, VR1 isnot listed as a vertical type inthe 100k value. (Note that,unusually, “horizontal” and“vertical” in this case refer tothe control shaft and not themounting.) Therefore, it is nec-essary to mount VR1 horizon-tally (with the shaft vertical),

bend the two outer legs to gothrough the board and thenextend the center wiper pin witha short length of wire beforesoldering this to the PCB.

As some of the wire linksand resistors sit under theswitches, these should be sol-dered in place first. The leadfrom the output capacitor C10and the earth lead can be sol-dered directly to the printed cir-cuit board, but thefour leads to sock-ets SK1 and SK2need to passthrough the boardfirst. For theseleads, suitablysized holes shouldbe drilled throughthe PCB at conve-nient points, takingcare not to drillthrough any of thecopper tracks! SeeFig.7.

The circuit board needs tobe held tightly against the frontpanel so that it cannot movewhen the switches are oper-ated. Rubber blocks or similarglued to the rear section of thecase can serve this purpose.

CASE PREPARATIONWhen making the oblong

cutouts for switches S1, S2 andS3, it was found that the easi-est way to do this was to firstdrill two or three small holes(about 2mm), cut between themwith a sharp knife to make aslot, and then insert a flat nee-dle file to enlarge the cutout tothe correct shape. The approxi-mate positioning of thesecutouts is indicated in Fig.8.

The probe comes in twoparts; the tip itself and an insu-lating cover. Solder a thickpiece of solid-core wire to thetip before pushing the cover on.This piece of wire needs to beas stiff as possible to stop theprobe from wobbling when inuse. Glue the probe into thecenter hole in the top of thecase then cut the wire off about1mm or so from the base andsolder one end of capacitor C10to it, see Fig.8.

A pair of 3⋅5mm stereosockets is used for SK1 and

Constructional Project

23mm

38mm

+ –

Fig.5. Suggested batteryPCB dimensions and foilmaster. 7mm

19mm 19mm

16mm

6mm

44mm

38mm

22mm

A

A

B

PCB FROM FOIL SIDE

HOLES 'A': 2mm DIAM.HOLE 'B': 7mm DIAM.

Fig.7. Circuit board drillingdetails for the control spindleshafts (A) and the case cen-ter pillar (B).

UNSLEAVED EXTENDER SOCKET

Fig.6. To cater for theswitch pin spacing the cen-ter connector socket has itsinsulating shroud removed.

Side view of the finished PCB showing theswitch mounting sockets.

Page 35: EPE_12-1998

EPE Online, December 1998 - www.epemag.com -104

SK2. The two center connec-tions on each socket aresoldered together to providetwo mono outputs.

Various combinations oftest leads can be made updepending on individual require-ments. For example, two phonoplugs at one end would providean identical signal to the left andright channels of a stereo ampli-fier. Another possibility could bea phono plug on one lead andcrocodile clips on the other.

TESTING ANDCALIBRATION

After checking the board fordry joints and solder bridges,the 3V supply can now be con-

nected. Before doing this, amilliameter wired in series withone lead will prove useful in de-termining whether there are anydrastic problems with the board.

The total quiescent currentdrain should lie between about4mA and 6mA. If this reads OKthen a check can be made for anoutput signal.

Switch to Range B, set pre-sets VR1 midway, VR2 to maxi-mum and switch S1 to Hi. Selectthe square wave output. A loud-speaker or earphone can now beconnected to the probe to checkfor an output; if working properlythis will be at about 800Hz to1000Hz or so and very loud.

If nothing is heard, refer to

the test voltage Table 1 to aidwith troubleshooting. Rememberthat all voltages relating to IC1are referenced to 0V (use the“earth” connection from the tri-angle output for this) while volt-ages relating to IC2 are refer-enced to battery negative (-V).

The frequency coverage ofeach range should agree ap-proximately with the prototype,even allowing for varyingtolerances of capacitors C3, C4and C5. An Oscilloscope orFrequency Counter is the bestway to accomplish accurate cal-ibration, although even with thisthe smallness of the scale willmean that only an approximateindication can be obtained.

Constructional Project

24mm

46mm

19.5mm 10.5mm

16mm

9mm

14mm

31mm

44mm

SHAFTHOLES 6mm

8.5mm

2mm

SWITCH CUTOUTS

S1, S3 2.5mm X 8mmS2 2.5mm X 7mm

CASE FRONT DRILLING DETAILS

(VIEWED FROM FRONT)

CASE FRONT VIEWED

FROM REAR

+

+

+–

C10

GLUE C10 FLUSHAGAINST FRONT PANEL

BATTERYCOMPARTMENT

SOLDERDIRECTLY

EARTH LEADHOLE

SK2

SK1

5mm

5mm

22mm

CASE TOP

PROBE HOLEDIAMETER 5mm

Fig.8. Case dimensions and drilling details, including top drilling for probe and “crocodile” lead.The output sockets are positioned in the side wall of the case lower section.

Page 36: EPE_12-1998

EPE Online, December 1998 - www.epemag.com -105

FINISHING OFFThe case as supplied is

black, so this was painted grayusing a car primer spray. Eachof the three scales were drawnusing a fine (0⋅6mm) permanentmarker pen and a circle tem-plate.

The lettering and numberswere put on using Letrasetrubdown transfers. Theseworked out rather expensive asthe very small lettering used(1⋅7mm) appears to only beavailable in large sheets. With alittle patience, a perfectly ac-ceptable job can be done usingjust the fine marker pen. Thesepens can be obtained from Artand Craft suppliers.

The scale pointer is formedfrom a solid piece of fairly thickwire that is simply pushed into apre-drilled hole in the knob onpreset VR1. Don't forget to set

VR1 fully at one end of its travelbefore drilling the hole, so that itcorresponds with the end of thescale.

IN USEAs the extreme upper limit

of each range becomes cramp-

ed and distortion increases, dueto changes in the duty cycle, thenext highest range should beselected and the required fre-quency obtained from this.

Note that the sine/square“grounds” (SK2 and the earth clip)cannot be connected directly tothe triangle output ground (SK1).However, these outputs can beused simultaneously, feeding sep-

arate inputs, providedthere is no commonground between them.

Finally, bear inmind that if the genera-tor is used for long pe-riods of time drivinglow impedance loads,then battery life will bereduced substantially.

Constructional Project

Layout of components inside the completed unit showing wiresto the output sockets. Note the plastic strip preventing the PCBtracks from shorting on the screened jack sockets.

IC1Pin

IC2Pin

12345678

0V +/-50mV0V +/-50mV0V +/-50mV

-1.5V0V +/-50mV0V +/-50mV0V +/-50mV

+1.5V

12345678

+3V0V0VN/C

+1.5V0VN/C

+1.5V

Voltages taken with a stan-dard 10 megohm impedanceDigital Voltmeter. Supplyvoltage +3V. Range switchS3 set to range B. Other con-trol settings not important.IC1 readings relative to 0Vrail. Ic2 readings relative tobattery negative (-V0.

Page 37: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 106

In Part 1 last month, weintroduced the PhizzyB Simula-tor software, which runs on anIBM-compatible PC computerunder Windows 95/98/NT. Theconstructional details for thereal hardware PhizzyB werealso provided.

This month's practicalarticle describes a simple pro-totyping I/O (input/output)board, which can be used toconnect external circuitsdirectly to your hardwarePhizzyB. This test boardallows sensor transducers,switches, and other compo-nents to be interfaced directlywith a PhizzyB.

Apart from introducingsome assembler and program-ming techniques, one of the

purposes of the experiments inPart 2 is to confirm that the I/Oports on your PhizzyB really dowork. They can be tested simplyby connecting a bank of

switches to an input port, andan LED array to an output port.

By downloading the relevantprogram (in the form of a *.ramfile) from the PC to yourPhizzyB, you can soon showthat the I/O ports are functioningas expected. Then, by changing

the program and reloadingthe corresponding *.ram file,you can swap the I/Ocircuits to other ports andprove that they operatecorrectly, as well.

Further down the road,we will be introducing avariety of applications whichutilize the I/O ports of yourPhizzyB.

It is again highlightedthat the PhizzyB is a com-mercial product, and thepurpose of this series is toconstruct and use the

software and hardware to emu-

Adding outside world communication options - inputcontrol switches and LED bargraph

PhizzyB COMPUTER by Alan Winstanley

1

1

3

3

5

5

7

7

9

9

11

11

13

13

15

15

17

17

19

19

2

2

4

4

6

6

8

8

10

10

12

12

14

14

16

16

18

18

20

20

(A)

(B)

Figure 1 Two sections of the 4-sectioned PhizzyB I/O board:(Left) component side view, (right)trackside view.

Assembled simple switchinput board

Page 38: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 107

late the operation of a real com-puterized control system.

Circuit diagrams of the I/Omodules are provided here, butotherwise the operation of thePhizzyB computer is beyond thescope of this educationalseries.

MULTIPURPOSE I/OBOARD

A specially-designedPhizzyB I/O board is available,which can be cut into foursections (see Fig.1). (Note thatFig.1 only shows two of the foursections.) Each section cancarry a 20-way connector nextto the prototyping area and issuitable for both input and out-put add-on circuits. The 20-wayconnector is hooked over toone of the PhizzyB’s input oroutput ports using a ribboncable.

Having divided the boardinto quarters (see later), thereis one important differencebetween them, which is that asingle continuous row of tracks(often called a “busbar”) may

either be at the top of a section(“A”) or at the bottom (“B”). This“A” and “B” notation helps to en-sure that the “correct” board isutilized by readers, as determinedby where the busbar actually is.

The four boards can each beused for either input or outputexperiments. Constructors shouldensure they use the “correct”board section to correspond withour drawings.

It is perfectly feasiblymerely to cut the board in half(rather than into four) and useeach section independently, aswe did in this month's experi-ments − see photos. Sparesections can be used for otherprototypes at a later date, sonothing goes to waste. What-ever method you adopt, pleaseremember to check the “busbar”before you start soldering.

Constructional Project

R19 x 4k7

0V(COMMON)

8

7

9

107

8

6

5

4

11

12

13

6

4

5

3 143

+5V

S18-WAY SPST

DIP SWITCH(SLIDE)

2

1

15

16

2

1

1 10

19

7

11

13

15

17

9

1

3

5

I ACKIP6

TO 20-WAYCONNECTOR

CON1

N.C.

19

17

15

13

11

9

IP0

IP1

IP5

IP2

IP3

IP4

IP0

IP6

IP5

IP4

IP3

IP2

IP1

IP7

7

5IP7 +5V

4

20 N.C.

8

10

12

14

16

18

6

0V

2 IRQ

INPUT PORT20-WAY CONNECTOR

(CON 1)

AERIAL VIEWOF PINS

Fig. 2 Circuit diagram for a Simple Switch Input board, plus 20-way input connector pinout details

1

1

3

3

5

5

7

7

9

9

11

11

13

13

15

15

17

17

19

19

2

2

4

4

6

6

8

8

10

10

12

12

14

14

16

16

18

18

20

20

(A)

(A)

(A)

(B)

(B)

(B)

BUSBAR

BUSBAR

BUSBAR

BUSBAR

BUSBAR

BUSBAR

ON

S1SPOT R1

CON1

NOTCH

1 2

19 20

1 16 1

10

CUT

CUT

CUT

A PHIZZYB I/O BOARDMAY BE DIVIDED INTOFOUR INDIVI DUA LBOARDS.

CUT(OPTIONAL)

Fig.3. Component layout and connections for the Simple SwitchInput board. Note that section “B” is used (the cutting details areshown on the right).

Page 39: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 108

We will provide all theconstructional and interwiringdetails, and it is all fairly straight-forward. It is emphasized, though,that some of the soldering issomewhat delicate, so a fine-tipped iron and a steady hand areneeded. However, if you con-structed your PhizzyB success-fully, you should have noproblems assembling theseadd-on boards.

INPUT SWITCHESBOARD

The circuit diagram for theSimple Switch Input test board isshown in Fig.2. This consists ofan 8-way dual-in-line (DIL or DIP)switch called S1. You will seethat the inputs to all eightswitches are wired to 5V via pins1 to 8, and their outputs run

directly to a 20-way connectorthat links over to the PhizzyB’sinput port pins (IP0 to IP7).

The switches can be closedto connect their correspondingoutputs to 5V (representing alogic 1 to a real PhizzyB inputport). So, by closing all eightswitches, you would input thebinary number 11111111 to aPhizzyB − always assumingyou've programmed it properly toread from that input port!

Furthermore, all the switchoutputs are connected via a 4k7(4⋅7 kilohms) resistor network(R1) to 0V. This is a way ofensuring that the input lines IP0to IP7 are usually tied low to 0Vand are never left “floating”(unconnected to anything). Theresistor network is self-containedwithin a single-in-line (SIL)package.

Commence construction bycutting a new I/O board into itsfour sections. Start by cuttingalong the middle row of holesspecially provided to help withthis. Use a “Junior” hacksaw or(for example) a Dremel cuttingdisc, and slice the board toproduce two boards.

You may then proceed to fur-ther divide each of these boards

into two if desired, in whichcase it's a good idea to labeleach one as an “A” type or “B”type board. Type “A” boardshave the busbar at the top, type“B” have it at the bottom (withthe IDC connector facing toyour right when looking at thetop side of the board − thenon-track side). File theboard edges smooth.

Note that two “B” typeboards are used for this month'sdemonstrations.

Start assembly by solderingthe 20-way IDC header intoposition on a type “B” board.Look closely to locate pin 1 ofthe connector, referring to thenotches on the molding, or lookfor a small arrowhead to denotepin 1. (See Fig.3.)

The connector should belevel against the board − use asmall piece of Scotch tape (orsimilar) to hold it in placetemporarily during soldering.Each solder joint should takeone or two seconds only anduse only 2mm or so of finegauge solder (e.g. 22 s.w.g.).Take extreme care to ensurethat you do not bridge adjacentjoints with excessive amountsof solder.

Next, solder into place theDIL switch, followed by the SILresistor. Position the compo-nents in the suggested locationsas shown in Fig.3. The resistorarray has a polarity marking,with pin 1 (the “common” pin forthe nine internal resistors − oneresistor is unused) signified bya dot. Ensure it is orientatedcorrectly.

Close inspection of theboard reveals that its coppertrack pattern is formed into“triplets” − a matrix of pads,each being three holes con-

Constructional Project

COMPONENTSResistors

R1 4k7 9-resistor SIL module (Bourns 4610X-101-472)R2 150 Ohm 9-resistor SIL module (Bourns 4610X-101-151)

See also theSHOP TALK Page!

SemiconductorsIC1 74LS540 or 74ALS540 octal bufferBAR1 10-segment DIL red LED bargraph display

MiscellaneousS1 8-way s.p.s.t. DIL switchCON1, CON2 20-way IDC non-latching box header (2-off)

PhizzyB I/O board type "B" (2 off)cut from 4-section I/O board (seetext) available from the EPE Onlinestore at www.epemag.com code7000216 (I/O board); 20-way 0.05-inch IDC connector (4 off); 20-way0.05-inch IDC cable, approx 30cm;solid-core hook-up wire; solder etc.

$20Approx. CostGuidance Only

POLARISING(BUMP)

ARROWHEAD(1)

CORE 1

STRAINRELIEF

CLIP

Fig.4. IDC connector assembly

Page 40: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 109

nected together. There is alsoone continual copper track (thebusbar referred to earlier),which can be used as a powersupply “rail” (for 5V in thiscase).

It will be seen that it isnecessary to join neighboringtriplets together in places by us-ing short jumper wires, formedfrom single-core tinned copperwire, or using insulated wire ifthere is a likelihood of neighbor-ing wires touching each other.Usually, solid-core tinnedcopper wire can be formed intoshape with pliers, often obviat-ing the need for insulation.Wiring should be effective butdoesn't need to look very tidy −you will be doing quite a lotof prototyping like this in thefuture!

Use solid-core jumper wiresto interconnect all the compo-nents as shown. The numberingpattern for the 20-way connec-tor is also given, and jumperwires are used to link thecomponents to the input linesIP0 to IP7 on the connector, aswell as to 5V and 0V powerlines. Closely inspect the sol-dering after assembly, lookingfor short-circuited joints or “dry”(bad or unsoldered) joints.

IDC CONNECTORA 20-way 0⋅05-inch pitch ribbon

cable is used to link the external I/O boards to the main PhizzyBhardware. This uses an industry-standard IDC (insulation displace-ment connector) to produce an ex-tremely reliable connection: insteadof trying to solder to the wires, thewire's insulation is pierced bysharp metal “teeth” and an electri-cal contact is then made to theconductor within, exactly like 3M“Scotchlok” connectors are usedfor car wiring − only infinitelysmaller, and twenty abreast!

The IDC connectors used onthe prototype were also made by3M, incidentally, but there areplenty of other brands available.(IDC connectors are used univer-sally in modern personal comput-ers, to interconnect disk drives tothe motherboard etc.) The generalorientation of the required IDC leadis illustrated in Fig.4. Note that:

1. A “bump” polarizes the connec-tor − this matches a notch inthe 20-way header soldered onthe printed circuit boards

2. A tiny arrowhead is molded intothe IDC connector to indicatepin 1

3. A red stripe on a (gray) ribboncable indicates pin 1 as well.

So that the interconnectionis properly orientated and pin 1on the input board links to pin 1on the PhizzyB input port, thenotches of the connectors mustbe orientated as per Fig.4. Cutthe ribbon cable to length (say,six inches − about 15cms) withvery sharp scissors to make aclean cut.

Feed the end of the ribbononto the connector's “teeth” andpress down the top section justto grip the wire. A strain reliefclamp is applied to the cableafterwards, but because theribbon is doubled back over theplug and clamped down with thestrain relief, the cable mustinitially be fed into the connec-tor from the opposite direction −see diagram. (If you get itwrong, don't worry, becauseIDC connectors can usually bepulled apart again and remade.)

It takes a surprising amountof pressure to fully squeeze theconnector together to pierce theinsulation. Don't worry − theconnectors are very accuratelymade and are remarkablystrong! The prototype leadswere tightened together using asmall bench vice, but any impro-vised method which applies uni-form pressure will be suitable.

Constructional Project

19

7

11

13

15

17

9

1

3

5

I ACK

OP7

OP1

OP2

OP3

OP4

OP5

OP6

OP0

+5V

4

20 N.C.

8

10

12

14

16

18

6

0V

2 IRQN.C. N.C.

N.C. N.C.

CON2

TO 20-WAYCONNECTOR

OP619

OP7

0V

OP415

17OP5

+5V

11

13

5

7

9OP2

OP3

OP0

OP1

9

10

12

11

7

8

14

13

IC174LS5405

6

1

2

3

4

15

16

20

19

18

17

20

19 2

1

N.C.

18

17

3

4

BAR110-WAY

BARGRAPHL.E.D.

16

15

14

13

12

11

5

6

7

8

9

10

10

R29 X 150W 1

(SPOT)

(SPOT)

OUTPUT PORT20-WAY CONNECTOR (CON 2)

AERIAL VIEW OF PINS

Fig 5. Circuit diagram for the LED Bargraph Output board, plus 20- way output connectorpinout details.

Page 41: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 110

hen double-over the rib-bon and push on thestrain relief clip to se-cure everything. Re-peat the procedure forthe other end of the ca-ble: you will see thatthe polarizing “bumps”on both connectorsface the samedirection. You shouldthen repeat this proce-dure for a secondcable, which is neededfor the output board, theconstruction of which isdescribed next.

OUTPUT BOARDThe basic circuit diagram of

the LED Bargraph Output Boardis shown in Fig.5. It contains adual-in-line integrated circuit (a74LS540 or 74ALS540 octalbuffer) which is used as a cur-rent amplifier to drive LEDs di-rectly through current-limitingresistors.

The chip should be treatedas static sensitive, so anti-static precautions are wise (seelast month's constructionalarticle for further guidance). It isrecommended that you use a20-way narrow-type DIL socketto mount it, although the proto-type chip was soldered directlyto the board having double-checked its position first.

Use another type “B” boardand solder the 20-way headerinto position, checking again forpolarity, see Fig.6. Continuewith the 10-LED bargraph array− pin 1 is annotated with achamfered corner, a dot, orother marking, and correctpolarity is important.

The SIL resistor (R2) shouldbe polarized as before, with pin1 being denoted by a spot onthe body. A series of shortjumper wires is needed to hooktogether the components, andthese can again be formed from

Constructional Project

1

1

3

3

5

5

7

7

9

9

11

11

13

13

15

15

17

17

19

19

2

2

4

4

6

6

8

8

10

10

12

12

14

14

16

16

18

18

20

20

CUT(OPTIONAL)

BUSBARCON2

NOTCH

"A" TYPEBOARD

"B" TYPEBOARD

19 20

1 2

IC1

BAR1

1 (SPOT)

R2

10

1

SPOT

Fig.6. Component layout and connections for the L.E.D. Bar-graph Output board.

Assembled switch input board

Assembled L.E.D Bargraph OutputBoard

Assembled L.E.D output board

Page 42: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 111

short pieces of tinned-copperwire.

Then use insulated jumperwires to carefully hook overfrom the integrated circuit to thecorresponding pads adjacent tothe 20-way header. Again thesolder pads of the 20-wayheader are offset in a particularorder and close attention shouldbe paid to the layout used.

After completion, scrutinizeall wiring very closely and theninsert the chip into its socket (ifused) looking for a notch or dim-ple to signify pin 1 (see Fig.2 inlast month's constructionalarticle).

PHIZZYBCONNECTION

In order to use the I/Oboards with your PhizzyB, sim-ply hook them to the mainsingle-board computer using thetwo ribbon cables. Power up thePhizzyB and then download andrun the relevant *.ram fileswhich accompany each demon-stration (these files and the var-ious experiments are detailed inthe related PhizzyB Tutorialelsewhere in this issue). If youhave any problems, werecommend that you:

• Closely inspect the solder-ing, looking for dry(incomplete) joints, or solderbridging adjacent strips onthe prototyping boards.

• Look for wires soldered intothe wrong locations, espe-cially at the 20-way headers(it is easy to make a mis-take).

• Inspect for any specks orpieces of swarf, solder, orwire offcuts, which have be-come stuck amongst the sol-dering.

• Compare the simple circuitdiagrams against your actualwired boards.

• Check for correct orientationof parts and pin numbers.

• Check the correct program isbeing used − open the Simu-lator assembler and re-assemble if necessary.

HELP!Remember that if there are

any queries or problems, theauthors are on hand to help. Forconstructional queries you cancontact Alan Winstanley [email protected].

You can also check the website of Maxfield & Montrose In-teractive www.maxmon.comwhere Max and Alvin can becontacted in relation to thePhizzyB Tutorial. Tell them howthey're doing − they're itching tohear from you!

Next month, we describehow to add a liquid-crystaldisplay to your PhizzyB.

Constructional Project

PhizzyBThis series is written for those wishing to learn what makes com-

puters really tick. The unique PhizzyB (Physical Beboputer) by Max-field & Montrose Interactive Inc. combines both software andhardware to interact between the on-screen demonstrations and theadvanced practical hardware − the PhizzyB − connected to your PCserial port.

Remember that this series is not aimed purely at electronicsenthusiasts, but also computer users and others wishing to train in orlearn about computer operation. Not a lot of previous electronicsexperience is required, basically just an ability to solder and recog-nize components.

Even if you have no particular electronics experience, thenprovided you can solder neatly using a fine-tipped soldering iron,there is an excellent chance that you will be able to solder the hard-ware together and that it will work first time.

RESOURCESThe following items are

available from the EPE Onlinestore at www.epemag.com(prices are in US Dollars anddon’t include shipping and han-dling):

• 4-section PhizzyB I/O board$5.00

• Full working version of thePhizzyB CD-ROM $24.95

• Pre-programmed PhizzyBmicrocontroller $24.95

• PhizzyB main PCB $24.95

A kit of parts for the PhizzyB I/Ocircuits described here in Part 2(including the board) is available

Page 43: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 112

The principle of the hot wirewind-speed indicator(anemometer) depends on anobject, much hotter than its am-bient surroundings, beingcooled by an amount propor-tional to the wind speed. Hereare twosimple methods by which thisprinciple can be utilized.

The circuit diagram shownin Fig.1a uses a self-compensating bridge circuitcontaining an opamp IC1 andan NTC thermistor RTH1 (5k @25°C). On power-up, the opampoutput goes high, which drivestransistor TR1 (an emitter fol-lower) to feed more current intothe bridge circuit comprisingresistors R1, R3 and R4 and thethermistor.

With the values given, thethermistor self-heats until thevalue drops to 1 kilohm (ataround 65°C) when it equals

resistor R4 in value. Equilibriumis then established, so that thecircuit supplies sufficient currentto the thermistor to match heatlosses through conduction orconvection currents around thedevice.

If the thermistor (RTH1) isexposed to air flow, this resultsin a proportional increase in theopamp output voltage, which

will try to maintain the state ofequilibrium. In order to compen-sate for low ambient tempera-tures, a second thermistor(shielded from the wind), couldbe arranged to offer a smallvoltage output of appropriatepolarity.

How an LM317 variableregulator, IC1, could be used inan alternative design is shownin Fig.1b. To self-heat thethermistor in still air so thatits resistance is 1k requires a

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-BasedOscilloscope

• 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 aPico Technology PC based oscilloscopecould be yours.

Every six months, Pico Technology willbe awarding an ADC200-50 digital storageoscilloscope for the best IU submission. Inaddition, two single channel ADC-40s willbe presented to the runners up.

36 b

2

7

4

+

-

R4RTH 11k5k

-t0

R1470

Ohms

R3470

Ohms

R22k2

+24V

0V

Output

IC1CA3140

Figure 1a “Hot-wire” principleAnemometer circuit

VR1220

Ohms

+

-

Output

RTH 1

-t0

C2100n

IC1LM317

ADJ

OUT+30V IN

C11u

+

0V

Figure 1b. Anemometerformed from a variableregulator.

HOT WIRE ANEMOMETER — Blowing Hot and Cold

Page 44: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 113

|voltage across it of around 12Vand a current of 12mA. Hence,preset VR1 should be set to justunder 100 ohms in value. Theregulator output is 13V in still airand rises markedly when thethermistor is exposed to airflow.

A method of displaying theoutput on a microammeter isshown in Fig.1c, and it is also agood idea to decouple the “stillair” quiescent voltage at the sametime. This “still air voltage” couldbe nulled out from thecurrent by using a 15V supply, sothat the meter only registers the“excess” voltage developed bythe airflow.

A.E. Whittaker,Stone, Staffs.

The simple circuit of Fig. 2is suitable for indicating whenyour soldering iron hasreached its operating tempera-ture. It may be used inconjunction with any thermo-static iron such as the WellerTCP series, and it can evenbe used with thermostaticirons that use a low voltagepower supply, and alsoelectronically controlled irons.

The circuit is connected inseries with the mains supply tothe soldering iron. The LEDD1 will illuminate when theiron is drawing enough currentto drop a few volts across re-sistor R1. This means thatwhen the thermostat in theiron switches off, the LED willextinguish to indicate that theiron is ready. The Zener diodeD2 protects the LED againstreverse voltages and limits theforward voltage to 5⋅6V.

With the values shown,load powers of between 45Wand 60W are suitable. Forother powers, resistor R1 isadjusted according to theformula R1=1000/P Ohms,where P is the power of theiron. This ensures about 15mAr.m.s. runs through the LEDwhen the iron is warming up.For R1=22 ohms and an ironof 45W, a normal 0⋅6Wresistor is fine.

Resistor power dissipationis given by the formula …

… watts, where P1 is theiron power and Vs is the mainsr.m.s. voltage.

The circuit must be con-structed within a fully insulatedplastic box and care must betaken to ensure than no metal

mounting screws etc. which areaccessible to the user can be-come live. Usenylon mounting screws.

Jeremy Siddons,Buxton, Derbyshire.

INGENUITY UNLIMITEDBE INTERACTIVE!IU is your forum where you

can offer other readers thebenefit of your ingenuity. Sharethose ideas and earn some cashand possibly a prize!

Ingenuity Unlimited

VR210k

-15V D.C.

0V

Input fromregulator (Fig. 1b)

R2100K

R1100K

uAME1100uA

Figure 1c Moving coil meterdisplay for the anemometerof figure 1b.

SOLDERING IRON “READY” INDICATOR -RED FOR GO

P = 12

P1Vs

R1( )2

MAINSINPUT

R122 Ohms

D2 5V6400mW

R2100

Ohms

MAINSOUTPUT

TO IRON

k a

ka

D1RED LED

Figure 2 Circuit diagram forthe Soldering iron ReadyIndicator. (See text forcomponent ratings.)

Page 45: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 114

Ingenuity Unlimited

NOT JUST 0 AND 1In the context of electronics, the term digital is often considered to refer to components or systems

that use just two voltage levels to represent two logical values (logic 0 and logic 1). Thus, a commonasumption is that “digital” always refers to a two-value set, such as 0 and 1, Up and Down, On and Off,Open and Closed, and so forth.

However, “digital” does not necessarily imply only two values. In its pure sense, a digital value is onethat can be represented as being in one of a finite number of discrete states called quanta. For example,consider a staircase comprising 6 steps mounted alongside a ramp, and also imagine a person slidingdown the ramp. The ramp-slider’s position may be accurately measured using a tape measure, or it maybe approximated to the closest step. In this latter case, we have a digital system comprising six quanta.

BITS AND TRITSToday’s digital computers are composed of large numbers of simple logic gates. As fate would have

it, it’s relatively easy to create logic gates that can generate, and respond to, two distinct voltage levels.For this reason, digital computers internally use the binary (base-2) number system. The term “binarydigit” is usually abbreviated to “bit.”

Some experimental work has been performed with tertiary logic, which refers to logic gates that cangenerate, and respond to, three distinct voltage levels. The digits used in the tertiary (base-3) numbersytem are called “trits.” Working with tertiary systems makes one’s brain ache, so you can be thankfulthat we’re not going to discuss this any further here.

Page 46: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 115

There are two ideas high-lighted this month. The first isassociated with minute connec-tions required within microelec-tronics circuits. The second newdevelopment relates to theperformance that needs to beachieved by integrated circuitstoday.

Even SmallerMiniaturization in electron-

ics is continuing at an ever-increasing rate. To achieve this,one of the main areas forresearch is naturally that ofachieving smaller feature sizeswithin the integrated circuits.New developments in lithogra-phy and the like are all underinvestigation.

However, there are manyother new and interesting ideasthat are equally important to theminiaturization process. In theyears to come, they will makelarge contributions to theincrease in the levelof integration.

Some of these ideas mayseem far removed from thecore electronics business, butthis does not mean to say thatthey will not affect it. In the pastmany ideas that may haveappeared to have no bearing onone area of technology havehad an enormous impact.

In one area of researchbeing undertaken at the GeorgiaInstitute of Technology, nan-otubes are being investigated.These tiny tubes are made fromcarbon and have inside diame-ters measuring less than ten

nanometers! The investigationsbeing performed on theseminute tubes could ultimatelyhave important applications inmicroelectronics where ex-tremely small conductors andother structures are required.

Test Tube ChipsWhilst the work is still in its

early stages, the researchershave been able to put materialsinto the tubes and manipulatethem. By doing this they havebeen able to induce chemicalreactions. This has opened upnew ways of thinking aboutthe structures and they can bethought of as extremely smalltest tubes.

The first stage in producingconductors was to try to deposita conductor on the inside of thewalls of the nanotube. In orderto achieve this, both ends of thetube were opened. Silver nitrate(AgNO3) was allowed to fill thetube by capillary action. Thenthe silver nitrate was decom-posed so that it formed metallicsilver. This was achieved byheating the tubes with a beamfrom an electron microscope.

Initially, the process onlyproduced tiny silver beads inthe tube, because a smallpocket of gas separated eachbead. The gas was underextreme pressure, estimated tobe over 1000 atmospheres. Theultimate idea was to enableminute conductors to be manu-factured that could be used inintegrated circuit manufacture.

Electric LightIt has also been found that

the nanotubes themselves actas conductors. In a phe-nomenon known as ballisticconductance, these minutetubes give very low values ofresistance. It has also beenshown that the heating effectcaused by the current flow ismuch reduced upon what wouldnormally be expected.

Enormous current densitieshave been seen, with values of10MA/cm2 being achieved. Hadthe current behaved in thenormal manner, then this wouldhave heated the tubes to tem-peratures in excess of 10,000K.

Investigations show that thecurrent is flowing in a differentmanner to that normally experi-enced. In this case, the currentis flowing through the nanotubesas if it was light passing throughan optical waveguide.

These effects have onlybeen noted in nanotubes thatare less than 5um in length. Atgreater lengths, the ballisticconductance effect appears tobe destroyed by the scatteringeffect of the electrons.

Whilst the maximum allow-able length of these nanotubesmay limit their usefulness, therewill be many applications withinmicroelectronics. In addition tothis, further development mayenable their applications to beextended. Despite the prob-lems, nanotubes should beanother technique that enablesIC designers to increase the lev-els of integration.

IAN POOLE REPORTS DISCOVERS THAT “TEST TUBE” TAKES ON A NEWMEANING FOR MICROELECTRONICS. AND THAT OXYGENATION EXTENDS CHIPPERFORMANCE.

Page 47: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 116

Silicon on InsulatorThe idea of silicon on insu-

lator (SOI) chips has beenknown for many years. How-ever, they have not been aswidely used as many would like.The problem has been in en-abling them to be made in com-mercial volumes.

Now researchers at IBMhave succeeded in developing aprocess that can be easilyapplied to a whole range ofCMOS processes. In fact, theprocess has been qualified fortheir 0⋅22um CMOS process,and is being developed for their0⋅15um technology. The newadvance results from a processcalled separation by implanta-tion of oxygen (SIMOX).

The advantage of SOI isthat as the device itself sits onan insulating layer its high fre-quency performance is greatlyimproved. This results from twomain effects. One is known asthe “body effect,” where the sizeof the substrate affects theperformance. The other is in thereduction of stray capacitancefrom components in the deviceto the substrate.

As a result, figures for SOIdevices typically show a 35 percent improvement in perfor-mance. This is not only usefulfor RF applications, but also togive the increased speeds

required by today's processorsand associated chips.

In addition to the higherspeeds, the SIMOX process asimplemented by IBM offers thepossibility of better low powerdevices. The reason for this isthat the performance of SIMOXdevices degrades less with volt-age than do conventionalCMOS devices. In testscarried out using SRAMs,SIMOX devices consumedless power for an equivalent ac-cess time.

Cosmic SuccessA final advantage is in the

reliability of memory devices.On occasions, cosmic rays andbackground radioactivity cancause data errors. It is foundthat the level of these errors isreduced with devices fabricatedusing SOI rather than conven-tional CMOS ICs. In fact, theprocess was first developed fordevices to be used in space.Here the levels of radiationare higher, and the degrees ofreliability required are muchgreater.

The process itself involvesthe use of very heavy doses ofoxygen, followed by annealingat high temperature until a thinoxide layer is formed. The over-all result of the process is togive a thin layer of N material

separated from the substrate bya thin oxide layer.

Development of the processhas been hailed a successbecause once the basic SIMOXprocess has been completedthe substrate can be processedin the normal way. As the gen-eration of the insulating layertakes place during the prepara-tion of the wafer itself, ratherthan during the fabrication ofthe components in the device,this can be undertaken off-line.In this way the fab lines are notdisturbed. A further advantageis that it can be added toexisting products, by simplyusing wafers that have under-gone the SIMOX process.

In view of the fact that thisprocess can be incorporatedinto existing lines, the cost of itsintroduction is much less thanone needing a completely newline to be set up. This will meanthat the ICs fabricated using thenew process will soon reach themarketplace.

Also, the cost of the chipswill be less than those requiringa completely new process withall the vast sums of investmentto get them up and running.This is all good news for the enduser who will be able to see im-proved performance for littleadded cost.

New technology Updates

Page 48: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 117

Hello there. Last month weintroduced you to the fantas-magorical and pedagogicalPhizzyB Simulator. If you’re newin town, PhizzyB stands forPhysical Beboputer, a uniquecombination of hardware andsoftware, which comprises acomputer tutorial, demonstra-tion, and application system.

You can program a “virtual”PhizzyB on-screen using thePhizzyB Simulator software run-ning on your Windows 95/98/NTpersonal computer. (If youhaven’t yet invested in a copy ofthe simulator, you can do so foronly $24.95 US Dollars bybouncing over to the EPE On-line Store (www.epemag.com)

Also in last month’s issue,that well-known bon vivant,raconteur, and man about townAlan Winstanley described howto build a real PhizzyB. Onceyou’ve created a program withthe PhizzyB Simulator, you candownload this program to thereal PhizzyB, which connectsvia a null-modem cable to theCOM1 or COM2 serial portson your PC.

In his constructional articleelsewhere in this month’s issue,Alan explains how to constructtwo very simple input/output(I/O) devices, which we can useto test the PhizzyB’s externalI/O ports. For our part, we willbe describing a suite of intro-ductory programs that will bothexercise these devices andteach you more about how thePhizzyB and PhizzyB Simulatorwork.

Note that you can performall of these experiments using

Part 2: Simple Input/Output devices

PhizzyB COMPUTERSUnderstanding Computers

By Clive “Max” Maxfield and Alvin Brown

Welcome to the second installment of a really unique and exciting electronics and computing project.This series of articles will be of interest to anyone who wants to know how computers perform their magic,because it uses a unique mix of hardware and software to explain how computers work in a fun andinteresting way.

This series doesn't assume any great technical knowledge, although an understanding of fundamentalelectronic concepts would certainly be an advantage. You do need, though, to have had some experienceat assembling components onto a printed circuit board. You should also be moderately familiar with usinga PC-compatible computer.

Figure1. The PhizzyB Simulator inter-face, represening a real PhizzyB inter-connected by ribbon cables to a varietyof expansion boards.

Page 49: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 118

only the PhizzyB Simulator, butthey’re a lot more fun if youhave a real PhizzyB to play withas well.

And one last point beforewe commence. If you invokeyour PhizzyB Simulator and se-lect the Help -> Search on HelpContents pull-down menu com-mand, you’ll discover how toaccess the PhizzyB User Man-ual Volume 1, which you canperuse on-screen and also printout for your later reading plea-sure. Amongst other things, thisdocument shows you how touse some of the PhizzyB Simu-lator’s tools and utilities, includ-ing the Assembler, the MemoryWalker display, and the CPURegister display. If you haven’talready done so, we stronglyrecommend you read this man-ual (it’s only about 30 pageslong) and perform theexperiments therein beforeplunging headfirst into the restof this article.

EXPERIMENT 1ATesting ports $F010and $F030

Use Start -> Programs ->PhizzyB -> PhizzyB to invokethe PhizzyB Simulator. Remem-ber that the large board at thebottom of the screen representsthe main PhizzyB (Fig.1), whilethe large board at the top of thescreen represents an expansioncard for use in future projects.

Now use the Tools -> As-sembler command to activatethe assembler and enter theprogram shown in Listing 1(you’ll also find it handy tocheck last month’s article torefresh your memory).

It’s not necessary to worryabout entering spaces to make

your program look identical tothis listing, but the commandsthemselves must be typed inaccurately as shown. Remem-ber that hash characters (‘#’)indicate comments, and anytext to the right of these charac-ters is only there to describewhat the program does.

As you’ll see, the first thingwe do is to assign labels to theinternal input port at address$F010 (the one connected tothe 8-bit switch) and the twoexternal input ports at ad-dresses $F011 and $F012. Sim-ilarly, we assign labels to theinternal output port ataddress $F030 (the one con-nected to the 8-bit LED display)and the two external outputports at addresses $F031 and$F032. In fact we’re only goingto use the INPORT0 and OUT-PORT0 labels in this experi-ment, but we’ll be using theothers a little later. (Note thatthe use of labels is introduced inthe PhizzyB User Manual Vol-ume 1, which we mentionedearlier in this article).

Following the constant labeldeclarations is the .ORGdirective, which sets the startaddress of the program to$4000 (this is the first location inthe PhizzyB’s RAM – see lastmonth’s article for more detailson this). Next we declare anaddress label called LOOP, weuse a LDA (“load accumulator”)instruction to load the accumu-lator from the 8-bit switchesconnected to input port $F010,we use a STA (“store accumula-tor”) instruction to store the con-tents of the accumulator to the8-bit LED display connected tooutput port $F030, and we use aJMP (“unconditional jump”) in-struction to jump back to thelabel LOOP, at which point we

start to do everything all overagain.

Once you’ve entered thisprogram, use the assembler’sFile -> Save As command tosave this file as aaexp1.asm,then use the assembler’s File ->Assemble command (or clickthe appropriate toolbar icon) toassemble this program, whichwill cause the assembler togenerate a machine code filecalled aaexp1.ram.

Iconize the assembler to getit out of the way, then click thePOWER button on the PhizzyBSimulator interface to power-upthe simulator. Use the simula-tor’s Memory -> Load RAMcommand to invoke a dialogoffering a list of the programsthat are currently available.Locate the aaexp1.ram file inthe scrolling list on the left-handside of the display and double-click this entry to add it to theright-hand list. Now click thedialog’s Load button to load thecontents of aaexp1.ram into thesimulator’s memory, then clickthe simulator’s Run (“Ru”) but-ton to execute our program.Initially nothing seems to behappening, but in fact our pro-gram is furiously racing aroundand around reading from the8-bit switches and writing to the8-bit LED display. Click one ofthe 8-bit switches and note thecorresponding LED light up onthe output display. Continue toplay with these switches untilyour appetite is sated, then clickthe Reset (“Rs”) button to let thesimulator take a rest.

EXPERIMENT 1BUsing the real PhizzyB

In order to perform this ex-periment, you must have al-ready constructed your PhizzyB.

Special Projects

Page 50: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 119

If you don’t have a real PhizzyB,you can proceed directly to Ex-periment 2 (although it probablywouldn’t cause you irreparabledamage to read this anyway).

But before we start, if youinvoke your PhizzyB Simulatorand use the Help -> Search onHelp Contents command, you’lldiscover how to access thePhizzyB User Manual Volume 2.Amongst other things, this docu-

ment describes how toinstall the PhizzyB hardwareand configure and use thePBLink utility (which is used todownload programs to thePhizzyB). If you haven’t alreadydone so, we strongly recom-mend that you read this manual(it’s only about 20 pages long)and perform the experimentstherein before hurling yourselfinto the rest of this experiment.

OK, before you do anythingelse, use a null-modem cable toconnect your PhizzyB to theCOM2 port on the back of yourPC (see Alan Winstanley’s Cir-cuit Surgery article elsewherein this issue for more details onnull-modem cables). Note thatthe PhizzyB’s PBLink utility usesCOM2 by default. If you are al-ready using your COM2 port forsomething else, then you canconnect your PhizzyB to COM1,

but you’ll have to configure thePBLink utility appropriately (thisprocess is discussed in thePhizzyB User ManualVolume 2).

Now connect the PhizzyB’spower supply, and note that thevarious displays flash on and offin exactly the same way as didthe simulator’s displays. Use thesimulator’s Tools -> PhizzyB In-terface command to invoke the

PBLink utility. Next use thePBLink utility’s File -> Opencommand to load ouraaexp1.ram file, then use theFile -> Download command (orclick the appropriate toolbaricon) to download this programto your PhizzyB. In order to runthis program, you can eitherpress the Run button on the realPhizzyB, or you can use thePBLink utility’s Control -> Runcommand (or click the appropri-ate toolbar icon) to achieve thesame effect.

As with the simulator, noth-ing seems to be happeninginitially, but once again our pro-gram is furiously racing aroundand around reading from the8-bit switches and writing to the8-bit LED display. Try flippingone or more of the 8-bitswitches (on the real PhizzyB ofcourse) and observe thecorresponding bits respond on

the 8-bit LED display (note thatthe real PhizzyB actually has a10-bit LED display, but only theright-hand 8-bits are used).Once your flipping frenzy hasrun its course, you can eitherpress the Reset (“Rst”) buttonon the real PhizzyB, or you canuse the PBLink utility’s Control-> Reset command (or click theappropriate toolbar icon) toachieve the same effect.

EXPERIMENT 2Testing input port $F011

Restore the assembler to itsnormal size (if you previouslyclosed the assembler thenactivate it again and use it toopen file aaexp1.asm), then useits File -> Save As command tosave your programunder the new name ofaaexp2.asm.

All we’re going to do in thisexperiment is to modify the LDA(“load accumulator”) instructionsuch that it now reads fromINPORT1 (the input port ataddress $F011):

LOOP: LDA [INPORT1]

Now use the assembler’sFile -> Assemble command toassemble this new program,followed by the simulator’sMemory -> Load RAM com-

Listing 1INPORT0: .EQU $F010 #Assign a label to input port $F010INPORT1: .EQU $F011 #Assign a label to input port $F011INPORT2: .EQU $F012 #Assign a label to input port $F012OUTPORT0: .EQU $F030 #Assign a label to output port $F030OUTPORT1: .EQU $F031 #Assign a label to output port $F031OUTPORT2: .EQU $F032 #Assign a label to output port $F032

.ORG $4000 #Set start address to $4000LOOP: LDA [INPORT0] #Load accumulator from input port STA [OUTPORT0] #Store accumulator to output port JMP [LOOP] #Jump to label LOOP and do it again .END

Special Projects

Page 51: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 120

mand to load the resultingaaexp2.ram machine code fileinto the simulator’s memory,then click the simulator’s Runbutton to execute this newprogram.

Try clicking the PhizzyBSimulator’s 8-bit switches. Notsurprisingly nothing happens,because our new program is nolonger reading from this inputport. Instead, our program isnow reading from the externalport at address $F011. If youlook at the simulator’s interface,you’ll see a representation of asmall circuit board at address$F011 (Fig.2). This is a genericdevice that we can use torepresent almost anything wemight wish to connect to thisport (we’ll discuss this aspect ofthings in more detail in futurearticles).

Note that this generic inputdevice has three fields. The top-most field is prefixed by a “%”

character, which is used to indi-cate that this field represents abinary value. The middle field isprefixed by a “$” character,which indicates a hexadecimalvalue. The bottom field doesn’thave a prefix, which means this

field represents a standarddecimal value.

Use your mouse to selectthe top field, enter a binaryvalue of 00110101, and clickthe board’s Set button. The actof clicking the Set button for-mally presents the new value tothe input port, at which point ourprogram can see it and light thecorresponding LEDs on the 8-bitdisplay. Also, clicking the Setbutton causes the hexadecimaland decimal fields on the boardto be updated with their equiva-lent values. In fact you canenter your data into whicheverfield is the most appropriate forwhatever you’re trying to repre-sent at the time.

Experiment by entering afew more values, then click thesimulator’s Reset button. Ifyou’ve built a real PhizzyB (andassuming you’ve constructedthe simple input and outputdevices described in Alan

Winstanley’s article elsewherein this issue), then now wouldbe a real good time to connectAlan’s simple 8-bit switch de-vice to the PhizzyB’s externalinput port at address $F011 (it’sgood practice to power downthe PhizzyB while you’re

connecting external devices).

Now power up the PhizzyB,use the PBLink utility to openyour aaexp2.ram file anddownload it to the PhizzyB, thenpress the PhizzyB’s Run button.Try flipping each of the 8-bitswitches in turn and note thecorresponding LED light up onthe 8-bit display (the bottomswitch corresponds to theright-most LED, and so forth).

In fact, the top-most switch(numbered 1) is the most-significant bit (MSB), while thebottom-most switch (numbered8) is the least-significant bit(LSB). This matches the num-bering scheme of the switchesconnected to port $F010 on themain PhizzyB board, whereswitch number 8 on the right isthe LSB.

Don’t forget to reset yourPhizzyB when you’ve finished.

EXPERIMENT 3Testing input port $F012

Use the assembler’s File ->Save As command to save youraaexp2.asm program under thenew name of aaexp3.asm. Nowmodify the LDA (“load accumu-

Figure 2 Generic input device at port $F011 Figure 3 Generic output device at port $F031

Special Projects

Page 52: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 121

lator”) instruction such that itreads from INPORT2 (the inputport at address $F012) andassemble this new program.Follow the remaining instruc-tions from experiment 2, but thistime test the input port at ad-dress $F012.

EXPERIMENT 4Testing output port $F031

Use the assembler to openour original aaexp1.asm pro-gram and save it under a newname of aaexp4.asm. This timewe’re going to modify the STA(“store accumulator”) instruction

such that it now writes to OUT-PORT1 (the output port ataddress $F031):

STA [OUTPORT1]

Assemble this new pro-gram, use the simulator’s Mem-ory -> Load RAM command toload the resulting aaexp4.rammachine code file into the simu-lator’s memory, then click thesimulator’s Run button to exe-cute the program.

Try clicking the simulator’s8-bit switches and observe thatnothing happens on the 8-bitLED display, because we’re nolonger writing to this port. In-stead, the fields on the genericoutput board connected to the

external port at address $F031update to reflect whatever valueis currently on the switches(Fig.3).

Experiment by entering afew more values, then click thesimulator’s Reset button. Onceagain, if you have a realPhizzyB, now would be a realgood time to connect the simple8-bit LED output device (asdescribed by Alan Winstanley)to the PhizzyB’s external outputport at address $F031. Now usethe PBLink utility to open aa-exp4.ram, download this pro-gram to the PhizzyB, press theRun button, and ensure that

everything is working correctlyin the real world (note that theleft-most switch on the 8-bitswitch device corresponds tothe bottom-most LED on Alan’soutput board, and so forth).

EXPERIMENT 5Testing output port $F032

Save your aaexp4.asm pro-gram under the new name ofaaexp5.asm. Now modify theSTA instruction such that itwrites to OUTPORT2 (the out-put port at address $F032) andassemble this new program.Follow the remaining instruc-tions from experiment 4, but thistime test the output port at ad-dress $F032.

EXPERIMENT 6The AND instruction

Digital computers are con-structed using large numbers ofprimitive logic gates, three ofwhich are known as AND, OR,and XOR (Fig.4).

In the case of the AND(Fig.4a), the output “y” is only“True” (logic 1) if both inputs “a”and “b” are True, otherwise theoutput is “False” (logic 0). Bycomparison, in the case of theOR (Fig.4b), the output “y” isTrue if either “a” or “b” are True.In fact this type of OR shouldmore properly be called an“inclusive-OR,” because theinput combinations that cause“y” to be True include the casewhere both “a” and “b” are True.Contrast this with the XOR or“exclusive-OR” (Fig.4c), inwhich “y” is only True if just oneinput is true, and which there-fore excludes the case whereboth of the inputs are true.

The reason this is of interestto us is that a computer’s Cen-tral Processing Unit (CPU) sup-ports a set of instructions knownas logical instructions, so-calledbecause they perform essen-tially the same logicaloperations as do our primitivegates (Fig.5).

Remember that the PhizzyBpredominantly works withchunks of data that are 8-bitswide, which is why this figurefeatures 8-bit quantities. Theselogical instructions may bereferred to as ”bitwise opera-tors,” because they performtheir magic on a bit-by-bit basis.In the case of the AND, for ex-ample, bit[0] of the first field isANDed with bit[0] of the secondfield to generate bit[0] of theresult, bit[1] of the first field isANDed with bit[1] of the secondfield, and so forth.

(a) 2-input AND

ay

b

yba

010001111

000

&

(b) 2-input OR

ay

b

yba

110101111

000

|

(c) 2-input XOR

ay

b

yba

110101011

000

|

Figure 4 The AND, OR and XOR logic gates

Special Projects

Page 53: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 122

In order to see these instruc-tions “in the flesh” as it were,bring up the PhizzyB’s assem-bler and enter the programshown in listing 2.

Save this file as aa-exp6.asm, assemble it to gener-ate aaexp6.ram, use the Mem-ory -> Load RAM command toload aaexp6.ram into the simu-lator’s memory, and click theRun button to execute this pro-gram. Now enter the value10101010 into the external inputport at address $F011 (don’t for-get to click the Setbutton) and set the 8-bitswitches (input port address$F010) to reflect a binary valueof 00001111. Observe that the8-bit LEDs show a binary pat-tern of 00001010 as was pre-dicted in Fig.5a.

Swap the values betweenthe two input ports and observethat the result remains thesame. This is because the ANDfunction is “commutative,”which means that the result ofthe operation is not affected bythe order in which we specifythe input values (this is also truefor the OR and XOR functions).

Experiment with differentvalues until you’re confident youunderstand how this flavor ofthe AND instruction works, then

click the simulator’s Reset but-ton. If you have a real PhizzyB,connect the simple input switchdevice to the external port ataddress $F011, use the PBLinkutility to download your aa-exp6.ram file to the PhizzyB,and check that the AND instruc-tion works the same way in thereal world. (Don’t forget to pressthe PhizzyB’s Reset buttonwhen you’ve finished).

EXPERIMENT 7The OR instruction

Use the assembler to saveaaexp6.asm to aaexp7.asm,change the AND instruction toan OR, assemble this newprogram to generate the corre-sponding aaexp7.ram file, andload this file into the simulator’smemory. Run this program anduse the values shown in Fig.5bto test that the OR instructionfunctions as expected. Experi-ment with some other valuesuntil you’re happy that the ORholds no further mysteries, thenclick the simulator’s Resetbutton. As usual, if you have areal PhizzyB, download aa-exp7.ram and test this programin the real world (don’t forget topress the PhizzyB’s Resetbutton when you’ve finished).

EXPERIMENT 8The XOR instruction

You know the drill by now!Use the assembler to saveaaexp7.asm to aaexp8.asm,change the OR instruction to anXOR, assemble this newprogram to generate the corre-sponding aaexp8.ram file, andload this file into the simulator’smemory. Run this program anduse the values shown in Fig.5cto test that the XOR instructionfunctions as expected. As usual,if you have a real PhizzyB,download aaexp8.ram and testthis program in the real world.

Note that if you set the 8-bitswitches to a binary value of11111111, then whatever valueyou enter on the external port isinverted (all the 0s are changedto 1s, and vice versa), as canbe seen on the 8-bit LEDdisplay. Similarly, if you set theexternal port to a binary valueof 11111111, then whatevervalue you set on the 8-bitswitches is inverted. Examinethe truth table in Fig.4c and theillustration in Fig.5c and makesure that you understand whythis is so. (Don’t forget to resetboth the simulator and the realPhizzyB when you’ve finished.)

(a) AND

1 0 1 0 1 0 1 0

0 0 0 0 1 1 1 1

AND

=

0 0 0 0 1 0 1 0

(b) OR

1 0 1 0 1 0 1 0

0 0 0 0 1 1 1 1

OR

=

1 0 1 0 1 1 1 1

(c) XOR

1 0 1 0 1 0 1 0

0 0 0 0 1 1 1 1

XOR

=

1 0 1 0 0 1 0 1

Figure 5. The AND , OR and XOR instructions

Special Projects

Page 54: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 123

NOT, NAND, NOR,AND XNOR IN-STRUCTIONS

The ability to invert a valueby XORing it with another valueof all 1s can be very useful,particularly in the case of thePhizzyB. In addition to the AND,OR, and XOR as discussedabove, many CPUs support aNOT instruction that inverts thecontents of the accumulator(that is, swaps the 0s for 1s andvice versa), and also the NAND,NOR, and XNOR instructions,which stand for “Not AND,” “NotOR,” and “eXclusive NOR,”respectively.

However, when we de-signed the PhizzyB we wantedto make it as simple as possi-ble, so it only supports the AND,OR, and XOR instructions. Butturn that frown upside down intoa smile, because all is not lostand your “quality of life” is notgoing to suffer. As we’ve seen,we can effect the samefunctionality as a NOT instruc-tion by XORing the contents ofthe accumulator with all 1s.Let’s call this a “pseudo-NOT.” Ittherefore follows that we canimplement a NAND by

performing an AND followed bya pseudo-NOT, and similarlyfor the NOR and XNOR func-tions.

THE CPU’S STATUSREGISTER

In last month’s article wenoted that the PhizzyB’s CPUcontains an 8-bit register calledthe accumulator (ACC), which ituses to store (accumulate)intermediate results. In fact the

CPU also contains another reg-ister called the status register,where the bits forming the sta-tus register are commonlyreferred to as status bits orstatus flags (Fig.6).

Due to the fact that we mayrequire to load the status regis-ter from the memory (or storeits contents in the memory), it isusual to regard this register asbeing the same width as thedata bus (8 bits in the case ofthe PhizzyB). However, thePhizzyB only actually employs

Listing 2

INPORT0: .EQU $F010 #Assign a label to input port $F010INPORT1: .EQU $F011 #Assign a label to input port $F011OUTPORT0: .EQU $F030 #Assign a label to output port $F030

.ORG $4000 #Set start address to $4000LOOP: LDA [INPORT0] #Load accumulator from input port 0 AND [INPORT1] #AND the contents of the accumulator #with the value from input port 1 STA [OUTPORT0] #Store accumulator to output port JMP [LOOP] #Jump to label LOOP and do it again .END

CPU

~reset

clock

I = Interrupt mask flagO= Overflow flag

Z = Zero flagC= Carry flag

N= Negative (sign) flag

Accumulator[7:0]

Status register [7

:0]

C

O

Figure 6. The Status Register LED display used on thehardware PhizzyB.

Special Projects

Page 55: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 124

five status flags, which occupythe five least-significant bits ofthe status register. This meansthat the three most-significantbits of the register exist only inour imaginations, so their non-existent contents are, by defini-tion, undefined.

This month we are onlygoing to consider two of thePhizzyB’s status flags: the Neg-ative (N) and the Zero (Z) flags:

The negative (N) flag: Thisflag, which is also called thesign flag, typically contains acopy of the most significant bitin the accumulator following anoperation on the computer. Thisflag is called the “negative flag”because a logic 1 in the most-significant bit of the accumula-tor indicates a negative number(this assumes that the value inthe accumulator is being re-garded as a signed, two’s com-plement value – we’ll discusssigned numbers in more detailnext month).

The zero (Z) flag: This flag ispredominantly used to indicatewhether or not the accumulatorcontains a value of zero follow-ing an operation on the accumu-lator. However, we should notethat this flag is also used to indi-cate the presence or absence ofa zero condition in the indexregister following INCX(“increment index register”) orDECX (“decrement indexregister”) instructions. The zeroflag is also used to indicatewhether or not two numbers areequal following a CMPA(“compare”) instruction.

Note the 8-bit LED displayjust to the right of the 7-segment displays on the simula-torinterface. The 5-bits marked “I”,“O”, “N”, “Z”, and “C” reflect thecurrent contents of the corre-sponding flags in the status reg-

ister. With regard to these flags,we also need to be aware of aconvention as follows:

Setting: A status flag is said tobe "set" if it contains a logic 1,which is used to indicate aTRUE condition. For example, ifthe zero flag is set (contains alogic 1), this indicates that: "It'sTRUE to say that the currentvalue stored in the accumulatoris zero" (that is, all of the bits inthe accumulator contain logic0s).

Clearing: A status flag is saidto be "cleared" if it contains alogic 0, which is used to indicatea FALSE condition. For exam-ple, if the zero flag is cleared(contains a logic 0), this indi-cates that: "It's FALSE to saythat the current value stored inthe accumulator is zero" (that is,one or more of the bits in theaccumulator contain a logic 1).

Unfortunately, this conven-tion can appear somewhatcounterintuitive (especially inthe case of the zero flag) and ittakes a little effort to wrap yourbrain around it the first time yousee it, but you'll find that it reallydoes make a lot of sense onceyou get into the swing of things.Trust us on this, have we everlied to you before? (Don’t an-swer that!)

EXPERIMENT 9The zero and negative flags

Activate the PhizzyB’sassembler, open your originalaaexp1.asm file, save this file

under the new name of aa-exp9.asm, then assemble it togenerate the correspondingaaexp9.ram file. Before you doanything else, use the assem-bler’s Window -> View ListingFile command to look at thecorresponding list file aaexp9.lst(Fig.7)

List files are discussed inmore detail in the PhizzyB UserManual Volume 1, which wementioned earlier in this article.For our purposes here, we needonly note that our LDA (“loadaccumulator”) instruction occursat address $4000, the STA(“store accumulator”) appears ataddress $4003, and the JMP(“unconditional jump”) ends upoccupying address $4006.

Use the simulator’s Memory-> Load RAM command to loadthe contents of aaexp9.ram intothe simulator’s memory. As youwill recall, this program loopsaround loading the accumulatorwith the value on the 8-bitswitches connected to the inputport at address $F010, andwriting these values to the 8-bitLED display connected to theoutput port at address $F030.

Before we execute thisprogram, ensure that all of the8-bit switches are in their “Off”positions (that is, with the redbits towards the bottom). Now,as opposed to using the Runbutton, click the simulator’sStep (“St”) button instead. Thiscauses the simulator to stepthrough the first instructionwhich loads the value on theswitches into the accumulator.

00008 .ORG $400000009 4000 91 F0 10 LOOP: LDA [INPORT0]00010 4003 99 F0 30 STA [OUTPORT0]00011 4006 C1 40 00 JMP [LOOP]

Figure 7 Part of the list file for program aaexp9

Special Projects

Page 56: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 125

Note that the program counter(PC) 7-segment displays nowshow a value of $4003, which isthe address of the next instruc-tion to be executed (the STA inthis case). More importantly, theZero (“Z”) flag on the 8-bitstatus register display has lit upto indicate that the accumulatornow contains a zero value.

Click the Step button again,which causes the value in theaccumulator to be stored to the8-bit LEDs at output port $F030(the reason nothing seems tohappen is that the accumulatorcontains zero of course). Notethat the PC displays update toshow a value of $4006, which isthe address of the next instruc-tion to be executed (the JMP).Now click the Step button onemore time, which executes theJMP instruction and returns usto address $4000.

Click the right-most switchon the 8-bit switch device, andnote that nothing happens to theZero flag because we haven’tloaded this value into the accu-mulator yet. Now click the Stepbutton to execute the LDAinstruction, and note that theZero flag is extinguished, be-cause the accumulator now con-tains a non-zero value. Click theStep button once more to exe-cute the STA instruction, andobserve the right-most bit onthe 8-bit LEDs at output port$F030 light up. Then click Steponce again to execute the JMPinstruction, which again returnsus to address $4000.

Now click the left-mostswitch on the 8-bit switchdevice and click the Step buttonto load this new value into theaccumulator. Remembering thatthe Negative (“N”) flag typicallycontains a copy of the mostsignificant bit in the accumulatorfollowing an operation on thecomputer, it should come as no

great surprise to see that thenegative bit lights up on thestatus register display.

Experiment by setting othervalues on the 8-bit switch inputdevice and stepping through theprogram until you are confidentthat you understand how thesetwo flags function (insofar asthe context of this experiment).Assuming that you have one, itwould be a good idea to down-load this program to your realPhizzyB and to repeat thisexperiment in the real world.Don’t forget to reset thesimulator and the PhizzyB whenyou’re done.

EXPERIMENT 10Conditional jumps

Fear not my braves,because this is the last of ourexperiments for this month(phew!). One of the mainreasons that computers are sopowerful and versatile is thatthey have the ability to deter-mine future actions based onthe results of previousoperations. The way in whichthis works is that the CPUunderstands special instructionscalled “conditional jumps.” Thismeans that these jump instruc-tion will only occur if specificconditions are true, and theseconditions are based on thevalues of the status flags.

Remembering that we’reonly considering the Zero (“Z”)and Negative “N”) flags at themoment, there are fourconditional jump instructionsassociated with these flags:

JZ = “jump if zero” (jump ifthe zero flag is true/logic 1)

JNZ = “jump if not zero”(jump if the zero flag is false/logic0)

JN = “jump if negative”

(jump if the negative flag istrue/logic 1)

JNN = “jump if not negative”(jump if the negative flag isfalse/logic0)

To understand how thisworks, we’re going to write asimple program that reads avalue from the 8-bit switchesconnected to the input port ataddress $F010 and writes thisvalue to the 8-bit LEDs con-nected to the output port ataddress $F030. But there’s atwist, because if the left-mostswitch is “On” (which meansthat it’s connected to a logic 1),then we’re going to invert thevalue (swap 0s for 1s and viceversa) before we write it to the8-bit LEDs.

Consider the flowchart inFig.8 and compare it to thecode in Listing 3. As per someof our earlier programs, the firstthing we do is to load the accu-mulator with the value on the8-bit switches. The act of load-ing the accumulator automati-cally updates the Zero andNegative status flags.

For the purposes of this par-ticular program, we want tocheck to see if the most-significant bit in the accumulatoris a logic 1. We know that theNegative flag is a copy of themost-significant bit in the accu-mulator, so all we really have todo is to check the value of thisflag.

If the Negative flag is False(contains a logic 0), then all wewant to do is to store the valuein the accumulator to the outputport driving the 8-bit LEDs. Butif the Negative flag is True(contains a logic 1), then wewant to invert the value in theaccumulator before we store it.One way to achieve this is touse a JNN (“jump if not nega-tive”) instruction, which will jump

Special Projects

Page 57: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 126

to a specified location if theNegative flag contains a logic 0.However, if the Negative flagcontains a logic 1, then the JNN

will fail and the program willsimply proceed to the next in-struction, in which we invert thecontents of the accumulator byXORing them with a value of all1s ($FF in hexadecimal =

11111111 in binary).

Enter the programshown in Listing 3 into theassembler, save it under thename of aaext10.asm, as-semble it, load it into thesimulator’s memory, and runit. Experiment byplacing different patterns onthe 8-bit switches and ob-serve that whenever the left-most switch is in its “On” po-sition, the resulting patternappearing on the 8-bit LEDsis the inverse of thepattern on the switches. Whenyou are happy that this is so,download this program to thePhizzyB and ensure that itfunctions the same way in thereal world.

HOMEWORK ANDFURTHER READING

You probably feel prettyconfident that you’re on top of

things at the moment, but it’salways easy to do somethingwhen you’re following someoneelse’s instructions, so let’s seejust how much your confidenceis justified shall we? Starting

from scratch, create a programthat loops around loading theaccumulator with values fromthe 8-bit switch device. Depend-ing on whether the left-mostswitch is “Off” or “On,” AND orOR the value in the accumula-tor with whatever value is pre-sent on the input device con-nected to the external port ataddress $F011, then display theresult on the output device con-nected to the external port at

address $F031.

Now use the simulator’sHelp -> Search on Help Con-tents command to activate theonline help, and then select theitem in the main page marked

Begin

Load ACC from $F010

Is "N"flag true

?

XOR ACC with $FF

Store ACC to $F030

Jump back to $4000

no

yes

Figure 8, Flowchart for pro-gram aaexp10

Listing 3INPORT0: .EQU $F010 #Assign a label to input port $F010OUTPORT0: .EQU $F030 #Assign a label to output port $F030

.ORG $4000 #Set start address to $4000LOOP: LDA [INPORT0] #Load accumulator from input port 0 JNN [STORE] #If N=0 jump to label STORE XOR $FF #.. otherwise invert contents of ACCSTORE: STA [OUTPORT0] #Store accumulator to output port JMP [LOOP] #Jump to label LOOP and do it again .END

Special Projects

Page 58: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 127

The Official Beboputer Micro-processor Databook. Westrongly recommend that youread Appendix D before nextmonth’s article, because thisAppendix contains a ratheruseful introduction to the Bebo-puter’s (and hence thePhizzyB’s) assembly language.

BUT WAIT, THERE’SMORE!

Next month we will intro-duce the Carry (“C”) and Over-flow (“O”) flags, unsigned andsigned binary numbers, and thestack and subroutines. Mean-while, in his construction pro-

ject, Alan Winstanley will beshowing you how to build a sim-ple LCD output display, andwe’ll be using our newfoundknowledge of subroutines tocreate a program to drive thislittle rascal.

Last but not least, we’ll in-troduce a little PhizzyB pro-gramming competition, the win-ner of which will receive ayear’s free subscription to theprinted version of EPE. Untilthen, we remain …… fond ofice cream! Best regards, Maxand Alvin.

Be sure to check out thismonth’s constructional article.

Computer simulation of the assembled PhizzyB printedcurcuit board

Special Projects

Page 59: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 128

Whether you are a student ofcomputers, a hobbyist, or just aninterested observer, every nowand then you’ll come across aterm, abbreviation, or mnemonicthat’s unfamiliar, but where canyou turn to discover what the littlerapscallion means? Well fear notmy braves, because AlanFreedan is riding to the rescuewith his celebrated ComputerDesktop Encyclopedia (see the“Free Demo and Special Offer”section at the end of this article).

IT WAS A DARK ANDSTORMY ....

Working for a major com-puter company as I do (IntergraphComputer Systems, Huntsville,Alabama, USA, I often receiverequests for information on com-puters, 3D graphics subsystems,and suchlike. So I wasn’t too sur-prised when one of my col-leagues handed over a caller re-questing information on 3D tex-ture processing algorithms. Whatdid surprise me was when thiscaller − Alan Freedman − pro-ceeded to bounce around fromtopic to topic with the agility of amountain goat, asking questionson everything under the sun.

It was only when I managedto get a word in edgewise that Idiscovered Alan was the creatorof the CD-ROM-based ComputerDesktop Encyclopedia, which isthe subject of this review. As Iwas to discover, once Alan hasdiscovered someone who canquench his thirst for definitions

.... well, you can run, but youcan’t hide!

THE MAN, THEMYTH, ...

Alan’s first experience withcomputers was with punchedcard data processing in 1960,but as he says “We could lookat the computers, but weweren't allowed to touch!” Infact it was three years later thatAlan first laid his hands on areal computer when he startedprogramming in IBM 1401 as-sembly language. With 38 yearsin the industry, Alan describeshimself as “One of the oldestliving relics in the computerfield!” Alan is also fond of point-ing out that he’s just like BillGates (because they bothdropped out of college).

In 1980, Alan started workon a project called The Com-puter Glossary, which formed acompendium to his computerliteracy seminars for managers.Due to the fact that Alancouldn’t find a good computerdictionary, he instead bought hisfirst microcomputer (a VectorGraphic) and used the CP/M-based Memorite word processorto pen the first edition (330terms − 60 pages) with hugeKroytype headers hand pressedonto each page by his adoringwife, Irma.

The end result of this hum-ble beginning was the longest-lived computer dictionary in his-

tory... some 300,000 books sold(including Spanish, Portuguese,and Korean versions), alongwith 125,000 official copies ofhis CD-ROM-based Glossaries/Encyclopedias (1,500,000copies unofficially!)

In 1996, the 7th edition ofthe Computer Glossary becamean abbreviated version, whilethe 1st edition of Alan’s newComputer Desktop Encyclope-dia, continued as the expanded,full-bodied version. Alan workedpart time on his glossary/dictio-nary from 1980 to 1987, andthen began to work on them fulltime from 1987 onwards. As hesays: “I am one of the longestlived computer lexicographersin the world ... I may even bethe only full-time computer lexi-cographer anywhere (noticehow many people are clamoringfor the job)!”

INSTALLATIONThe Computer Desktop

Encyclopedia works on any PCrunning Windows 3.1, Windows

The Computer Desktop EncyclopediaBy Clive “Max” Maxfield

Alan in a thoughtful moment(photo by Etti Palitz)

Page 60: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 129

95, or Windows NT, andinstalling it is as easy ascan be. Once you’veplaced the CD in the driveand used Start -> Run toactivate the “install.exe”program on the CD, youare presented with threeoptions:

a) To only install anicon and to run the rest ofthe encyclopedia directlyfrom the CD.

b) To install all of thetext, but only essential il-lustrations (the remainingillustrations and imagesare accessed directly offthe CD).

c) To install the textand all of the graphicsonto your main hard drive(this results in the fastestresponse, but requires90MB of disk space onyour drive.

Following the installa-tion, you can invoke theencyclopedia using Start ->Programs -> Computer DesktopEncyclopedia (or if you’veplaced a shortcut on yourdesktop you can simplydouble-click it).

USING THEENCYCLOPEDIA

Out of all the tools I’veplayed with, Alan’s encyclope-dia has one of the easiest-to-use interfaces. The left-handside of the screen contains ascrolling index, while the right-hand side contains the body ofthe encyclopedia. Above theindex is a “Look-up” field. Whileyou are entering a word into thisfield, the index automaticallyscrolls to the required entry(double-clicking on any indexentry immediately loads thattopic into the main window).

Alternatively, you can entera word into the “Search Text”box, then repeatedly pressingthe <Enter> key on your key-board will jump you through theentire encyclopedia to succes-sive instances of this keyword.

One key aspect to the inter-face is that EVERY word in themain document acts as a hyper-link. This means that if you areperusing a topic and see an un-familiar (or interesting) term,simply clicking on that term im-mediately takes to you the re-lated topic.

Another aspect to this inter-face (which Alan created espe-cially for this encyclopedia) isthat it is amazingly FAST! Theinterface can bounce from topicto topic in a heartbeat on evenrelatively slow machines.

OTHER USEFUL FEATURES

In fact the interface is re-plete with simple, easy to use,yet surprisingly useful features,including the fact that phoneticentries such as “scuzzy,”“gooey,” and “morray” will linkyou to the correct topics of“SCSI,” “GUI,” and “moiré,” re-spectively. The fact that yourlookups are automaticallyrecorded and saved is also use-ful, as are the Topic Lists whichlet you explore subjects system-atically, along with the Windowsquick references, tutorials, and“how to’s.”

MORE THAN 12,000ENTRIES

The Computer Desktop En-cyclopedia provides more than

Special Review

Page 61: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 130

Special Review12,000 definitions, illustrations,photos, diagrams, and charts,from microprocessors to main-frame computing concepts. Thetopics include PCs, MACS,UNIX, networking, clients andservers, graphics, multimedia,the Internet, the World WideWeb, standards, major productsand vendors, tips and tech-niques, and anecdotes andepisodes.

Fundamental concepts areexplained in depth, providing aclear perspective for the begin-ner, while the wide range ofacronyms, buzzwords, technicaldrawings, charts, diagrams, andspecifications provide invalu-

able references for power users.And for history buffs, there aregreat photos of early machines,the first supercomputers, andthe founders of the computerindustry.

SPECIAL OFFER!With only a little arm twist-

ing, Alan has kindly agreed tooffer a special 20% off deal forreaders of EPE Online. A singlecopy of the encyclopedia CD is$31.95 US dollars to EPE On-line readers (the usual price is$39.95), plus shipping and han-dling.

You can purchase the ency-clopedia from the EPE OnlineStore at www.epemag.com

Page 62: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 131

Robert PenfoldSERIAL L.C.D REMOTE MONITOR FOR YOUR PC

Serial LCD Remote Moni-tor for your PC

In a previous Interface arti-cle (Sept '98) (of the printedEPE magazine, Ed.) weconsidered the subject of using“intelligent” liquid crystal display(LCD) modules as a simpleform of monitor for a PC. Inter-facing to the PC was via the“easy route” provided by aparallel printer port. Some read-ers prefer to use a PC serialport wherever possible, becausetheir PC has a spare serial port,but the parallel port or ports areoccupied. Serial interfacingalso has a potential advantagein that it can be used with longconnecting cables, and in thisapplication a simple two-wirelink is all that is needed. Thisopens up the possibility of usingan LCD module as a remotemonitor for a PC.

As explained in pre-vious Interface articles,operating your PC add-ons via a serial port isinevitably morecomplex than using aparallel port. One reasonfor this is simply that theinterface mustinclude parallel-to-serialand (or) serial-to-parallelconversionsin addition to themain circuit of youradd-on device.

There can also beproblems with a lack of hand-shake lines. A serial port doesactually have handshake inputsand outputs, but these only pro-vide basic on/off control of thedata flow. Your add-on may re-quire something more than this,and it is often necessary to im-provise in order to obtain thedesired result.

A serial interface is alsorelatively slow, but this does notmatter in all applications, andis of no significance in the cur-rent context. An ordinary serialinterface can transfer one or twokilobytes per second, which issufficient to rewrite the displayin a fraction of a second.

Input

2.4576MHzOscillator

4-Stage BinaryCounter

Inverter/Converter

UART

C-RDelay

Counter/Latch

Inverter

LCDModule

DR DRR RS

E

8-Bit Databus

Fig.1. Block diagram for the Serial LCDMonitor for your PC.

Fig.2. Full circuit diagram for the Serial LCD Monitor for your PC.

Page 63: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 132

PERFECT TIMINGThe block diagram of Fig.1

helps to explain the way inwhich this serial interface forLCD modules functions. Asexplained in the previous Inter-face article, it is possible to readinformation from the modules,but in normal operation this isunnecessary. Accordingly, thisLCD interface can write data tothe module but it cannot readany status information from it.

The serial to parallel con-version is provided by a 6402UART (universal asynchronousreceiver-transmitter), and in thiscase only the receiver device isutilized. No connections aremade to the transmitter sectionof the device.

Due to the lack of anyclock or other timing signals, thetransmitting and receivingdevices can only be accuratelysynchronized by using standardtransmission rates. This inter-face is designed to operate at9600 baud, which means thatbits are sent at a rate of 9600bits per second.

The UART's clock signalis at 16 times the requiredbaud rate, which works out at153⋅6kHz for a baud rateof 9600. This is provided by a2⋅4576MHz crystal oscillatorand a four stage (divide by 16)binary counter circuit.

NEW DATARS232C serial interfaces

do not use normal 5V logiclevels, but instead operate withnominal signal voltages of plusand minus 12V. The input signalmust therefore be processedto produce an output at normallogic levels for the UART. Also,the raw input signal is of thewrong polarity and must be

inverted before it is fed to theUART. A single transistorinverter stage is all that isrequired to provide this signalconditioning.

As soon as bytes of datahave been decoded they areplaced onto the 8-bit output ofthe UART. This is fine as far asit goes, but the LCD module hasno way of knowing when newdata is present on the data bus.Each time new data is placedon the bus a strobe pulse mustbe applied to the enable (E)input of the LCD module. The“data ready” output of the UARTgoes high each time new data isplaced on the outputs, and thisflag can be reset by taking the“data reset ready” input of theUART low.

In this interface the data“ready output” is automaticallyreset by feeding it from the“data ready reset” output via aninverter. A simple C-R circuitprovides a delay that stretchesthe output pulse produced at the“data ready” output, and thisensures that it reliably latchesdata into the LCD module.

SHORT-COMINGSThis still leaves a major

short-coming, in that two typesof data are written to themodule. Initially two or threebytes of data are written to themodule to set it to the correctoperating mode, and the“register select” (RS) input ofthe module must be held lowwhile these instructions aresent. Then the “register select”input is taken high, and furtherbytes of data are interpreted ascharacter information.

The simple system used inthis interface has a counter thatholds the “register select” inputlow for the first three bytes of

data, and holds it highthereafter. This enables themodule to be set up in therequired manner, and it canthen be fed with the relevantdata information.

There is an obvious flaw inthis arrangement, which doesnot permit the module to be setback to the command mode topermit cursor positioning.Despite this limitation the inter-face is perfectly usable, and itis just a matter of using themode of operation that automat-ically scrolls the display eachtime it receives a new byte ofdata. The cursor remainsstationary and the displayscrolls to the right, rather thanvice versa.

If necessary, with this modeof operation the screen can becleared simply by writing aseries of spaces to the moduleso that any existing charactersare scrolled of the end of thedisplay. Admittedly thisscrolling method of operationis relatively crude, but it keepsthe interface reasonably simple,and also avoids complicationsin the software.

CIRCUIT DETAILSThe full circuit diagram for

the Serial LCD Remote Monitorfor PC interface appears in Fig.2. Transistor TR2 is used in theinverter stage at the serial input,and it operates as a simplecommon emitter switch. Theclock oscillator uses TR1 in aconventional crystal oscillatorcircuit, and IC1 is the four stagebinary divider. The 4024BEused for IC1 is actually aseven-stage divider, but in thiscircuit only the first four stagesare used. As suggested by the“universal” part of its name, theUART (IC2) can handle any nor-

InterFACE

Page 64: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 133

InterFACE

mal serial word format. Its con-trol inputs are hard-wired for op-eration with one start bit, eightdata bits, one stop bit, and noparity checking. A long positivereset pulse is required at switchon, and this is provided bycapacitor C4 and resistor R6.

The eight data outputs ofIC2 connect direct to the corre-sponding inputs of the LCDmodule. Potentiometer VR1 isthe contrast control for thedisplay module, it is adjustedfor the best display quality.

DATA READYThe “data ready” output of

IC2 (pin 19) drives inverter TR3by way of a simple C-R timingcircuit that is comprised of resis-tor R7 and capacitor C5. Theinverted signal at the collectorof TR3 drives the “data readyreset” input of IC2 (pin 18).

As explained previously,this produces a positive pulseeach time fresh data is placedon the outputs of IC2. Thispulse is fed to the “enable” inputof the LCD module (pin 6) toindicate that new data is avail-able, and it is also fed to theclock input of IC3 (pin 14). Thelatter is a 4017BE decadecounter and one-of-10 decoder.

The LCD module's RS input(at pin 4) is driven from output 4(pin 10) of IC3's decoder sec-tion, which goes low at switch-on when IC3 is reset by thesame reset circuit that is usedfor the UART. After three bytesof control data have been writ-ten to the LCD module, output 4goes high, taking the moduleinto the mode where it treatsreceived data as character in-formation.

It also takes the “inhibit”input of IC3 high so that further

of serial port used on your PC.Connection details for bothtypes of port are provided inFig. 3. (This figure shows therear, solder-side view of theconnectors to be used on eitherend of the serial lead, but youshould check the type used byyour own PC before buying anycomponents. Incidentally, thismonth’s Circuit Surgery furtherclarifies the pin-numberingscheme used on 9-pin and25-pin D-type connectors.)

SOFTWAREThe interface will only work

properly if the serial port is setfor the correct baud rate andword format. From MS-DOSthis is achieved using the Modecommand. For serial ports oneand two respectively, use thecommand “com1:96,n,8,1,” or“com2:96,n,8,1,”.

The easiest way of sendingserial data is to write informa-tion to the base address of theappropriate serial port. This iseither &H3F8 for serial port one,or &H2F8 if you are using serialport two.

As the Serial LCD RemoteMonitor for PC interface doesnot use any form of handshak-ing, it is necessary to provide ahold-off to prevent data frombeing written at an excessiverate. The speed of the system is

pulses at the clock input haveno effect. After the initial threebytes of data the LCD moduletherefore treats all further dataas characters to be displayed.

POWER POINTDue to the use of CMOS

integrated circuits and a liquidcrystal display, the total currentconsumption of the circuit istypically less than 10mA. Thereis no 5V output available from aPC serial port, but methods ofobtaining a suitable supply fromone of the other ports have

been described in previ-ous articles. If you havea fairly modern PC, itmight be worthwhile in-vestigating its USBports, as these can pro-vide a 5V supply output.

The connections tothe serial port are madevia a 9-way or 25-wayfemale D-connector,depending on the style

1 13

14 25

TX Data GND

1 5

6 9

TX Data GND

Fig.3. Connection details forboth types of PC serial port.

Page 65: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 134

InterFACE

limited by the rate at which theserial interface can transferdata, and with a baud rate of9600 just over one milli-secondis required per byte of data.

The accompanying GW-BASIC listing sets the displaymodule to the correct mode ofoperation and then transferssingle characters from thekeyboard to the module. Notethat the GW-BASIC INPUTfunction will not accept a spaceas a valid character for a textstring, and that entering a spacewill terminate the program withan error message.

Line 20 assigns a value of&H2F8 to the variable SPORT(serial port), and this is theaddress of serial port 2. If youare using the interface on serialport 1, a value of &H3F8 mustbe used here instead.

The next six lines of theprogram output three bytes ofdata to the display, and theseset it to the correct operatingmode. First a value of 48 setsthe display to single line opera-tion, 8-bit data transfers, andthe normal 7 x 5 font. Then a

value of 14 switches on thedisplay and selects a visible butnon-blinking cursor.

Finally, a value of 5 sets theentry mode, and in this case thecursor is set to stay at the left ofthe display with the on-screencharacters scrolling one place tothe right each time a new |character is received. A subrou-tine provides a delay thatensures the data is not writtento the display too quickly.

CHARACTER LOOPThe next part of the pro-

gram is a loop that waits for acharacter to be entered at thekeyboard, and the RETURN keyto be pressed. It then outputsthe corresponding ASCII valueto the display, which should pro-duce the appropriate characterimmediately to the right of thecursor.

The program loops indefi-nitely so that you can enter asmany characters as you like, butthey must only be entered oneat a time. The usual CONTROL-BREAK combination willterminate the program.

Entering a dollar ($) signcauses the program to branch tothe subprogram at line 200. Thisloops the program 40 times,writing a space (ASCII value 32)to the LCD module on eachloop, so that the screen iscleared.

There is a minor irritationwhen using the LCD module inthe right scrolling mode, whichis that the text strings have tobe written in reverse order!Thus, in order to display “Hello-World” it is actually “dlroW-olleH” that has to be written tothe display.

Additional NotesFor your interest, an abso-

lutely excellent two-part articleon how to use these displaysappeared in the February andMarch 1997 issues of EPE. Foryour further reading pleasure,specially re-formatted PDF ver-sions of this article are availablein the EPE Online Web site (inthe “Library”) atwww.epemag.com

Page 66: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 135

Null Modems andD-connectors

If you're interested inlearning about how computerswork, and how to use your PCto program and control externalcircuitry, you need look nofurther than our new PhizzyBComputers series. Thiscombines an interactivedemonstration tool with a realhardware PhizzyB connected toyour serial port.

You can then assemble aprogram on your PC using thePhizzyB Simulator editor, anddownload it using the PBLinkutility to a real PhizzyB. You canthen run the same program bothon your PC as well as the realthing: the real hardware versionwill then interface to other add-on units including (next month)a Liquid Crystal Display.

The PhizzyB requires a nullmodem serial cable to be used

to connect to the “host” PC.Such cables are also usedwhen connecting one PC toanother, to enable games orfile transfers between twoPCs. The TxD (“transmitdata”) and RxD (“receivedata”) signals cross overwithin the cable, to connectthe transmit data of one portto the receive data of theother, and vice versa.(Magenta Electronics offer afull kit (or ready assembled)PhizzyB, and they can alsosupply the null modem cable,see my PhizzyBconstructional articleelsewhere in this issue).

Some bucket-part PCshave serial ports mounted onthe chassis with a separateoff-board bracket and ribboncable, whilst many serial portsmount directly onto themotherboard. The latter typeseem to be more common and

use 9-pin D-connectors, but wehave come across someexamples where 25-pin serialports are used.

The numbering scheme for9-pin and 25-pin D-type femaleconnectors, as used in thesuggested null-modem lead,seen from the rear (solder) viewof the sockets is shown inFig.1a. However, things can getvery confusing, especially whencomparing female and male D-connector numbering schemes,which are mirror images of oneanother.

Note the sequence ofnumbering on the D-connectorsin Fig.1b, where this time theyare compared with the pin viewrather than the solder view. In afemale connector, pin 1 is top-right, but is top-left in a maleplug as shown. Obviously if youturn the plug around to insert itinto the socket, then you willsoon see that the pin numbersof both components allcorrespond.

This stands to reason andlooks obvious, but it can be veryconfusing especially whenconfronted with D-connectorsfor the first time. Luckily,manufacturers often annotatethe pins of their connectors inthe plastic molding just to besure, but whenever you areinterpreting any interwiringdiagrams, you can saveyourself some wasted effort anddelicate soldering by doublechecking whether the diagram isthe solder view or the pin view,and whether it's a female ormale connector!

To round off this topic, Fig.2 shows the interwiringdiagrams for 9-pin and 25-pinnull modem leads. All views are

We take a quick look at null modem leads for PhizzyBfollowers, and we check out relay ratings and light-dependent resistors too, with a simple light-dependentswitch circuit

by ALAN WINSTANLEY

5 11 5

9 66 9

9-PIN FEMALED-CONNECTOR(RECEPTACLE VIEW)

9-PIN MALED-CONNECTOR(PIN VIEW)

4 23 32 4

8 77 8

Fig.1b. Comparison of theschemes for 9-pin D-type maleand female connectors, takenfrom the receptacle or pin view.The same principle applies tolarge connectors.

1 5 1 13

6 9 14 25

9-PIN FEMALE(SOLDER SIDE VIEW)

PIN 5 - SIGNAL GROUNDPIN 3 - TxDPIN 2 - RxD

25-PIN FEMALE(SOLDER SIDE VIEW)

PIN 7 - SIGNAL GROUNDPIN 2 - TxDPIN 3 - RxD

Fig. 1a. Pin numbering schemes of 9-pin and 25-pin female D-type connectors, shown from ‘solder’ view.

Page 67: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 136

of the solder-sides of theconnectors. Be sure to confirmthe type of serial port used onyour own PC before youpurchase any parts, though.

Pull-ups and RelaysMr. Harsh Mehta had a

variety of queries as follows:

Can you provide me someguidance with the followingqueries? I would like to knowwhat is the use of Pull-Up andPull-Down resistors and how dothey function?

Also, with mechanicalrelays I found the followingspecifications. 24V D.C./220VA.C. What does this mean? Arethere A.C. and D.C. relays?How do they work? Last of all,what is a Photo Cell and howdoes it work?

the PhizzyB constructionalarticle this month, in which aseries of switches are hooked toa PhizzyB input port ( Fig. 3).

The inputs to the switches(S1 to S8) are all wired to 5V(logic high) and the outputsconnect directly to the inputdata bus of the PhizzyB via a20-way ribbon cable. If any ofthe switches are open (off) thenthe corresponding input dataline could be left “floating”(unconnected) in anindeterminate logic state, whichmay affect the reliability of thedata read by the PhizzyB fromthat port. Hence it was decidedto force all unused inputs low byusing 4k7 pull-down resistors.

Rather than use separatediscrete resistors, we utilized asingle-in-line (SIL) package,which contains nine resistors allcommoned together (one isunused). This common isconnected to 0V (logic low), toproduce a convenient bank ofpull-down resistors. (By wiringthis terminal high to 5V, a seriesof pull-up resistors could becreated instead.)

Obviously, the common pinmust be correctly identified andwired low, hence the need toidentify it as pin 1. In the caseof the specified Bournsresistors, pin 1 is marked with adot on the body.

Relay ContactsYour question on relays

next. The two main aspects tocheck are the contact ratingsand the relay coil values. Arelay manufacturer such asOmron will quote the followingvalues for the coil and thecontacts.

The maximum switchingvoltage is the maximum opencircuit load voltage that can be

There's quite a lot to dealwith, so let's start with yourquestion concerning pull-upresistors. These are used inlogic circuits to ensure that alogic input is normally biasedtowards a logic “1”, say 5V; thenwhen a logic 0 signal comesalong, the input is taken low bythe signal.

Conversely, a pull-downresistor biases that point to logic0 (the 0V rail) instead. This isnecessary if you want to ensurethat a particular point is firmlyheld at a logic high or low, inbetween data being received bythat input.

In discrete logic circuits,ordinary resistors can be usedwhose values are notparticularly critical (say 10k(kilohms) or so for bipolar, or1M (megohms) for CMOS). Agood example will be seen in

Circuit Surgery

5

1

5

1

1

1

5

13

9-PIN TO 9-PIN

9-PIN TO 25-PIN

9-PIN TO 9-PIN

PIN 5 TO PIN 5PIN 2 TO PIN 3PIN 3 TO PIN 2

9-PIN TO 25-PIN

PIN 5 TO PIN 7PIN 2 TO PIN 2PIN 3 TO PIN 3

PHIZZYB

PHIZZYB

PC

PC

BACK

VIE

W

BACK

VIE

W

BACK

VIE

W

BACK

VIE

W

Fig.2. Interwiring for 9-pin and 25-pin null modem leads. Fe-male connectors are used throughout, although you shouldcheck the connector used on your PC first.

Page 68: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 137

switched by the relay contacts.You will often see both d.c. anda.c. values quoted.

The maximum switchingcurrent is not surprisingly themaximum current (a.c. or d.c.)which the contacts are able tointerrupt without damage. Thismay sometimes belower than the carrycurrent, which is the(higher) value thecontacts can handleproviding they don'thave to interrupt thecircuit as well.

Bear in mind that acertain amount of relaycontact arcing andswitch bounce willoccur when the load isswitched, whicheventually causes thecontacts to pit and“soot up”: the makerswill obviously restrictthe maximum valueswhich the contacts canbe expected to switchreliably. Somewhathigher currents canoften be carried by thecontacts if they are notexpected to switch at thoselevels.

Another specification is themaximum switching capacity,which is the maximumpermissible contact load inWatts or VA. This is notnecessarily the same as thevalue obtained by multiplyingthe maximum contact ratings (inVolts and Amps) together, as itdepends on the load beingswitched.

A simple resistive load(such as a large heatingelement) is “kindest” to relaycontacts, but if complexelectrical loads are used(including inductors, motors orfluorescent lighting, which

include a power factorcorrection capacitor) the relaycontacts must be de-ratedsubstantially as per the load'sVA rating. I'm not too sure whya minimum switchingcapacity is sometimes quoted, Iguess it relates to the minimum

load required to overcomecontact resistance and electricalnoise.

Other parameters for thecontacts are usually less critical,and include the operate timeand release time, inmilliseconds. Whether oneperiod is greater than the otherdepends on the mechanicaldesign of the relay.

A figure of 10ms to 15ms istypical for a large power relay,but a small telecommunicationstype relay used in a modemcould switch in 3ms. (Figuresfor contact bounce times of say0⋅3ms to 0⋅5ms can sometimesbe quoted which can be criticalto the work of telecoms or logicdesigners.)

Coil RatingsLooking next at the coil

ratings, two values will bespecified, the coil voltage andits resistance. As you spottedfor yourself, you can buy botha.c. and d.c. voltage coils.Flicking through a relay

manufacturer's catalogue,one popular range of plug-in relays includes both a110V d.c. coil (resistance9,300 ohms, current 12mA− as calculated by Ohm'sLaw), and a 110V a.c. coil(1,800 ohms 20mA).

The current drawn bythat a.c. coil depends onits a.c. resistance orinductive reactance (whichis why Ohm's Law doesn'twork!), so a.c. and d.c.coils should not beconsidered asinterchangeable merelybecause their voltagerating is the same. Somea.c. coils may be specifiedat 50Hz or 60Hz operationor “dual frequency”,remembering thatfrequency has a bearing

on the reactance of a coil andthe current drawn.

The d.c. coil's resistance isof interest to hobbyists, becauseusing Ohm's Law we cancalculate the direct currentneeded by the coil, and then theadditional circuitry can bedesigned (e.g. using a transistorbuffer − see Circuit Surgery lastmonth). Don't forget to use areverse diode across a d.c. coil,to shunt out the enormous back-e.m.f. that a relay coil generateswhen it switches off.

This is created when themagnetic field which surroundsthe coil suddenly implodes backinto the windings and induces avoltage in the coil. A 12V coilcan produce as much as 300V

Circuit Surgery

IP7

IP6

IP5

IP4

IP3

IP2

IP1

IP0

S1 - S8

+5V

0V

TO PHIZZYBINPUT PORT

SI L RESISTOR'COMMON'CONNECTION

. . .

R1 - R8PULL-DOWNRESISTORS(8 x 4k7)

Fig.3. PhizzyB input port experiment, using 8-way DIP switch and a SIL resistor network forpull-down resistors.

Page 69: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 138

Visit our Web site at www.epemag.com

In our library you will find:

♦ Alan Winstanley’s internationally aclaimed andinvaluable guide to soldering

♦ An amazingly useful article on LCD displays

♦ And much, much more!

Circuit Surgeryreverse e.m.f. which is clearly apotential source of trouble forany components in the samecircuit.

If much larger loads are tobe controlled (such as giantpumps or process machinery),industrial engineers will employwhat is effectively a hugeversion of a power relay − aclunky device called acontactor, which has separatecoil and contacts mountedtogether in a control box, alongwith stop/start push-buttoncontrols. Check any of the largercatalogues for details.

Light-dependent switchLooking at your final

question, a “photo cell” is just thepopular name coined for a photo-conductive cell, which is nothingmore than a light-dependentresistor (LDR) based on cadmiumsulphide (CdS). They respond tolight in the visible and infra redspectrums.

An LDR should not beconfused with a “photo-voltaiccell” which actually creates asmall voltage relative toincidental light levels. In the

golden days of EverydayElectronics magazine, using anLDR in a project (e.g. my world-beating Auto Nightlight of July1978 vintage) always impliedusing the ORP12, asmanufactured at the time byMullard. There are severalalternatives readily availabletoday.

As a final wrap this month,Fig. 4 shows a suggested circuitbased on a transistor Schmitt

trigger, which combines an LDRwith a transistor-driven relay toproduce a light-dependentswitch suitable for dusk-to-dawnswitching. Just the thing forthese winter months!

Component values are notcritical, and you should not beafraid to substitute for otherparts to hand. See you nextmonth!

bc

e

bc

e

b

c

e

+9 - 12V D.C.

R315k

R25k6

VR122k

R63k3

TR1BC548

TR2BC548

TR3BC558

D1LED. . .

RLA1

185 D21N4001

C11µ

R1ORP12

0V

PL1 SK1

LOAD

RLA1

a a

k

k

ON

Fig.4. A light-operated, “snap action” circuit using an LDR (light-dependent resistor R1) as a sensor to control a transistor-drivenrelay. Components are not critical and preset VR1 sets theswitching level.

Page 70: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 139

Welcome to this month'sNet Work, our columnspecially written for In-ternet users.

PLIGHT OF THENAVIGATOR

Microsoft Internet Explorer4 recently arrived in my officeas an unwelcome guest prein-stalled on a new Dell computer.After delivery, Step One was todisable the Active Desktopwhich I found gimmicky, point-less and irritating. Step Two wasto attempt to configure all myDial-Up Networking connec-tions, and my E-mail software.Unfortunately things rapidlywent downhill, with recurrentmodem nightmares, crashesand re-boots galore and otheranomalies. And no I haven't gotWindows 98 (thanks).

A dozen phone calls to Delland Microsoft, a new mother-board, a new memory, threemodems and several on-sitevisits later, two technical sup-port representatives suggestedthat one way of curing problemsmight be to type “ieremove” atthe Run line, and therebyde-install Microsoft InternetExplorer 4. In the event, wedecided to give it up as a badjob and my shiny new PC had tobe shipped back to Irelandanyway, and − credit to DellComputer Corporation − it wascollected within five hours of mycomplaining.

Upon its return, I wasn'tsurprised to see that Explorer 3had been installed as thedefault web browser: I would

have done the same myself.When I queried this, though, itwas suggested that if I pro-ceeded to re-install Explorer 4, Iought not to use the ActiveDesktop which has been knownto “cause problems.” As attoday, not having the ActiveDesktop installed may nowcause a problem as well,because my very latest versionof Hot Metal Pro 5 requires −you guessed − the Active Desk-top to be enabled if I am toaccess all of Hot Metal's fea-tures. The only alternative, saysSoftquad, is to use Windows 98.

I guess this will be thepattern of events for the nextyear or two. Anyway, just for therecord, I am delighted to reportthat the PC hasn't misseda beat, and as an anonymouscustomer I found Dell'sCustomer Service highlycommendable.

BLACK SPOTI was soon to find that using

version 3 of Explorer created afew problems of its own, whenaccessing the web sites ofMicrosoft and Dell in search ofpatches and drivers. Both sitesuse Active Server technology.My attempts at navigatingaround their web sites repeat-edly came to a dead end,because of an error message“The object has moved and maybe found here.” Trying to jump“here” caused my session togrind to a frustrating halt; funnilyenough the only way forwardwas to return fully armed withNetscape Navigator 4.0. Exactlythe same happened with myCompuServe browser which I

resurrected on the new PC.(The latest release of NetscapeNavigator is V4.5, by the way:more at www.browsers.com)

For many experienced PCusers, Microsoft Internet Ex-plorer 4 is still one upgrade toomany which they can probablyquarantine alongside Windows98. Unfortunately, the depen-dency of some web sites ondisplaying properly (if at all)only if a certain browser is used,is as frustrating for users asever. Let us also not forget themyriad of browser plug-insextolled by some web sites:checking the BT Home Highwayweb site(www.highway.bt.com), forexample, I found that the use ofMacromedia Shockwave didlittle to present the data behindBT's sales pitch more effec-tively than a web site full ofstatic HTML would have done,only the Shockwave-enabledsite took far longer to visit andtherefore told me less in thetime available. Some usersmay find the images of spinningmotorway signposts captivating,though.

SOFTWARESELECTION

Several popular FTP pro-grams are available via the In-ternet and the rule is to fetch ashareware version and then buythe one which works for you.Features to look out for includean automatic "reget" of trans-fers, which means that ifinterrupted, the transfer can berestored from where it left off,rather than having to fetch the

Alan Winstanley

SURFING THE INTERNET

Page 71: EPE_12-1998

EPE Online, December 1998 - www.epemag.com - 140

entire file again. Also, the abilityto store sessions (the configura-tion, URL, passwords and otherset-up data) related to particularFTP sites is useful. This monthI've provided a list of some In-ternet software tools worthchecking.

Absolute FTP is sharewareand is said to boast an Explorer-type interface, drag-and-dropfile transfers, reget, plus theability to run simultaneoustransfers from multiple FTPsites, bandwidth permitting. Trywww.vandyke.com for moredetails. For Macintosh users,Anarchie Pro (v3.0) is nowavailable fromwww.shareware.com withenhanced web support, offlinebrowsing, and an improvedgraphical front end.

Terrapin FTP and TerrapinPostbox (E-mail client) are atwww.terra-net.com and CuteFTP is available from

www.cuteftp.com. I like thelooks of Crystal Art Software'sCrystal FTP (www.casdk.com)which installed and worked in-stantly. It has a handy-looking"Quick" button and could be justthe thing for struggling Windowsusers. Web site maintainersmight also enjoy Crystal SiteUp-dater [sic] from the same site. Ithelps with the publishing, syn-chronization and validation ofweb sites, but it hasn't beentested by me. FTPPro98 is anExplorer-style FTP client fromwww.ftppro.com, and BulletPro FTP looks particularly at-tractive at www.bpftp.com.

FTP Explorer fromwww.ftpx.com has similar con-trols to Microsoft Windows Ex-plorer, which beginners mightappreciate, and Anawave(noted for its “Websnake” soft-ware) offers a W95 FTP clientinterface called FTP Icon Con-nection at www.anawave.com.

Another popular Macintosh FTPapplication is Fetch fromwww.dartmouth.edu.

WinZIP (now in version 7) isthe totally indispensable Win-dows Zip utility for compressingor decompressing files. A handybrowser add-on means that youcan view the contents of zippedfiles in your browser, withouthaving to unzip them sepa-rately. Buy it! More fromwww.winzip.com. “Zip up theWeb” is a W95/NT freewareutility which (it says here) en-ables you to zip up and E-mail acollection of web pages withoutfacing the chore of downloadingthe text and graphics. It createsa self-executable file of the webpages, which you can E-mailonwards. It's atwww.shareware.com.

I welcome your suggestionsfor links to share with fellowreaders. E-mail ideas [email protected].

Net Work

Bebop BYTES Back(An Unconventional Guide to Computers)By Clive “Max” Maxfield and Alvin BrownFree CD-ROM, 870 pages, $39.96 US Dollars (plus S&H)

This follow-on to Bebop to the Boolean Boogie is a multimedia extravaganzaof information about how computers work. It picks up where the first Bebop leftoff, guiding you through the fascinating world of computer design ...... and you'llhave a few chuckles, if not belly laughs, along the way. In addition to over 200

megabytes of mega-cool multimedia, the accompanying CD-ROM (for Windows 95 machines only) con-tains a virtual microcomputer, which simulates the way a real computer works in an extremely realisticmanner. In addition to a wealth of technical information, myriad nuggets of trivia, and hundreds of carefully drawn illustrations, the book contains a set of lab experiments for the virtual microcomputer. If you're the slightest bit interested in the inner workings of computers, then you don't dare to miss this little beauty!

Available from the EPE Online Store at www.epemag.com