Download - Constructional Project VERsfrTILE PIg F&ASHEfr · Constructional Project VERsfrTILE PIg F&ASHEfr STEVE CHALLINOE Enhance your Chrrstmas decorations or your child's ceiling with this

Transcript

Constructional Project

VERs��frTILEPIg F&ASHEfrSTEVE CHALLINOEEnhance your Chrrstmas decorations oryour child's ceiling with this versatilePlC-controlled flasher display

eHINI this design was an idea tomake an interesting ceiling displayfor a child's bedroom. One of the

author's colleagues had seen a display ofblue lights in a shopping centre and want-ed to know if the author could duplicatethis.

The lights needed to be slowly increas-ing and decreasing in brightness andbehaving in a random fashion. Therebywas perceived a means by which the authorcould lull his own insomniac toddler tosleep, and so set to work immediately!

TAKE YOUE PICBasing. the system on a PIC micro-

controller, it was found that the resultswere so pleasing that it was thought tobe of interest to EPE readers - butabsolutely no guarantee about the sleepremedy!

The original idea has been expandedto create a number of different effects,so that apart from the slow and soothingbedroom display, quite a number ofother display options are possible. Pre-programmed PICs are available as stat-ed later for the benefit of readers whodo not have PIC programming facilities.

There are five dual-inline (d.i.1.)switches which select a total of thirty-two possibilities. There are eight out-puts, but the light emitting diodes(l.e.d.s) may be chained together tomultiply this number. There is too muchgoing on to notice if two or more l.e.d.sare doing the same thing!

APPLICATIONSApart from the ceiling display, one

variant is a wall display, with a lumi-nous moon crescent mounted on a circleofblack card and eight blue l.e.d.s scat-tered over the rest of the circle. Anotheris a star, again for wall mounting, with21 l.e.d.s of different colours. Again thisis a wall display but it would make anexcellent star for the Christmas tree, orwhy not a miniature tree for the interiorof the car? There must be many imagi-native applications.

852

Although an l.e.d. display was in mindfrom the outset, the open collector outputscan sink up to 500mA, thus it would alsobe possible to drive filament bulbs. Thiscould drive the Christmas tree lights in anew way (after substituting a normal bulbfor the flasher bulb). This only applies tolow voltage types, though, with a +24Vsupply and multiple strings of low voltagebulbs. However, this article only discussesthe l.e.d. version.

F€AD IN SPEED, MOOUUTIONFFOM SWITCHES STOFE IN FAM

GETMARK FROM ARRAYSTORE IN FAM

SET PEAPD =25s

Fig.1. Flow chart for the PIC Flasher.

Looking at his own tree lights in thisway, which are +24Y and have eightstrings of ten 2.4Y bulbs, the author won-dered is this could be matched using thePIC. However, the problem was the way inwhich the strings were interlaced, whichseemed like a headache to sort out!

The star display is found to be mosteffective where all the l.e.d.s can be seentogether. The ever-changing outputs createa fascinating display.

LIGHTTNGCONCEPT

Ideally, the light output should be ana-logue, with the l.e.d.s varying from fullyon to fully off. However, the author refusedto entertain the idea of eight digital-to-ana-logue converters with associated drivers.

Instead the circuit uses Pulse WidthModulation (PWM), with themark/space ratio controlling the bright-ness of the l.e.d.s - space fully off,mark fully on.

The mark is obtained from an arrayin programmed PIC memory whichmay be termed the brightness profile.Thus one complete cycle, from off tomaximum and back to off again isobtained as the program reads in valuesfrom the whole array. However, eachoutput has a slightly different arraylength, giving a continual shift in phasebetween the outputs and hence anapparently random effect.

Each value of marVspace is repeateda number of times to give control overthe speed of flashing. Referring to theflow chart in Fig.1, the core operation isthe central loop where the mark isdecremented to see whether to output ahigh or a low. The output is set high aslong as the mark is non-zero, then lowfor the rest of the period (the space).

This is repeated up to eight timesaccording to speed and then for everyother mark in the array (about two hun-dred of these) at the same time as jump-ing about between all eight outputs.This keeps the PIC busy enough not torequire delay routines, with the oscilla-tor running at top speed, 20MHz.

CTRCUIT DIAOEAMReferring to the circuit diagram in

Fig.2, switches Sla and S1b set thespeed. Switches Slc and S1d controlthe depth of modulation, meaning how

Ev e rt day P ractic aI E le c tronic s. D e c emb e r 2 002

far from fully on the l.e.d. goes towardsoff, i.e. selecting just a central portionof the brightness array. Thisgives a pulsating effectiather than-an on/offflash. ffi

Switch S 1e selectsbetween two bright-ness profiles. One is .,!.,'smooth, but the otherhas a high speed flash builtinto the profile. The speed is 'ii

related to the controls set bv the iI

other switches, and at higher ':I

speeds gives an "icy shimmer"the disolav. Table 1 summarisessettings for the switches.

The PIC16F84A microcontroller isshown as IC1 and is run at 20MHz, as setby crystal Xl. Note that the "ordinary"

PICI6F84 (without the 'A" suffix) is nolsuitable for this design since it has notbeen manufactured to run at the 2OMHzrate required.

The switches Sla to Sle are biased nor-mally high by frve resistors. These arewithin a single resistor module, marked asRMl. The status of the switches is read bythe PIC's Port A lines, RAO to RA4.

The l.e.d.s are controlled by the PIC'sRBO to RB7 lines. They control theswitching of transistors TRl to TR8, viacurrent limiting resistors Rl to R8. As saidearlier, the transistors are used in open-col-lector mode to drive the l.e.d.s, with resis-tors R10 to Rl7 limiting the current flow.

The PIC16F84A's Port B is capable ofsourcing a maximum of l00mA or sinkingl50mA, so it would be feasible to directlycontrol eight single Le.d.s. However, theprovision of the open collector transistorsallows several l.e.d.s to be chained togeth-er for this larger display.

The number chained will depend on thevoltage supply, with roughly l.8V per

ResistorsRM I 10k S-way commoned

resistor module. s. i . l .R1 to Rg 10k (8 off)R 9 1 kR10 to R17 see Table 2

SeeSH@

Capacitorsc1, c2c3, c5c4

tor the

Table 1: Mode switches settings(0 = switch on)

Sla S lb SpeedFastMedium fastMedium slowSlow

Slc Sld Modulatlon100%50y"25"/o12.5%

Sle ProfileSmoothFlash

l.e.d. required (double this for blue orwhite) with enough voltage left over toprovide a sensible current limiting resistor.

TALKpage

10p ceramic (2 off)100n ceramic (2 off)100p radial elect. 10V

SemiconductorsD1 to D8 l.e.d., see text regarding

quantities and stylesTR1 toTRS B�C337 npn transistor

(8 otf)rc1 Plc16F84A

microcontroller,preprogrammed(see text)

lC2 78L05 +5V voltaoeregulator

MiscellaneousS1 S-way d.i.l. switch, p.c.b.

mounting20MHz crystal2-way terminal block,

p.c.b. mounting (5 off)2.1mm d.c. power socket,

p.c.b. mounting

Printed circuit board. available tromthe EPE PCB Service, code 377; 18-pind.i.l. socket; display construction material(see text); connecting wire; solder, etc.

0 01 00 11 1

0 01 00 11 1

X1TB1

sK1

01

r-----------I

+VE

MCLR

TOCKVRA4

DIO/F87

RA3

CLKR86RA2

RAo rc1

Prc16F84ARAl RB4

R83

tN RB2

RB1

OUTINT/RBO

TBlEAND

Tgl/10{coMMoN}

IprsPrA'/s]TB1/1 TO e

+VE{SEFTEXTI

TPov,,EBl

Fig.2, Complete circuit diagram (except power supply - see brt) lor the Versatile PIC Flasher.

Everyday Practical Electronics, pecember 2002 853

,r.4fr 'hfi--t",M;../:LTT lii:l ui:-r 4p\r;8E--Wd:jt. *Y@,,;rno(ll'6-3-5 "-cdf --g

+ *" in-r iffi .,.|

Fig.3. Flasher printed circuit boardcomponent layout, full-size copper foilmaster and lead-off wires to the l.e.d."chains".

Table 2 shows suitable resistor values touse with a power supply of +12V or +24Y.These values are very conservative as thepeak current is only reached at the peak ofthe profile, and this is only a very smallpart of the overall cycle.

It is worth considering which l.e.d.s touse to suit ambient lighting conditions. Fornormal room lighting, "standard" l.e.d.sare far too dim, although for a night-timeceiling display they would be fine.However, for use in a normal room lightingsituation, super-bright, ultra-bright andeven hyper-bright Le.d.s are available with

l ro prsPlAysl

's'

output intensities comparable withfilament bulbs, and these will be suitablefor the majority of applicatrons.

In the prototype, diffused 5mm Le.d.shaving 400mcd intensity were used. Theyprovide a wide viewing angle which works

. -qf

L.E.D.s secured

s '*"'"rff,oJr'l;:nr.. ,, hot-melt glue.

very well for wall displays. Should youwant to go for even larger displays, there isan abundance of different intensities andsizes available to choose from.

Voltage regulator IC2 provides the PICwith the +5V required. The regulator maybe fed with any d.c. voltage between about7V and 24V or so. The l.e.d.s are poweredfrom the input voltage supply, not by the+5V from the regulator.

CONSTRUCTTONThe printed circuit board (p.c.b.) compo-

nent and track layout details are shown inFig.3. This board is available from the EPEPCB Service, code 377.

Assemble the board in order of compo-nent size. Use a socket for the PIC16F84A,ICl. Do not insert the PIC until you havechecked the correctness of the output volt-age from regulator IC2.

The prototype p.c.b. was glued to theback of a Christmas Star and Moon cutfrom stout card. Holes were ounched intothe card and the l.e.d.s pushed through andsecured using holt-melt glue.

E

N

#

Table 2: L.E.D. current limiting resistor values for +12V and+24V power supplies

L.E.D.s peroutput(n) Red/YellowlGreen

R10 to R17 at 20mABlue White One Blue OneWhlte

+n(B/Y/G) +n(BfY/G)

12a

4

470Q39003300220c2

+12V Power Supply

390sl' : "

470Q27:a

270Q220fJ120s]

330O220eJ15:a

e

4

6

1 K820s,680f2560O

+24V Power Supply

560()390()220c2

680c2560Q390A220A

680e)560Q470f2390e2

820f)680O560O4709.

Completed p.c.b.showing the

power socket andl.e.d. connecting

blocks.

vr

o €

ffifrtltl8,ffiF+rl rl..c

F ccF.-..c.r F-.--......4

854 Ev e ry day P rac ti c al EI e c troni c s, D e c e mb e r 2 002

There are no great requirements for thepower supply. A plug mounted typeshould suffrce, with a rating of 250mA.There's no necessity for it to be regulatedeither, as the PIC is powered via the +5Vregulator.

Having completed the assembly,apply power (without thePIC inserted) and checkthat the output voltageftom IC2 is +5V. Alwavsdisconnect the power supplybefore making changes to theconstrucnon.

With the programmed PIC inserted,check again that the +5V output fromIC2 is correct. If the flasher doesn'twork straight off check that the l.e.d.sare connected the right way round.

SETTINE UP llluminated colouredl.e.d.s on the com-pleted festive star.

Prototype wall mounted luminous"moon" with blue l.e.d. "stars" mountedon the black "skf.

The l.e.d. quantity and the order inwhich they are connected is entirely up tothe user.

Remember, though, that each l.e.d. has avoltage drop across it and so there is a limitto the number of l.e.d.s that can beconnected in series in relation to the powersupply voltage. There is also a limit to thenumber of l.e.d.s that can be used in paral-lel without overloading their driving tran-sistor, or the power supply.

Having wired up the l.e.d.s, there arethen just two extemal wires required, to thechosen power supply.

Using the d.i.l. switches and refening toThble 1, the maximum display speed shouldbe selected together with maximum modu-lation (the l.e.d.s should go from fully offtofully on) and with a smooth brightness pro-file. Then it's just a matter of finding themost suitable settings according to situationand taste. There are thirty-two possibilities.

SOFTWAREThe software is available for free down-

load from the EPE ftp site. This is most eas-ily accessed via the main page of tJ;re EPEweb site at www.epemag.wimborne.co.uk.At the top is a click-link saying X'TP site

(downloads), click it then click on PUB andthen on PICS, in which screen you will findthe Versatile PIC Flasher folder.

The software can also be obtained on3.5-inch disk (Disk 5) from the Editorialoffice. There is a nominal handling chargeto cover admin costs. Details are given onthe EPE PCB Service page, and in thismonth's Shoptak, which also gives detailsabout obtaining preprograrnmed PICS.

Enjoy yourdisplay ofPICNoelogy! n