You are on page 1of 15

DIGITAL CLOCK USING RTC

SUJEETHA Y
REG. NO. 2018617022
ABSTRACT
This project uses DS1307 real time clock chip to develop a clock/calendar

system. DS1307 will provide the information of seconds, minutes, hours, day,
date, month and year. This information will be read by the PIC and displayed on
LCD. The DS1307 RTC can work either in 24-hour mode or 12-hour mode with
AM/PM indicator. It automatically adjusts for months fewer than 31 days
including leap year compensation up to year 2100. DS1307 comes with built-in
power sensing circuit which senses power failures and automatically switches to
back up supply. 3V CMOS Battery is provided for that. Communication between
PIC Microcontroller and DS1307 takes place through I²C Bus.
OBJECTIVE
• To construct a simple system to deliver the current time which can also be
used in various applications that needs to keep in track of real time
COMPONENTS REQUIRED
• PIC16F877A Microcontroller
• DS1307 RTC
• 16×2 LCD
• Battery
• 3x Micro Switches (Push Button)
• Voltage regulator
BLOCK DIAGRAM

DS1307
LCD DISPLAY
RTC MODULE
PIC
16F877A

PUSH BUTTONS
DS1307
• The DS1307 serial real-time clock (RTC) is a low power, full binary-coded
decimal (BCD) clock/calendar plus 56 bytes of RAM chip.
• Address and data are transferred serially through an I2 C, bidirectional bus.
• The end of the month date is automatically adjusted for months with fewer
than 31 days, including corrections for leap year.
• The clock operates in either the 24-hour or 12-hour format with AM/PM
indicator.
• The DS1307 has a built-in power-sense circuit that detects power failures
and automatically switches to the backup supply.
• Timekeeping operation continues while the part operates from the backup
supply.
INTERFACING DS1307 WITH PIC
INTERFACING DS1307 WITH PIC
• DS1307 chip consists of 8 pins.
• The first 2 pins (X1 & X2) are connected to a 32.768KHz crystal.
• The 3rd pin (VBAT) is the backup supply input which connected to a 3V
battery.
• The SDA pin is the data input/output pin for the I2 C serial interface while
the SCL pin is the clock input for the I2 C interface and is used to
synchronize data movement on the serial interface.
• The 2 pins must be connected to the I2 C pins at microcontroller (RC3 and
RC4) and pulled high.
• The SQW/OUT pin is the Square Wave/Output Driver. When enabled, the
SQWE bit set to 1, the SQW/OUT pin outputs one of four square-wave
frequencies (1Hz, 4KHz, 8kHz, 32kHz).
• In this project, the out pin is not used.
WORKING
• DS1307 RTC is fully Binary Coded Decimal (BCD) clock/calender.
• The data read from DS1307 should be converted to required format
according to our needs and data to be written to DS1307 should be in BCD
format.
• Library for Interfacing LCD With PIC Microcontroller of MikroC needs
Character or String Data. So data to be displayed in the LCD Screen should
be converted to Character.
• Addition and Subtraction cannot be directly applied on BCD. Here I first
convert BCD to Binary. Then addition and subtraction can be simply
applied on Binary. Then the Binary is converted back to BCD.
WORKING
• BCD2UpperCh() and BCD2LowerCh() are the two functions used to convert
BCD to Character. Hour, Minute, Second, Date, Month and Year data are
stored in DS1307 in separate 8-bit registers in BCD format.
• We read the data of these registers to access time/date.
• BCD2UpperCh() converts most significant 4 bits to corresponding character
and BCD2LowerCh() converts least significant 4 bits to corresponding
character.
• The BCD2Binary() converts the BCD data read from the RTC to
corresponding Binary for addition or subtraction and Binary2BCD converts
the Binary back to BCD.
• Bit 6 of Hour register is defined as the 24-hour or 12-hour mode selection
bit. When this bit is made high, 12-hour mode is selected and Bit 5 will
represent AM/PM (Logic High represents PM).
ADVANTAGES
• Better readability
• Quicker and more accurate
• Functional in low light
SIMULATED OUTPUT
HARDWARE OUTPUT
CONCLUSION
The designed digital clock is accurate because of it real
time clock module that keeps track of the system time and
updates. The DS1307 has a built in power sense circuit that
detects power failures and automatically switches to the
3V Li Cell battery supply incorporated with the RTC. Most
of the digital clock in the market does not cover all the
time functios whether our designed digital clock covers all
the time options.
FUTURE WORKS
• Time alarm by adding a buzzer
• Timer – activate relay when preset time reached.
• Record data with time and date known.

You might also like