PIC Based Real Time Digital Clock
Time is the indefinite continued progress of existence and events that occur in apparently irreversible succession from the past through the present to the future. Time is a component quantity of various measurements used to sequence events, to compare the duration of events or the intervals between them and to quantify rates of change of quantities in material reality or in the conscious experience. It is often referred as the fourth dimension along with the three spatial dimensions.
The time has prime importance and plays supreme role in all the disciplines of life.Every phenomenon in universe is occurring according to its specified time, so punctuality is must. You need to be on time to accomplish your task and succeed in your life. Clocks, being time exhibitors to humans, are one of the sources to make human punctual by notifying them. Analog and digital clocks are the main types, analog shows time by pointing towards the dial while the digital shows time on the LCD, Seven segment display or in any other format. We used a micro-controller and a 16x2 LCD to display time.
What is Digital Clock?
A digital clock is a type of clock that uses electronic methods of keeping time and displays a numeric representation of time. Digital clocks were invented in 1956 and became more popular as microchips and LEDs became cheaply available. Digital clocks typically use the 50 or 60 hertz oscillation of AC power or a crystal oscillator as in a quartz movement to keep time. To represent the time, most digital clocks use a sevensegment LED, VFD, LCD display for each of the four digits.
Two numeric display formats are commonly used on digital clocks
.
.
1. The 24-hour notation with hours ranging from 00 –23.
2. The 12-hour notation with AM/PM indicator, with hours indicated as 12AM followed by 1AM- 11AM, followed by 12 PM, followed by 1PM – 11PM.
Most digital clocks use an LCD and LED display, now display technologies are used as well such as cathode ray tubes, nixie tubes. After a reset, battery change or power failure, digital clocks without a backup battery or capacitor either start counting from 00:00, or stay at 00:00, often with blinking digits indicating that time needs to be set. Some newer clocks will actually reset themselves based on internet-time servers which in turn are tuned to National atomic clocks.
Digital clocks are very small, useful, and inexpensive. For these reasons, they are often incorporated into virtually every electronic device. Most commonly, digital clocks are incorporated into bedside alarm clock radios, but they are also found in televisions, microwave ovens, standard ovens, watches and computers.
Micro Controller PIC16f877a
The PIC micro controller PIC16f877a is one of the most renowned micro controllers in the industry. This controller is very convenient to use, the coding or programming of this controller is also easier. It uses FLASH memory technology, has a total 40 pins among which 33 are input output pins. It also has EPROM, 2x8-bit timers and 1x16-bit timer, 8 channels of 10-bit ADC module, 2 PWM / capture compare modules, serial port configuration and USART.
PIC microcontrollers are equipped with one or more precision timing systems known as Timers. They can be used to perform a variety of time precision functions, such as generating events at specific times, measuring the duration of an event, keeping date and time record, counting events, etc. The main component of a timer module is a free running binary counter that increments for each incoming pulse. Since it runs independently, it can count pulses concurrently with the main program execution. A PIC16F877a microcontroller has three built-in hardware timer modules: Timer0, Timer1 and Timer2
Components
1. PIC 16F877A
2. LCD 16x2
3. Veroboard/PCB Board
4. Crystal
5. Regulator 7805
6. Capacitors
7. Push Buttons
8. Variable Resistor
Micro Controller PIC16f877a
Timer Module
PIC microcontrollers are equipped with one or more precision timing systems known as Timers. They can be used to perform a variety of time precision functions, such as generating events at specific times, measuring the duration of an event, keeping date and time record, counting events, etc. The main component of a timer module is a free running binary counter that increments for each incoming pulse. Since it runs independently, it can count pulses concurrently with the main program execution. A PIC16F877a microcontroller has three built-in hardware timer modules: Timer0, Timer1 and Timer2
The main component of such a timing system is a free running binary counter. The counter increments for each incoming timing pulse. The counter counts continuously from 0 to 2n-1, where n is the number of bits in the counter. Since it runs independently, it can count inputs or clock pulses concurrently while the microcontroller is executing the main program. If the input clock to the binary counter has a fixed known frequency, we can make an accurate measurement of time interval by counting the pulses from the clock. For example, if a particular clock’s frequency is 1 MHz (period 1 μs), and we have counted 3000 pulses on the clock signal, then the elapsed time is 3000 microseconds.
Since timer1 counter can count from 0-65535 (216-1), this particular arrangement can measure time ranging from 0 to 65535 x 1 μs = 65.535 milliseconds, with a resolution of 1 μs. The maximum time interval a timer can measure is known as the timer’s range, whereas the resolution of a timer defines the minimum interval it can measure.
The timer module has an additional output, overflow flag that indicates the counter reaches its maximum output, in which case the timer rolls over to 0. In microcontrollers, the built-in timers generate timer overflow interrupts when they roll over back to 0 after reaching their maximum counting range.
A more advanced timer has a prescalar. A pre scalar is essentially a configurable clock-divider circuit. Depending on the selected configuration bits, the prescaler output could be the same as the input signal, or it may have half the frequency, one-fourth the frequency, one-eighth the frequency, etc. Thus, a prescaler can extend a timer’s range by reducing its resolution. For example, if we use a prescaler to our previous 16-bit timer to divide the clock frequency by 8, then the new range of the timer will be 65535 x 8 μs = 524.280 milliseconds. But the new resolution is reduced to 8 μs.
Memory
There are three types of memory Program (Flash) memory, Data memory and EEPROM (Electronically Erasable Program Read Only Memory). Micro-controller flash memory makes it possible to program a microcontroller many times before installing to device and even after the installation we can change the program. RAM Data Memory is used for storing data temporarily during program execution and it is volatile. That is, this memory is cleared when the power is gone or after CPU reset. RAM Data Memory locations are also called General Purpose Registers (GPR). These two memories have faster response time.The third memory is EEPROM memory which can be read and write electrically, can be accessed through program. It is a non volatile memory but has slower response time. EEPROM memory can be used to store data such as sensor logs, device parameters which should not be loss during power loss or CPU reset.
EEPROM
The data in the EEPROM and Flash Program Memory can be read/write during normal operations (over full VDD range). These memories are not mapped in the register file space, instead of it can be accessed through the following four Special Function Registers (SFR) for read and write operations.
1. EEDATA holds the data stored/retrieved from EEPROM
2. EEADR holds the address to which data is stored/retrieved from EEPROM
3. EECON1 holds control bits for read and write operations
4. EECON2 contains key used in writing operation
Implementation
Basic Circuitry For Digital Clock |
Digital Clock State When Power is Supplied |
Digital Clock State when Set Button is pressed caption |
Digital Clock State after setting hours & minutes |
good one
ReplyDeletesir kya plez hmen iski coding mil skti hy ....?
ReplyDeleteSure
Delete