In this project, I will show you how to design a simple Digital Clock Circuit using 8051 and DS12C887 as well as DS1307 RTC Modules.
A digital clock displays the time using numbers and it has 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 display the time and date accurately.
The circuit displays the time on LCD. For this clock, we can set the time at any instant. Here, the clock can work in either 24-hour mode or 12-hour mode and the RTC chip is configured by programming 8051 controllers.
I will demonstrate two circuits of Digital Clocks using 8051 Microcontroller: one uses the RTC DS12C887 and the other uses the RTC DS1307.
The main principle of both the circuits is the 8051 controller continuously reads the data from Real-time clock IC’s and process it in correct order to display the time on LCD.
Circuit Diagram Digital Clock Circuit using 8051 and DS12C887
- 8051 microcontroller
- Project PCB
- Programming cable
- DC Battery or 12V, 1A adaptor
- DS12C887 RTC IC
- 16*2 alphanumeric LCD
- Push buttons – 4
- Slide switches – 3
- 2 ceramic capacitors – 33pF
- 12 MHz crystal
- Electrolytic capacitor – 10uF, 16V
- Resistor (1/4 watt) – 10k
- Pot – 10k
- 5V DC power supply circuit
- Single pin connecting wires
The circuit shows you how to interface RTC IC to the 8051 controllers. Port P0 is used as a data port of Real-time clock. Port P2 of the controller is connected to the data pins of LCD. Pins P1.1, P1.2, and P1.3 of the controller are connected to the RS, RW, EN pins respectively. P1.0 is connected to the RESET of RTC. Push buttons are connected to the P1.4 and P1.5. These are used set the time. P1.6 is configured as START pin used to run the clock with time set by the user. P3.3 is connected to the push button used to call the set_time function.
DS12C887 Real Time Clock
This IC is used most of the applications to provide accurate time and date. This IC provides the time in both 12-hour mode and 24-hour mode. This IC also provides calendar components day, month and year. This RTC uses an internal lithium battery to keep the time and date updated when power is failed. This IC has 128 bytes of RAM memory. In these 128 bytes of RAM 14 bytes are used for time, date and registers. Remaining 114 bytes are used to store general purpose data.
The control registers of RTC are accessible only when the power is applied from an external source. This IC requires more than 4.25V power supply and the control registers are accessible after 200ms when external power is supplied.
- MOT: It is a bus type selection pin used to select between Intel and Motorola bus types. This pin is connected to VCC to select Motorola bus type and connected to GND or unconnected to select Intel bus type.
- 2, 3: Unused pins
- 4 – 11 (AD0 – AD7): These pins are bidirectional address and data lines of RTC. On these pins, an address is present in the first portion of the cycle and data is present in the second portion of the bus cycle.
- 12 (GND): This pin is connected to Ground.
- 13 (CS): This pin must be low to access the chip during reading and write operations.
- 14 (AS): The high pulse on this pin is used to demultiplex the data and address.
- 15 (R/W): This pin is used for reading or writes operations.
- 16: Unused pin
- 17 (DS): This is a Data Strobe pin.
- 18 (RESET): The low pulse on this pin resets all the flags and interrupts but it does not affect time and date.
- 19 (IRQ): This is an active low pin used as an interrupt input to the controller.
- 20 – 22: Unused pins
- 23 (SQW): Used to generate a square wave with predefined frequencies
- 24 (VCC): This pin is connected 5V supply
RTC Address Map
This RTC has 128 bytes of RAM with addresses 00H – 07H. The first ten locations (00 – 09) are used for clock, calendar, and alarm data. 0A – 0D address locations are used for status and control registers. Remaining address locations are used for general data. The following table shows the address locations for clock, calendar, and alarm.
This IC has 4 control and status registers namely register A, register B, Register C, register D. We need to configure all these registers to get the accurate time and date. In order to configure these registers go through the DS12C887 Datasheet
Circuit Diagram Digital Clock Circuit using 8051 and DS1307
- 8051 Microcontroller
- 8051 Development Board (Optional)
- 8051 Programmer
- DS1307 RTC Module
- 11.0592MHz Crystal (for 8051)
- 32.768 KHz Crystal (for DS1307 RTC)
- Capacitors – 33pF x 2, 10µF
- Resistors – 1KΩ x 2, 10KΩ x 2, 8 x 1KΩ Pull-up, 10KΩ POT
- 3V Lithium Battery
- Push Button
- 16×2 LCD Display
How to Operate?
- Initially, burn the program to the 8051 microcontroller
- Now give the connections as per the circuit diagram
- Switch on the board supply
- Now you can observe the time on LCD. If you want to set the time make the start pin low and press the pushbutton connected to the P3.3
- LCD shows set time message. Now use a push button which is connected to P1.4 to set hours and use another push button to set minutes.
- Now make start pin high to run the clock.
- This project is used in offices, houses, hotels, and automobiles to display the time and date.
- We can also set the alarm in this project with a little modification.