Real time clock is a digital clock which display real time on 16×2 LCD display. Here in this circuit we can also set alarm and time. The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I²C, bidirectional bus. The ck/calendar provides seconds, minutes, hours, day, date, month, and year information. 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.
Fig. 1: Circuit Diagram of 8051 Microcontroller and DS1307 IC based Real Time Clock
Fig 1.1: Proteus circuit of Real time digital clock
Description:-
In this circuit Port 2 of microcontroller connected to the data pins of 16×2 LCD display and bit P3^0 and P3^1 of port 3 connected to the command pin of 16×2 LCD display rs and en respectively. And serial data SDA and clock SCL pin of ds1307 connected to P1^0 and P1^1 of microcontroller respectively. 4 switches/ push buttons also used to set time and alarm. Bits P3^2, P3^3,P3^4 and P1^2 are configured as increment digit, increment value, set time and set alarm respectively. And an alarm indicator LED also connected to P1^3 for indicating alarm. When alarm time will match with the real time of clock then led will be activate. In this clock the RTC is used in 24 hour mode which gives accurate time and can be displayed on LCD through microcontroller.The microcontroller continuously reads the data from the RTC. Program continuously read the data from ds1307 and show on display. Bit P3^4 is made active low when and low signal comes to program calls time set function and bits P3^2 and P3^3 is also made active low to set time/date/day as well as alarm time after pressing bit P1^2.
Fig. 2: Overview of 8051 Microcontroller and DS1307 IC based Real Time Clock
Fig 1.3: Circuit Diagram of RTC
Component Used
Component Used:-
89S52 microcontroller
A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications.
Fig. 3: Typical Image of AT89S52 8051 Microcontroller
16×2 LCD
LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16×2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments and other multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on.
A 16×2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5×7 pixel matrix. This LCD has two registers, namely, Command and Data.
The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc.
The data register stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD. Click to learn more about internal structure of a LCD.
Fig. 4: Pin Diagram of 16X2 Character LCD
DS1307
The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I²C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. 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.
Fig. 5: Typical Image of DS1307 RTC IC
You may also like:
Project Source Code
### #includesbit rs=P3^0; sbit en=P3^1; sbit SDA=P1^0; //data pin for ds1307 bi-directional bit sbit SCL=P1^1; //clock pin for ds1307 output bit sbit alarm_set=P1^2; //set alarm input bit sbit alarm_beep=P1^3; //alarm indicator output bit sbit next=P3^2; //increament digit sbit inc=P3^3; //increament value input bit sbit set=P3^4; //set time input bit void set_time(); //time/date/day set function void display(); //time/date/day display function void alarm(); //alarm set function char ack; unsigned char day1=1; unsigned char k,x; unsigned int date=1, mon=1, year=0x14, hour=0, min=0, sec=0; unsigned int alarm_min, alarm_hour; void I2CStart() { SDA=1;SCL=1,SDA=0,SCL=0; } //"start" function for communicate with ds1307 RTC void I2CStop() { SDA=0,SCL=1,SDA=1; } //"stop" funci=tion for communicate wit ds1307 RTC unsigned char I2CSend(unsigned char Data) //send data to ds1307 { char i; static bit ack_bit; for(i=0;i<8;i++) { if(Data & 0x80) SDA=1; else SDA=0; SCL=1; Data<<=1; SCL=0; } SDA=1,SCL=1; ack_bit=SDA; SCL=0; return ack_bit; } unsigned char I2CRead(char ack) //receive data from ds1307 { unsigned char i, Data=0; SDA=1; for(i=0;i<8;i++) { Data<<=1; do{SCL=1;} while(SCL==0); if(SDA) Data|=1; SCL=0; } if(ack)SDA=0; else SDA=1; SCL=1; SCL=0; SDA=1; return Data; } void delay(unsigned int time) // delay function { unsigned int i,j; for(i=0;i //without time and alarm set #includesbit rs=P3^0; sbit en=P3^1; sbit SDA=P1^0; sbit SCL=P1^1; char ack; char array[7]; void I2CStart(){SDA=1;SCL=1,SDA=0,SCL=0;} void I2CStop(){SDA=0,SCL=1,SDA=1;} unsigned char I2CSend(unsigned char Data) { char i; static bit ack_bit; for(i=0;i<8;i++) { if(Data & 0x80) SDA=1; else SDA=0; SCL=1; Data<<=1; SCL=0; } SDA=1,SCL=1; ack_bit=SDA; SCL=0; return ack_bit; } unsigned char I2CRead(char ack) { unsigned char i, Data=0; SDA=1; for(i=0;i<8;i++) { Data<<=1; do{SCL=1;} while(SCL==0); if(SDA) Data|=1; SCL=0; } if(ack)SDA=0; else SDA=1; SCL=1; SCL=0; SDA=1; return Data; } void delay(int time) {unsigned int i,j; for(i=0;i
Circuit Diagrams
Circuit-Diagram-8051-Microcontroller-DS1307-IC-Based-Real-Time-Clock | |
Circuit-Diagram-8051-Microcontroller-DS1307-IC-Based-Real-Time-Clock |
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.