Vous êtes sur la page 1sur 21

ABSTRACT

Now-a-days people prefer digital clocks more than an analog clock because of their
elegant outlook, inexpensiveness, small size and accuracy. As a result many smart
digital clocks are manufactured by different popular companies. Because of its low
price and tiny size, it is often incorporated into all kinds of devices such as cars,
radios, televisions, microwave ovens, standard ovens, computers and cell phones to
enhance the quality of that device. In this particular project, design of a smart
multipurpose clock is provided. This clock is designed with two PIC microcontrollers
and a Real Time Clock (RTC) IC. The display section is designed with Seven
Segment display and LED. A temperature sensor is also integrated with the system to
show the current temperature in Seven Segment. A seven segment display is the
most basic electronic display device that can display digits from 0-9. They find wide
application in devices that display numeric information like digital clocks, radio,
microwave ovens, electronic meters etc. The most common configuration has an array
of eight LEDs arranged in a special pattern to display these digits. They are laid out as
a squared-off figure 8. Every LED is assigned a name from 'a' to 'h' and is identified
by its name. Seven LEDs 'a' to 'g' are used to display the numerals while eighth LED
'h' is used to display the dot/decimal.
A seven segment is generally available in ten pin package. While eight pins
correspond to the eight LEDs, the remaining two pins (at middle) are common and
internally shorted. These segments come in two configurations, namely, Common
cathode (CC) and Common anode (CA). In CC configuration, the negative terminals
of all LEDs are connected to the common pins. The common is connected to ground
and a particular LED glows when its corresponding pin is given high. In CA
arrangement, the common pin is given a high logic and the LED pins are given low to
display a number. Find out more information about a seven segment display and its
working

INTRODUCTION
A digital clock is no different than an analog clock. It simply handles the timing
functions electronically rather than mechanically [1]. A digital clock is a type of clock
that displays the time digitally , i.e. in the LCD, LED or Seven Segment display, as
opposed to an analog clock, where the time is displayed by hands [2]. Electronic
clocks have predominately replaced the mechanical clocks as they are much reliable,
accurate, maintenance free, portable and cost effective [3]. In this project work a
multipurpose digital clock is developed which not only shows the time operations but
also indicates the room temperature. The whole controlling operation is maintained
by a PIC microcontroller 16F877A which not only communicates with a Real Time
Clock IC but also calculates the whole time functions and displays it with Seven
Segment and LED displays. Another PIC microcontroller 16F72 is used to enhance
the number of ports and synchronizes with main controller IC to display the days in
the LED. A real-time clock (RTC) is used to keep 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 [4] for precise work to be maintained.

Fig 1: Overall proposed system

OVERALL SYSTEM

An overall block representation of the proposed smart multipurpose clock is shown


in figure 1. In this system a main controller IC PIC 16F877A is used to synchronize
the operation of a RTC IC DS1307 and Seven Segments. The time and date are
displayed by Seven Segments whether the day and AM/PM operations are
displayed with LED. There is an additional option in this clock. It also displays the
temperature in Seven Segments. In a simple LED package, typically all of
the cathodes (negative terminals) or all of theanodes (positive terminals) of the
segment LEDs are connected and brought out to a common pin; this is referred to as
a "common cathode" or "common anode" device.[6] Hence a 7 segment plus decimal
point package will only require nine pins, though commercial products typically
contain more pins, and/or spaces where pins would go, in order to match
standard IC sockets. Integrated displays also exist, with single or multiple digits.
Some of these integrated displays incorporate their own internal decoder, though
most do not: each individual LED is brought out to a connecting pin as described.

A multiplexed 4-digit, seven-segment display with only 12 pins

Multiple-digit LED displays as used in pocket calculators and similar devices


used multiplexed displays to reduce the number of I/O pins required to control the
display. For example, all the anodes of the A segments of each digit position would
be connected together and to adriver circuit pin, while the cathodes of all segments
for each digit would be connected.

To operate any particular segment of any digit, the controlling integrated


circuit would turn on the cathode driver for the selected digit, and the anode drivers
for the desired segments; then after a short blanking interval the next digit would be
selected and new segments lit, in a sequential fashion.

In this manner an eight digit display with seven segments and a decimal point
would require only 8 cathode drivers and 8 anode drivers, instead of sixty-four
drivers and IC pins.[7]Often in pocket calculators the digit drive lines would be used
to scan the keyboard as well, providing further savings; however, pressing multiple
keys at once would produce odd results on the multiplexed display.

HARDWARE DESIGN

Main Controller Section


The control module is built with the microcontroller IC. The central controller is
Microchip PIC16F877A. PIC 16F877A is an upper range and 16 series low cost 8
bit microcontroller [5], [6]. It consists of 33 I/O (Bi directional lines) with 25mA
current in per pin. It also has 5 channel built-in A/D converter and serial
communication. Its synchronous serial port can be configured as either 3-wire
Serial Peripheral Interface (SPI) or the 2-wire Inter-Integrated Circuit (IC) bus.
Universal Asynchronous Receiver Transmitter (UART) is another useful feature of
this device. Another PIC microcontroller 16F72 is used in this project to show the
DAY option of the digital clock. It is synchronized with 16F877A. PIC 16F72 is a
28 pin 8-bit microcontroller with 8-bit ADC [7].

Real Time Clock DS1307


Clocked by 32.768 kHz crystal; the Maxim DS1307 is one of the popular I2C
8-pins RTC chip available on the market [8], [9]. Equipped with Automatic
Power-Fail Detect and Switch Circuitry the Maxim DS1307 will continue to
operate accurately even though the main power supply is lost and because its
consumed less than 500nA on 3 volt lithium backup battery (48mAhr or greater),
the DS1307 will continue to operate more 10 year in the absence of the main
power supply. The DS1307 is capable to count accurately the second, minute, hour,
day of the week, date of the month, month and year include the leap year until the
year 2100; with its I2C interface capabilities make this chip easily to be integrated
with widely available microcontrollers that have build in I2C peripheral. The
DS1307 Serial Real-Time Clock is a low-power; full binary-coded decimal (BCD)
clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred
serially via a 2-wire, bi-directional bus. The clock/calendar provides seconds,
minutes, hours, day, date, month, and year information. The end of the month date
is automatically adjusted for months with fewer than 31 days, including
corrections for leap year. The clock operates in either the 24-hour or 12-hour
format with AM/PM indicator. The DS1307 has a built-in power sense circuit that
detects power failures and automatically switches to the battery supply.

Fig : Connection Diagram of DS1307

FEATURES

Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day

of the week, and year with leap-year


compensation valid up to 2100
56-byte, battery-backed, nonvolatile (NV)
RAM for data storage
Two-wire serial interface
Programmable square wave output signal
Automatic power-fail detect and switch circuitry
Consumes less than 500nA in battery backup mode with oscillator running
Optional industrial temperature range: 40C to +85C
Available in 8-pin DIP or SOIC Underwriters Laboratory (UL) recognized

PIN ASSIGNMENT

PIN DESCRIPTION

VCC - Primary Power Supply

X1 X 2 - 32.768 kHz Crystal Connection

VBAT - +3V Battery Input

GND - Ground

SDA - Serial Data

SCL - Serial Clock

SQW/OUT - Square Wave/Output Driver

The DS1307 operates as a slave device on the serial bus. Access is obtained by
implementing a START condition and providing a device identification code
followed by a register address. Subsequent registers can be accessed
sequentially until a STOP condition is executed. When VCC falls below 1.25 x
VBAT the device terminates an access in progress and resets the device address
counter. Inputs to the device will not be recognized at this time to prevent
erroneous data from being written to the device from an out of tolerance
system. When VCC falls below VBAT the device switches into a low-current
battery backup mode. Upon power-up, the device switches from battery to VCC
when VCC is greater than VBAT + 0.2V and recognizes inputs when VCC is
greater than 1.25 x VBAT. The block diagram in Figure 1 shows the main
elements of the serial RTC.

SIGNAL DESCRIPTIONS

VCC, GND DC power is provided to the device on these pins. VCC is the
+5V input. When 5V is applied within normal limits, the device is fully
accessible and data can be written and read. When a 3V battery is connected to
the device and VCC is below 1.25 x VBAT, reads and writes are inhibited.
However, the timekeeping function continues unaffected by the lower input
voltage. As VCC falls below VBAT the RAM and timekeeper are switched over
to the external power supply (nominal 3.0V DC) at VBAT.

VBAT Battery input for any standard 3V lithium cell or other energy source.
Battery voltage must be held between 2.0V and 3.5V for proper operation. The

nominal write protect trip point voltage at which access to the RTC and user
RAM is denied is set by the internal circuitry as 1.25 x VBAT nominal. A
lithium battery with 48mAhr or greater will back up the DS1307 for more than
10 years in the absence of power at 25C. UL recognized to ensure against
reverse charging current when used in conjunction with a lithium battery.

SCL (Serial Clock Input) SCL is used to synchronize data movement on the
serial interface.

SDA (Serial Data Input/Output) SDA is the input/output pin for the 2-wire
serial interface. The SDA pin is open drain which requires an external pullup
resistor.

SQW/OUT (Square Wave/Output Driver) When enabled, the SQWE bit


set to 1, the SQW/OUT pin outputs one of four square wave frequencies (1Hz,
4kHz, 8kHz, 32kHz). The SQW/OUT pin is open drain and requires an external
pull-up resistor. SQW/OUT will operate with either Vcc or Vbat applied.

X1, X2 Connections for a standard 32.768 kHz quartz crystal. The internal
oscillator circuitry is designed for operation with a crystal having a specified
load capacitance (CL) of 12.5pF. For more information on crystal selection and
crystal layout considerations, please consult Application

Crystal Considerations with Dallas Real-Time Clocks. The DS1307 can also
be driven by an

External 32.768kHz oscillator. In this configuration, the X1 pin is connected to


the external oscillator signal and the X2 pin is floated.

CLOCK ACCURACY

The accuracy of the clock is dependent upon the accuracy of the crystal and the

accuracy of the match between the capacitive load of the oscillator circuit and
the capacitive load for which the crystal was trimmed. Additional error will be
added by crystal frequency drift caused by temperature shifts. External circuit
noise coupled into the oscillator circuit may result in the clock running fast.

RTC AND RAM ADDRESS MAP

The address map for the RTC and RAM registers of the DS1307 is shown in
Figure 2. The RTC registers are located in address locations 00h to 07h. The
RAM registers are located in address locations 08h to 3Fh. During a multi-byte
access, when the address pointer reaches 3Fh, the end of RAM space, it wraps
around to location 00h, the beginning of the clock space.

DS1307 ADDRESS MAP

CLOCK AND CALENDAR

The time and calendar information is obtained by reading the appropriate

register bytes. The RTC registers are illustrated in Figure 3. The time and
calendar are set or initialized by writing the appropriate register bytes. The
contents of the time and calendar registers are in the BCD format. Bit 7 of
register 0 is the clock halt (CH) bit. When this bit is set to a 1, the oscillator is
disabled. When cleared to a 0, the oscillator is enabled.

Please note that the initial power-on state of all registers is not defined.

Therefore, it is important to enable the oscillator (CH bit = 0) during initial


configuration.

The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours
register is defined as the 12- or 24-hour mode select bit. When high, the 12hour mode is selected. In the 12-hour mode, bit 5 is the AM/PM bit with logic
high being PM. In the 24-hour mode, bit 5 is the second 10 hour bit (20- 23
hours).

On a 2-wire START, the current time is transferred to a second set of registers.


The time information is read from these secondary registers, while the clock
may continue to run. This eliminates the need to reread the registers in case of
an update of the main registers during a read.

DS1307 TIMEKEEPER REGISTERS

CONTROL REGISTER

The DS1307 control register is used to control the operation of the SQW/OUT
pin.

OUT (Output control): This bit controls the output level of the SQW/OUT pin
when the square wave output is disabled. If SQWE = 0, the logic level on the
SQW/OUT pin is 1 if OUT = 1 and is 0 if OUT = 0.

SQWE (Square Wave Enable): This bit, when set to a logic 1, will enable the
oscillator output. The frequency of the square wave output depends upon the
value of the RS0 and RS1 bits. With the square wave output set to 1Hz, the
clock registers update on the falling edge of the square wave.

RS (Rate Select): These bits control the frequency of the square wave output
when the square wave output has been enabled. Table 1 lists the square wave
frequencies that can be selected with the RS bits.

SQUAREWAVE OUTPUT FREQUENCY

2-WIRE SERIAL DATA BUS

The DS1307 supports a bi-directional, 2-wire bus and data


transmission protocol. A device that sends data onto the bus is defined as a
transmitter and a device receiving data as a receiver.
The device that controls the message is called a master. The devices
that are controlled by the master are referred to as slaves. The bus must be
controlled by a master device that generates the serial clock (SCL), controls
the bus access, and generates the START and STOP conditions.
The DS1307 operates as a slave on the 2-wire bus. A typical bus
configuration using this 2-wire protocol.

TYPICAL 2-WIRE BUS CONFIGURATION

Data transfer may be initiated only when the bus is not busy.
During data transfer, the data line must remain stable whenever the clock line
is HIGH. Changes in the data line while the clock line is high will be
interpreted as control signals.

Accordingly, the following bus conditions have been defined:

Bus not busy: Both data and clock lines remain HIGH.

I2C PROTOCOL
I2C is a serial data bus protocol that allows multiple devices to connect to
each other with fairly slow data transfer rates for better collaboration [10]. Many
microcontrollers have libraries to support I2C. The I2C bus use only 2 bidirectional
data lines for communicating with the microcontroller. The I2C protocol use
master and slave method, the master which is usually the microcontroller while the
slave can be any I2C device such as Real Time Clock DS1307. I2C communication
requires two ports, one for the serial data called SDA (serial data) to communicate
with SCK pin of PIC IC and the other for synchronize clock called SCL (serial
clock) to communicate with SDI pin of PIC IC[11].

Seven Segment Display


A seven-segment display (SSD), or seven-segment indicator, is a form of
electronic display device for displaying decimal numerals that is an alternative to the
more complex dot-matrix displays. Seven-segment displays are widely used in digital
clocks, electronic meters, and other electronic devices for displaying numerical
information. A seven segment display is the most basic electronic display device that
can display digits from 0-9.
They find wide application in devices that display numeric information like
digital clocks, radio, microwave ovens, electronic meters etc. The most common
configuration has an array of eight LEDs arranged in a special pattern to display these
digits. They are laid out as a squared-off figure 8. Every LED is assigned a name
from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to 'g' are used to display the
numerals while eighth LED 'h' is used to display the dot/decimal.
This is generally available in ten pin package. While eight pins correspond to
the eight LEDs, the remaining two pins (at middle) are common and internally
shorted. These segments come in two configurations, namely, Common cathode (CC)
and Common anode (CA). In CC configuration, the negative terminals of all LEDs
are connected to the common pins. The common is connected to ground and a
particular LED glows when its corresponding pin is given high. In CA arrangement,
the common pin is given a high logic and the LED pins are given low to display a
number. Find out more information about a seven segment display and its working
The segments themselves are identified with lower-case letters "a"
through "g," with segment "a" at the top and then counting clockwise. Segment "g"
is the center bar. Most seven-segment digits also include a decimal point ("dp")
[12]. There are two types of displays available, common anode and common
cathode [13]. In this project we use common cathode Seven Segment display to
show the time, date and temperature option.

WORKING PRINCIPLE

In this project DS1307 IC operates as a slave and it communicates with the


main controller PIC 16F877A by I2C protocol. As a master PIC 16F877A can read
and write data in DS1307 by using SDA and SCL ports. The whole clock operations
are maintained by RTC DS1307. PIC 16F877A only reads the data from RTC
DS1307 and shows it in common cathode Seven Segment displays. Six Seven
Segments are used to show the time, six are used to show date and two are used to
show temperature.
The ports of Seven Segment, i.e. a, b, c, d, e, f and g pins are scanned by
PORT B of main controller. To show the TIME, Port C of 16F877A controls the
cathodes of corresponding Seven Segments by switching of transistors. Again DATE
and Temperature Seven Segments are controlled by PORT D of 16F877A.
The temperature is measured by LM35DZ sensor and the data of the sensor is
collected by ADC port RA2 of 16F877A. AM and PM are showed by two LEDs
which are switched by a transistor from RA3 pin of main controller IC.
For setting operation two touch switches (SET and UP) are used and those are
connected in RA0 and RA1 pin of 16F877A. To connect Seven Segments, LEDs,
switches, sensor and DS1307 IC, 29 I/O pins of 16F877A are used and only 4 I/O
pins are left to show the DAY option of the designed clock.
So another PIC 16F72 which is a low cost microcontroller is used to show the
DAY option in seven LEDs. To maintain the current DAY a combination is provided
to PIC 16F72 by using the four pins of main controller.

FLOW CHART

ADVANTAGES

1. Low cost,less complexity.


2. Low Power consumption
3. Accuracy is high
4. Frees the main system for time-critical task
5. As we can reduce manpower increasing the economy to some extent

DISADVANTAGES
1. When power of total system is off so always keep battery .

APPLICATIONS
1. RTCs are present in almost any electronic device which needs to keep accurate
time.
2. It is used in devices like personal computers, servers and embedded systems.

CONCLUSION

In these days different pattern of digital clocks are available in market. Most
of them are of very high price and low quality. Many of those cannot provide the
time accurately for longer period as those are designed with timer ICs like 555
timer.

Again some digital clocks loss their data whenever the power supply shuts
down. But our designed multipurpose digital clock is accurate because of its Real
Time Clock module that keeps track of the system time and update.

The DS1307 has a built-in power sense circuit that detects power failures and
automatically switches to the 3V Li Cell battery supply which is incorporated with
the RTC. Most of the digital clock in the market does not cover all the time functions
whether our designed digital clock covers all the time options and we will also
incorporate the alarm option in next version.
However, the Temperature displaying is an additional feature of our smart
digital clock. It is possible to develop this system with only USD 7. So this version
of digital clock is really a cheap, precise and well featured device for the present
market.

REFERENCES

[1] How digital clock works


http://electronics.howstuffworks.com/gadgets/clocks- watches/digital-clock1.htm
[2] Digital Clock, 12 January 2012 (online). Available:
http://en.wikipedia.org/wiki/Digital_clock
[3] Pan Thu Tun, Development and Implementation of Microcontroller-based
Digital Clock, World Academy of Science Engineering and Technology 42
2008, pp: 362365.
[4] Real Time Clock, 29 January 2012 (online). Available:
http://en.wikipedia.org/wiki/Real-time_clock
[5] PIC16F87XA Data Sheet: 28/40/44-Pin Enhanced Flash Microcontrollers,
2003, Microchip Technology Incorporated.
[6] PIC Tutorial Hardware- PIC Vietnam (Online). Available:
http://www.picvietnam.com/download /Nigel%tutorial.pdf
[7] PIC
16F72, 31
January
2012 Available:
http://ww1.microchip.com/downloads/en/devicedoc/39597 b.pdf
[8] Booting CD/M 3 from an SD card, Available:
http://benryves.com/journal/tags/DS1307
[9] DS1307 RTC Real time clock (online).
Available:http://www.ladyada.net/learn/breakoutplus/ds130 7rtc.html
[10] Display Real Time Clock (RTC) On LCD, 5 February
2012.Available:http://www.cytron.com.my/attachment/Det ails
%20Description/PR12%20v4.pdf
[11] Sagar. G. Yadav, K. A. Narayanankutty, A Versatile Industrial Timer and Real
Time Keeper, Wireless Engineering and Technology, 2011, 2, 196-203.
[12] The Seven Segment LED, 12 January, 2012 (online). Available:
http://www.engineersgarage.com/electronic- components/7-segment-display

Vous aimerez peut-être aussi