A Brief about Real Time Clock with Circuit Description

The acronym of the term RTC is a real time clock, basically it is just like a watch. Because, it works with a battery so that we can maintain time even there is no power and we can keep track of long timelines, even if you reprogram your microcontroller. The RTC device is used to give an accurate date and time in many applications. The mother board of an IBM PC uses an RTC device, that includes a battery to maintain the date and time even there is no power. These devices are used in some microcontrollers while other devices require interfacing. The most widely used real time clock IC is DS 1307. This article gives a brief information about what is a real time clock and its circuit diagram.


DS1307 RTC Board
DS1307 RTC Board

Real Time Clock DS1307 IC

The DS1307 IC is most widely used real time clock, it consists of a 3V external lithium battery to keep functioning for over ten years maximum in the lack of external power supply. This IC (Integrated Circuit) uses a CMOS technology to maintain low power consumption. This IC is used to keep track of the date, month and year, hours, minutes and seconds and also day of week. This IC provides a leap year facility that is valid up to 2100. The compensation of the leap year is done by checking

Last two digits of the year. The information about all these is provided in the form of HEX or BCD. O know about the further details of DS1307 IC please follow the  link. RTC DS1307 – Pin Description, Features & Working of DS1307

DS1307 Pin Configuration
DS1307 Pin Configuration

RTC DS1307 and PIC Microcontroller based Digital Clock

The circuit diagram of RTC DS1307 IC is shown below, that is built with digital clock, PIC microcontroller and seven segment display or LCD.

The IC DS1307 is a low power serial real time clock which is integrated with BCD (binary coded decimal clock and 56 bytes of nonvolatile static RAM. Address and data are transferred serially through an I2C bus. The real time clock provides the information about date, month, year and second, minute and hour. This IC operates with 12hr or 24 hr format with an indicator of AM and PM. The DS1307 IC circuit built with a power sensing circuit. This sensing circuit is used to switch the backup supply when the power failures. This real time clock IC uses an external oscillator (32.768khz) and it doesn’t require any resistor or capacitor to operate

RTC Circuit Diagram
RTC Circuit Diagram

The PIC 18F2620 microcontroller is built with the I2C bus. Although, the digital clock can be designed without an external RTC chi, but uses only internal PIC timer. The RTC IC makes the software easier as it takes care of all the functions of calendar and months adjustments, leap years accounting.

PIC 18F2620 Microcontroller
PIC 18F2620 Microcontroller

In the above circuit, the RTC IC is interfaced to port C of the PIC microcontroller. This microcontroller includes an I2C bus and connect two pull up resistors to operate the bus. Connect the 3V battery to pin3 (VBAT) of the IC to back up the battery.In this circuit, an internal oscillator is used for the PIC microcontroller and the MCLR is disabled. If the external oscillator is required, then it can be connected to the pins 9 and 10. If the MCLR is required to reset the microcontroller, then it can be connected to +v supply through a 10K resistor.In the above circuit, three push buttons are connected to Port C and these buttons are used to set the date and time. When the button is pressed, then the device enters into the setup mode. Up button is used to increment the hour and down button is used to decrease. Pressing the button again will move the cursor to month minus, and an LCD display is connected to Port-B

MPLAB XC8 software is used to write the code and it includes libraries or I2C bus, that make it easy to read or write, date & time information from the IC.registers comprising the information of time and date, that can be found by implementing a START and followed by device identification address. Then these registers can be retrieved serially by using its address until a STOP condition is performed. The library of the microcontroller will help to find the document in the installation folder of the compiler, that includes the description of the macros & functions to read or write from the bus.

MPLAB XC8 Software
MPLAB XC8 Software

The real time clock is a BCD clock or calendar. So the data read from the IC must be changed to a necessary format according to our requirements as well as data to be written to IC must be in BCD format. Interfacing LCD with PIC microcontroller using MPLAB CXB library functions it needs a string or character data. So data to be exhibited in the display that must be converted to character. Addition & subtraction cannot be applied on the binary coded decimal

This is all about real time clock and its working, this IC gives a precise time and date, which can be used in many applications. The RTC device plays a vital role in the real time systems like attendance systems, digital clock and digital cameras. This device is a good option where time stamp is required. We hope that you have got a better understanding of this concept. Furthermore, any queries regarding this concept or interfacing RTC with a microcontroller and its programming, please comment in the comment section below.

Photo Credits: