PIC -- Based Analog/Digital Alarm Clock with
The idea here was to have an
alarm clock with a rerecordable alarm sound, to afford
some variety to the waking-up ritual and to provide
respite from the insufferable beepings and raspings
of usual alarm clocks. The basic concept is easily
realized with a microprocessor, an LCD display module,
a voice recorder chip, and some audio circuitry, and
along the way I figured I could improve the appearance
by adding a stepper motor to drive an analog face. The
result is a basically totally trivial piece of circuitry
enclosed in an ever-so-slightly less trivial mechanical
housing, and with the schematics and assembly code here
you too can build one, in no time, for fun and -- well,
probably not for much profit.
Before I forget (it's so easy to take free software for
granted these days...) let's be sure to acknowledge
some of the outstanding open-source tools without the
free availability of which this project, and so much
else I have ever done, would have been prohibitively
expensive to complete:
the open-source PIC assembler and linker,
the open-source PIC simulator,
the open-source schematic capture tool, and of course
- vim, without which
life would just be miserable.
Table of Contents
A brief description of
how it works.
of the circuit.
of the constituent parts before assembly.
assembly language code
for the PIC microprocessor at the heart of the clock.
How It Works
The innards of this thing are really so trivial as to
render a 'how it works' section somewhat superfluous,
but here are the salient points.
- The microcontroller is a PIC16F870 (28 pin PDIP package),
running at 4.096 MHz from a 5 volt supply.
- The LCD module is a Lumex LCM-S01602DSF/A (Digikey
part no. 67-1758-ND), 16x2 LCD display with LED
backlight. This guy uses a standard Hitachi LCD
controller, which has the convenient feature of
allowing the eight-bit data bus to be accessed
as two four-bit nibbles, thereby allowing the entire
module to be controlled with just six microprocessor
pins (four for the data bus, one for the data/command
select line, and one for the enable line). I use
PIC port C, bits 2-7, to drive the LCD display.
- The voice chip is an ISD1100, Winbond Electronics,
28-pin DIP package (Digikey part no. ISD1110P-ND).
This guy gives 10 seconds of record/playback time
and is very easy to use. For the audio circuitry
I largely followed the recommendations of its
data sheet, with some tweaks. The datasheet suggests
driving a speaker from the ISD1100 directly, but I
found this didn't give me enough volume (the thing
does, after all, need to be loud enough to wake you
up), so I threw in an LM386 audio amplifier chip
between the ISD1100 and the speaker. The condenser
microphone and speaker are random parts I scavenged
from an old Lucent answering machine.
- Analog clock face: The minute hand is mounted on the
axis of a stepper motor, Portescap Danaher Motion
part no. 26M048B1B (Digikey part number 403-1005-ND).
The hour hand is mounted on a larger axis that fits
over the axis of the minute hand and is geared to rotate
1 turn for every 12 turns of the minute hand. (After
scouring hobby shops and small-parts stores in vain for
a gearing mechanism to achieve this, I bought a $6.00
plastic clock and ripped out its Delrin gears. They
seem to work fine.)
The stepper motor is driven by the PIC as suggested
in the motor's technical support info, using PIC port
A bits 0--3 and some MOS switches (MPF960 N-channel
and BS250 P-channel).
Due to an error in my calculations the BS250 P-channel
MOSFETS I ordered have too little current-handling
capability for the purpose, so I wound up having
to insert two in parallel where I had planned to use
just one. Don't make the same mistake -- use large
enough P-channel devices!
- The human-computer interface consists of time- and
alarm-set buttons (push to enter the corresponding
mode), hour- and minute-increment buttons (push to
advance the time or alarm setting), an alarm on/off
switch, a 'Record Alarm' button (push, hold, and speak
into the microphone to record your message), and a
'Sample Alarm' button (push to listen to the alarm
you just recorded).
All buttons are normally-open momentary pushbutton
switches (Radio Shack part nos. 275-1556 and similar),
with debouncing done by the software.
For the button and switch inputs to the PIC I use
port B, pins 0-5, because port B has convenient
built-in pullup resistors.
- The power supply is a 6 volt DC adaptor (Radio Shack)
regulated down to 5 volts by an LM317 three-terminal
regulator. (N. B. In hindsight this seems
to have been something of a design flaw, as the LM317
datasheet claims its dropout voltage is much higher
than 1V, but it seems to work so I'll leave it for now.)
Originally I was driving the LCD backlight
from this supply, but the backlight draws a lot of current
(160 mA) and caused the LM317 to heat up, so I switched
over to taking the LCD backlight power from the
unregulated 6 volt supply, through a 10-ohm (1 watt)
- The circuit board, LCD, microphone, speaker, buttons,
switches, and thumbwheel controls are housed in a
polycarbonate enclosure (Hammond Manufacturing, Newark
part no. 50H6350). The clock face, which screws onto
the polycarbonate box in place of its usual lid, is
a 1/8" thickness of aluminum which I cut to size
and decorated in my characteristically
aesthetically-challenged fashion. The stepper motor
is mounted on the rear of the clock face with its axis
sticking through a hole in the middle of the clock face.
The clock hands and gearing mechanism are mounted
on the stepper motor axis, and the back end of the
stepper motor protrudes down into the polycarbonate box
until it just touches the bottom of the circuit board.
Hooray for gschem!
click the image below for a larger view.
| Circuit board (component side).
| Circuit board (solder side).
| Stepper motor mounting, view 1
| Stepper motor mounting, view 2
| My PIC programmer, which I built following
Assembly Language Code
Homer Reid: Analog/Digital Voice-Recordable Alarm Clock, by Homer Reid