Digital Calendar
Digital Calendar
Digital Calendar
OVERVIEW
1.1 INTRODUCTION
1
BLOCK DIAGRAM:
LCD DISPLAY
RTC 12887
AT89S52
KEY PAD
POWER 4X4
SUPPLY
Methodology:
This project consists of seven major blocks. They are
1)Power supply 2)Microcontroller 3)RTC 4)Key pad 5) LCD Display
1) Power supply:
Since we are using electronic components which only work on DC we should supply
DC power to them. So we convert 220V a.c to required amount of DC power. It converts
a.c to DC using following sequence. Transformer to rectifier circuit to filter to regulator.
The output of regulator is DC. Here we are using two regulators (7805, 7812) due to our
requirement. LEDs indicate the supply of power.
2
2) Micro controller:
We are using 8952micro controller in this project. Micro controller is the control unit of
the project. All the devices are connected to the micro controller. Its function is to receive
the signal from RTC and to transmit the signal to LCD display. The appropriate date and
time would we displayed on the LCD screen.
3) RTC:
It’s a drop in replacement for IBM at computer clock/calendar. Totally non-volatile with
over 10 years of operation in the absence of power, self contained sub-system includes
lithium, quartz and support circuitry. It counts seconds, minutes, hours, days, day of the
week, date, month, and year with leap year compensation valid upto 100 years.
4)Keypad:
It is used to update the date and time when the microcontroller is reset.
5)LCD Display:
It is another output device of the system. We used 2X16 LCD display. As and when
an interruption occurs it displays the type and location of interruption with the help of
micro controller.
3
FIGURE 2 : PROJECT LAYOUT
4
2. EMBEDDED SYSTEMS
2.1 DEFINITIONS
as “Firm ware”.
implementations. The main purposes of the microprocessors are simplifying the system
design and improve flexibility. In the embedded systems, the software is often stored in a
Embedded systems are found in wide range of application areas. Originally they
were used only for expensive industrial control applications, but as technology brought
down the cost of dedicated processors, they began to appear in moderately expensive
5
Today's embedded systems are so inexpensive that they are used in almost every
electronic product in our life. Embedded systems are often designed for mass production.
• Computer printers
• Disk drives
• Handheld calculators
• Household appliances
• Medical equipment
• Measurement equipment
• Multifunction printers
2.3 ADVANTAGES
6
• All embedded systems that are based on microcontroller have low power
single chip.
2.4 DISADVANTAGES
2.5 APPLICATIONS
• Communication applications
7
3. MICROPROCESSOR AND MICROCONTROLLER
3.1 OVERVIEW
embedded product uses a microprocessor (or microcontroller) to do one task and one task
only.
computer central processing unit. Although popularly known as a "computer on chip", the
stack pointer, some working registers, a clock timing circuits and interrupt circuit.
addition special purpose devices such as interrupts, counters may be added to relieve the
large system can be configured around the CPU as the application demands. The internal
CPU architecture as well as the resultant machine level code that operates that
that data and store those calculations in mass storage devices or display the results for
user use. The program is used by microprocessor are stored in the mass storage devices
8
A microcontrollers is a computer on a single chip .Micro suggest that the device is
small and controller tells that the device is used to control objects, process or events
comprising a computer. Typically this includes a CPU, RAM, Input/ Output ports, timers,
general purpose computer which also includes all of these devices. A microcontroller is
A microcontroller is a general purpose device but one that is meant to read data,
performs limited calculations on that data and control its environment based on those
calculations.
fixed program that is stored in ROM that does not change over the life time of the system.
3.2 ADVANTAGES
• cost is less
• speed is more
• compact device
9
3.3 MICROPROCESSOR VERSUS MICROCONTROLLER
computer.
microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial
port, and four ports all on a single chip. At the time it was also referred as “A SYSTEM
ON A CHIP”
The 8051 is an 8-bit processor meaning that the CPU can work only on 8 bits data
at a time. Data larger than 8 bits has to be broken into 8 bits pies es to be processed by the
CPU. The 8051 has a total of four I\O ports each 8 bit wide.
10
There are many versions of 8051 with different speeds and amount of on-chip
ROM and they are all compatible with the original 8051. This means that if you write a
The 8051 is an original member of the 8051 family. There are two other members
in the 8051 family of microcontrollers. They are 8052 and 8031. All the three
microcontrollers will have the same internal architecture, but they differ in the following
aspects.
• 8051 has 4K ROM, 128 bytes of RAM, two timers and 6 interrupts.
• 8052 has 8K ROM, 128 bytes of RAM, three timers and 8 interrupts.
11
4. 8952 MICROCONTROLLER
The AT89C52 provides the following standard features: 8Kbytes of Flash, 256
bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a six-vector two-level interrupt
architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition,
the AT89C52 is designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes. The Idle Mode stops the CPU
while allowing the RAM, timer/counters, serial port, and interrupt system to continue
functioning. The Power down Mode saves the RAM contents but freezes the oscillator,
disabling all other chip functions until the next hardware reset.
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel
12
• Three 16-Bit Timer/Counters
In addition, the AT89C52 is designed with static logic for operation down to zero
The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port
and interrupt system to continue functioning. The Power down Mode saves the RAM
contents but freezes the oscillator disabling all other chip functions until the next
hardware reset.
13
4.3 BLOCK DIAGRAM OF MICROCONTROLLER
14
4.4 PIN CONFIGURATIONS
Pin Description
• VCC
Pin 40 provides Supply voltage to the chip. The voltage source is +5v
• GND.
• Port 0
15
Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. As an output
port each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can
low-order address/data bus during accesses to external program and data memory. In this
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 bidirectional I/O port with internal pull-ups from pin 1 to 8. 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 pull-ups 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
program verification.
• Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28.
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 pull-ups 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
16
@ 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 bidirectional I/O port with internal pull-ups from pin 10 to 17.
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 pull-ups and can be used as inputs. As
inputs, Port 3 pins that are externally being pulled low will source current (IIL)
Port 3 also serves the functions of various special features of the AT89C51 as
listed below:
Port 3 also receives some control signals for Flash programming and
programming verification.
17
• RST
Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this pin,
the microcontroller will reset and terminate all activities. A high on this pin for two
• ALE/PROG
Address Latch is an output pin and is active high. 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
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
• PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89C52 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
• EA/VPP
18
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. EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming, for
• XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
• XTAL2
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on chip oscillator, as shown in Figure .
Either a quartz crystal or ceramic resonator may be used. To drive the device from an
external clock source, XTAL2 should be left unconnected while XTAL1 is driven as
shown in Figure.
19
FIGURE 5:CRYSTAL CONNECTIONS
There are no requirements on the duty cycle of the external clock signal, since the
input to the internal clocking circuitry is through a divide-by two flip-flop, but minimum
and maximum voltage high and low time specifications must be observed.
20
4.6 TIMERS
o Timer 0 and 1
Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer
1 in the AT89C51.
o Timer 2
counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has
three operating modes: capture, auto-reload (up or down counting), and baud rate
generator. The modes are selected by bits in T2CON, as shown in Table . Timer 2
consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is
incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods,
transition at its corresponding external input pin, T2. In this function, the external input is
sampled during S5P2 of every machine cycle. When the samples show a high in one
cycle and a low in the next cycle, the count is incremented. The new count value appears
21
in the register during S3P1 of the cycle following the one in which the transition was
detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-
to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that
a given level is sampled at least once before it changes, the level should be held for at
There are no restrictions on the duty cycle of external input signal, but it should
for at least one full machine to ensure that a given level is sampled at least once before it
changes
4.7 INTERRUPTS
The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0
and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These
22
Each of these interrupt sources can be individually enabled or disabled by setting
or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA,
Note that Table shows that bit position IE.6 is unimplemented. In the AT89C51,
bit position IE.5 is also unimplemented. User software should not write 1s to these bit
Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register
T2CON. Neither of these flags is cleared by hardware when the service routine is
23
vectored to. Infact the service routine may have to determine whether it was TF2 or
EXF2 that generated the interrupt, and that bit will have to be clear in software.
The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in
which the timers overflow. The values are then polled by the circuitry in the next cycle.
However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which
Idle Mode :
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain
active. The mode is invoked by software. The content of the on-chip RAM and all the
special functions registers remain unchanged during this mode. The idle mode can be
terminated by any enabled interrupt or by a hardware reset. It should be noted that when
idle is terminated by a hardware reset, the device normally resumes program execution,
from where it left off, up to two machine cycles before the internal reset algorithm takes
control.
On-chip hardware inhibits access to internal RAM in this event, but access to the
port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin
when Idle is terminated by reset, the instruction following the one that invokes Idle
In the power down mode the oscillator is stopped, and the instruction that invokes
power down is the last instruction executed. The on-chip RAM and Special Function
Registers retain their values until the power down mode is terminated. The only exit from
power down is a hardware reset. Reset redefines the SFRs but does not change the on-
24
chip RAM. The reset should not be activated before VCC is restored to its normal
operating level and must be held active long enough to allow the oscillator to restart and
stabilize.
TABLE 4: STATUS OF EXTERNAL PINS DURING IDLE AND POWER DOWN MODE
Programming Interface:
Every code byte in the Flash array can be written and the entire array can be
erased by using the appropriate combination of control signals. The write operation cycle
25
5. POWER SUPPLY
There are many types of power supply. Most are designed to convert high voltage
AC mains electricity to a suitable low voltage supply for electronics circuits and other
devices. A power supply can by broken down into a series of blocks, each of which
performs a particular function.
Similarly, 12v regulated supply can also be produced by suitable selection of the
individual elements. Each of the blocks is described in detail below and the power
supplies made from these blocks are described below with a circuit diagram and a graph
of their output:
5.1 TRANSFORMER
A transformer steps down high voltage AC mains to low voltage AC. Here we are
using a center-tap transformer whose output will be sinusoidal with 36volts peak to peak
value.
26
FIGURE 9: OUTPUT WAVEFORM OF TRANSFORMER
The low voltage AC output is suitable for lamps, heaters and special AC motors.
It is not suitable for electronic circuits unless they include a rectifier and a smoothing
capacitor. The transformer output is given to the rectifier circuit.
5.2 RECTIFIER
A rectifier converts AC to DC, but the DC output is varying. There are several
types of rectifiers; here we use a bridge rectifier.
The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage
using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the
figure. The circuit has four diodes connected to form a bridge. The ac input voltage is
applied to the diagonally opposite ends of the bridge. The load resistance is connected
between the other two ends of the bridge.
For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with
the load resistance RL and hence the load current flows through RL.
For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct
whereas, D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series
with the load resistance RL and hence the current flows through RL in the same direction
as in the previous half cycle. Thus a bi-directional wave is converted into unidirectional.
27
FIGURE 10:BRIDGE RECTIFIER CIRCUIT
The smoothing block smoothes the DC from varying greatly to a small ripple.
The ripple voltage is defined as the deviation of the load voltage from its DC value.
Smoothing is also named as filtering.
Filtering is frequently effected by shunting the load with a capacitor. The action
of this system depends on the fact that the capacitor stores energy during the conduction
period and delivers this energy to the loads during the no conducting period. In this way,
the time during which the current passes through the load is prolongated, and the ripple is
considerably decreased. The action of the capacitor is shown with the help of waveform.
28
FIGURE 12:CAPACITOR AND ITS OUTPUT WAVEFORM
5.4 REGULATOR
Regulator eliminates ripple by setting DC output to a fixed voltage. Voltage
regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output
voltages. Negative voltage regulators are also available
Many of the fixed voltage regulator ICs has 3 leads (input, output and high impedance).
They include a hole for attaching a heat sink if necessary. Zener diode is an example of
fixed regulator which is
shown here.
29
FIGURE 14:REGULATOR
30
6.RTC 12887
31
• Three interrupts are separately software maskable and testable Time-of-day alarm
once/second to once/day Periodic rates from 122_s to 500ms
• End-of-clock update cycle
PIN DESCRIPTION
32
AS - Address Strobe
R/W - Read/Write Input
DS - Data Strobe
RESET - Reset Input
IRQ - Interrupt Request Output
SQW - Square-Wave Output
VCC - +5V Main Supply
RCLR - RAM Clear
GND - Ground
DESCRIPTION :
33
7.LCD
7.1 OVERVIEW
The alphanumeric 16character X 2line LCD requires 8data lines and also 3
control signals and they are interfaced to 3664.By using 2 ports, port 0&3 data pins are
connected to LCD as data bus. Port0 can be basically used as I/O port i.e. it can be
programmed as an input or as an output port.
That means if it is programmed as output port, suppose if it is required to read data
from LCD immediately it is not possible. Before reading the data it is required to make
the port as an input port. Data reading from LCD gives an erroneous reading & should
not be implemented. Because of this port5 is made as input / output port depending on the
situation. The control signals are connected to port 3 pins. They are EN bar & RS bar,
RW bar. At different instance such as data write / command write / data read etc. Various
signals are to be provided as indicated by the by the LCD manufacturers.
To interface the LCD, to the Micro controller it require an 8 bit and also three control
signals differentiate the data from the control words send to the LCD. The Micro
controller has to send the necessary control words followed by the data to be displayed.
Depending on the operation to be performed the control words are selected and
passes to the LCD. The data to be displayed on the LCD is to be sent in the ASCII
format. Thus all the character to be displayed are converted into ASCII form and then
sent to the LCD along with different control words. The control word differentiated the
various operations and are executed. It is also possible to read the LCD data if required.
34
The control signals to the LCD are also provided by the Micro controller. This is
also done through pins 3.5,3.6&3.7.Through program necessary control signals are
passed to the LCD by using the bits of the port. The remaining can be used for some
other purpose if there is a need. The software controls the necessary ports and performs
the task it is designed for. The soft ware and associated hardware perform the LCD
interface.
LCD DISPLAY
A liquid crystal is a material (normally organic for LCDs) that will flow like a
liquid but whose molecular structure has some properties normally associated with solids.
The Liquid Crystal Display (LCD) is a low power device. The power requirement is
typically in the order of microwatts for the LCD. However, an LCD requires an external
or internal light source. It is limited to a temperature range of about 0C to 60C and
lifetime is an area of concern, because LCDs can chemically degrade.
There are major types of LCD’s which are :
1) Dynamic-scattering LCD s
2) Field-effect LCD s
Field-effect LCD s are normally used in such applications where source of energy is a
prime factor (e.g., watches, portable instrumentation etc.).They absorb considerably less
35
power than the light-scattering type. However, the cost for field-effect units is typically
higher, and their height is limited to 2 inches. On the other hand, light-scattering units are
available up to 8 inches in height. Field-effect LCD is used in the project for displaying
the appropriate information. The turn-on and turn-off time is an important consideration
in all displays. The response time of LCD s is in the range of 100 to 300ms.The lifetime
of LCD s is steadily increasing beyond 10,000+hours limit. Since the colour generated by
LCD units is dependent on the source of illumination, there is a wide range of colour
choice.
LCD
To send any of the commands from given table to the lcd, make pin RS =0.For
data, make RS=1.then send a high to low pulse to the E pin to enable the internal latch of
the LCD As shown in figure for LCD connections.
36
Pin
Symbol Level I/O Function
number
1 Vss - - Power supply (GND)
2 Vcc - - Power supply (+5V)
3 Vee - - Contrast adjust
0 = Instruction input
4 RS 0/1 I
1 = Data input
0 = Write to LCD module
5 R/W 0/1 I
1 = Read from LCD module
6 E 1, 1->0 I Enable signal
7 DB0 0/1 I/O Data bus line 0 (LSB)
8 DB1 0/1 I/O Data bus line 1
9 DB2 0/1 I/O Data bus line 2
10 DB3 0/1 I/O Data bus line 3
11 DB4 0/1 I/O Data bus line 4
12 DB5 0/1 I/O Data bus line 5
13 DB6 0/1 I/O Data bus line 6
14 DB7 0/1 I/O Data bus line 7 (MSB)
37
Pin
Symbol Level I/O Function
number
1 DB7 0/1 I/O Data bus line 7 (MSB)
2 DB6 0/1 I/O Data bus line 6
3 DB5 0/1 I/O Data bus line 5
4 DB4 0/1 I/O Data bus line 4
5 DB3 0/1 I/O Data bus line 3
6 DB2 0/1 I/O Data bus line 2
7 DB1 0/1 I/O Data bus line 1
8 DB0 0/1 I/O Data bus line 0 (LSB)
9 E1 1, 1->0 I Enable signal row 0 & 1 (1stcontroller)
0 = Write to LCD module
10 R/W 0/1 I
1 = Read from LCD module
0 = Instruction input
11 RS 0/1 I
1 = Data input
12 Vee - - Contrast adjust
13 Vss - - Power supply (GND)
14 Vcc - - Power supply (+5V)
15 E2 1, 1->0 I Enable signal row 2 & 3 (2ndcontroller)
16 n.c.
TABLE 7 : PIN ASSIGNMENT
Instruction set
0 = Cursor blink off 1 = Cursor blink on
S/C 0 = Move cursor 1 = Shift display
R/L 0 = Shift left 1 = Shift right
DL 0 = 4-bit interface 1 = 8-bit interface
N 0 = 1/8 or 1/11 Duty (1 line) 1 = 1/16 Duty (2 lines)
F 0 = 5x7 dots 1 = 5x10 dots
BF 0 = Can accept instruction 1 = Internal operation in progress
38
TABLE 8: INSTRUCTION SET
8. KEIL COMPILER
39
FIGURE 20:CREATING NEW PROJECT
5. Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\
40
6. Then Click on Save button above.
7. Select the component for u r project. i.e. Atmel……
8. Click on the + Symbol beside of Atmel
41
FIGURE 24:USING STARTUP CODE TO PROJECT
15. Click on the file option from menu bar and select “new”
42
FIGURE 26:OPEN A NEW FILE
16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
43
FIGURE 28:ASM FILE IS CREATED
19. Now right click on Source group 1 and click on “Add files to Group Source”
44
FIGURE 30:SELECT C SOURCE FILE(.C)
21. Now select as per your file extension given while saving the file
22. Click only one time on option “ADD”
23. Now Press function key F7 to compile. Any error will appear if so happen.
45
24. If the file contains no error, then press Control+F5 simultaneously.
25. The new window is as follows
46
FIGURE 34:OUTPUT IS DISPLAYED IN PORTS
29. Now keep Pressing function key “F11” slowly and observe.
30. You are running your program successfully
47
8.2 PROGRAM
#include <stdio.h>
#include<reg51.h>
#include <absacc.h>
#define COL P3
#define ROW P1
sbit rs=P1^5;
sbit rw=P1^6;
sbit en=P1^7;
#define ldata P2
void lcdinit();
void rtcinit();
void lcddata(unsigned char);
void lcdcmd(unsigned char);
void lcddelay(int);
void lcdoption();
void lcdhr();
void lcdmin();
void lcdmonth();
void lcdday();
char KEYPD();
void bcdconv(unsigned char);
unsigned char keypad[4][4]={'0', '1', '2', '3',4', '5', '6', '7', '8',
'9', 'A', 'B','C', 'D', 'E', 'F'};
void rtcinit(void)
{
lcddelay(250);
XBYTE[10]=0x20;
XBYTE[11]=0x83;
XBYTE[0]=0x30; //sec
XBYTE[2]=0x30; //min
XBYTE[4]=0x13; //hour
XBYTE[7]=0x27;
XBYTE[8]=0x02;
XBYTE[9]=0x08;
XBYTE[11]=0x03;
48
void bcdconv(unsigned char mybyte)
{
unsigned char x,y;
x=mybyte & 0x0F;
x=x|0x30;
y=mybyte&0xF0;
y=y>>4;
y=y|0x30;
lcddata(y);
lcddata(x);
}
void lcddelay(int k)
{
int i,j;
for (i=0; i<=k;i++)
for (j=0; j<=1275;j++);
}
return;
}
return;
}
49
void lcdinit()
{
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x80);
}
void lcdoption()
{
lcddata('1');
lcddata(':');
lcddata('2');
lcddata(':');
lcddata('3');
lcddata(' ');
lcddata(':');
}
void lcdhr()
{
lcddata('E');
lcddata('N');
lcddata('T');
lcddata(' ');
lcddata(‘H’);
lcddata('R');
lcddata(':');
}
void lcdmin()
{
lcddata(' ');
lcddata('E');
lcddata('N');
lcddata('T');
lcddata(' ');
lcddata('M');
lcddata('I');
lcddata('N');
lcddata(':');
}
50
void lcdmonth()
{
lcddata('E');
lcddata('N');
lcddata('T');
lcddata(' ');
lcddata('m');
lcddata('o');
lcddata('n');
lcddata(':');
}
void lcdday()
{
lcddata('E');
lcddata('N');
lcddata('T');
lcddata(' ');
lcddata('d');
lcddata('a');
lcddata('y');
lcddata(':');
}
char KEYPD()
{
51
colloc &= 0x0F;
}
while(colloc==0x0F);
lcddelay(1);
colloc=COL;
colloc&=0x0F;
}
while(colloc==0x0F);
while(1)
{
ROW=0xFE;
colloc=COL;
colloc&=0x0F;
if (colloc != 0x0F)
{
rowloc=0;
break;
}
ROW=0xFD;
colloc=COL;
colloc&=0x0F;
if (colloc != 0x0F)
{
rowloc=1;
break;
}
ROW=0xFB;
colloc=COL;
colloc&=0x0F;
if (colloc != 0x0F)
{
rowloc=2;
break;
}
ROW=0xF7;
colloc=COL;
colloc&=0x0F;
if (colloc != 0x0F)
{
rowloc=3;
break;
}
52
}
if (colloc== 0x0E)
return(keypad[rowloc][0]);
else if(colloc==0x0D)
return(keypad [rowloc][1]);
else if(colloc==0x0B)
return(keypad [rowloc][2]);
else
return(keypad [rowloc][3]);
}
lcdhr();
lcddelay(25);
ch_hr[1]=KEYPD();
lcdcmd(0x01);
lcdcmd(0x80);
lcddata(ch_hr[1]);
ch_hr[0]=KEYPD();
lcddata(ch_hr[0]);
lcddelay(15);
lcdcmd(0x01);
lcdcmd(0x80);
lcdmin();
lcddelay(25);
53
lcdcmd(0x01);
lcdcmd(0x80);
ch_min[1]=KEYPD();
lcddata(ch_min[1]);
ch_min[0]=KEYPD();
lcddata(ch_min[0]);
lcddelay(15);
if(ch==’2’)
{
lcdcmd(0x01);
lcdmonth();
lcddelay(25);
ch_hr[1]=KEYPD();
lcdcmd(0x01);
lcdcmd(0x80);
lcddata(ch_hr[1]);
ch_hr[0]=KEYPD();
lcddata(ch_hr[0]);
lcddelay(15);
lcdcmd(0x01);
lcdcmd(0x80);
lcdday();
lcddelay(25);
54
lcdcmd(0x01);
lcdcmd(0x80);
ch_min[1]=KEYPD();
lcddata(ch_min[1]);
ch_min[0]=KEYPD();
lcddata(ch_min[0]);
lcddelay(15);
switch(ch)
{
case '1': XBYTE[4]=HOUR; //min
XBYTE[2]=MINUTE;
}
}
main()
{
unsigned char HR, MIN, SEC,day,month,year;
IE=0x81;
lcdinit();
rtcinit();
55
while(1)
{
HR=XBYTE[4];
bcdconv(HR);
lcddata(':');
MIN=XBYTE[2];
bcdconv(MIN);
lcddata(':');
SEC=XBYTE[0];
bcdconv(SEC);
lcdcmd(0xc2);
day=XBYTE[7];
bcdconv(day);
lcddata('/');
month=XBYTE[8];
bcdconv(month);
lcddata('/');
year=XBYTE[9];
bcdconv(year);
lcddelay(45);
lcdcmd(0x01);
lcdcmd(0x82);
IE=0x81;
}
56
9.CONCLUSION
Embedded systems are emerging as a technology with high potential. In the past decades
micro processor based embedded system ruled the market. The last decade witnessed the
revolution of Microcontroller based embedded systems. This project basically deals with
how many number of persons are in the room very accurately with the help of
Microcontroller. With regards to the requirements gathered the manual work and the
complexity in counting can be achieved with the help of electronic devices.
57
10. REFERENCES
[1] Muhammad Ali Mazidi -The 8051 Microcontroller and Embedded Systems 2nd
edition, PEARSON EDUCATION, 2008
[2] Daniel W Lewis Fundamentals Of Embedded Software
[3] www.howsstuffworks.com
[4] www.alldatasheets.com
[5] www.electronicsforu.com
[6] www.knowledgebase.com
[7] www.8051 projectsinfo.com
[8] Datasheets of Microcontroller AT89C52
[9] Datasheets of 555 timer
58