Professional Documents
Culture Documents
SUBMITTED TO
THE DEPARTMENT
ENGINEERING
FACULTY OF ENGINEERING
ENUGU STATE UNIVERSITY OF SCIENCE AND TECHNOLOGY,
(ESUT), ENUGU
OCTOBER 2006
CERTIFICATION
I,
NNAM
AMOGECHUKWU
with
registration
number
Design and
------------------------------------------------------NNAM
Date
AMOGECHUKWU
APPROVAL
This project titled Design and construction of a microcontroller
based digital calendar with time, date, month was approved
for and carried out in accordance to the standard of computer
engineering department in partial fulfillment of the requirements
for the award of bachelor of Engineering degree in Electrical and
Electronics Engineering.
The following undersigned are witnesses.
DR.
ENEH
DATE
(PROJECT SUPERVISOR)
DEDICATION
I wish to acknowledge with thank, God Almighty, who
has given me life and made this project/research work a success;
I give him all the glory.
I wish to acknowledge with gratitude the effort of my Lecturers
who worked so hard to transform me to what I am today.
I would also like to acknowledge and thank my Parents for a job
well done; their wonderful contribution through out my
educational pursuit. They have supported me financially, morally
and spiritually and I wish to express my deepest thanks to them.
ACKNOWLEDGEMENT
TABLE OF CONTENT
Title Page...i
Certification.....ii
Approval Page..iii
Dedication iv
Acknowledgement.v
Abstract .vi
Table of Contentvii
List of Figures.....viii
List of Tablesix
Abstract..x
CHAPTER ONE: INTRODUCTION
LIST OF FIGURES
FIGURE
PAGE
TITLE
LIST OF TABLES
TABLE
TITLE
PAGE
CHAPTER ONE
INTRODUCTION
controller
base
design
on
digital
calendar
is
an
MICRO
-CONTROLLER UNIT
MICRO-CONT
UNIT
ALARM UNIT
DECODER UNIT
DISPLAY UNIT
1. Keypad unit
These are soft touch buttons mounted on the front of the casing
from which input signal is sent to the microcontroller unit to
either set the calendar, time or the alarm unit.
2. Microcontroller (AT89C51):
This is an integrated circuit programmed with an EPROM
programmer to receive input signals and relating it to other
interfaced sub-unit attached to it for their corresponding signals
generation.
3. Display unit
The display unit consists of the light emitting diodes and power
transistors design to sink current to the light emitting diode
(LED). It is necessary to have these power transistors because
the micro controller cannot produce the large current needed by
4. Alarm unit
This unit is made up of the buzzer and the alarm indicator. The
alarm indicator light when the alarm is set by the depressing of
the alarm set button.
5. Decoder unit
The unit is made up of the DM74LS138 three to eight line
decoder which receive input signal from the microcontroller via
pin 1,2,3 and sends this input signal to the output pins displaying
days.
CHAPTER TWO
LITERATURE REVIEW
The digital calendar with date, month, year and time is designed
to be hung in offices, rooms, churches and even car dashboard,
where time and date can be easily accessed.
There can be little doubt that the first clock appeared shortly
after 1500, when Peter Heinlain, a black smith in Nurberg
Germany introduced main spring as a replacement for weights in
driving clocks. Early clocks were made in Germany and at Blois
in France. This early timepiece measured some 4 to 5 inches (100
to125mm) in diameter and about 3 inches (75mm) in depth.
They were carried about in hand.
One of the main defect of the early clocks was greater when fully
wound than when it was almost run down since the time/date
keeping of a clock fitted with a verge escapement is greatly
influenced by the force driving it, this problem was quite serious.
Solution of the problem was advanced between 1515 and 1540
by the invention by Jacob the Czech of praque, of the fuse, a
coned shaped groove pulley used together with a barrel
containing the mainspring is made to rotate a barrel in which it is
housed.
The most famous English clock/calendar maker of his time, who is
known for clock making improvement, was Tampion Thomas.
Tampion made an early repealing clock with calendar a type that
could be made to sound the nearest hour and nearest quarter
hour by pushing two pieces extending from the side of the clock.
Tampion devised improvement in pendulum and he constructed
several clocks made to run for a year without rewinding.
The progressive miniaturization of electronics components in the
20th century made possible the development of all electronic
clocks with calendar.
CHAPTER THREE
DESIGN ANALYSIS
Designing the system was the major part of this project work
and this involved the planning and estimation of the entire
system
before
the
actual
implementation.
Here,
every
MICRO-CONTROLLER UNIT
MICRO-CONT
UNIT
ALARM UNIT
DECODER UNIT
DISPLAY UNIT
time display.
2.
3.
P3.6, P3.7, P3.0, P0.7, and P3.1 have the same connection as
explained in P1.7 above. Therefore, this is illustrated on the
figure below
VCC
VCC
40
10k
P3.6
MICROCONTROLLER AT89C51
10K
20
P3.7
P1.7
P3.0
P0.7
10K
10K
10K
10K
INCREMENT BUTTON
DECREMENTT BUTTON
ENTER BUTTON
P3.1
GND
GND
VCC
AN7805
220/240
12vac
ac
4O
2200uf/25v
20
GND
MICROCONTROLLER AT89C51
3.1.3
Alarm unit
MICRO
- CONTROLLER AT89C51
1k
P2.7
28
vcc
VCC
VCC
Buzzer
4.7k
2k
P2.6 27
GND
Ground.
Port 0
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output
port, each pin can sink eight TTL inputs. When 1s are written to
port 0 pins, the pins can be used as high impedance inputs. Port
0 may also be configured to be the multiplexed low order
Address/data bus during accesses to external program and data
memory. In this mode P0 has internal pull-ups. Port 0 also
receives the code bytes during Flash programming, and outputs
the code bytes during program verification. External pull-ups are
required during program verification.
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The
Port 1 output buffers can sink/source four TTL inputs. When 1s
are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are
externally being pulled low will source current (IIL) because of the
internal pull-ups. Port 1 also receives the low-order address bytes
during Flash programming and verification.
Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The
Port 2 output buffers can sink/source four TTL inputs. When 1s
are written to Port 2 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are
externally being pulled low will source current (IIL) because of the
internal pull-ups. Port 2 emits the high-order address byte during
fetches from external program memory and during accesses to
external data memory that uses 16-bit addresses (MOVX @
DPTR). In this application, it uses strong internal pull-ups when
emitting 1s. During accesses to external data memory that uses
8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2
Special Function Register.
Port 2 also receives the high-order address bits and some control
signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The
Port 3 output buffers can sink/source four TTL inputs. When 1s
are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs,
Port 3 pins that are externally being pulled low will source current
(IIL) because of the pull-ups. Port 3 also serves the functions of
various special features of the AT89C51 as listed below.
Table 3.1 Alternate functions of port 3
ALE/PROG
Address Latch Enable output pulse for latching the low byte of
the address during accesses to external memory. This pin is also
the program pulse input (PROG) during Flash programming. In
normal operation ALE is emitted at a constant rate of 1/6 the
oscillator frequency, and may be used for external timing or
clocking purposes. Note, however, that one ALE pulse is skipped
during each access to external Data Memory. If desired, ALE
operation can be disabled by setting bit 0 of SFR location 8EH.
With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the
ALE-disable bit has no effect if the microcontroller is in external
execution mode.
PSEN
Program Store Enable is the read strobe to external program
memory. When the AT89C51 is executing code from external
program memory, PSEN is activated twice each machine cycle,
except that two PSEN activations are skipped during each access
to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to
enable the device to fetch code from external program memory
locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be
internally latched on reset.
XTAL1
Input to the inverting oscillator amplifier and input to the internal
clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.
green, yellow and orange LED readouts are also available. The
readouts come packaged in standard DIP configurations with
arrangement.
But
common
anode
SEVE
SEGMENT DISPLAY
LAYOUT
The
varying
input
voltage
and
produces
constant
Regulator
Transistor,
but it is actually a complex
Integrated Circuit.
Transformer Equation
E1/E2 = N1/N2 = I2/I1
Where E = Voltage
N = No of turns
I = current
Numbers 1 =primary, 2 = secondary
3.7 Analysis of power transistor (i.e. LED drivers)
A power transistor is a bipolar junction formed by joining three
sections of some conductor materials, each with a different
doping concentration. The three sections can be either a thin n
region sandwiched between p and p+ layers, or a p region
between n and n+ layers where the superscript plus indicates
more heavily doped materials .The resulting BJTs are called pnp
and npn transistors respectively [3].
YES
IS CALENDAR SET
NO
YES
IS TIME SET
NO
YES
IS ALARM SET?
END
NO
CHAPTER FOUR
DESIGN OF PROJECT
SET BUTTON
SEVEN SEGMENT
DISPLAY
TRANSISTORISE D
SEGMENT DRIVERS
AT89C51
ALARM
DECODER
LED DISPLAY
Power supplies made from these blocks are described below with
a circuit diagram and a graph of their output:
Transformer only
Transformer + Rectifier
4.2.2 Micro-Controller
From the circuit diagram below, an overview of the connection of
the various components can be explained. Thus the 10uf/16v
capacitor was connected to the reset pin and pulled high to +5v.
This is to enable the microcontroller to resets itself as power is
switched on. The reset pin requires a logic 1 to reset and at start
up the capacitor acts as a short circuit and charges up within
seconds (t=RC) via the resistor keeping the reset key at logic
zero.
The microcontroller also requires a clock input of 16 MHz
generated the crystal oscillator.
Port 1,2,3 and 0 were used for interfacing; Port 1 (pin 1-7) and
Port 0 (pin 33,34,35,36,37,38,39) were connected to the calendar
and time display segments a, b, c, d, e, f, and g of the seven
segment display. The segments of the seven segment receives a
logic signal of either 1or0 from the micrcontroller. In Port 2, pin
21, 22,23,24,25 and 26 were use as output pins to drive the
switching transistors of the individual anodes of the time and
calendar segment. Port 2 (pin 27 and 28) to switch on the alarm
and the LED to indicate alarm set. Port 3 (pin 13,14,15) are use
to send logic signals to the input select of the 3-8 line decoder
(pin 1,2,3).
TO COMMON ANODE
2K
TO PORTS
C945
VCC
CONDITIONS
MIN.
MAX.
UNIT
VCBO
OPEN EMITTER
----------
60
VCEO
OPEN BASE
------------ 50
VEBO
OPEN COLLECTOR
------------ 5
IC
------------ 100
mA
ICM
------------ 200
mA
IBM
------------ 100
mA
hfE
------------ 120
-
Analysis;
Maximum current from port 1, 2, 3 of the microcontroller is
15mA. The transistor is design to sink a minimum current of
2.5mA, therefore from OHMS LAW
R= V/I, 5/2.5=2 K.
The resistor value connected to the base of the collector is 2k.
PLANING
HARDWARE
INTERFACING
TESSTING
4.3.2
Program Code
#include "at89x51.h"
code unsigned char
digit[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0,
0x10,0x08,0x03,0x46,0x21,0x06,0x0e};
bit flag,flag1,over;
char sec,min,year,hour,day,month;
unsigned int del;
//delay function:
void delay(int pause)
{
while (!(pause==0))
{
pause--;
_asm;
mov r6,#3
mov r7,#215
00111$:
djnz r7,00111$
djnz r6,00111$
_endasm;
}
}
//;;;;;;;;;;;;;;;;;;;;;;Display Functin;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//disable timer
if((del>400)&&(disp_pos==0)){
del=1;
if(sec==60){
sec=0;
min++;
if(min==60){
min=0;
hour++;
if(hour==12){
hour=0;
//hour=0;
flag1 = !flag1;
day++;
if(++day_name==7)day_name = 0;
switch(month){
//jan
case 1:
if(day==32){
day=1;
month++;}
break;
//feb
case 2:
if((year%4)==0){
if(day==30){
day=1;
month++;}
break;
}
else{
if(day==29){
day=1;
month++;}
}
break;
//mar
case 3:
if(day==32){
day=1;
month++;}
break;
//apr
case 4:
if(day==31){
day=1;
month++;}
break;
//may
case 5:
if(day==32){
day=1;
month++;}
break;
//june
case 6:
if(day==31){
day=1;
month++;}
break;
//july
case 7:
if(day==32){
day=1;
month++;}
break;
//aug
case 8:
if(day==32){
day=1;
month++;}
break;
//sep
case 9:
if(day==31){
day=1;
month++;}
break;
//oct
case 10:
if(day==32){
day=1;
month++;}
break;
//nov
case 11:
if(day==31){
day=1;
month++;}
break;
//dec
case 12:
if(day==32){
day=1;
month=1;
year++;
if(year==100)year=0;}
break;
default:
break;
}
}
}
}
}
if(i>5){
display_buffer1=dec[year];
display_buffer2=dec[month];
display_buffer3=dec[day];
display_buffer5=dec[sec];
display_buffer6=dec[min];
display_buffer7=dec[hour];
i=0;}
switch(i){
case 0:
P2_5=0;
buffer=display_buffer1 & 0x0f;
// show
first character
if(flag&&(disp_pos!=1)){P1=0x3f;}
else{P1=digit[buffer];}
// show
break;
case 1:
P2_0=0;
buffer=(display_buffer1>>4) & 0x0f;
// show
second character
if(flag&&(disp_pos!=1)){P1=0x3f;}
else{P1=digit[buffer];}
break;
case 2:
// show
P2_1=0;
buffer=display_buffer2 & 0x0f;
// show
first character
if(flag&&(disp_pos!=2)){P1=0x3f;}
else{P1=digit[buffer];}
// show
p first character
if(flag&&(disp_pos!=5)){P0=0x3f;}
else{P0=digit[buffer];}
P2_2=1;
break;
case 3:
P2_2=0;
buffer=(display_buffer2>>4) & 0x0f;
second character
if(flag&&(disp_pos!=2)){P1=0x3f;}
else{P1=digit[buffer];}
// show
// show
second character
if(flag&&(disp_pos!=5)){P0=0x3f;}
else{P0=digit[buffer];}
P2_3=1;
break;
case 4:
P2_3=0;
buffer=display_buffer3 & 0x0f;
// show
first character
if(flag&&(disp_pos!=3)){P1=0x3f;}
else{P1=digit[buffer];}
// show
P2_4=1;
break;
case 5:
P2_4=0;
buffer=(display_buffer3>>4) & 0x0f;
// show
second character
if(flag&&(disp_pos!=3)){P1=0x3f;}
else{P1=digit[buffer];}
// show
default:
break;
}
i++; del++;
TH0=180;
// load timer
TL0=240;
TR0=1;
//enable timer
void main(void){
TMOD=0;
ET0=1;
EA=1;
TR0=1;
flag=flag1=i=0;
//intitialize variables
del=1;set_pos=disp_pos=0;day_name = 1;
sec=00;min=16;hour=10;day=17;month=12;year=11;
//P0=P1=x=0;
while(1){
if(!P3_3){
delay(30);
if(!P3_3){
switch(disp_pos){
case 1:
if(++year > 99)year=06;
break;
case 2:
if(++month>12)month=1;
break;
case 3:
if(++day>31)day=1;
if(+
+day_name==7)day_name = 0;
break;
case 4:
if(++sec > 59)sec=0;
break;
case 5:
if(++min > 59)min=0;
break;
case 6:
if(++hour > 12)hour=1;flag1=!
flag1;
break;
}
}
while(!P3_3){;}
}
if(!P3_4){
delay(30);
if(!P3_4){
switch(disp_pos){
case 1:
if(--year==05)year=99;
break;
case 2:
if(--month==0)month=12;
break;
case 3:
if(--day==0)day=31;
if(--day_name==1)day_name = 6;
break;
case 4:
if(--sec==-1)sec=59;
break;
case 5:
if(--min==-1)min=59;
break;
case 6:
if(--hour==-1)hour=12; flag1=!
flag1;
break;
}
}
while(!P3_4){;}
}
if(disp_pos!=0){
flag=1;}
else{
flag=0;
}
if(!P3_6){
delay(30);
if(!P3_6){
disp_pos++;
if(disp_pos>6)disp_pos=0;
}
while(!P3_6){;}
delay(300);
}
The
software
is
written
to
acknowledge
the
hardware
interface
existing
between
the
input/output
unit
subsystems.
When the totality of the modules was integrated together, the
system was created and all modules and sections responded to
as specified in the design through the power supply delivering
into the system designed.
5.2.1
Components Test
tested and the value read and recorded. Also for transistor test
the DMM was switched to the diode range with the symbol
in the following order. The collector, emitter and base pins were
gotten from the data analysis on power transistor.
Table 5.1 Test for Transistor
1 test on pins
2nd test on pins
st
Black probe
Collector
Emitter
Red probe
Base
Base
Capacitor
Transistor
VALUE
10000
VALUE
10000
2000
2000
220
218
10000
9980
10
10.20
10
10.15
30
29.82
Rbe
520
550
Rbc
510
548
TOLERANCE
5%
Transformer
12Vac @
13.2 @
voltage
Regulator
240Vac input
5.00
210
5.02
V
V
This section of this project report forms the concluding part of the
write up and takes a look at some of the problems encountered
during the progressive job on the system and also brings in
suggestions for further improvement and/or enhancement for the
system design.
REFERENCES
APPENDIX A
SYSTEM COMPONENTS LIST
1. Vero Board
2. Connection Wire
3. Seven Segment Display
4. Light Emitting Diode
5. Soldering Iron
6. AC Cord
7. 240 / 12v, 200 mA Transformer
8. Rectifier Diodes
9. 2200uf /25V Capacitor
10. 10uf 16V Capacitor
11. 30pf capacitor
12. Resistors
13. 7805 Voltage Regulator
14. Touch Buttons
APPENDIX B
S/N COMPONENTS
QUANTIT
UNIT PRICE
QUANTIT
300
Y PRICE
300
Y
1
220V/12V,300mA
Rectifier Diodes
40
40
2200uf/25V
30
30
10uf/16V
30
30
30pf
30
60
10k resistor
30
220 resistor
14
70
4.7k resistor
2k resistor
14
70
10
LEDS
35
11
78LS05
60
60
12
Touch Button
30
180
13
16MHz Oscillator
70
70
14
AT89C51
1700
1700
15
74LS138
150
150
16
60
60
S/N COMPONENTS
QUANTITY
UNIT PRICE
QUANTIT
17
50
Y PRICE
50
18
Connection Wires
15 yards
150
150
19
Vero Board
180
180
20
Seven Segment
120
720
21
Display
Soldering Lead
6 yards
20
120
22
AC Cord
60
60
23
Battery
60
60
24
Casing
1800
1800
APPENDIX C
CAPACITOR
TRANSFORMER
BRIDGE DIODE
VOLTAGE
REGULATOR
RESISTORS
SEVEN SEGMENT
TRANSISTOR
SEVEN SEGMENT
TRANSISTORS
RESISTORS
RESISTORS
74138
TRANSISTORS
LEDS
XTAL
AT89C51
APPENDIX D
CIRCUIT WIRING OF AT89C51
Uc / 1Segment a of seven segment of
calendar
Uc / 16..Calendar Set
Uc / 17 .....Time Set
Uc / 18 .Crystal Oscillator
Uc / 19 .Crystal Oscillator
Uc / 20 To Gnd
Uc / 21 Anode of seven segment
Uc / 22 Anode of seven segment
Uc / 23 Anode of seven segment
Uc / 24 .Anode of seven segment
Uc / 25.Anode of seven segment
Uc / 26 .Anode of seven segment
Uc / 27 .To transistor Alarm
Uc / 28 .Alarm set indicator
Uc / 32 .Decrement Button
Uc / 33 Segment g of seven segment of
calendar
Uc / 34 Segment f of seven segment of
calendar
Uc / 35 .Segment e of seven segment of
calendar
Pin 1.. Uc / 13
Pin 2 .. Uc / 14
Pin 3 .. Uc / 15
Pin 4,5,8 Gnd
Pin 6 ..Vcc
Pin 9 .. LED
Pin 10. LED
Pin 11 .LED
Pin 12 .LED
Pin 13 .LED
Pin 14 .LED
Pin 15 .LED
Pin 16 .Vcc +5v
APPENDIX F
USING C LANGUAGE)
#include "at89x51.h"
mov r7,#215
00111$:
djnz r7,00111$
djnz r6,00111$
_endasm;
}
}
//;;;;;;;;;;;;;;;;;;;;;;Display Functin;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
void display(void) interrupt 1
{
TR0=0;
//disable timer
if((del>400)&&(disp_pos==0)){
del=1;
//======running the normal clock
loop=============
sec++;
if(sec==60){
sec=0;
min++;
if(min==60){
min=0;
hour++;
if(hour==24){
hour=0;
day++;
switch(month){
//jan
case 1:
if(day==32){
day=1;
month++;}
break;
//feb
case 2:
if((year%4)==0){
if(day==30){
day=1;
month++;}
break;
}
else{
if(day==29){
day=1;
month++;}
}
break;
//mar
case 3:
if(day==32){
day=1;
month++;}
break;
//apr
case 4:
if(day==31){
day=1;
month++;}
break;
//may
case 5:
if(day==32){
day=1;
month++;}
break;
//june
case 6:
if(day==31){
day=1;
month++;}
break;
//july
case 7:
if(day==32){
day=1;
month++;}
break;
//aug
case 8:
if(day==32){
day=1;
month++;}
break;
//sep
case 9:
if(day==31){
day=1;
month++;}
break;
//oct
case 10:
if(day==32){
day=1;
month++;}
break;
//nov
case 11:
if(day==31){
day=1;
month++;}
break;
//dec
case 12:
if(day==32){
day=1;
month=1;
year++;
if(year==100)year=0;}
break;
default:
break;
}
}
}
}
}
if(i>7){
display_buffer1=dec[day];
display_buffer2=dec[month];
display_buffer3=dec[year/100];
display_buffer4=dec[year%100];
display_buffer5=dec[hour];
display_buffer6=dec[min];
display_buffer7=dec[sec];
i=0;}
switch(i){
case 1:
P2_0=0;
// show
first character
if(flag&&(disp_pos!=1)){P1=0x3f;}
else{P1=digit[buffer];}
buffer=display_buffer5 & 0x0f;
// show
p first character
if(flag&&(disp_pos!=4)){P0=0x3f;}
else{P0=digit[buffer];}
P3=i;P2_0=1
break;
case 0:
P2_0=0;
buffer=(display_buffer1>>4) & 0x0f;
// show
second character
if(flag&&(disp_pos!=1)){P1=0x3f;}
else{P1=digit[buffer];}
P3=i;P2_0=1;
buffer=(display_buffer5>>4) & 0x0f;
second character
if(flag&&(disp_pos!=4)){P0=0x3f;}
// show
else{P0=digit[buffer];}
P3=i;P2_0=1;
break;
case 3:
P2_0=0;
buffer=display_buffer2 & 0x0f;
// show
first character
if(flag&&(disp_pos!=2)){P1=0x3f;}
else{P1=digit[buffer];}
buffer=display_buffer6 & 0x0f;
// show
p first character
if(flag&&(disp_pos!=5)){P0=0x3f;}
else{P0=digit[buffer];}
P3=i;P2_0=1;
break;
case 2:
P2_0=0;
buffer=(display_buffer2>>4) & 0x0f;
second character
if(flag&&(disp_pos!=2)){P1=0x3f;}
// show
else{P1=digit[buffer];}
P3=i;P2_0=1;
buffer=(display_buffer6>>4) & 0x0f;
// show
second character
if(flag&&(disp_pos!=5)){P0=0x3f;}
else{P0=digit[buffer];}
P3=i;P2_0=1;
break;
case 5:
P2_0=0;
buffer=display_buffer3 & 0x0f;
// show
first character
if(flag&&(disp_pos!=3)){P1=0x3f;}
else{P1=digit[buffer];}
buffer=display_buffer7 & 0x0f;
p first character
if(flag&&(disp_pos!=6)){P0=0x3f;}
else{P0=digit[buffer];}
P3=i;P2_0=1;
break;
// show
case 4:
P2_0=0;
buffer=(display_buffer3>>4) & 0x0f;
// show
second character
if(flag&&(disp_pos!=3)){P1=0x3f;}
else{P1=digit[buffer];}
buffer=(display_buffer7>>4) & 0x0f;
// show
second character
if(flag&&(disp_pos!=6)){P0=0x3f;}
else{P0=digit[buffer];}
P3=i;P2_0=1;
break;
case 7:
P2_0=0;
buffer=display_buffer4 & 0x0f;
first character
if(flag&&(disp_pos!=3)){P1=0x3f;}
else{P1=digit[buffer];}
P3=i;P2_0=1;
break;
// show
case 6:
P2_0=0;
buffer=(display_buffer4>>4) & 0x0f;
second character
if(flag&&(disp_pos!=3)){P1=0x3f;}
else{P1=digit[buffer];}
P3=i;P2_0=1;
break;
default:
break;
}
i++; del++;
TH0=180;
// load timer
TL0=240;
TR0=1;
//enable timer
}
void main(void){
TMOD=0;
ET0=1;
// show
EA=1;
TR0=1;
//run timer
flag=i=0;
//intitialize variables
del=1;set_pos=disp_pos=0;
sec=59;min=20;hour=11;day=31;month=8;year=2006;
//P0=P1=x=0;
while(1){
if(!P2_2){
delay(30);
if(!P2_2){
switch(disp_pos){
case 1:
if(++day>31)day=1;
break;
case 2:
if(++month>12)month=1;
break;
case 3:
if(++year > 2100)year=2006;
break;
case 4:
if(++hour > 23)hour=0;
break;
case 5:
if(++min > 59)min=0;
break;
case 6:
if(++sec > 59)sec=0;
break;
}
}
while(!P2_2){;}
}
if(!P2_3){
delay(30);
if(!P2_3){
switch(disp_pos){
case 1:
if(--day==0)day=31;
break
case 2:
if(--month==0)month=12;
break;
case 3:
if(--year==2005)year=2100;
break;
case 4:
if(--hour==-1)hour=23;
break;
case 5:
if(--min==-1)min=59;
break;
case 6:
if(--sec==-1)sec=59;
break;
}
}
while(!P2_3){;}
}
if(disp_pos!=0){
flag=1;}
else{
flag=0;
}
if(!P2_1){
delay(30);
if(!P2_1){
disp_pos++;
if(disp_pos>6)disp_pos=0;
}
while(!P2_1){;}
delay(300);
}
}
}
APPENDIX G
SYSTEM USERS GUIDE
PROCEDURES
Step 1: Plug the power cord to AC main
Step 11: Switch the power button ON
Step 111: Press either time, calendar or alarm button to activate
the corresponding parameter to be set
Step 1V: Use the increment or decrement button to set
parameters
Step V: Then press the enter button to display either the time,
calendar or alarm.
APPENDIX I
ATMEL 89C51 MICROCONTROLLER INSTRUCTION SET