This is only a preview of the July 2001 issue of Silicon Chip. You can view 31 of the 104 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 HeartMate Heart Rate Monitor":
Items relevant to "Do Not Disturb Telephone Timer":
Items relevant to "Pic-Toc - A Simple Digital Alarm Clock":
Items relevant to "A Fast Universal Battery Charger; Pt.2":
Purchase a printed copy of this issue for $10.00. |
The Simplest Digital Alarm Clock Ever
PIC-TOC
PIC-TOC
What has less than twenty components and can
make sure you wake up in time for work, school,
that early morning golf game . . . It’s an alarm
clock, of course. But it’s not just any alarm clock . . .
It’s a PIC TOC!
Design by Michael Moore Words by Ross Tester
N
ow before you say “Oh no,
not another clock project…”
have a closer look at this one.
It has just a handful of components
yet offers features such as a melody
alarm, high-brightness readout and a
seconds display.
It’s designed to operate from a
plugpack supply but is just as happy
running from a car or caravan battery
(in fact, anything from about 9-17V
DC).
So if you’re travelling a lot and want
a reliable alarm clock for the ’van or
motorhome, this one is ideal. And
you’ll be able to knock it up in less
than an hour.
Everything mounts on one small PC
board and the “case”, if you can call
it that, is simply a cheap, tiny photo
frame from your local bargain store
(about two bucks’ worth!).
And because it’s based on a PIC micro, we’ve called it the PIC TOC. Oh,
come on, it’s not that bad! PIC TOC.
TIC TOC. Geddit?
The circuit
As you might expect, to be as simple
as what it is the clock uses just a single
micro – in this case, the ubiquitous
60 Silicon Chip
PIC16F84. All that is attached to the
PIC is a 4MHz crystal-controlled oscillator (so it’s nice and accurate), the
push-button setting switches, a buzzer
and four low current, high intensity
7-segment LED displays (via suitable
resistors).
Apart from the power supply, that’s
all there is to the circuit.
The secret is, of course, in the software –
FEATURES:
build!
Cheap and easy to
4 very bright digits
Push-button setting
Melody alarm
AM/PM indication
in this case, the PIC is loaded with
a program called alexcloc.hex. And
just in case you’re wondering, Alex is
the little girl this clock was first built
for. So now you know!
PortA 0-3 (RA0-RA3) of the PIC
serves as the multiplexer, sourcing
one of four seven-segment common
anode LEDs in turn. These LEDs re-
quire just 3mA per segment and give
a nice bright display straight from the
PIC without the added complexity of
driver or multiplexer circuitry.
3mA times 8 segments (don’t forget
the decimal points!) equals 24mA –
just below the 30mA sourcing limit
of a PIC16F84 I/O port.
The fifth PortA (RA4) is used to
drive the audio output, which goes
to a piezo buzzer. RA4 is an “open
drain” output – that is, it will only go
low, not high.
Because of this, some buzzers may
require a resistor in parallel (say 1.1kΩ
to keep it all nice and simple!) but in
the case of the buzzer specified, no
resistor is necessary. Provision is made
for such a resistor on the PC board
should it be needed.
PortB feeds the individual LED
segments – when one of the PortB
I/O pins (RB0-RB7) goes low, the
segment turns on. Obviously, Port A
controls on which digit the segment
gets turned on.
PortA multiplexer outputs which
are not having a turn as a source are
kept in the high impedance input
mode. This is more for experimental
reasons than anything to do with the
The PICTOC is housed in one of the cheapest cases we’ve ever used: a $2.00 photoframe! But it sure looks the part . . .
design/software presented. By putting
them into high impedance mode, it
would be possible to add on additional
common cathode 7-segment LEDs in
parallel with the existing four common
anode 7-segment LEDs, or add a set of
switches. Port A can act as a Tristate
4-output pin multiplexer, giving each
of 4 pins a turn at being a sink, a
source, or off.
Incidentally, I had planned originally to add two extra 7-segment
displays to the clock (ie, seconds) but
decided not to do so because the extra
LEDs would have reduced the brightness.
There is nothing to stop this circuit
being adopted to become a frequency
counter, tachometer or variable sweep
generator with appropriate software –
and in this case, brightness is probably
less important.
Four switches are connected to the
highest digit’s PortA pin (RA0). Every
hundred milliseconds or so, PortB
(which normally drives the LED segments) is switched to input mode and
RA0 goes low. If one of the switches
is being pressed the relevant PortB
input will be pulled low. The software
detects which switch is being pressed.
Normally, these switches would
short out the corresponding LED
segment when pressed unless they
were connected via a diode opposite
in polarity to the LED segment. But
in this case – a 12-hour clock – only
three segments are used for the highest
digit’s display. So the four switches
are connected to the unused segments,
keeping the component count to a
minimum.
The program
We are not going to attempt to print
the program listing for alexcloc.hex –
Here’s another view of the photo-frame
“case”, this time sans bits. You cannot
even see the glass – but it’s there. We
would have preferred a piece of red
acrylic but didn’t have any on hand. . .
apart from taking a lot of pages, who
in their right mind would type it out
when you can download it, free of
charge, from the SILICON CHIP website: www.siliconchip.com.au?
This program can be loaded into
your PIC using one of the PIC Programmers described earlier this year
(January and March 2001 issues).
Alternately, it is expected that
some kit suppliers will have available
pre-programmed PICs.
There is only one hardware timer
in the PIC16F84, and this is needed
to keep a precise count for the clock.
So it cannot be used to produce audio
output – a software timer is used to
regulate the audio tone instead.
All the main duties such as monitoring the hardware timer, keeping
track of the time, multiplexing the
digits and so on, are broken down
into identical length subroutines. The
main program counts these subroutines to time the period of the note
that is being played and can therefore
generate a note at the correct frequency.
The main program actually generates a tone continuously but the tone
is inaudible unless a key is pressed
July 2001 61
or the alarm goes off . The method is
not exact but is exact enough – the ear
cannot detect anything amiss!
Construction
The clock is housed in a tiny
picture frame. OK, so it’s not quite
in – it’s more ON the picture frame,
surrounded by part of a plastic box.
All components – switches included
– mount on a small PC board, coded
04207011.
Most components mount in the normal way on the top of the board. The
exceptions are the four time-setting
switches, the main filter capacitor and
the piezo buzzer, all of which solder
to the back (copper side) of the board.
Start by cutting and soldering the
various links on the PC board. Some
of these are very close together and
should therefore be insulated.
Also, room must be left for the 7-segment displays – some links are hard
against the displays. One link, on the
right side, actually goes around the
end display so ensure enough length
is left to achieve this.
Next, solder in the four LED displays. Note that two of these mount
the opposite way to the other two (this
gets the “colon” between the hours
and minutes.
Note where the labels on the displays are and place them the same way
as shown on the component overlay
(Fig. 2).
Be careful soldering the pins – there
isn’t a great deal of room between them
(the same comments apply to the PIC
Fig.1: yes, this is the complete clock circuit. There’s not much in it, is there!
Just a PIC, oscillator, piezo buzzer and four setting switches plus power
supply regulator make up the entire project.
62 Silicon Chip
Here’s the DSE Utility Case after we
“operated” on it to make it shorter
than the maker intended! At 10mm
high and with no “bottom”, it’s perfect
for the switches to poke through
as seen in a later photograph. The
“stand” came from the original frame.
Fig.2: here’s how the components go on the PC board.
The four push buttons, 100µF electrolytic capacitor
and piezo buzzer are mounted on the underside.
socket and the resistor array. Make
sure the PIC socket goes in the right
way around (cutout closest to the edge
of the board).
If your eyes aren’t as good as they
once were (and perhaps even if they
still are!) check for solder bridges with
a powerful magnifying glass.
The PC board is designed for either
an 8 x 1.1kΩ resistor array or eight
individual 1.1kΩ resistors. We prefer the individual resistor approach
because arrays are not only harder to
find, they’re more expensive.
Complete the top side construction
by soldering in the polarity protection
diode, regulator, crystal and various
capacitors. Crystals and ceramic capacitors aren’t polarized; electrolytic
capacitors are. Note that the 10µF
capacitor lays on its side.
Now turn the board over for soldering on the underside components.
Three of the switches – black, green
and yellow – mount the same way with
their flat side facing to the left when
you look at the copper side of the board
with the switches at the bottom. The
fourth switch, the red one, mounts
with its flat side facing upwards – see
the component overlay again for a
clearer picture.
You’re going to need a very fine
point on your soldering iron to solder
the switch pins to the tracks underneath.
The 100µF electrolytic capacitor
and piezo buzzer solder on the underside of the PC board. The capacitor
(lying on its side) is easy because you
have access to the legs. The buzzer is
not so easy.
The way we did it was to apply
solder to the copper pads, poke the
There are minor differences between this photo and the
overlay at left (it’s of an earlier prototype) but nevertheless
will give you a good idea of where the bits go!
piezo’s leads through and then heat
the leads from the top side. This
melted the solder underneath and the
joint was made. But it’s not a method
you’ll find in the rules according to
Hoyle (or whoever wrote the soldering
rules!). Remember too that the piezo
is polarised – it won’t work the wrong
way around.
Finally, solder in the wires to the
DC supply socket. The socket should
be connected with the positive to the
center, which is the convention for
plugpacks more often than not – until
some idiot manufacturer decides his
plugpacks are going to have negative
to the middle!
There’s not much room in the case to
mount the DC socket – we managed to
squeeze it in one side after making sure
all the terminals were well covered
with insulation to prvent shorting to
the back of the PC board.
The protection diode will prevent any catastrophes if you do use
a wrong-polarity plugpack – but of
course, the clock won’t work. You’ll
need to find a plugpack with the right
polarity – anything capable of seven
or more volts (up to about 17V) and
a couple of hundred milliamps will
be fine.
Carefully plug the pre-programmed
PIC into its socket – the right way
around and without bending any pins
– and your clock is now electrically
complete, ready for testing and then
mounting in its case.
Testing
Apply power via the DC socket.
The display should read 1:23, with a
dot up in the left corner (indicating
PM). And you should be greeted with
a “ta-da” tone.
Press the black (mode) button – it
cycles the display through its various
modes.
Press once and the display changes from hours/minutes to seconds
(preceded by a high-pitched tone),
press it again it changes from seconds
to alarm (preceded by a short melody)
and press it one more time to switch
The purpose of this pic is two-fold: (a) to show the way we (carefully!!) soldered
the four pushbutton switches to the back of the PC board (with the piezo buzzer
and electrolytic capacitor somewhat hidden behind) and (b) to highlight the fact
that two of the 7-segment displays are reversed with respect to their mates.
July 2001 63
At left is the reverse (copper) side of the PC board
(again, an earlier prototype than the final board whose
same-size pattern is shown above). As you can see, this
board also needed a bit of surgery due to over-etched
tracks – something you need to check your board for.
back to clock mode again (preceded
by a low-pitched tone).
If all this is OK, move on to checking
the alarm function with the red button.
Pressing this not only turns the alarm
on (and of course off), it also lights the
bottom right dot LED to show it is in
alarm mode.
Finally, the green and yellow buttons are used to change the two left
and two right digits respectively,
incrementing the digits in both clock
Parts List – PIC TOC
1 PC board, 50 x 75mm, coded 04207011
1 Plastic utility case, 57 x 82 x 33mm (DSE Cat H-2923)
1 Miniature wooden photo frame (with glass), 107 x 81 x 17mm
with “photo” cutout 51 x 76 x 10mm (available from bargain stores)
1 2.5mm DC power socket
1 mini PC board mounting normally open single-pole pushbutton switch,
red (Jaycar SP-0720 or similar)
1 mini PC board mounting normally open single-pole pushbutton switch,
yellow (Jaycar SP-0722 or similar)
1 mini PC board mounting normally open single-pole pushbutton switch,
green (Jaycar SP-0724 or similar)
1 mini PC board mounting normally open single-pole pushbutton switch,
black (Jaycar SP-0721 or similar)
1 piezo transducer, PC board mounting (Jaycar AB-3459 or similar)
1 4MHz crystal
1 200mm length of insulated tinned copper wire (for links)
1 100mm length mini figure-8 (or two strands of rainbow cable)
Semiconductors
4 HDSPH101 high intensity, low current, 7-segment common anode LED
displays (Farnell Electronics 324-723)
1 PIC16F84, pre-programmed with alexcloc.asm (downloadable from
www.siliconchip.com.au)
1 78L05 low power 5V regulator (TO-92 package)
1 1N4004 silicon power diode
Capacitors
1 100µF 25VW PCB-mounting electrolytic
1 10µF 16VW PCB-mounting electrolytic
1 0.1µF ceramic or polyester (code 104 or 100n)
2 22pF ceramic (code 22 or 22p)
Resistors (0.25W, 1%)
8 1.1kΩ (brown brown red brown or brown brown black brown brown) *
* PC board will also accept an 8 x 1.1kΩ resistor array
64 Silicon Chip
and alarm modes. In seconds mode
the yellow button increments the
minutes and the green button resets
the seconds to zero.
If all this appears to be working as
it should, you only have two more
tests to make.
One is that the clock does actually
work – set the time and ensure the
digits change – and the other is that the
alarm actually works – set the alarm
time for, say, two minutes ahead and
then wait that two minutes to ensure
that Beethoven’s Pastoral Symphony
greets you!
Once you’re happy it all checks out
OK, it’s time to place the clock in its
unique case.
The “case”
As we mentioned before, the clock
mounts inside a cheap (two dollar)
miniature photo-frame which we
obtained from our local bargain store.
The frame we used measures 107 x
81mm and is about 17mm deep but
the more important dimension is the
cut-out for the “picture”.
In our frame it was 76 x 51mm –
you’d almost think the PC board at 75
x 50mm was designed to fit, wouldn’t
you?
Our frame had a small piece of glass,
against which you’d normally place
the picture. Instead, we placed the
PC board – the LEDs contacting the
glass.
To be honest, we would have preferred a piece of 2mm-thick red acrylic
in place of the glass – it would hide
everything inside and accentuate the
LEDs. But time beat us so we stuck
with the glass.
Now, what holds the PC board
in place? You can’t use the normal
backing supplied but don’t throw it
out – we’re going to use the support
stand attached to it.
Instead, we used a Utility Box from
Dick Smith Electronics. Actually,
that’s a lie: we used 1/3 of a Utility
Box from Dick Smith Electronics.
The box we used (H-2923) has cable
entries and mounting points emerging
from each end. We didn’t need the
cable entries but the mounting points
we did!
The box is 57 wide, 82 deep and
33mm high. The width and depth are
fine, the height is far too much.
So we removed the lid and carefully measured a line 12mm down
from the case top, cut this with a
hacksaw then smoothed it on a sheet
of sandpaper (ie, rubbing it on the
sandpaper, not the other way around).
The photo shows you what we ended
up with.
In the lid, we drilled 10mm holes for
each of the four pushbutton switches
and the DC socket (see photo above
right).
And remember that support stand
we mentioned a moment ago? This
was also fastened to the lid to allow
And it’s finally
assembled. We see
a cut-down instrument case which
holds the “works”
onto the photo-frame. The four
push- buttons set
time and alarm.
What you cannot
see in this photo
is the side-mounted socket for DC
power input.
the clock to stand up vertically (again,
refer to the photographs).
The PC board is not glued or
screwed to the case – it doesn’t need
to be. Just pop the four push-buttons
through their holes. (That’s the reason
the holes are slightly oversize – it
allows for a little bit of error.) When
finished, we simply placed the lid
onto our piece of case and screwed
the whole lot to the wooden frame
Winning Gold . . .
. . .After the Games
EX OLYMPIC GENUINE
MAG LITE TORCHES
Made in USA, complete with
240V battery charger kit and
in car battery charger kit.
As used by Police, Navy & RTA
using some 20mm self-tappers. (Drill
a pilot hole in the frame first to avoid
splitting).
If necessary, some foam rubber can
be slipped in between the lid and the
PC board to keep the LEDs hard against
the glass in front.
And that’s it. Plug in power, set the
clock and settle back and enjoy!
Now, what can we do with 2/3 of a
SC
utility case without a lid?
HURRY! This is your LAST CHANCE to
grab some of the equipment left over
from the Sydney 2000 Olympic Games
at never-to-be-repeated prices!
CALL NOW!
PH: (02) 9879 6782
FAX: (02) 9879 6993
180 ea
$
EX OLYMPIC SECURITY
DURACELL 9 VOLT BATTERIES
Brand new (expiry dates 2004) Boxed lots of 48
1
00
$
79 ea
$ 80
ea
EX OLYMPIC TOA MEGAPHONES
Complete with shoulder harness
and alkaline batteries
ALL
PRICE
INCLUDS
E
GST
®
DON’T MISS OUT!
®
Registered Trade Mark Australian Video Systems
July 2001 65
|