This is only a preview of the November 1998 issue of Silicon Chip. You can view 28 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "The Christmas Star":
Items relevant to "Turbo Timer For Your Car":
Items relevant to "Build Your Own Poker Machine":
Articles in this series:
Articles in this series:
Items relevant to "Lab Quality AC Millivoltmeter; Pt.2":
Articles in this series:
Articles in this series:
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
The Christmas Star
What’s this? A Christmas project in November?
Well, we were so taken with this cute little project that we
just had to run it this month so that readers would have
plenty of time to build it for Christmas. It’s a Christmas
“star” which lights up its
LEDs in a seemingly
endless variety
of patterns.
Build it to add
that “something
different” to
your Christmas
tree. Or put it in
the front window
to impress the
neighbours!
The PC board has just one IC to
drive 30 LEDs which are arrayed
in a five-pointed star. But we can’t
show you what the star looks like
since the LEDs constantly flash in lots
of different ways.
Sometimes the LED “points” of the star
will flash, then they will rotate, then reverse direction, then the whole star lights
up from the centre outwards and so on.
The circuit uses just one IC and yet the
range of flashing patterns seems endless,
although it does actually repeat the
sequence after a minute or so.
With such a simple circuit producing such a variety of patterns
the conclusion is inevitable.
Yes, the IC is a microprocessor
otherwise it would not be able
to produce such a huge variety.
The PC board is five-sided
and is quite small, suitable
for mounting at the top of
your Christmas tree if you
want. It is powered by a
9V DC plugpack and has
an onboard 5V regulator.
The microprocessor is
an Atmel AT89C2051,
a relatively recent derivative of the very
common 8051. It
comes in a 20-pin
plastic package
and contains 2K
18 Silicon Chip
bytes of program memory, 128 bytes of
RAM, 15 programmable I/O lines, on-chip
oscillator, two 16-bit counter/timers, six
interrupt sources and a full duplex serial
port (UART).
This all sounds very much like a small 8051
until we add that the program memory is re-programmable Flash with 1000 erase/write cycles,
the oscillator runs to 24MHz (double that of
the original 8051), the I/O pins can sink
20mA for directly driving LEDs and two
I/O pins are connected to an on-chip
analog comparator.
In other words, it is a somewhat
souped-up 8051 and it can drive the
LEDs direct, without any other circuit
components.
This project started just before
last Christmas when my daughters
asked “Why don’t we have any
flashing Christmas tree lights?”
So, while they were out shopping, my son and I grabbed a
dozen LEDs, some ribbon cable
and a microcontroller. While
my son wired up the LEDs, I
wrote some simple software. It
was all installed and running
when they came home after
spending all my money.
That’s why we didn’t have
lights before... The smiles
on their faces made it all
worthwhile!
I then resolved to do
by LES GRANT*
something better for this coming
Christmas. And here is the result.
Why use a Microcontroller?
Using a PC’s parallel port to control
external devices is a popular approach
these days but I certainly couldn’t afford to tie up a PC for the few weeks
leading up to Christmas just to flash a
few LEDs; just think of the power bill
to run a few LEDs in this way!
So, why not use a small microcontroller? They are cheap and easy to
use and if the design doesn’t work
first time, you simply re-program it.
So that is what I did.
As already mentioned, the hardware
is the Atmel '2051 micro. To make it
start thinking, we need a reset circuit
and this simply consists of the 10µF
capacitor (C7) connected to pin 1.
The reset function works because
the capacitor briefly holds pin 1 high
when power is first applied. Then the
capacitor charges up and this causes
pin 1 to be pulled to 0V.
When the power is switched off,
diode D2 forces this capacitor to discharge quickly, ready for the next time
power is applied.
To set how fast the micro thinks,
we need a 12MHz crystal X1 (in fact
we used 11.0592MHz) and associated
capacitors C1 and C2, connected to
pins 4 & 5. Note that the crystal could
be replaced by a 12MHz ceramic resonator. This allows the ‘2051 to execute
an instruction every 1 or 2µs.
As you can see from the circuit of
Fig.1, the 30 LEDs are connected in
an X-Y matrix. Why 30 LEDs? Engineering is full of trade-offs or com-
promises. I wanted a 5-pointed star
so the number had to be divisible by
5. For aesthetic reasons, we need an
even number of LEDs per point. Six
LEDs per point looked “about right”.
The next step up would have been
40 LEDs which would have required
13 I/O pins to drive them and a more
complicated PC board.
We can drive 30 LEDs from only 11
I/O pins using a process called multiplexing. The appropriate combination
of LEDs in a column is switched on
for a short time (about 2ms in this
case). This process is repeated for
each column in turn, taking 10ms for
a full cycle.
Provided the multiplexing is done
quickly enough, the persistence of
the human eye “fills in the gaps” and
we see any combination of LEDs on
without any flicker. The minimum
practical multiplexing frequency is
about 100Hz which is the frequency
used by the star.
Fig.1: the micro drives the 30 LEDs in 5 x 6 matrix, with 5 colums and 6 rows. There is provision for an
optional EEPROM which will store extra patterns in the future.
November 1998 19
Ideally, the LEDs should be high
brightness types for best effect and
in an ideal world would be matched
for brightness. Maybe that's going a
tad too far . . .
The power supply uses the ubiquitous 7805 3-terminal regulator with
0.1µF bypass capacitors at its input
and output. Diode D1 provides reverse polarity protection so that you
can’t blow up the circuit if the DC
supply is connected the wrong way
around.
The maximum current drawn by
the star is about 150mA with all LEDs
on but is less than about 50mA for
most patterns.
The maximum temperature rise of
the 7805 when the star is run from a
typical 9V DC unregulated plug-pack
is about 30°C which is quite acceptable. If run from a 12V DC unregulated plug-pack it gets warmer and
therefore should be provided with a
small heatsink.
Star software
TWINKLE, TWINKLE little star. How I wonder how you are. . . Bet you never
saw a star twinkle like this one. Its on-board micro drives the LEDs in all
sorts of patterns to light up the star.
Fig.2: the component overlay, Make sure that you insert all the LEDs
correctly: the cathode, or flat side, is oriented to the right in all cases. Don’t
insert the micro until you’ve done a voltage check on the board (see text).
20 Silicon Chip
In the spirit of Christmas, the basic
source code is available free (you may
download it from the SILICON CHIP
Web site – www.siliconchip.com.
au). An extended version that uses
the EEPROM for storage is available
at minimal cost from Grantronics
Pty Ltd. The software was written in
C language using the low cost Dunfield Development Systems Micro/C
compiler.
There is nothing particularly
“smart” or “tricky” about the software – it was written to be easy to
understand and to encourage use of
small micros.
Consequently, there are no interrupt routines and no use of the
counter/timers, the UART or the
comparator although Micro/C can
make use of these resources.
The software is table driven. This
means that the display patterns and
sequences are determined by data
stored in a table (an array of bytes).
There is a simple interpreter that
scans through the table to perform
the specified operations.
The defined byte values are listed
in Table 1. Note that there are quite
a few undefined values so future expansion is possible.
Putting it together
Assembly is quite straight forward.
You will need a soldering iron with
Byte value or range
01 to 30 (0x01 to 0x1e)
33 to 62 (0x21 to 0x3e)
64 (0x40)
65 to 79 (0x41 to 0x4f)
128 (0x80)
129 to 191 (0x81 to 0xbf)
253 (0xfd)
254 (0xfe)
255 (0xff)
Operation
Turn on LED 1 to 30
Turn off LED 1 to 30 (LED number = byte – 32)
Go back to byte after loop start
Loop start, count = byte – 64
Delay (use last delay count), each count = 10ms
Delay, count = byte – 128, each count = 10ms
All LEDs on
All LEDs off
End of table
a fine tip, preferably temperature
controlled to about 600°F or 320°C.
The first step is to carefully check
for shorts between tracks and broken
tracks. Fit the smallest parts first, the
wire links, followed by the resistors
and diodes.
Next, fit the crystal (or resonator)
and an IC socket for the micro. Then
install the transistors, capacitors and
LEDs.
Pay particular attention to the
orientation of the LEDs – they don’t
work when installed backwards! Finally, install the 3-terminal regulator
and the 2.1mm DC power socket.
Don’t insert the micro into its socket
just yet.
Do another close visual inspection,
looking for solder bridges especially
Fig.3: actual size artwork
for the PC board.
on the transistor pads. Then apply
power and check for the presence of
5V between pin 20 (+) and pin 10 of
the IC1 socket. If all is OK, remove
power, plug in the micro (careful!)
and apply power again. After a brief
pause, the micro starts to do its thing
and generates quite a range of patterns
which then repeat after a while.
At the time of writing, the patterns
weren’t quite finalised but there is
enough to entertain you. Everyone
who saw the prototype thought that
it was cute – or words to that effect.
The two holes in the board near
LED1 may be used to hang the star
and the holes near SK1 may be used
to secure the plugpack’s cable.
Finally, the appearance of the star
may be enhanced by placing a piece
ELECTRONIC
COMPONENTS &
ACCESSORIES
• LARGE RANGE OF ICs,
RESISTORS, CAPACITORS
& OTHER COMPONENTS
• MAIL ORDERS WELCOME!
CROYDON STORE ONLY
ELECTRONIC DISPOSALS
CLEARANCE!
• OPEN FRAME 240V INDUCTION
MOTORS 600 WATT AND 900
WATT.
600 WATT - $15 EACH OR 10 FOR $100
900 WATT - $18 EACH OR 10 FOR $120
• LARGE VARIETY OF
DISPOSALS TRANSFORMERS
AT GIVEAWAY PRICES!
Croydon Ph (03) 9723 3860
Fax (03) 9725 9443
MilduraPh (03) 5023 8138
Fax (03) 5023 8511
M
W OR A
EL D IL
C ER
O
M
E
TABLE 1
Truscott’s
ELECTRONIC WORLD Pty Ltd
ACN 069 935 397
30 Lacey St
Croydon Vic 3136
24 Langtree Ave
Mildura Vic 3500
SILICON
CHIP
This advertisment
is out of date and
has been removed
to prevent
confusion.
November 1998 21
of red cellophane over the front.
Parts List
Fault finding
1 5-sided PC board, code
08211981
1 2.1mm DC connector (SK1)
1 crystal or ceramic resonator,
approx. 12MHz (X1)
1 20-pin IC socket
1 9V DC 150mA plugpack,
Jaycar MP-3003 or equivalent
Semiconductors
1 AT89C2051 programmed
microprocessor (IC1)
1 7805 regulator (REG1)
1 24C16 EEPROM (optional,
enhanced version only)
30 red LEDs (LED1-LED30)
5 BC557 PNP transistor (Q1-Q5)
1 1N4002 power diode (D1)
1 1N4148 or 1N914 diode (D2)
Resistors (0.25W, 5%)
5 470Ω
6 120Ω
NS_16_8 PCB is a system conditioning card with 16 optically
isolated inputs set-up for either
12V or 24V operation. The board
provides 8 single pole, double
throw relays with 10 Amp contact rating.
KITS & CARDS
NS_DC_DC is a step down
converter with an input range
11 to 35V DC and an output of
5 volts DC at 5 Amps, with an
output ripple of approx 150mV.
There is an IN/OUT 50-way
connector isolating the 5V and
12V+ &12V- rails of the PC
power supply. This segregates
PC’s power when working on
prototypes.
NSDC_DC1 module used with
NS_DC_DC & NSDC_DC4
converters is a 5V to 12V(+/-)
step- up converter. The board
utilises 743 switch mode IC with
2 x 12V regulators, with output
ripple of approx 200mV.
NS_UTIL1 prototyping board
has 1580 bread board holes access to any 3 groups (0 to 4) on
the 50-way cable pinout. Power
is available from the 50-way
cable format 5 volts at 2 Amps
& 12V+ 12V- at 1 Amp. There
is provision for array resistors
with either a ground or positive
common connection.
For brochure write to: Reply Paid 68, NORBITON SYSTEMS, PO Box 687, Rockingham WA 6968
http://www.users.bigpond.com/norbiton
22 Silicon Chip
Where to buy a kit
We understand that the complete
Christmas Star kit will be available
from all Jaycar Electronics stores from
SC
this month for $29.95
* Les Grant is the Engineering Director at Grantronics Pty Ltd, electronics
design engineers. They can supply the programmed microprocessors for
$10 plus $5 for packing and postage.
Send remittances to Grantronics Pty Ltd,
PO Box 275, Wentworthville, NSW 2145. Phone (02) 9896 7150.
NORBITON SYSTEMS
NS_LED PCB gives visual
access to five groups (0 to 4) of
the NS_PC1OX. There is a total
of 40 status LEDs. The board
offers a 25-way “D” type female
socket. The lines are driven by
74244 ICs & configured as a
parallel printer port. This socket
gives access to printer port kits,
eg, stepper motors, LCDs, direct
digital synthesis.
The future
The star is still evolving. That is
Capacitors
1 4.7µF 16VW electrolytic
3 0.1µF monolithic or MKT
polyester
2 27pF ceramic
NS_PC101 card for XT/AT/PCs
allows access to 48 I/O lines.
There are 5 groups (0 to 4)
available on a de-facto industrial
standard 50-way ribbon cable
used in STEbus and VMEbus
19" rack mount control systems.
The board uses 2 x 8255 ICs.
Multiple boards can be used if
more I/O lines are required.
If the 5V DC is not present, check
the applied power polarity. The centre pin of the 2.1mm plug (SK1) must
be positive. Check that D1 is correctly
fitted. Check the tracks from SK1 via
D1 and the 7805 to IC1 for breaks or
shorts.
If one LED does not work, it may
be inserted backwards or it may be
shorted by a solder bridge between its
pads. If one group of adjacent LEDs
does not work, check the circuitry
and soldering around the appropriate
column drive transistor. If several
individual LEDs do not work, check
the corresponding row drive circuitry.
Remember, faulty components are
rare, soldering problems are common!
part of the attraction of using a micro
– it is so easy to change the behaviour
by changing the software. And what
about that optional EEPROM? Well,
an enhanced version of the star will
read its data from the EEPROM for
much longer sequences. To check
out the latest version of the software,
log on to the Grantronics web-site at
http://www.grantronics.com.au
If you don’t have Internet access,
send a stamped ($1) self-addressed
envelope with an IBM format 3.5" disc
to Grantronics and they will send you
the current software files.
We hope you have as much fun
building the star and playing with the
software as I did creating it. Enjoy!
Protect Your Valuable Issues
Silicon
Chip
Binders
REAL
VALUE
AT
Heavy board covers with 2-tone
green vinyl covering
$12.95
PLUS P
&
P
Each binder holds up to 14 issues
SILICON CHIP logo printed in gold-coloured lettering on spine & cover
Price: $A12.95 plus $A5 p&p each (Aust. only).
Just fill in & mail the handy order form in this issue; or
fax (02) 9979 6503; or ring (02) 9979 5644 & quote your
credit card number.
|