CHAPTER 1 INTRODUCTION 1.0. OVERVIEW OF THE PROJECT. The Digital clock is the type of clock that displays time digitally. The digital clock was design in order to enhance the student’s knowledge on circuit design using software’s, circuit building using bread board and implementation of the circuit on PCB. This was made through contributions from all the group members. Each and every member contributed to his best ability to ensure that the digital clock is being created. The digital clock has three mainly parts namely, the hour section, minute’s sections and the second’s sections. Each of the minute and second section has been designed to give a count from 00 to 59 after which it resets to 00 and the hour section to give a count from 00 to 23 hours after which it resets to 00. For each cycle of 00 to 59 in second section the minute section increases its count by 1. Where all the three sections will be generated from AT89C51 microcontroller which is from the 8051 family. The Atmel AT89C51 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89C51 microcontroller is the one responsible in generating the timing because it’s a programmable chip that has input and output pins, and also having timer. Finally all the three parts will be discussed later in the chapters. 1.1 AIM OF THE PROJECT 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CHAPTER 1
INTRODUCTION
1.0. OVERVIEW OF THE PROJECT.
The Digital clock is the type of clock that displays time digitally. The digital clock was design in order to
enhance the student’s knowledge on circuit design using software’s, circuit building using bread board
and implementation of the circuit on PCB. This was made through contributions from all the group
members. Each and every member contributed to his best ability to ensure that the digital clock is being
created.
The digital clock has three mainly parts namely, the hour section, minute’s sections and the second’s
sections. Each of the minute and second section has been designed to give a count from 00 to 59 after
which it resets to 00 and the hour section to give a count from 00 to 23 hours after which it resets to 00.
For each cycle of 00 to 59 in second section the minute section increases its count by 1. Where all the
three sections will be generated from AT89C51 microcontroller which is from the 8051 family.
The Atmel AT89C51 is a powerful microcontroller which provides a highly-flexible and cost-effective
solution to many embedded control applications. The AT89C51 microcontroller is the one responsible in
generating the timing because it’s a programmable chip that has input and output pins, and also having
timer.
Finally all the three parts will be discussed later in the chapters.
1.1 AIM OF THE PROJECT
The main aim of this project is to build team work among the students and also to help the students to
enhance their knowledge and apply their knowledge to design and build a 24hrs digital clock.
1.2 OBJECTIVE OF THE PROJECT
1. To build a team working experience among students.
2. To design and build a digital clock
3. To develop a program for the microcontroller
1
1.3 PROJECT SPECIFICATIONS
The students were required to design a working 24hrs alarm digital clock. The students were given the
opportunity to use any method in creating the digital alarm or day indication clock which show’s hours,
minutes and seconds.
It was stated that the digital clock should have alarm or day indicator. Students were also required to
provide a power supply unit for the digital clock with a battery backup facility.
1.4 Module Structure
The entire project has been divided into Five modules. They are as follows:
Second section
Using port 1(Microcontroller) in such a way that this portion produces output from 00 to 59
continuously .
Using Driver IC (IC 7447) and seven-segment display to display the counts. Both the ICs are of
common anode type.
Checking the output of the circuit.
Minute section
Using port 2 (Microcontroller) in such a way that this portion produces output, the output should
count from 00 to 59 with a frequency of 1Hz.for
Using Driver IC (IC 7447) and seven-segment display to display the counts. Both the ICs are of
common anode type.
Checking the output of the circuit.
Hour section
Using port 0(Microcontroller) in such a way so that this portion produces output, the output should
counts from 23.59.59 then resets to 00.
Here the counting proceeds with a frequency of one pulse per hour.
Using Driver IC (IC 7447) and seven-segment display to display the counts. Both the ICs are of
common anode type.
Checking the output.
2
Day indication section
Port 3 is programmed in such a way to produce the day indications. When the time reaches 24hrs the
LED will light.
The 74138 IC will be used to switch on or off the LED when it reaches 24hrs.
Assembling the Four sections together.
Checking the final output of the circuit.
CHAPTER 23
LITERATURE REVIEW
2.1 Introduction
This chapter will present the overview about the digital clock.
2.2 Digital Clock Overview
Digital clock is a type of clock that displays the time digitally, as opposed to an analog clock,
where the time is displayed by hands. Digital clocks were invented in 1959 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 seven segment LED or LCD.Usually, digital clocks are associated with electronic
drivers, unlike the analog clock which function is mechanically or also electrically driven. There are
many ways to design a digital clock such as using PIC, Atmel etc and C++, C or assembly languages are
used for the program. (http://www.waset.org/journals/waset/v42/v42-67.pdf)
2.3 AT89C51 MICRCONTROLLER.
For this project the AT89C51 is chosen to be used as its core and the assembly language is used
for the program. Atmel At89c51 is a microcontroller that is widely used in electronic projects. A
microcontroller (MCU) is a functional computer system-on-a-chip. It contains a processor core, memory,
and programmable input/output peripherals. The AT89C51 was chosen for its immense functionalities,
low-power, and high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and
The Atmel AT89C51 used in this project is a 40 pin AT89C51. Where it
is divided into port 0, port 1, port 2, port 3, while the remaining pins
went to ground, Vcc, reset and crystal oscillator etc.
PORT 0 (pins 32 to 39)
The port zero is the first upper right side port of the microcontroller, which consists of 8 pins which are P1.0, P1.1 ,P2.2 ,P3.3 ,P4.4,P5.5 ,P6.6 ,P7.7 . Port 0 also receives the code bytes during Flash programming and outputs the codes byte during program verifications. The Hours’ section was generated from the PORT 0
PORT 1 Pins 1 to 8)
The port zero is the first upper left side port of the microcontroller, which consists of 8 pins which are P1.0, P1.1 ,P1.2 ,P1.3 ,P1.4 ,P1.5 ,P1.6 ,P1.7 . Port 1 also receives the code bytes during Flash programming and outputs the codes byte during program verifications. The second’s section was generated from the PORT 1
1. Connect 330-ohm resistors to Pin 16 to 5volts supply and pin 8 to ground.2. Connect pins 13, 12, 11, 10, 9, 15 and 14 of the 7447, to the, b, c, d, e, f, and g segments of the 7-
segment LED.3. Connect the pins 1,2,6 and pin 7 of the 7447 to the A,B,C,D of the microcontroller.
BCD INPUT OUTPUT ( 7segment) DISPLAY
D C B A a b c d e f g
0 0 0 0 1 1 1 1 1 1 0 0
0` 0 0 1 0 1 1 0 0 0 0 1
0 0 1 0 1 1 0 1 1 0 1 2
0 0 1 1 1 1 1 1 0 0 1 3
0 1 0 0 0 1 1 0 0 1 1 4
0 1 0 1 1 0 1 1 0 1 1 5
0 1 1 0 0 0 1 1 1 1 1 6
0 1 1 1 1 1 1 0 0 0 0 7
1 0 0 0 1 1 1 1 1 1 1 8
1 0 0 1 1 1 1 0 0 1 1 9
TRUTH TABLE
CHAPTER 4
4.1 SOFTWARE IMPLEMETATION
i. Description of codings:-
The hour, minutes, seconds and the day indication section were obtained or generated from the
AT89C51 microcontroller through series of codes. The four sections codes will be explained below:
12
Seconds section
First initialize the data value to the port 1 by moving 00 hexadecimal to register 0, then move the register 0
to port 1 of the microcontroller because the digital clock starts at 0 seconds. Acall delay is a function used
as a time delay for setting the clock frequency. The whole program starts from increasing the second by one
using the accumulator (A) and the seconds is converted from hexadecimal to decimal using DA, which
mean decimal adjustment, then move A back to register 0 then to port 1 It will then compare the value at the
register 0 with 60 hexadecimal; if it is not equal 60, it will jump back to the start and add one to the second.
After the second is equal to 60, it will reset the value of the R0 to 00 and start increasing the minute by one.
Note:-
- DA A means decimal adjustment for addition, which converts hexadecimal to decimal values. The
DA instruction works only on A. In other word, while the source can be an operand of any
addressing mode, the destination must be in register A in order for DA to work.
- The A is a register called the accumulator, and by default it receives the result of all arithmetic
operations.
- R0 is a register in port 1 used to store information temporarily.
PSEUDOCODES IMPLEMENTATION
SECONDS
Move data 00 to register0
Move register0 to port1
Label START
13
Move register0 to port1
Move register0 to Accumulator A
Call DELAY
Add 1 to Accumulator
Decimal adjustment Accumulator
Move Accumulator to register0
Move register1 to port1
Compare register0 with 60
If register0 not equal to 60
Go to START
If register0 equal 60
Move data 00 to register0
DELAY
Move data 10 to register7
Label L3
Move data 200 to register6
Label L2
Move data 250 to register5
Label L1
Compare register5 with 0
If register5 not equal to 0
Decrease register5 by 1 and go to L1
If register5 equal to 0
Compare register6 with 0
If register6 not equal to 0
14
Decrease register6 by 1 and go to L2
If register6 equal to 0
Compare register7 with 0
If register7 not equal to 0
Decrease register7 by 1 and go to L3
If register7 equal to 0
Return to program after delay.
Minutes section:
First initialize the data value to the port 2 by moving 00 hexadecimal to register 2, then move the register 2
to port 2 of the microcontroller because the digital clock starts at 0 minutes. The whole program starts from
increasing the minutes by one using the accumulator (A) and the minutes is converted from hexadecimal to
decimal using DA, which mean decimal adjustment, then move A back to register 2 then to port 2. It will
then compare the value at the register 2 with 60 hexadecimal; if it is not equal 60 it will jump all the way
back to the increment of seconds till the seconds reaches 60 seconds before adding one to the minutes. After
the minute is equal to 60, it will reset the value of the R2 to 00 and start increasing the hour by one.
MINUTES PSEUDOCODES
Move data 00 to register2
Move register2 to port2
Move register2 to Accumulator A
Add 1 to Accumulator
Decimal adjustment Accumulator
Move Accumulator to register2
Move register2 to port2
Compare register2 with 60
If register2 not equal to 60
Go to START
15
If register2 equal 60
Move data 00 to register2
Move register2 to port2
Hour section:-
Once the minute reach 60, it will reset the value of Register2 to 00 and start increasing the hour by one.
Port0 is used for the hour display. After adding one to Register1, the program will compare Register1
with 24, if it is not equal; it will jump back to seconds counting till it reaches 60 seconds and go all the
way to 60 minutes again before adding one to the hour. When the hour reaches 24, it will be reset to 00
and the whole digital clock will reset to 0, which is the initial condition. And then repeat the entire three
processes continuously, That was why SJMP was used.
Note:-
- SJMP mean short jump, which is used in repeating the seconds, minutes and hours continuously.
HOURS PSEUDOCODES
Move register1 to Accumulator A
Add 1 to Accumulator
Decimal adjustment Accumulator
Move Accumulator to register1
Compare register1 with 24
If register1 not equal to 24
Go to START
If register1 equal 24
Move data 00 to register1
Move register1 to port1
Day indication section:-
Port 3 of the microcontroller is used for day indicator. First, declare register 3 as 0 and move it to port 3. This will be the initial condition, which is the first day when the digital clock starts. This data is then comparing with 7, if it is not equal; it will continue showing 0 until the next 24 hours
16
reached. The port 3 of microcontroller is connected with a demultiplexer 74138, which will convert the data to binary and light the respective LED.
After 24 hours, the value of register 3 will be increased by 1 and compare again with 7. The whole process will continue until the value reaches 7, where it will be reset to 0 again after 24 hours.
DAY INDICATOR PSEUDOCODES
Increase register3
Compare register3 with 7
If register3 not equal to 7
Go to SKIP
If register3 equal to 7
Move data 00 to register3
Label SKIP
Move register3 to port3
4.2.HARDWARE CONSTRUCTION
The entire digital clock was first build on a breadboard to test the connections, and later on the
components were placed on a Printed circuited board. The printed circuit processes will be explained
below:
P.C.B. DESIGNING
i. P.C.B. LAYOUT
The entire circuit was assembled on a general purpose PCB board. PCB layout of the circuit and
preparations are the first and most important in any printed circuit board. Firstly layouts of components
were designed according to the available component dimensions in a PCB software.
The following points are to be observed while forming a PCB:
1. Between two components, sufficient space should be maintained to avoid partial contacts
2. High voltage dissipated components should be mounted at a sufficient distance from
semiconductor and electrolytic capacitors.
17
P.C.B. DESIGNING & WORKING
Printed circuit board (P.B.C) is used to avoid most of all the disadvantages of convectional breadboard.
These also avoid the use of thin wires for connecting the components.
PCB consist of the following processes:-
1. Designing in the software
2. Ironing
3. Etching
4. Drilling
5. Soldering
6. Troubleshooting.
4.3 ELECTRICAL CONSTRUCTION.
The entire clock was controlled electrically with the use of the power supply unit. Where the power supply unit consists of different components as shown in Fig 4.3 :-
V1
230 Vrms 50 Hz 0°
U6LM7805CTLINE VREG
COMMON
VOLTAGEC11mF
T1D1
1B4B42 1
2
4
3
D21N4001
Battery9 V
Fig 4.3
1. Transformer:-To step down high voltage AC mains to low voltage AC.
2. Bridge Rectifier:- To convert AC to DC, but the DC output is varying.
3. Electrolytic capacitor:- To smooth the DC from varying greatly to a small ripple.
4. 7805:- To eliminate ripple by setting DC output to a 5 voltage.
5. 1N4001: To serve as switch between main supply and the battery.
6. Battery: To serve as backup power supply.
CHAPTER 5
RESULTS AND DISCUSSION.
5.1. SIMULATION RESULTS AND DISCUSSION 18
In this chapter, the power supply unit will be discussed in detail.
1. Transformer:- To step down high voltage AC to low voltage AC.The output result is shown below:
Input signal output signal
2. Bridge Rectifier:- To convert AC to DC, but the DC output is varying. The output is shown below:
V1
230 Vrms 50 Hz 0°
D1
1B4B42
1
2
4
3
T1
XSC1
A B
Ext Trig+
+
_
_ + _
3. Filter:- smooth the DC from varying greatly to a small ripple. The output result is shown below:
T1C21mF
V1
230 Vrms 50 Hz 0°
D1
1B4B42
1
2
4
3
XSC1
A B
Ext Trig+
+
_
_ + _
4. Regulator:- To eliminate ripple by setting DC output to a 5 voltage. The output result is shown below:
19
V1
230 Vrms 50 Hz 0°
D1
1B4B42
1
2
4
3
T1C11mF
U1LM7805CTLINE VREG
COMMON
VOLTAGE
XSC1
A B
Ext Trig+
+
_
_ + _
5.2 DESIGN CALCULATIONS
Calculating 330 ohms resistor for 7 segment
7 segment voltage=1.7volts
7 segment current=10mA
Total voltage=5Volts
R= 5 v−1.7 v
10 mA=330ohms
Calculating electrolytic capacitor.
c= Vsmax∆ V . Fp. RL
c= 25(25−7 )∗50 Hz∗29
=957.85uF ≅ 1000 uF
Calculating the period , T= 1F
= 150 Hz
=20 mS
Calculating Vpp = Vpp=Vmax−Vmin=19.2 — (−18.8)
Vpp=38.0 Volts
Vp=Vpp2
=382
=19 V
Calculating Vrm= V rms=¿ Vp
√2=19
√2=13.5Volts
Vavg=2 Vpπ
20
Where :−Vsmax of regulator=25 volts
Vmin of regulator=7 volts ,
∆ V ¿ ¿ the regulator ¿=25 V−7 V
Fp=50 Hz
RL=29 Ώ
Vdc=Vpπ
= 193.142
=6.04
Ripple factor=VrmsVdc
=13.56.04
=2.23
CHAPTER 6
CONCLUSION AND RECOMENDATION
6.1 CONCLUSION
Our project met our expectations, because students were able to develop a working 24hrs digital
clock with a day indicator. Through studying Microcontrollers it is clear that designing a digital clock is
much easier than using decade counters. Yet in order for this to happen, the microcontroller must be
programmed in such a way to generate and control the time.
Finally the initial specifications of the project were fulfilled within the time allocated, and
students were able to applied what they have learned and achieved all the project objectives and
challenges.
6.2 RECOMMENDATION
The AT89C51 was a fairly simple component to use, and the program commands were easy to learn and
ideal for our application. Yet further enhancements could have been made, such as setting the time and
day.
21
(Electronic design)
REFERENCE:-
Online:
At89c51 datasheet available at http://www.keil.com/dd/docs/datashts/atmel/at89c51_ds.pdf
accessed march 6th 2011
http://en.wikibooks.org/wiki/Embedded_Systems/8051_Microcontroller accessed March 10th
2011
JOHN HEWES power supply unit 2010 available at http://www.kpsec.freeuk.com/powersup.htm,
accessed april 1st 2011.
PERRY ANDREWS Digital Clock September 2007 available at
http://www.pelnet.co.uk/elect/projects/clock/Clock_a.pdf accessed April 2nd 2011
NOOR AZIANA Real time clock display MAY 2006 available at
http://library.utem.edu.my/index2.php?
option=com_docman&task=doc_view&gid=691&Itemid=113 accessed April 2nd 2011
74LS47 datasheet available at http://focus.ti.com/lit/ds/symlink/sn74ls47.pdf accessed on 4th April
2011
74LS138 datasheet available at http://focus.ti.com/lit/ds/symlink/sn74ls138.pdf accessed 6th
April 2011
Interfacing to7-Segment Numeric Displays available at
http://www.thelearningpit.com/lp/doc/7seg/7seg.htm accessed march 10
7447 BCD to 7-segment display driver available at http://www.elektropage.com/default.asp?
tid=438&kw=Drives accessed march 2nd 2011
Elaine Anderson Analog Vs. Digital Clocks 2010 available at
(http://www.ehow.com/facts_7211103_analog-vs_-digital-clocks.html) accessed march 12th 2011
Pan Thu Tun Development and Implementation of Microcontroller-based Digital Clock
2008available at (http://www.waset.org/journals/waset/v42/v42-67.pdf) accessed 20th march 2011
BOOKS:-
1. Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. McKinlay The8051 Microcontroller
and Embedded Systems Using Assembly and C Second Edition Prentice Hall Inc.