Digital Clock Using 8051 Microcontroller With RTC
Digital Clock Using 8051 Microcontroller With RTC
1
Abstract
Digital clock is displays the time using RTC. This circuit is used many applications
like cars, railway stations, houses, offices, etc. In order to provide accurate time and date, In
this type of applications, normally we use RTC (Real Time Clock) ICs to displays the time
data accurately. This Circuit displays the time on LCD. For this clock, we can set the time
and alarm at any instant. Here the clock works in 24 hours mode and the RTC chip is
configured by programming 8051 controller. Here 8051 controller continuously reads data
from RTC and process it in correct order to display on time on LCD.
2
ACKNOWLEDGEMENT
We take this opportunity to humbly express our sincere thanks to all those concerned
with our project titled “DIGITAL CLOCK WITH TIME AND ALARM SET
FUNCTIONS”. We have taken efforts in this project. However there are many individuals
and senior members who gave their essential guidance. We would like to extend our sincere
thanks to all of them. We wish to express our warm gratefulness appreciation to all those who
have contributed to this project, both directly and indirectly, without the co-operation of
whom, it would not have been possible to complete this project. We are highly indebted to
our colleagues for their immense support and Mr. A M Bhatt (HOD, Dept. of ECE) and our
project guide Ms. F. G. Patel and Mr. A. M. Bhatt for their guidance and constant
supervision as well as for providing necessary information regarding the project & also for
their support in completing the project. We would like to express our gratitude towards our
parents & faculties of Electronics & Communication Dept. Of Government Polytechnic,
Jamnagar for their kind co-operation and encouragement which help us in completion of this
project.
With Regards,
Maulik M. Sanchela
3
Index:
1 Introduction 7
3 Circuit Diagram 10
4 Hardware description 12
6 Bill of Material 42
7 Troubleshooting 43
9 Future Enhancement 45
10 Conclusion 46
11 Reference 47
4
Chapter – 1: Introduction
In controlling, in this several push buttons are uses for different works, They
consist alarm set, time set, hour and minute set of time and alarm, reset button, and all
have particular works for set.RTC varies the time continuous and delays.
5
Chapter -2: System Block Diagram
Figure 1
6
Block Description:
2. LCD: LCD is the Output device. In LCD, we can get the output signal, and day,
date, time, month, and year.
3. Buzzer: Generates loud and sound when we the alarm time is come.
4. Microcontroller: The microcontroller can be controller the full circuit and it can
give the output to the LCD.
5. Real Time Clock: The RTC is Real Time Clock chip. It can be used for to take
up Time, Calendar, and Day, Date, Month, Year, because of inbuilt Battery.
RTC is main Block of our Project.
7
Chapter – 3: Circuit Diagram
Figure 2
8
Description of Circuit Diagram:
The circuit diagram shows the connection of RTC with the microcontroller. Port P0 is
used as data port for LCD and P3.5, P3.6, P3.7; The PORT 2 is used for Push Buttons.
In this clock the RTC is used in 24 hour mode which gives accurate time and can be
displayed on LCD through microcontroller.
Firstly oscillator is set, than RTC is set in 24 hour mode by setting 0X20 in register.
The microcontroller continuously reads the data from the RTC. The algorithm
processes the data and displays the data in correct order on the LCD screen. Interrupt
2 of the microcontroller is used to set time. Whenever Start pin is made low (0),
interrupt2 comes and set time function is called for setting the time. After setting the
time, start pin is made high and the clock starts with the time set by user.
9
PCB Design:
10
Chapter – 4: Hardware Description
2 Capacitor 33pf,10 uf
3 IC 7805
4 LED -
5 Microcontroller At89s52
8 LCD 16*2
9 Buzzer -
10 Relay Ras-0510
11 Push Button -
11
Resistor:
Figure 3
Performance Specification
Temperature Coefficient : ≤10Ω : ±350PPM/°C 11Ω to 99kΩ : 0 to -450PPM/°C100kΩ to 1MΩ
: 0 to -700PPM/°C1.1MΩ to 10MΩ : 0 to -1500PPM/°C
Load Life in Humidity : Normal Type : <100kΩ : ±(3% +0.05Ω)Max. ≥100kΩ : ±(5%
+0.05Ω)Max.
Load Life : Normal Type : <56kΩ : ±(2% +0.05Ω)Max. ≥56kΩ : ±(3% +0.05Ω)Max.
12
Features of Resistor:
Too low or too high values can be supplied on case to case basis
13
Capacitor:
Figure 4
Features:
For general purpose.
Wide CV value range.
Safely vent construction products, RH series are guaranteed 2,000 hours at 105°C.
General Description:
When one plate is charged with electricity from a directcurrent or electrostatic source,
the other plate have induced in it a charge of theopposite sign; that is, positive if the
original charge is negative and negative if theoriginal charge is positive.
Capacitors are limited in the amount of electric charge they can absorb; they
canconduct direct current for only instances but function well as conductors
inalternating current circuits.
Fixed capacity and variable capacity capacitors are usedin conjunction with coils as
resonant circuits in radios and other electronic equipment. Capacitors are produced in
a wide variety of forms. Air, Mica,Ceramics, Paper, Oil, and Vacuums are used
asdielectrics depending on the purpose for which the device is intended.
14
General Description of Capacitor:
15
IC 7805:
Figure 6
Features:
16
General Description of IC 7805:
The LM78XX series of three terminal positive regulators are available in the TO -220
package and with several fixed output voltages, making them useful in a wide range of
applications. Each type employs internal current limiting, thermal shut down and safe
operating area protection, making it essentially indestructible. If adequate heat sinking is
provided, they can deliver over 1A output current. Although designed primarily as fixed
voltage regulators, these devices can be used with external components to obtain adjustable
voltages and currents.
17
LED:
Electronic Symbol
18
General Description of LED:
A light-emitting diode (LED) is a two-lead semiconductor light source.
It is a PN-junction diode, which emits light when activated.
When a suitable voltage is applied to the leads, electrons are able to recombine
with electron holes within the device, releasing energy in the form of photons.
This effect is called electroluminescence, and the color of the light is determined by
the energy band gap of the semiconductor.
LEDs convert electrical energy into light energy.
Characteristics of LED:
Color
White light
Intensity
Eye safety information
Visibility
Operating Life
Voltage/Design Current
Specification:
Color Wavelength range (nm) Typical efficacy (lm/W) Typical efficiency (W/W)
Red 620 < λ < 645 72 0.39
19
Microcontroller At89s52:
Figure 8
20
Features of Microcontroller:
21
Crystal Oscillator:
Figure 9
The crystal oscillator circuit sustains oscillation by taking a voltage signal from the
quartz resonator, amplifying it, and feeding it back to the resonator.
22
Features of Crystal Oscillator 32.768 MHz:
Model :CXO\VCXO
Frequency range:1.000125.000MHz
Ts :<10ms
Storage temperature:-40+85
Frequency
stability:+25ppm/+50ppm/+100ppm
Symmetry:40%60% 45%55%
Output 0 level:0.5V
Output 1 level:>4.5V(5.0V)/>2.4V(3.3V)
23
RTC DS1307:
Figure 10
A real-time clock (RTC) is a computer clock (most often in the form of an integrated circuit)
that keeps track of the current time. Although the term often refers to the devices in personal
computers, servers and embedded systems, RTCs are present in almost any electronic device which
needs to keep accurate time
Although keeping time can be done without an RTC, using one has benefits:
Most RTCs use a crystal oscillator, but some use the power line frequency. In many cases the
oscillator's frequency is 32.768 kHz. This is the same frequency used in quartz clocks and watches,
and for the same reasons, namely that the frequency is exactly 2 cycles per second, which is a
convenient rate to use with simple binary counter circuits.
24
Figure 11
Features of RTC Ds1307:
• Real time clock counts seconds, minutes ,hours , date of month ,day of week
and year with leap year compensation valid up to 2100.
• 56 byte nonvolatile RAM for general data storage
• 2-wrire interface (I2C)
• Automatic power fail detect
• Consumes less than 500 nA for battery back-up
25
Liquid Crystal Display (LCD):
Figure 11
26
General Description of LCD:
Available as an optional extra is the Serial LCD Firmware, which allows serial control of the
display. This option provides much easier connection and use of the LCD module. The
firmware enables microcontrollers (and microcontroller based systems such as the PICAXE)
to visually output user instructions or readings onto an LCD module. All LCD commands are
transmitted serially via a single microcontroller pin. The firmware can also be connected to
the serial port of a computer.
To display the notifications of dedicated charges and also to display the information. It
contain certain characteristics like.
27
Buzzer:
Figure 12
Uses :-
1. Electronic metronomes.
5. Electrical alarms.
28
Relay Ras0510:
Figure 13
Feature:
Silver alloys:
24 VDC / 10A
120 VAC / 10A
250 VAC / 7A
Pin Terminal.
29
Chapter – 5 Software Logic Explanations
Flowchart
Start
Match
the time
with
RTC
Alarm is ON
Stop
30
ALGORITHM:
1. START
2. initialize LCD
3. clear LCD
10. STOP
31
SOFTWARE DESCRIPTION
1 - PROTEUS
2 – KEIL
General Description:
Proteus 7.0 is a Virtual System Modeling (VSM) that combines circuit simulation,
animated components and microprocessor models to co-simulate the complete
microcontroller based designs. This is the perfect tool for engineers to test their
microcontroller designs before constructing a physical prototype in real time. This
program allows users to interact with the design using on-screen indicators and/or
LED and LCD displays and, if attached to the PC, switches and buttons.
One of the main components of Proteus 7.0 is the Circuit Simulation -- a product that
uses a SPICE3f5 analogue simulator kernel combined with an event-driven digital
simulator that allow users to utilize any SPICE model by any manufacturer.
Proteus VSM comes with extensive debugging features, including breakpoints, single
stepping and variable display for a neat design prior to hardware prototyping.
In summary, Proteus 7.0 is the program to use when you want to simulate the
interaction between software running on a microcontroller and any analog or digital
electronic device connected to it.
32
Codes of Project:
#include<reg51.h>
#include<string.h>
#include<rtc.h>
bit new_sms = 0;
bit incoming_call_flag = 0;
unsigned char ms_count=0,reltime=0;
33
rw1 = 1;
rw2 = 1;
rw3 = 1;
if(cl0 == 0)
{
key_number = 12;
while(cl0 == 0);//for key debounce it will wait here.
}
else if(cl1 == 0)
{
key_number = 13;
while(cl1 == 0);
}
else if(cl2 == 0)
{
key_number = 14;
while(cl2 == 0);
}
else if(cl3 == 0)
{
key_number = 15;
while(cl3 == 0);
}
rw0 = 1;
rw1 = 0;
rw2 = 1;
rw3 = 1;
if(cl0 == 0)
{
key_number = 0;
34
while(cl0 == 0);
}
else if(cl1 == 0)
{
key_number = 1;
while(cl1 == 0);
}
else if(cl2 == 0)
{
key_number = 2;
while(cl2 == 0);
}
else if(cl3 == 0)
{
key_number = 3;
while(cl3 == 0);
}
rw0 = 1;
rw1 = 1;
rw2 = 0;
rw3 = 1;
if(cl0 == 0)
{
key_number = 4;
while(cl0 == 0);
}
else if(cl1 == 0)
{
key_number = 5;
while(cl1 == 0);
}
35
else if(cl2 == 0)
{
key_number = 6;
while(cl2== 0);
}
else if(cl3 == 0)
{
key_number = 7;
while(cl3== 0);
}
rw0 = 1;
rw1 = 1;
rw2 = 1;
rw3 = 0;
if(cl0 == 0)
{
key_number = 8;
while(cl0 == 0);
}
else if(cl1 == 0)
{
key_number = 9;
while(cl1 == 0);
}
else if(cl2 == 0)
{
key_number = 10;
while(cl2 == 0);
}
else if(cl3 == 0)
36
{
key_number = 11;
while(cl3 == 0);
}
return(key_number);
}
37
void lcd_command(unsigned char lc)
{
P0 = lc;
RS = 0;
RW = 0;
EN = 1;
delay();
EN = 0;
}
38
void lcd_init()
{
lcd_command(0x38);
lcd_command(0x0C);
lcd_command(0x01);
}
void main()
{
unsigned char temp;
rel=0;
lcd_init();
lcd_command(0x01);
lcd_command(0x0E);
lcd_string(0x80,"REAL TIME CLOCK");
lcd_string(0xC0,"TIME:");
while(1)
{
RTC_Read();
RTC_Display();
buzzer();
temp = keyboard();
// lcd_command(0x80);
// lcd_data(temp+0x30);
// mydelay(100);
if(temp!=16)
{
if(temp==15)
{
RTC_Edit();
39
}
if(temp==10)
{
ALARM_Edit();
}
}
}
}
40
Chapter – 6: Bill of Material
41
Chapter – 7: Troubleshooting
Instead of Use of Push button, we used the SPDT relay Start and Stop the alarm.
We tested output of LCD and RTC independently to check it’s properly working.
42
Chapter – 8: How to run project
4. Now you can observe the time on LCD, if you want to set the time make the start
pin low and press the push button.
5. LCD show set time message, now use push button for setting time.
7. To set the alarm set the alarm with the push button and set hour and minute.
8. When the alarm time matched with Real Time, the alarm will ON and the Buzzer
is on.
43
Chapter – 9: Future Enhancement
In the future we will implement in our project that we use any sensor and displays it
value in display and recorded in the PC.
In our project we also implement GSM module for give the data to Mobile from the
circuit.
To reduce the circuit are in future we implement this on the advance controller.
44
Chapter – 10: Conclusion
On working this project we conclude that to varied the time and functions to set the
alarm on the Digital Clock, which sated particular time the buzzer will be ring up and
indicate the time of alarm has been exceed at the sated time.
45
Chapter – 11: Reference
www.engineersgaurage.com
www.circuitstoday.com
www.8051projects.com
www.sunrom.com
www.mikroe.com
46
Photo of Our Project:
47