Project Report
Project Report
1. Title Page
• Title: Digital Clock Using 8051 Microcontroller
2. Table of Contents
• Introduction
• Project Requirements
o Hardware Components
o Software Tools
o Code Explanation
• Conclusion
• References
3. Introduction
This project involves designing and implementing a digital clock using the 8051 microcontroller.
The microcontroller will manage timekeeping through timers and interrupts, while the current
time is displayed on a 7-segment display or LCD. The clock can be configured using push
buttons to set the hours and minutes.
Objectives:
4. Project Requirements
4.1 Hardware Components
• 8051 Microcontroller (AT89C51)
The system is built around the 8051 microcontroller, which is responsible for timekeeping and
managing user inputs. The clock will use a crystal oscillator for accurate timing and timers for
managing second, minute, and hour counts. Push buttons allow users to set the time.
Block Diagram:
• 8051 Microcontroller: Central control unit, managing time and user input.
Connections:
• Push Buttons: Connect to the microcontroller's input pins with pull-up resistors to avoid
floating states.
• Oscillator: Connect the crystal oscillator to the XTAL1 and XTAL2 pins of the 8051 for
clock pulses.
• Power Supply: Provide a stable 5V DC supply to power the microcontroller and display.
7. Flowchart and Working Principle
Flowchart:
5. Increment Time: When the interrupt triggers, increment seconds, minutes, and hours as
needed.
6. Update Display: Refresh the display with the new time values.
7. Check for Button Presses: If a button is pressed, enter the time-setting mode.
8. Set Time: Adjust hours and minutes based on user input.
• Timekeeping: The microcontroller uses its internal timer to generate an interrupt every
second. When the timer overflows, it triggers an interrupt service routine that increments
the seconds counter. If the seconds reach 60, minutes are incremented, and the seconds
reset to 0. Similarly, when minutes reach 60, hours are incremented, and minutes reset to
0. When hours reach 24, they reset to 0.
• Time Setting: Push buttons allow the user to adjust the hours and minutes. When a
button is pressed, the microcontroller enters a time-setting mode where the user can
increment hours or minutes.
The code is written in C and compiled using the Keil uVision IDE. The microcontroller is
programmed to handle timekeeping via timer interrupts and update the display accordingly. The
push buttons are used for setting the time.
Code:
void update_display() {
// Code to update the 7-segment display or LCD with the current time
}
void timer_init() {
TMOD = 0x01; // Timer0 in mode 1 (16-bit timer)
TH0 = 0xFC; // Load timer high byte for 1 second delay
TL0 = 0x66; // Load timer low byte
IE = 0x82; // Enable Timer0 interrupt
TR0 = 1; // Start Timer0
}
void main() {
timer_init(); // Initialize timer
while(1) {
// Main loop: clock update handled in the interrupt
// Handle button input for setting the time
}
}
Code Explanation:
• Interrupt Handling: The timer0_isr() function increments the time variables and calls
update_display() to refresh the display.
• Main Loop: The main loop continuously runs, with most of the time management
handled by interrupts.
9. Testing
Hardware Testing
10. Conclusion
Summarize the outcome of the project:
• Reflect on any challenges and how they were overcome (e.g., timing issues, display
refresh).