Real Time Digital Clock

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.

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

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.


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 


Pic16f877a Based Digital Clock using push buttons
Basic Circuitry For Digital Clock

Microcontroller Based Digital Clock using EEPROM & Push Buttons

Digital Clock State When Power is Supplied

PIC16F877A based Digital Timer using EEPROM & Push Buttons for setting the time

Digital Clock State when Set Button is pressed caption

EEPROM Function Based Digital Clock display on LCD

Digital Clock State after setting hours & minutes

PIC 16f877A based Digital Clock Hardware using EEPROM Function and timer of microcontroller

Digital Clock in Hardware Form




Working of the Circuit

There are three push buttons (one latched action and two momentary actions) at first three pins of port b (B0 – B2). The state of button at pin B0 determines whether the user wants to set time or not. If the user wants to set time, the switch must be turned on and only then time can be changed and set. If the button at pin B0 is off, the time will not be changed even by pressing the buttons at pin B1 and B2. As button at B0 is in ON state for time setting purpose, the button at B1 is used to increment the hours and rolls over to one (1) after twelve (12) while the button at B2 is used to increment minutes and rolls over to zero (0) after fifty nine (59). The changing in time are readable at LCD. After setting the time, button at B0 must be switched OFF so that the clock starts working in normal format. If somehow the button B0 remains in ON condition, the program will stay in this function and the clock will never run. The data here also being written in EEPROM of micro-controller, if somehow the power goes off, the micro-controller will keep the last saved value and displays it on LCD.



When the button is in OFF state, the timer module starts working and starts time which is displayed on LCD. In case of power loss, the data is not lost as the data is continuously moved to EEPROM of microcontroller using function Write_Data() and is retrieved from there by calling function of Read_Data().






Note : Leave Comments about the blog. Critics are also welcome.


Comments

Post a Comment