This is only a preview of the June 2005 issue of Silicon Chip. You can view 39 of the 112 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. Articles in this series:
Items relevant to "The Coolmaster Fridge/Freezer Temperature Controller":
Items relevant to "PICAXE Colour Recognition System":
Items relevant to "PICAXE In Schools, Pt.2":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Design by SCOTT MELLING*
*Grantronics Pty Ltd.
A LED Clock
with a
difference
Here’s a LED digital clock with a difference
– a circular 60-LED array which chases anticlockwise each second to build up a count
of seconds until it gets to 60, whereupon
the chase starts all over again. The effect is
mesmerising.
Have you even been accused of
being a clock-watcher? Whether you
have or not, there is a definite risk of
being entranced (enchanted?) with
this new LED digital clock. You tend
to ignore the central 4-digit display
and just concentrate on that magical
circular LED performance.
At the beginning of each minute,
each successive LED races anticlockwise around the periphery to take
up its position as the seconds count
builds up. As the seconds count nears
26 Silicon Chip
30, each new LED only has to traverse
half the circle and so each LED makes
its circuit slightly slower than the last
until finally, as the count approaches
60, the last few LEDs make the transit
very slowly indeed. But each LED
transit around the circle, whether it
covers the whole 360° or just a few,
takes exactly one second.
So you find yourself wondering:
just what fancy machinations have
been pulled to achieve that? The answer is, of course, that there is a fancy
microcontroller calling all the shots.
But even knowing that and having
considered all the programming that
must have gone into it, you still tend
to sit there mesmerised by this clock.
You just have to see it but be warned
– when you do, you will probably
want one!
Apart from that magic circular LED
array, this wall clock also has a 4-digit
readout with 12 or 24-hour operation.
It also features an alarm with piezo
sound and opto output, a battery
backup for time-keeping and alarm
functions, AC mains synchronisation
and crystal timebase for precise timing, an efficient switchmode supply
powered by a 12V AC plugpack and
a high quality double-sided, screenprinted and solder-masked PC board
with plated-through holes. What more
could you want?
The hours and minutes display
consists of the four large digits in the
siliconchip.com.au
How The Seconds Chaser Works
centre of the clock face. It can be set
to display either 12 or 24-hour time,
depending on the position of a single
jumper link (JP1). On the righthand
side of the minutes digits is an AM/
PM indicator LED and this is active
for PM hours if the 12-hour display
mode is chosen.
The timing uses a crystal oscillator for short term accuracy with the
chaser control and is synchronised to
the mains AC cycles when present for
long term accuracy.
The clock’s alarm features need explaining. Apart from the piezo buzzer
that can be set to sound as an alarm,
there is an optocoupler output which
allows the clock to trigger an external
device. Once both or either of these
outputs has been enabled and becomes
active, they can be reset by pressing
any of the three time-setting buttons
on the back of the clock.
There is provision to connect a
backup battery to the clock for periods
when the mains power fails. When
running from the backup battery, the
LEDs are not illuminated, to enhance
battery life. Unlike many other designs, however, the alarm output and
opto output will still activate during
a mains power failure. The battery
backup circuit also includes a charging
facility so that NiMH or Nicad cells
can be used.
There are three buttons on the back
of the clock labelled UP, MODE and
DOWN. The functions of these buttons
vary depending on which “mode” the
clock is currently displaying.
Four seconds into the minute. At the
start of each second, the chase LED
starts at the top and travels anticlockwise around the clock face, as
indicated by the green arrow.
Eighteen seconds into the minute.
The chaser LED is shown here
travelling anti-clockwise past the
40s mark. Note: the green arrow is
not part of the clock display.
Thirty seconds into the minute. The
chase LED is now really starting to
slow down, since it has much less
distance to travel in 1s.
Forty-seven seconds in and the
chase LED is getting slower and
slower. It now travels less than 45°
of arc in one second.
Coming down the straight . . . the
chase LED moves very slowly
during the last few seconds of the
minute.
Finished – 60 seconds is up and
the minutes digit “ticks” over. The
seconds LEDs now go out and the
chase sequence starts again.
Menus and setup
When AC power is first applied, the
clock will power up and proceed to
run, beginning with a default time of
0:00 and 0 seconds. This is the “run”
mode, identified by the standard LED
chasing pattern described above.
In all other “utility” modes, as set
by the MODE button, there is a very
different chase sequence to indicate
you are not in “run” mode. In the
“time-hours set” mode, the hours
digits display as “Ch”. You can then
press the UP and DOWN buttons to
set the clock’s hours.
In “time-minutes set” mode, the
hours digits display as “C” and pressing the UP and DOWN buttons allow
the clock’s minutes to be set.
In “alarm/opto enable” mode, the
UP button toggles the alarm on and
off. When enabled, the hours digits
siliconchip.com.au
show “AL.” The DOWN button toggles
the opto output on and off. When this
is enabled, the minutes digits reads
“Au.”
In “alarm-hours set” mode, the
hours digits display “Ah” while in
“alarm-minutes set” mode, the hours
digits display “A .” Using the UP and
DOWN buttons in both modes allows
the clock’s hours or minutes display
to be set for alarm triggering.
The same comments apply to the
“opto-hour set” mode (display “Hh”)
and “opto-minutes set” (display “H”).
June 2005 27
(LD61) is enabled (ie, it lights after
12 o’clock midday). Conversely, shorting pins 2 & 3 with a jumper converts
the clock to 24-hour operation and
disables the AM/PM indicator LED.
Programming header
As well as JP1, Fig.1 also shows a
6-way pin header connected to pins
9, 6, 8 & 7 of the microcontroller. This
header was included during development to allow for in-circuit programming of the microcontroller and has
been retained for those who like to
experiment.
Most people will not want this facility, in which case the pin header can
be left off the PC board.
Power supply
The LED clock comes as a complete kit of parts and includes a double-sided
plated-through PC board with a solder mask and silk-screened overlay.
When triggered, both the audible
alarm and the opto output are disabled
by pressing any of the pushbuttons.
Circuit description
The brain behind the operation of
the clock is an Atmel ATMEGA851516PC microcontroller – see Fig.1. It
runs at 8MHz, which gives approximately 8MIPS throughput with a machine cycle of 125ns – eat your heart
out Microchip!
The PC board layout was actually designed for the now obsolete
Atmel AT90S8515, together with its
MC34064P-5 under-voltage sensor
(U4), but the ATMEGA8515 is a dropin replacement. It also incorporates an
on-chip under-voltage detector which
has made the MC34064P-5 redundant.
The ATMEGA8515-16PC will operate
happily down to 2.7V, relying on its
own internal brownout detector.
The short-term timing of the clock is
derived from an 8MHz crystal but this
may drift slightly over several months.
To help combat the drift problem, the
micro samples the AC mains supply,
comparing this cycle count every
hour to the expected cycle count for
the 50Hz (or 60Hz) AC supply. If it is
close to being in sync, the assumption
is that there has been some small drift
and the micro is re-synchronised.
If there is a large difference, the assumption is that the AC mains supply
28 Silicon Chip
is not present or was not present for a
part of the last hour’s operation, and
the synchronisation process is skipped
for that time around.
LED arrays
All of the LEDs on the clock face,
except the LED that sits in parallel
with the buzzer, are in three 5 x 7
matrices. Each LED in each matrix is
individually controllable except in the
case of the digits where each segment
is controllable. Seven bits of ports
A, C and D on the ATMEGA8515 are
used to drive three ULN2003 7-way
Darlington transistor drivers (ie, driving three matrices), allowing the clock
to multiplex up to 21 LEDs on at any
one time.
There are five BD682 PNP transistors
on the supply side of the LED arrays,
breaking it into parts that can be time
division multiplexed with about a
20% duty cycle. The base cycle time
used is 1ms, so each LED (if required)
is on for 1ms in every 5ms. The associated 220W resistors limit the current
in any LEDs that are active.
Display format
The 3-way pin header labelled JP1 is
used to control the display format – ie,
whether the clock shows 12-hour or
24-hour time. If pins 2 & 3 are left open
circuit, the clock operates in 12-hour
mode and the AM/PM indicator LED
Power for the clock circuit is derived from a 12VAC plugpack and
bridge rectifier DB1. The resulting
unfiltered 16-17V rail from DB1 is
then fed via diode D1 to a 2200mF
filter capacitor and to pin 1 (Vin) of an
LM2575 switching regulator, U5. This
IC produces a regulated +5.8V rail for
driving the LEDs.
Schottky diodes D4 & D5 and the
associated 47W resistor provide a
simple charging circuit for a 4-cell
NiMH or Nicad backup battery. It also
allows the micro to be powered from
the main +5.8V DC rail (via D4) when
available and then automatically fall
back to the backup supply when the
main source fails.
The added voltage drop across D4
(about 0.3V) also puts the microcontroller’s supply well below its absolute
maximum rating of 6V. During a mains
failure, the microcontroller continues
to run and power is also available
to the opto output and piezo buzzer
but the power-hungry LED array is
not powered. This allows maximum
backup battery life and still preserves
operation of the alarm functions.
Mains synchronisation signal
The unfiltered 100Hz signal from
DB1 is also fed to the base of transistor
Q7 to derive the mains synchronisation signal. This pulses Q7 on and off
at a 100Hz rate, which in turn drives
pin 4 (PB3) of the microcontroller
(U3).
The internal software in U3 processes this signal to derive the mains
synchronisation signal for the 8MHz
crystal oscillator. In effect, the clock
relies on the mains for its long term
siliconchip.com.au
siliconchip.com.au
June 2005 29
Fig.1: an ATMEGA8515-16 microcontroller (U3) is at the heart of the LED clock. It performs all the timekeeping functions and drives the LEDs via Darlington
transistors Q1-Q5 and three ULN2003A Darlington transistor arrays (U1, U2 & U6).
Fig.2: the circle LEDs are multiplexed by the microcontroller (U3), with Darlington transistors Q1-Q5 used to
provide buffering and switching for the individual groups. Q1-Q5 also switch the digit LEDs.
30 Silicon Chip
siliconchip.com.au
siliconchip.com.au
June 2005 31
Fig.3: the four digit displays in the centre of the clock each consist of 28 individual LEDs (ie, four LEDs to each digit segment)
Fig.4: the parts layout for the top of the PC board. Install a shorting link on pins 2 & 3 of JP1 for 24-hour operation.
accuracy but falls back to the crystal
oscillator during a power failure.
Alarm outputs
When the alarm is triggered, the
microcontroller switches its OC1B output (pin 29) high. This logic high then
turns on transistor Q6 which sounds
a small piezo buzzer and turns on the
alarm indicator LED (LD70).
32 Silicon Chip
At the same time, PD0 (pin 10) also
goes high and this activates the optocoupler (OC1). As mentioned before,
its output can then be used to control
a low-voltage external device.
Assembly
Before starting the assembly, it’s
a good idea to carefully inspect the
supplied PC board and the parts lay-
out diagram (Fig.4). In particular, pay
special attention to the screw terminals mounted on the rear of the board
– the supply and back-up terminals
are labelled in copper and are hard to
see under the solder mask.
The PC board is double-sided with
plated-through holes and a solder
mask. This makes the assembly easy
– there are no feed-through links to
siliconchip.com.au
Fig.5: the parts layout for the back of the PC board. The capacitors & choke L1 can be secured using hot-melt glue.
install and you only have to solder
the component leads on one side of
the board.
Note, however, that a few parts are
mounted on the back of the board,
which means that soldering takes
place on the top (LED side) of the
board.
The main thing to watch out for with
this project is the large number of posiliconchip.com.au
larity sensitive parts – particularly the
LEDs. And because the board is platedthrough, removing a part that’s already
been soldered in will be extremely
difficult and risks damaging the board.
The rule is: check and double check
before soldering.
Apart from that, the assembly is
quite straightforward and should only
take a few hours.
Begin the assembly by installing all
the resistors on the board. To save any
confusion, it’s best to install all those
with the same value at a time. It’s also
a good idea to install them all with the
tolerance band facing the same way,
as this makes it easier to check the
assembly later on.
Once the resistors are in, you can
install the diodes, taking care to ensure
June 2005 33
Above: the completed PC board is secured to the case using two M3 x 6mm
screws and nuts, located at the 3-o’clock and 9-o’clock positions.
This view shows the parts on the back of the PC board. Be sure to mount
the two electrolytic capacitors exactly as shown, so that they clear the
battery compartment.
34 Silicon Chip
each device is installed in the correct
location and is correctly orientated.
D1 & D2 are 1N4007s, while D3-D5 are
1N5819s (don’t get them mixed up).
That done, install the two BC547
transistors (Q6 & Q7), the bridge rectifier (DB1), the optocoupler (OC1) and
the IC sockets. Push the transistors
down onto the board as far as they
will comfortably go before soldering
their leads and watch the orientation
of the bridge rectifier.
The IC sockets should all be orientated so that their notched ends match
the parts layout (this will make it easier
when it comes to plugging the ICs in
later on). Note that the socket for U6
(and the IC itself) faces in the opposite
direction to the other sockets.
Don’t fit the ICs into the socket just
yet, though – that step comes later after
the power supply has been tested.
There’s just one wrinkle when it
comes to fitting the socket for the
microcontroller (U3) – the 6-way pin
header for in-circuit programming
mounts on the rear side of the board,
directly under this socket. This pin
header can be omitted in the vast
majority of cases, since the microcontroller comes pre-programmed.
If you do need the programming
header, it will need to go in before the
IC socket – just flip the board over and
solder it in.
The optocoupler (OC1) solders directly to the board. Be sure to install
it with its notched end towards U3, as
shown on Fig.4. Once it’s in, install the
adjacent 3-pin header (JP1).
Next, install the crystal (X1), followed by the five BD682 Darlington
transistors (Q1-Q5). The latter are all
installed by first bending their leads
downwards through 90° about 4mm
from their bodies, with the labels
facing up. They are then installed so
that they lie flat against the PC board,
before soldering the leads.
The LM2575T switching regulator
(U5) is installed in similar fashion. As
before, bend its leads down through
90° about 4mm from its body, then
mount it in position and fasten its
metal tab to the PC board using an M3
x 10mm screw and nut. That done, its
leads can be soldered and trimmed in
the usual manner.
Note: don’t solder U5’s leads before
bolting it to the PC board. If you do,
the leads may be unduly stressed as
the screw is tightened, which could
fracture the PC board tracks.
siliconchip.com.au
Par t s Lis t
1 188mm-diameter double-sided
PC board with black solder
mask
1 clock case to suit PC board
1 330mH 3A ferrite choke (L1)
1 8MHz crystal (X1)
1 mini piezo buzzer (PC mount)
3 2-way PC-mount screw terminal blocks
4 AAA 1.2V rechargeable cells
(NiMH or Nicad)
1 4 x AAA cell holder
3 miniature momentary contact
PC-mount switches (SW1SW3)
3 M3 x 6mm screws
3 M3 nuts
1 3-way pin header
1 jumper shunt
1 black cable tie, 150 x 3mm
3 16-pin DIL IC sockets
1 40-pin IC socket
The clear plastic bezel is fitted with a dark filter and simply clips into position
via a couple of locating lugs. Once it’s in place, the filter is sandwiched between
the bezel itself and the 5mm LEDs.
The ceramic and monolithic capacitors are the next in line. Follow these
with two 10mF tantalum capacitors.
The latter are polarised, so make sure
their positive leads go towards the top
of the board.
Installing the LEDs
Now the real fun begins – you have
to install no less than 176 LEDs. OK,
so this job is a bit tedious but if you
install them in groups of seven or eight,
it won’t take long at all.
As mentioned before, you really
have to watch the orientation of the
LEDs – put them in the wrong way
around and the little blighters won’t
work. The cathode lead is the shorter
of the two (see Figs.1-3) and this corresponds to the flat edge shown on
each LED outline in Fig.4.
Note that, depending on the manu-
facturer, each LED may actually have
a flat side to also indicate the cathode.
However, the LEDs supplied with the
prototype were completely round, so
don’t count on this.
Basically, it’s just a case of pushing
each group of LEDs all the way down
onto the PC board and splaying their
leads slightly to hold them in place
for soldering. Be sure to double-check
their orientation before actually applying the solder – get one (or more
wrong) and it will be difficult to
remove!
Flip side
Now for the parts on the reverse side
of the PC board – see Fig.5. Flip the
board over and install the three 2-way
screw terminal blocks, followed by the
piezo buzzer and the three pushbutton
switches (SW1-SW3). Make sure the
Where To Buy A Kit Of Parts
This project was developed by Grantronics Pty Ltd for Jaycar Electronics and
the design copyright is owned by Jaycar Electronics.
A kit of parts is available from Jaycar for $A129.00 – Cat. KC-5404. This includes
the clock case, the battery holder, the PC board and all on-board parts but does
not include a plugpack supply or the rechargeable batteries. The 12VAC plugpack
supply (Cat. MP-3020) is available for $22.95.
siliconchip.com.au
Semiconductors
3 ULN2003N Darlington
transistor arrays (U1,U2,U6)
1 ATMEGA8515-16PC microcontroller – pre-programmed
(U3)
1 LM2575T-ADJ switchmode
regulator (U5)
1 PS2505-1 optocoupler (OC1)
5 BD682 PNP Darlington
transistors (Q1-Q5)
2 BC547 NPN transistors
(Q6,Q7)
1 WO4 bridge rectifier (DB1)
2 1N4007 silicon diodes (D1,D2)
3 1N5819 Schottky diodes
(D3-D5)
164 high-brightness 3mm red
LEDs
12 high-brightness 5mm red
LEDs
Capacitors
1 2200mF 25V PC-mount electrolytic
1 1000mF 10V PC-mount electrolytic
2 10mF 16V tantalum
3 100nF monolithic (code 104)
2 33pF NPO ceramic (code 33)
Resistors (0.25W, 1%)
1 100kW
1 1.8kW
1 68kW
7 330W
1 6.8kW
14 220W
5 4.7kW
57 120W
1 3.3kW
1 47W
June 2005 35
mount the electrolytic capacitors, the
choke or the buzzer on the top of the
board. They will interfere with the
dark filter when the clear plastic
bezel is later clipped into position if you do.
Assuming everything is OK, switch
off and install the chips into their
sockets, taking care to ensure that they
are all correctly orientated. Be careful
when handling the chips, to avoid
damage from static electricity. Don’t
touch the pins and be sure to discharge
yourself by touching an earthed metal
object before touching the ICs.
Note that U6 faces in the opposite
direction to the others. Note also that
pin 9 of U6 must NOT go into its corresponding socket pin. This pin can
either be cut off using a pair of sidecutters or splayed out so that it runs
down the outside of the socket– ie, this
pin must NOT make any connection to
the circuit (OK, we admit it – we made
a mistake on the PC board).
That done, connect the backup battery pack and re-apply power from the
AC plugpack. The clock should immediately show 0:00 and the seconds LED
should start chasing anti-clockwise.
It’s then just a matter of setting the
time and checking out all the functions using the pushbutton switches,
as described earlier.
After that, it’s simply a matter of
securing the PC board inside the case
using the M3 screws and nuts provided
and clipping the front bezel into place.
It’s up to you whether or not to use the
dark filter material supplied. If you do
decide to use it, it must be cut into a
neat circle exactly 197mm in diameter,
to fit inside the bezel.
When the bezel is fitted, the filter is
sandwiched between it and the 5mm
LEDs and held firmly in position.
Leave the filter out if you want the
display to be really bright.
Finally, if one or more LEDs fails to
light, check its orientation. If a group
of LEDs fails to light, check the corresponding BD682 driver transistor and
its associated base bias resistors. SC
Fit the stickers
The rechargeable battery pack fits
neatly in the battery compartment
and can be secured using adhesive
tape. Make sure it’s connected the
right way around.
buzzer goes in the right way around
(ie, positive terminal to the left).
That done, install the 2200mF and
1000mF electrolytic capacitors and the
330mH choke (L1). Note that, in both
cases, the capacitor leads are bent
down by 90°, so that their bodies lie
flat against the PC board. Pay attention to the polarity of the capacitors
and position them exactly as shown
in Fig.5, so that they will clear the
battery compartment
A blob of hot-melt glue or epoxy
adhesive can be used to secure them
in position. Similarly, use hot-melt
glue to secure the choke or you can
secure it using a plastic cable tie – just
loop the cable tie through the holes on
either side.
By the way, don’t be tempted to
A number of adhesive
labels are supplied with
the kit and these indicate
the switch functions and
the connections to the screw
terminal blocks. The ones
for the screw terminal blocks
are affixed directly to the PC
board. Be sure to get these correct – if the 12V AC plugpack is
connected to the back-up battery
terminals, it will blow every chip
on the board!
The switch function labels are affixed to the back of the case, above the
access slot. They are, from left to right:
“Down”, “Mode” and “Up”.
That’s it – the PC board assembly
is complete and you’re now ready for
the smoke test. Well, actually there
shouldn’t be any smoke but you know
what we mean!
Testing
Before fitting the ICs, it’s best to
check that the supply regulator (U5)
is working correctly. To do this, apply
power from a 12VAC plugpack and
check the voltage at the anode of D4
– you should get a reading of close to
+5.8V. D4’s cathode should be at about
+5.3V and this voltage should also be
present on pin 40 of U3’s socket. The
tab of the LM2575 regulator makes a
convenient ground point.
If you don’t get anything at D4’s anode, check the voltage at the cathode
of D1 – you should get a reading of
about 16-17V DC.
Table 1: Resistor Colour Codes
o
o
o
o
o
o
o
o
o
o
o
No.
1
1
1
5
1
1
7
14
57
1
36 Silicon Chip
Value
100kW
68kW
6.8kW
4.7kW
3.3kW
1.8kW
330W
220W
120W
47W
4-Band Code (1%)
brown black yellow brown
blue grey orange brown
blue grey red brown
yellow violet red brown
orange orange red brown
brown grey red brown
orange orange brown brown
red red brown brown
brown red brown brown
yellow violet black brown
5-Band Code (1%)
brown black black orange brown
blue grey black red brown
blue grey black brown brown
yellow violet black brown brown
orange orange black brown brown
brown grey black brown brown
orange orange black black brown
red red black black brown
brown red black black brown
yellow violet black gold brown
siliconchip.com.au
|