Digital Clock with Alarm Using DS1307

Ajay Bhargav   ajay_bhargav@hotmail.com

Hello friends, here is a very good project for Final year students.

DS1307 is a hardware realtime clock, which works on I2C protocol. Better graphics using the same old fashioned alphanumeric LCD (type HD44780). Icons which shows the status for Alarm ON/OFF state, which gives a nice and cute look to the clock.

Figure 1: Circuit Diagram for Digital Clock
Figure 1 shows the circuit diagram for the digital clock. 2x16 LCD is connected to the port 2 of AT89C51. P1.0 of uC will provide the SCL (serial clock) and P1.1 SDA (serial data) for I2C communication.

There are four switches connected to the uC, as shown in the figure. Function of the keys are same as clear from their names.

When the power supply is switched on it will give you the default date and time, but later you can change it to the desired value. After setting once, the backup battery will keep the clock ticking even after the power is not there.

A little about I2C:
There are basically four main conditions in I2C protocol.
1) Start Condition
2)Stop Condition
3)Data Validity

1)Start Condition:
when SCL is high and SDA H->L, will be taken as start condition for the communication.
2)Stop Condition:
when SCL is high and SDA L->H, will generate a stop condition.
3)Data Validity:
When SCL is high there should be no chande in SDA line only then the data is valid, the data change should be made only when SCL is low.
After sending of one byte of data the reciever has to acknowledge the sender for the successful reception. for this the sender make the SDA line high and reciever pulls down the SDA low, which tells the sender that data has reached safely.

Now the source code written in assembly, basically implements the I2C protocol. the assembly source written for Keil download here clock.asm and the direct hex file for programming the controller from here clock.hex. The schematic for the Digital clock is available in PDF format can be downloaded from here clock.pdf.

NOTE: For ppl who wants to edit the code but they dont have the A51 Macro assembler/Keil, they can use the following software to disassemble the hex file and change it according to their need. The disassembling software can be downloaded from following link
DIS8051 Cross-Disassembler V2.1 its a free 8051 disassembler for MS-DOS by Data Sync Engineering.

Reassembling can be done using any of the free softwares
Crimson Editor 3.45 R2, a free versatile editor by Ingyu Kang. or you can use
PseudoSam 8051 Cross Assembler, V1.4.09 (Recommended)

Belows shows a working demo of the digital clock, you can see on the second line that there is an icon with a bell and a spreaker in off condition shows that alarm is off. Many more features are there in the clock. So just go for it. its worth doing ;-)

Figure 2: Working Demo of Digital Clock

Please send me your feedbacks regarding the project at ajay_bhargav@hotmail.com
For any help regarding the project please mail me anytime.