Digital Calendar

75
1.OVERVIEW 1.1 INTRODUCTION The title of the project is ‘DIGITAL CALENDAR’ which is an embedded based project. An embedded project is a combination of hardware and software. Microprocessors and microcontrollers are widely used in such embedded system products. Each embedded system is unique and highly customized to the application at hand. The main basics that includes in embedded programming are either assembly programming or it may be high level languages such as C,C++ or Embedded C. This project “DIGITAL CALENDAR” using microcontroller ia an advanced digital calendar, which displays the Seconds,Minutes,Hours, Date, Day, Month over the LCD display. It has the advantage of setting these features. It has an 8-bit microcontroller which runs on the program embedded on its ROM. 1.2 AIM OF THE PROJECT The main objective of the project is designing a “DIGITAL CALENDAR” by interfacing microcontroller with RTC, in which time, date, day of the week, name of the month, can be reset, displayed and updated. 1

Transcript of Digital Calendar

Page 1: Digital Calendar

1.OVERVIEW

1.1 INTRODUCTION

The title of the project is ‘DIGITAL CALENDAR’ which is an embedded based

project.

An embedded project is a combination of hardware and software.

Microprocessors and microcontrollers are widely used in such embedded system

products. Each embedded system is unique and highly customized to the application at

hand. The main basics that includes in embedded programming are either assembly

programming or it may be high level languages such as C,C++ or Embedded C.

This project “DIGITAL CALENDAR” using microcontroller ia an advanced

digital calendar, which displays the Seconds,Minutes,Hours, Date, Day, Month over the

LCD display. It has the advantage of setting these features. It has an 8-bit microcontroller

which runs on the program embedded on its ROM.

1.2 AIM OF THE PROJECT

The main objective of the project is designing a “DIGITAL CALENDAR” by

interfacing microcontroller with RTC, in which time, date, day of the week, name of the

month, can be reset, displayed and updated.

1.3 ORGANISATION REPORT

Chapter 2 deals with Embedded Systems.

Chapter 3 deals with the overview of microprocessor and microcontroller.

Chapter 4 deals with the 8952 Microcontroller IC.

Chapter 5 deals with Power Supply of project.

Chapter 6 deals with the Real Time Clock (RTC 12887A).

Chapter 7 deals with LCD display and its pin description.

Chapter 8 deals with software description and code of the project.

Chapter 9 covers conclusion.

1

Page 2: Digital Calendar

BLOCK DIAGRAM:

FIGURE 1 : BLOCK DIAGRAM

This project “DIGITAL CALENDAR” using microcontroller ia an advanced digital

calendar, which displays the Seconds,Minutes,Hours, Date, Day, Month over the LCD

display. It has the advantage of setting these features. It has an 8-bit microcontroller

which runs on the program embedded on its ROM.

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

AT89S52

LCD DISPLAY

KEY PAD 4X4

RTC 12887

POWER SUPPLY

Page 3: Digital Calendar

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

Page 4: Digital Calendar

FIGURE 2 : PROJECT LAYOUT

4

Page 5: Digital Calendar

2. EMBEDDED SYSTEMS

2.1 DEFINITIONS

Embedded system is a combination of hardware and software; it is also named

as “Firm ware”.

An embedded system is a special purpose computer system, which is completely

encapsulated by the device it controls. It is a computer-controlled system

An embedded system is a specialized system that is a part of a larger system or

machine. As a part of a larger system it largely determines its functionality. Embedded

systems are electronic devices that incorporate microprocessors with in their

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

read only memory (RAM) chip.

Embedded systems provide several major functions including monitoring of the

analog environment by reading data from sensors and controlling actuators.

2.2 EXAMPLES OF EMBEDDED SYSTEMS

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

applications such as automobiles, communication and office equipments and television

5

Page 6: Digital Calendar

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.

Some examples of embedded systems:

Automatic Teller Machines

Cellular telephone and telephone switches

Computer network equipment

Computer printers

Disk drives

Engine controllers and antilock break controllers for automobiles

Home automation products

Handheld calculators

Household appliances

Medical equipment

Measurement equipment

Multifunction wrist watches

Multifunction printers

Mobile phones with additional capabilities

Programmable Logic Controllers

2.3 ADVANTAGES

One of the advantages of an embedded system is to decrease power

consumption and space.

6

Page 7: Digital Calendar

All embedded systems that are based on microcontroller have low power

consumption in addition to some form of I\O,COM port and ROM all on a

single chip.

2.4 DISADVANTAGES

Higher Hardware/Software development overhead

Design, Compilers, Debuggers may result in delayed time to market

2.5 APPLICATIONS

Military and aerospace software applications

Communication applications

Electronics applications and consumer devices

Industrial automation and process control software

7

Page 8: Digital Calendar

3. MICROPROCESSOR AND MICROCONTROLLER

3.1 OVERVIEW

Microprocessors and microcontrollers are used in embedded system products. An

embedded product uses a microprocessor (or microcontroller) to do one task and one task

only.

Microprocessor as the term come to be known is a general purpose digital

computer central processing unit. Although popularly known as a "computer on chip", the

microprocessor is in no sense a complete digital computer.

Microprocessor CPU contains Arithmetic Logical Unit, a program counter, a

stack pointer, some working registers, a clock timing circuits and interrupt circuit.

To make complete microcomputer memory must add, usually Read Only

Memory, Random Access Memory, memory decoders and an Input/Output devices. In

addition special purpose devices such as interrupts, counters may be added to relieve the

CPU from time consuming counting or timing chores.

The hardware design of microprocessor CPU is arranged so that a small or very

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

architecture is comprehensive but as flexible as possible.

The prime use of microprocessor is to read data perform extensive calculations on

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

and loaded into RAM as the user directs.

8

Page 9: Digital Calendar

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

Microcontroller is a highly integrated chip that contains all the devices

comprising a computer. Typically this includes a CPU, RAM, Input/ Output ports, timers,

interrupts. So microcontroller is also called as "true computer on a chip". Unlike a

general purpose computer which also includes all of these devices. A microcontroller is

designed for a very specific task to control a particular system.

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.

The prime use of microcontroller is to control the operation of machine using a

fixed program that is stored in ROM that does not change over the life time of the system.

3.2 ADVANTAGES

The advantages of microcontroller over microprocessor are

cost is less

speed is more

power consumption is less

compact device

external components are minimum

9

Page 10: Digital Calendar

3.3 MICROPROCESSOR VERSUS MICROCONTROLLER

The contrast between microprocessor and microcontroller is best exemplified by

the fact that:

Most microprocessor have operational codes for moving data from

external memory to CPU, microcontroller may have one or two.

Microprocessor may have one or two types of bit handling instructions

microcontroller will have many.

Microprocessor concerned with rapid movement of code and data from

external address to the chip, microcontroller is concerned with rapid data

movement of bits with in chip.

Microcontroller can function as a computer with out addition of external

devices, but microprocessor must have many additions to operate an

computer.

3.4 A BRIEF HISTORY OF 8051

In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051. This

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 pieses to be processed by the

CPU. The 8051 has a total of four I\O ports each 8 bit wide.

10

Page 11: Digital Calendar

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

program for one it will run on any of them.

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.

8031 has 128 bytes of RAM, two timers and 6 interrupts.

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.

Of the three microcontrollers, 8051 is the most preferable. Microcontroller

supports both serial and parallel communication.

In the concerned project 8052 microcontroller is used. Here microcontroller used

is AT89C52, which is manufactured by ATMEL laboratories.

11

Page 12: Digital Calendar

4. 8952 MICROCONTROLLER

4.1 DESCRIPTION OF 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

AT89C52 is a powerful microcomputer which provides a highly flexible and cost

effective solution to many embedded control applications.

4.2 FEATURES OF MICROCONTROLLER (8952)

Compatible with MCS-51 Products

8 Kbytes of In-System Reprogrammable Flash Memory

Endurance: 1,000 Write/Erase Cycles

Fully Static Operation: 0 Hz to 24 MHz

Three-Level Program Memory Lock

256 x 8-Bit Internal RAM

32 Programmable I/O Lines

Three 16-Bit Timer/Counters

12

Page 13: Digital Calendar

Eight vector two level Interrupt Sources

Programmable Serial Channel

Low Power Idle and Power Down Modes

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.

4.3 BLOCK DIAGRAM OF MICROCONTROLLER

13

Page 14: Digital Calendar

FIGURE 3:BLOCK DIAGRAM OF 8052

4.4 PIN CONFIGURATIONS

14

Page 15: Digital Calendar

FIGURE 4:PIN DIAGRAM OF 8952

Pin Description

V CC

Pin 40 provides Supply voltage to the chip. The voltage source is +5v

GND .

Pin 20 is the grounded

Port 0

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

be used as high-impedance inputs. Port 0 may also be configured to be the multiplexed

15

Page 16: Digital Calendar

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 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

@ 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

16

Page 17: Digital Calendar

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)

because of the pull-ups.

Port 3 also serves the functions of various special features of the AT89C51 as

listed below:

TABLE 1: SPECIAL FEATURES OF 89C52

Port 3 also receives some control signals for Flash programming and

programming verification.

RST

17

Page 18: Digital Calendar

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

machine cycles while the oscillator is running resets the device.

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

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

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

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

18

Page 19: Digital Calendar

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

parts that require 12-volt VPP.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating

circuit.

XTAL2

Output from the inverting oscillator amplifier.

4.5 OSCILLATOR CHARACTERISTICS

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.

FIGURE 5:CRYSTAL CONNECTIONS

19

Page 20: Digital Calendar

FIGURE 6:EXTERNAL CLOCK DRIVE CONFIGURATION

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.

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

Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event

counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has

20

Page 21: Digital Calendar

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,

the count rate is 1/12 of the oscillator frequency.

TABLE 2: TIMER 2 OPERATING MODES

In the Counter function, the register is incremented in response to a 1-to-0

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

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

least one full machine cycle.

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

21

Page 22: Digital Calendar

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

interrupts are all shown in Figure .

FIGURE 7:INTERRUPTS SOURCE

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,

which disables all interrupts at once.

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

positions, since they may be used in future AT89 products.

22

Page 23: Digital Calendar

TABLE 3: INTERRUPTS ENABLE REGISTER

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

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

the timer overflows.

Idle Mode :

23

Page 24: Digital Calendar

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

should not be one that writes to a port pin or to external memory.

Power down Mode:

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-

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

24

Page 25: Digital Calendar

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

is self-timed and once initiated, will automatically time itself to completion.

TABLE 5: FLASH PROGRAMMING MODES

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.

For example a 5V regulated supply can be shown as below

25

Page 26: Digital Calendar

FIGURE 8:BLOCK DIAGRAM OF REGULATED POWER SUPPLY SYSTEM

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.

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

26

Page 27: Digital Calendar

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.

FIGURE 10:BRIDGE RECTIFIER CIRCUIT

FIGURE 11:THE OUTPUT WAVEFORM OF THE RECTIFIER

The varying DC output is suitable for lamps, heaters and standard motors. It is not

suitable for electronic circuits unless they include a smoothing capacitor.

5.3 SMOOTHENING

27

Page 28: Digital Calendar

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.

FIGURE 12:CAPACITOR AND ITS OUTPUT WAVEFORM

FIGURE 13: THE WAVEFORM OF THE RECTIFIED OUTPUT AFTER SMOOTHENING

5.4 REGULATOR

28

Page 29: Digital Calendar

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.

FIGURE 14:REGULATOR

FIGURE 15:Transformer + Rectifier + Smoothing + Regulator:

29

Page 30: Digital Calendar

6.RTC 12887

6.11 FEATURES OF DS12887A

Drop-in replacement for IBM AT computer

clock/calendar

Pin compatible with the MC146818B and DS1287A

Totally nonvolatile with over 10 years ofoperation in the absence of power Self-

contained subsystem includes lithium,quartz, and support circuitry

Counts seconds, minutes, hours, days, day of the week, date, month, and year

with leapyear compensation valid up to 2100

Binary or BCD representation of time,calendar, and alarm

12- or 24-hour clock with AM and PM in 12-hour mode

30

Page 31: Digital Calendar

Daylight Savings Time option

Selectable between Motorola and Intel bus timing

Multiplex bus for pin efficiency

Interfaced with software as 128 RAM locations 15 bytes of clock and control

registers 113 bytes of general purpose RAM

Programmable square-wave output signal

Bus-compatible interrupt signals (IRQ)

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

6.2 PIN ASSIGNMENT

FIGURE 16:PIN DIAGRAM OF RTC

31

Page 32: Digital Calendar

PIN DESCRIPTION

AD0–AD7 - Multiplexed Address/Data Bus

NC - No Connect

MOT - Bus Type Selection

CS - RTC Chip Select Input

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 :

The DS12C887A real-time clock plus RAM is designed to be a direct upgrade

replacement for the DS12887A in existing IBM-compatible personal computers to add

hardware year-2000 compliance. A century byte was added to memory location 50, 32h,

as called out by the PC AT specification. The DS12C887A is identical in form, fit, and

function to the DS1287A, and provides additional 64 bytes of general-purpose RAM.

Access to this additional RAM space is determined by the logic level presented on AD6

during the address portion of an access cycle. The RCLR pin is used to clear (set to logic

1) all 113 bytes of general purpose RAM but does not affect the RAM associated with the

real time clock. In order

to clear the RAM, RCLR must be forced to an input logic 0 (-0.3V to +0.8V) during

battery-backup mode when VCC is not applied. The RCLR function is designed to be

used via human interface (shorting to ground manually or by switch) and not to be driven

32

Page 33: Digital Calendar

with external buffers. For a complete description of operating conditions, electrical

characteristics, bus timing and pin descriptions other than RCLR , see the DS12C887

data sheet.

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.

33

Page 34: Digital Calendar

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.

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.

FIGURE 17:LCD PIN DIAGRAM

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

Gnd vcc preset rs rw en d0 d1 d2 d3 d4 d5 d6 d7 vcc gnd

LCD DISPLAY

34

Page 35: Digital Calendar

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

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.

35

Page 36: Digital Calendar

FIGURE 18:8 BIT LCD INTERFACE

Pin number

Symbol  Level   I/O Function

1 Vss - - Power supply (GND)

2 Vcc - - Power supply (+5V)

3 Vee - - Contrast adjust

4 RS 0/1 I0 = Instruction input1 = Data input

5 R/W 0/1 I0 = Write to LCD module1 = 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)

36

Page 37: Digital Calendar

TABLE 6 : PIN ASSIGNMENT

Pin number

Symbol  Level   I/O Function

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 IEnable signal row 0 & 1 (1stcontroller)

10 R/W 0/1 I0 = Write to LCD module1 = Read from LCD module

11 RS 0/1 I0 = Instruction input1 = Data input

12 Vee - - Contrast adjust

13 Vss - - Power supply (GND)

14 Vcc - - Power supply (+5V)

15 E2 1, 1->0 IEnable signal row 2 & 3 (2ndcontroller)

16 n.c.      TABLE 7 : PIN ASSIGNMENT

37

Page 38: Digital Calendar

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

TABLE 8: INSTRUCTION SET

8. KEIL COMPILER

8.1 SOFTWARE DESCRIPTION

1. Click on the Keil uVision Icon on Desktop

2. The following fig will appear

FIGURE 19:START PAGE

38

Page 39: Digital Calendar

3. Click on the Project menu from the title bar

4. Then Click on New Project

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:\

39

Page 40: Digital Calendar

FIGURE 21:SELECTING TEMP FILE

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

FIGURE 22:SELECTING ATMEL SERIES

9. Select AT89C51 as shown below

40

Page 41: Digital Calendar

FIGURE 23: SELECTING THE MICROCONTROLLER

10. Then Click on “OK”

11. The Following fig will appear

FIGURE 24:USING STARTUP CODE TO PROJECT

12. Then Click either YES or NO………mostly “NO”

13. Now your project is ready to USE

41

Page 42: Digital Calendar

14. Now double click on the Target1, you would get another option “Source

group 1” as shown in next page.

FIGURE 25:SOURCE CODE CREATION

15. Click on the file option from menu bar and select “new”

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.

42

Page 43: Digital Calendar

FIGURE 27:NEW PAGE HAS BEEN CREATED

17. Now start writing program in either in “C” or “ASM”

18. For a program written in Assembly, then save it with extension “. asm” and

for “C” based program save it with extension “ .C”

FIGURE 28:ASM FILE IS CREATED

19. Now right click on Source group 1 and click on “Add files to Group Source”

43

Page 44: Digital Calendar

FIGURE 29:ADD THE FILE TO SOURCE GROUP

20. Now you will get another window, on which by default “C” files will appear.

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.

44

Page 45: Digital Calendar

FIGURE 31:BUILD OPERATION IS DONE

24. If the file contains no error, then press Control+F5 simultaneously.

25. The new window is as follows

FIGURE 32:RUNNING OF THE FILE

26. Then Click “OK”

27. Now Click on the Peripherals from menu bar, and check your required port as

shown in fig below

45

Page 46: Digital Calendar

FIGURE 33:PORT SELECTION

28. Drag the port a side and click in the program file.

FIGURE 34:OUTPUT IS DISPLAYED IN PORTS

29. Now keep Pressing function key “F11” slowly and observe.

30. You are running your program successfully

46

Page 47: Digital Calendar

8.2 PROGRAM

#include <stdio.h>#include<reg51.h>#include <absacc.h>

#define COL P3#define ROW P1sbit 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);

47

Page 48: Digital Calendar

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; //secXBYTE[2]=0x30; //minXBYTE[4]=0x13; //hourXBYTE[7]=0x27;XBYTE[8]=0x02;XBYTE[9]=0x08;XBYTE[11]=0x03;

}

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++);}

void lcdcmd(unsigned char value){ldata=value;rs=0;rw=0;en=1;lcdelay(1);

48

Page 49: Digital Calendar

en=0;

return;}

void lcddata(unsigned char value){ldata=value;rs=1;rw=0;en=1;lcddelay(1);en=0; return;}

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’);

49

Page 50: Digital Calendar

lcddata('R');lcddata(':');}

void lcdmin(){lcddata(' ');lcddata('E');lcddata('N');lcddata('T');lcddata(' ');lcddata('M');lcddata('I');lcddata('N');lcddata(':');}

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(){

50

Page 51: Digital Calendar

char colloc, rowloc;COL=0xFF;while(1){do{ROW=0x00;colloc=COL;colloc&=0x0F;} while(colloc!=0x0F);do{do {lcddelay(1);colloc=COL;

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;

51

Page 52: Digital Calendar

}

ROW=0xFB;colloc=COL;colloc&=0x0F;if (colloc != 0x0F){rowloc=2;break;}

ROW=0xF7;colloc=COL;colloc&=0x0F;if (colloc != 0x0F){rowloc=3;break;}}

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]);}

}

void userintface(void) interrupt 0{char ch, ch_hr[2], ch_min[2], HOUR, MINUTE,MONTH,DAY;IE=0x80;lcdcmd(0x01);lcdoption();ch=KEYPD();lcddata(ch);lcddelay(200);if(ch== '1') {

52

Page 53: Digital Calendar

lcdcmd(0x01);

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);

lcdcmd(0x01);lcdcmd(0x80);

ch_min[1]=KEYPD();lcddata(ch_min[1]);ch_min[0]=KEYPD();lcddata(ch_min[0]);lcddelay(15);

HOUR= ch_hr[0] & 0x0F;ch_hr[1]=ch_hr[1] & 0x0F;ch_hr[1]= ch_hr[1]<<4;HOUR=HOUR | ch_hr[1];

MINUTE= ch_min[0] & 0x0F;ch_min[1]=ch_min[1] & 0x0F;ch_min[1]=ch_min[1]<<4;MINUTE=MINUTE | ch_min[1];

}

if(ch==’2’){

53

Page 54: Digital Calendar

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);

lcdcmd(0x01);lcdcmd(0x80);

ch_min[1]=KEYPD();lcddata(ch_min[1]);ch_min[0]=KEYPD();lcddata(ch_min[0]);lcddelay(15);

MONTH= ch_hr[0] & 0x0F;ch_hr[1]=ch_hr[1] & 0x0F;ch_hr[1]= ch_hr[1]<<4;MONTH=MONTH | ch_hr[1];

DAY= ch_min[0] & 0x0F;ch_min[1]=ch_min[1] & 0x0F;ch_min[1]=ch_min[1]<<4;DAY=DAY | ch_min[1];

}

switch(ch){

54

Page 55: Digital Calendar

case '1': XBYTE[4]=HOUR; //minXBYTE[2]=MINUTE;

case '2':XBYTE [8]=MONTH;XBYTE[7]=DAY;

}}

main(){unsigned char HR, MIN, SEC,day,month,year;IE=0x81;lcdinit();rtcinit();

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);

55

Page 56: Digital Calendar

lcdcmd(0x01);lcdcmd(0x82);

IE=0x81;}

}

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.

56

Page 57: Digital Calendar

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

57