06-05-2013, 03:10 PM
Automatic bidirectional visitor counter for controlling room light using 8051 microcontroller (AT89S52)
Automatic bidirectional.pdf (Size: 2.72 MB / Downloads: 167)
ABSTRACT
A counter that can change its state in either direction, under control of an
up–down selector input, is known as an up–down counter. The circuit
given here can count numbers from 0 to 9999 in up and down modes
depending upon the state of the selector. It can be used to count the
number of persons entering a hall in the up mode at entrance gate. In the
down mode, it can count the number of persons leaving the hall by
decrementing the count at exit gate. It can also be used at gates of parking
areas and other public places.
This circuit divided in three parts: sensor, controller and counter display.
The sensor would observe an interruption and provide an input to the
controller which would run the counter in up/down mode depending upon
the selector setting. The same count is displayed on a set of 7-segment
displays through the controller.
COMPONENT DESCRIPTION
1)MICRO-CONTROLLER 8051 DESCRIPTION
The IC 8051 is a low-power; high-performance CMOS 8-bit microcomputer with 4K
bytes of Flash programmable and erasable read only memory (PEROM). The device
is manufactured using Atmel’s high-density nonvolatile memory technology and is
compatible with the industry-standard MCS-51 instruction set and pin out. The onchip
Flash allows the program memory to be reprogrammed in-system or by a
conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU
with Flash on a monolithic chip, the Atmel IC 8051 is a powerful microcomputer
which provides a highly-flexible and cost-effective solution to many embedded
control applications. The IC 8051 provides the following standard features: 4K bytes
of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector
two-level interrupt architecture, full duplex serial port, on-chip oscillator and clock
circuitry. In addition, the IC 8051 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.
PROCESSOR
A processor is an electronic device capable of manipulating data in a way specified by
a sequence of instructions.
INSTRUCTIONS
Instructions in a computer are binary numbers just like data. Different numbers, when
read and executed by a processor, cause different things to happen. The instructions
are also called opcodes or machine codes.
Different bit patterns activate or deactivate different parts of the processing core.
Every processor has its own instruction set varying in number, bit pattern and
functionality.
PROGRAM
The sequence of instructions is what constitutes a program. The sequence of
instructions may be altered to suit the application.
ASSEMBLY LANGUAGE
Writing and understanding such programs in binary or hexadecimal form is very
difficult ,so each instructions is given a symbolic notation in English language called
as mnemonics. A program written in mnemonics Form is called an assembly language
program. But it must be converted into machine language for execution by processor.
Data Memory
The right half of the internal and external data memory spaces available on Atmel’s
Flash microcontrollers. Hardware configuration for accessing up to 2K bytes of
external RAM. In this case, the CPU executes from internal Flash. Port 0 serves as a
multiplexed address/data bus to the RAM, and 3 lines of Port 2 are used to page the
RAM. The CPU generates RD and WR signals as needed during external RAM
accesses. You can assign up to 64K bytes of external data memory. External data
memory addresses can be either 1 or 2 bytes wide. One-byte addresses are often used
in conjunction with one or more other I/O lines to page the RAM. Two-byte addresses
can also be used, in which case the high address byte is emitted at Port 2.
The Instruction Set
All members of the Atmel microcontroller family execute the same instruction set. This
instruction set is optimized for 8- bit control applications and it provides a variety of fast
addressing modes for accessing the internal RAM to facilitate byte operations on small
data structures. The instruction set provides extensive support for 1-bit variables as a
separate data type, allowing direct bit manipulation in control and logic systems that
require Boolean processing. The following overview of the instruction set gives a brief
description of how certain instructions can be used.
Program Status Word
The Program Status Word (PSW) contains status bits that reflect the current state of the
CPU. The PSW, shown in Figure 11, resides in SFR space. The PSW contains the Carry
bit, the Auxiliary Carry (for BCD operations), the tworegister bank select bits, the
Overflow flag, a Parity bit, and two user-definable status flags. The Carry bit, in addition
to serving as a Carry bit in arithmetic operations, also serves as the “Accumulator” for a
number of Boolean operations.
The bits RS0 and RS1 select one of the four register banks shown in Figure 8. A number
of instructions refer to these RAM locations as R0 through R7. The status of the RS0 and
RS1 bits at execution time determines which of the four banks is selected. The Parity bit
reflects the number of 1s in the Accumulator: P=1 if the Accumulator contains an odd
number of 1s, and P=0 if the Accumulator contains an even number of 1s. Thus, the
number of 1s in the Accumulator plus P is always even. Two bits in the PSW are
uncommitted and can be used as general purpose status flags.
Indexed Addressing
Program memory can only be accessed via indexed addressing. This addressing mode is
intended for reading look-up tables in program memory. A 16-bit base register (either
DPTR or the Program Counter) points to the base of the table, and the Accumulator is set
up with the table entry number. The address of the table entry in program memory is
formed by adding the Accumulator data to the base pointer. Another type of indexed
addressing is used in the “case jump” instruction. In this case the dest ination address of a
jump instruction is computed as the sum of the base pointer and the Accumulator data.
Voltage Comparator LM 358
The LM158 series consists of two independent, high gain, internally frequency
compensated operational amplifiers which were designed specifically to operate from a
single power supply over a wide range of voltages. Operation from split power supplies is
also possible and the low power supply current drain is independent of the magnitude of
the power supply voltage. Application areas include transducer amplifiers, dc gain blocks
and all the conventional op amp circuits, which now can be more easily implemented in
single power supply systems. For example, the LM158 series can be directly operated off
of the standard +5V power supply voltage, which is used in digital systems and will
easily provide the required interface electronics without requiring the additional ±15V
power supplies. The LM358 and LM2904 are available in a chip sized pack-age (8-Bump
micro SMD) using National’s micro SMD pack-age technology.
RELAY
The relay takes advantage of the fact that when electricity flows through a coil, it
becomes an electromagnet. The electromagnetic coil attracts a steel plate, which is
attached to a switch. So the switch's motion (ON and OFF) is controlled by the current
flowing to the coil, or not, respectively.
A very useful feature of a relay is that it can be used to electrically isolate different parts
of a circuit. It will allow a low voltage circuit (e.g. 5VDC) to switch the power in a high
voltage circuit (e.g. 100 VAC or more).
RESISTORS
Resistors
The resistor's function is to reduce the flow of electric current. There are two classes of
resistors; fixed resistors and the variable resistors. They are also classified according to
the material from which they are made. The typical resistor is made of either carbon film
or metal film. There are other types as well, but these are the most common. The
resistance value of the resistor is not the only thing to consider when selecting a resistor
for use in a circuit. The "tolerance" and the electric power ratings of the resistor are also
important. The tolerance of a resistor denotes how close it is to the actual rated resistence
value. For example, a ±5% tolerance would indicate a resistor that is within ±5% of the
specified resistance value.
Variable Resistors
There are two general ways in which variable resistors are used. One is the variable
resistor which value is easily changed, like the volume adjustment of Radio. The other is
semi-fixed resistor that is not meant to be adjusted by anyone but a technician. It is used
to adjust the operating condition of the circuit by the technician. Semi-fixed resistors are
used to compensate for the inaccuracies of the resistors, and to fine-tune a circuit. The
rotation angle of the variable resistor is usually about 300 degrees. Some variable
resistors must be turned many times to use the whole range of resistance they offer. This
allows for very precise adjustments of their value.