|This project uses the Atmel AT89C2051 Microcontroller with
the Dallas DS1307 64 X 8 Serial Real Time Clock IC to build a Battery Backed Alarm Clock.
Click HERE for the schematic for this project.
The DS1307 is a Serial Timekeeping Chip that will count seconds, minutes, hours, date of the month, month, day of the week, and year with leap year compensation. It has 56 bytes of nonvolatile RAM for data storage, 2-wire serial interface, a programmable square wave output, and automatic power fail detect and switch circuitry. The DS1307 requires the use of a 32.768 KHz quartz crystal with a load capacitance of 12.5pF for the internal clock oscillator circuitry. An external 3 volt battery is used to maintain the internal RAM data.
THE ATMEL AT89C2051 MICROCONTROLLER
The AT89C2051 is an 8-Bit Microcontroller with 2Kbytes Flash Program Memory. I prefer using this micro due to its quick programming and ease of use.
NOTES ON OPERATION
Four normally open pushbutton switches are used for user input to set the time/date and alarm time. The following illustrates the functions of each pushbutton switch.
P3.0 switch #1 will increment the time/date etc..
Alway press the ENTER key when you finish each setting to move to the next setting. You can use the ENTER key to move to each individual area of the display until you get to the function you wish to set. Operation of the alarm is handled by the DS1307 pin-7 SQW/OUT. This pin is a programmable square wave output.
The SQW/OUT pin is programmed to output a 1Hz square wave and pulse the alarm buzzer at a rate of 1 beep per second for the alarm. This pin may be programmed to output different frequencies of 1Hz, 4KHz, 8KHz and 32KHz. using these higher frequencies however would result in a steady tone for the alarm buzzer, instead of the intermittent beep like most alarm clocks.
You can refer to the schematic to see how the 2N2222 NPN Transistor is setup to drive the alarm buzzer. Make sure to use an alarm buzzer with an internal resistance sufficient to keep from over loading the transistor.
The code that comes with this project will sound the alarm buzzer for 1 minute, then turn the alarm off. You can easily modify this routine to leave the alarm on for any length of time. The time and alarm settings you set are stored inside the DS1307 nonvolatile RAM area and will remain unless you remove all power from the circuit, including the external battery backup.
The DS1307 has an internal power sense circuit that will automatically switch to the external battery power supply when it detects a power failure. I have included the complete data sheets for the DS1307 and the Atmel AT89C2051 in the file clock.zip to help you with this project.
The code for this project will also require that you use a 16 X 2 LCD, unless you modify it to use another. The LCD is operated in 4-Bit Mode because of limited I/O using the AT89C2051 Microcontroller. You can use any 8051 derivative Microcontroller for this project that you would like, the code should be compatible with any 8051 variant. You may want to modify the pin assignments for whatever I/O you will have available. Any 8051 type micro with 13 available I/O pins will work just fine.
1 Atmel AT89C2051 Microcontroller, or any 8051 variant with
13 available I/O pins.
The rest of the required parts you can see on the schematic, and are pretty generic, you most likely have them lying around in your parts-bin
NOTE: The file name is clock.zip and contains all of the following files: