thouters.be

- Thomas' Webjar full of joy -

Alarm clock with PIC

Author: Thomas Langewouters
description:An alarm clock I built with a microcontroller
alarmclock lcd

This is an alarm clock I built. It was very effective during the sort time I used it, because I programmed it to play a very annoying tune through a speaker. I actually started to wake up before the alarm went of, so other people in the house didn't wake up from the annoying pitches it played.

The JAL source code is available on my download page

Features

  • Timekeeping using the PIC's timer0 interrupt
  • 4x20 hd44780 compatible backlit LCD, displaying the time in big numbers (4x4 and 4x3) * Alarm sound tune using PWM
  • computer interface for synchronizing time with the web.
  • (maybe battery backup (in case of a power outage...))

Status

Timekeeping:Rewritten in assembler. (losing one stack level, previously losing two stack levels, ISR and procedure time...) :Display: Done. Use's Vasile's 4-line lcd routines and tables to store the texts.
Bignumbers:Done. Data stored in tables.
Backlight:The backlight is dimmed using the internal CCP1 module of the PIC in PWM mode. :Input: Four pushbuttons on port D, handled by buttons.jal (function keypress(byte in key) return bit).
Alarm sound:Uses CCP2 in PWM mode, inspired by Vasile!
Menu code:Works. Can set time/alarm.
Computer link:(interface code) Nothing yet.

Circuit Board

Here are some details of the PCB:

pcb

A wall wart (adaptor) delivers a voltage between 7.5 and 12V to JP4. Buffer capacitors C9 and C7 ensure the voltage is clean DC (just to be sure), and IC3 lowers the voltage to 5V. C8 is provided to short high frequencies. The microcontroller is used with a 20Mhz crystal (as usual connected to two 22pF cap's), and can be reset by pushing switch S1. To connect the micro to a pc (synchronize with pc's rtc), a MAX232 TTL to rs-232 level converter is necessary. It's connected to two rows of pins, which can be connected to a flatcable with a DB9-M connector and a box connector [1]. The PCB can then be connected to a pc using a nullmodem cable. The backlight of the LCD is dimmed by the PIC's internal PWM1 module and Q2. PWM2 and Q3 drives an 8 Ohm speaker connected to JP2.

[1]those are often found in old pc's, where they are used to provide a second serial port on the back of the pc.

Timekeeping

The timekeeping is done by an interrupt service routine that gets called when timer 0 overflows. The clock uses Roman's zero error method, which Roman explains on this webpage, I rewrote the code to better fit in with my own code.

To DO

  • Build housing
  • Design second PCB with a dedicated real time clock (Dallas or I2C)
  • Store alarm time in EEPROM memory
  • Implement mobile phone ring tones as alarm sounds :)
  • Make a system of light bulbs that fade in to reach full brightness when the alarm goes off over a given period. (Like some people use to wake up animals)

Design flaws

I'll be finding some soon enough! ;-)

Pictures

Finished without housing

thumb
The clock
geheel.jpg
thumb
The clock
geheelboven.jpg
thumb
The clock
geheelschuin.jpg
thumb
the main menu
menu.jpg
thumb
the pcb at first
pcb-v1.jpg
thumb
the pcb
print.jpg
thumb
setting time...
settime.jpg
thumb
running...
tijd.jpg

Lab setup

thumb
im000280.jpg
thumb
im000281.jpg
thumb
im000282.jpg
thumb
im000283.jpg
thumb
im000284.jpg
thumb
im000285.jpg
thumb
im000286.jpg
thumb
im000287.jpg
thumb
im000288.jpg
thumb
im000289.jpg
thumb
im000290.jpg
thumb
im000369.jpg
thumb
im000381.jpg
thumb
im000382.jpg
thumb
im000383.jpg
thumb
im000384.jpg
thumb
im000385.jpg
thumb
im000386.jpg
thumb
im000387.jpg
thumb
im000388.jpg
thumb
im000389.jpg
thumb
im000392.jpg
thumb
im000393.jpg
thumb
im000394.jpg