digital visitor counter using 8051 microcontroller

30
Digital Visitor counter using 8051 microcontroller (AT89C52) Abstract : This project titled “Microcontroller based Bidirectional Visitor counter” is designed and presented in order to count the visitors of an auditorium, hall, offices, malls, sports venue, etc. The system counts both the entering and exiting visitor of the auditorium or hall or other place, where it is placed. Depending upon the interrupt from the sensors, the system identifies the entry and exit of the visitor. On the successful implementation of the system, it displays the number of visitor present in the auditorium or hall. This system can be economically implemented in all the places where the visitors have to be counted and controlled. Since counting the visitors helps to maximize the efficiency and effectiveness of employees, floor area and sales potential of an organization, etc.

Upload: chandra-bhanu

Post on 11-Nov-2014

2.513 views

Category:

Documents


19 download

DESCRIPTION

Final Year Project Documentation

TRANSCRIPT

Page 1: Digital Visitor Counter Using 8051 Microcontroller

Digital Visitor counter using 8051 microcontroller (AT89C52)

Abstract :

This project titled “Microcontroller based Bidirectional Visitor counter” is

designed and presented in order to count the visitors of an auditorium,

hall, offices, malls, sports venue, etc. The system counts both the entering

and exiting visitor of the auditorium or hall or other place, where it is

placed. Depending upon the interrupt from the sensors, the system

identifies the entry and exit of the visitor. On the successful

implementation of the system, it displays the number of visitor present in

the auditorium or hall. This system can be economically implemented in

all the places where the visitors have to be counted and controlled. Since

counting the visitors helps to maximize the efficiency and effectiveness of

employees, floor area and sales potential of an organization, etc.

Page 2: Digital Visitor Counter Using 8051 Microcontroller

Description :

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.

In this circuit, two infrared (IR) sensor modules are used each for up and

down counting, respectively. Whenever an interruption is observed by the

Page 3: Digital Visitor Counter Using 8051 Microcontroller

SensorsLogic

Control Circuit

Micro-controller AT89C52

Display

PowerSupply +5V

first IR sensor, it increments the counter value. Similarly, when the second

sensor detects an obstacle, the count is decremented. The count value is

calculated depending upon the sensor’s input and is displayed on a set of

four seven segment displays by using the concept of multiplexing. The

data pins of each 7-segment display are connected to port P2 of the

microcontroller AT89C51. The first four pins of port P1 (P1^0-P1^3) are

connected to control pins to enable a particular 7-segment. P1^5 & P1^6

are configured as input pins at which the sensors are connected. The

sensor inputs are defined as up and down selector modes for the counter

in the code. Each time the first sensor is blocked, it gives a high signal at

P1^5 and the count value gets incremented. The value gets decremented

when P1^6, connected to second sensor, gives high input. At each step,

the value of the counter is sent to be displayed on the segments.

Block Diagram:

Page 4: Digital Visitor Counter Using 8051 Microcontroller

Enter

Exit

IR TX1

IR TX2 RX2

RX1

Sensor arrangement at the way :

Circuit Diagram :

Page 5: Digital Visitor Counter Using 8051 Microcontroller

Circuit Components :

Page 6: Digital Visitor Counter Using 8051 Microcontroller

Transistor BC547

BC547 is an NPN bi-polar junction transistor. A transistor, stands for transfer of resistance, is commonly used to amplify current. A small current at its base controls a larger current at collector & emitter terminals. BC547 is mainly used for amplification and switching purposes. It has a maximum current gain of 800. Its equivalent transistors are BC548 and BC549.

Seven Segment Display

A seven segment display is the most basic electronic display device that can display digits from 0-9. They are laid out as a squared-off figure ‘8’. Every LED is assigned a name from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to 'g' are used to display the numerals while eighth LED 'h' is used to display the dot/decimal.

AT89C51 Microcontroller

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

Infrared LED

An IR LED, also known as IR transmitter, is a special purpose LED that transmits infrared rays in the range of 760 nm wavelength. Such LEDs are usually made of gallium arsenide or aluminium gallium arsenide. They, along with IR receivers, are commonly used as sensors.

Light emitting diodes

Light emitting diodes (LEDs) are semiconductor light sources. The light emitted from LEDs varies from visible to infrared and ultraviolet regions. They operate on low voltage and power. LEDs are one of the most common electronic components and are mostly used as indicators in circuits.

Page 7: Digital Visitor Counter Using 8051 Microcontroller

Transistor BC547:

Description:

BC547 is an NPN bi-polar junction transistor. A transistor, stands for transfer of resistance, is commonly used to amplify current. A small current at its base controls a larger current at collector & emitter terminals. BC547 is mainly used for amplification and switching purposes. It has a maximum current gain of 800. Its equivalent transistors are BC548 and BC549. The transistor terminals require a fixed DC voltage to operate in the desired region of its characteristic curves. This is known as the biasing. For amplification applications, the transistor is biased such that it is partly on for all input conditions. The input signal at base is amplified and taken at the emitter. BC547 is used in common emitter configuration for amplifiers. The voltage divider is the commonly used biasing mode. For switching applications, transistor is biased so that it remains fully on if there is a signal at its base. In the absence of base signal, it gets completely off.

Page 8: Digital Visitor Counter Using 8051 Microcontroller

Pin Diagram:

Page 9: Digital Visitor Counter Using 8051 Microcontroller
Page 10: Digital Visitor Counter Using 8051 Microcontroller

Seven Segment Display:

Description:

A seven segment display is the most basic electronic display device that can display digits from 0-9. They find wide application in devices that display numeric information like digital clocks, radio, microwave ovens, electronic meters etc. The most common configuration has an array of eight LEDs arranged in a special pattern to display these digits. They are laid out as a squared-off figure ‘8’. Every LED is assigned a name from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to 'g' are used to display the numerals while eighth LED 'h' is used to display the dot/decimal. A seven segment is generally available in ten pin package. While eight pins correspond to the eight LEDs, the remaining two pins (at middle) are common and internally shorted. These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA). In CC configuration, the negative terminals of all LEDs are connected to the common pins. The common is connected to ground and a particular LED glows when its corresponding pin is given high. In CA arrangement, the common pin is given a high logic and the LED pins are given low to display a number.

Page 11: Digital Visitor Counter Using 8051 Microcontroller

Pin Diagram:

Page 12: Digital Visitor Counter Using 8051 Microcontroller
Page 13: Digital Visitor Counter Using 8051 Microcontroller

AT89C51 Microcontroller:

Description:

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually.

Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts.

Page 14: Digital Visitor Counter Using 8051 Microcontroller

Pin Diagram:

Page 15: Digital Visitor Counter Using 8051 Microcontroller

Pin Description:

Page 16: Digital Visitor Counter Using 8051 Microcontroller

 Pin No  Function  Name1

8 bit input/output port (P1) pins

P1.02 P1.13 P1.24 P1.35 P1.46 P1.57 P1.68 P1.79 Reset pin; Active high Reset

10Input (receiver) for serial

communicationRxD

8 bit input/output port (P3) pins

P3.0

11Output (transmitter) for serial

communicationTxD P3.1

12 External interrupt 1 Int0 P3.213 External interrupt 2 Int1 P3.314 Timer1 external input T0 P3.415 Timer2 external input T1 P3.516 Write to external data memory Write P3.617 Read from external data memory Read P3.718

Quartz crystal oscillator (up to 24 MHz)Crystal 2

19 Crystal 120 Ground (0V) Ground21

8 bit input/output port (P2) pins/

High-order address bits when interfacing with external memory

 P2.0/ A8

22  P2.1/ A9

23  P2.2/ A10

24  P2.3/ A11

25  P2.4/ A12

26  P2.5/ A13

27  P2.6/ A14

28  P2.7/ A15

29 Program store enable; Read from external program memory PSEN

30Address Latch Enable ALE

Program pulse input during Flash programming Prog

31External Access Enable;  Vcc for internal program executions EA

Programming enable voltage; 12V (during Flash programming) Vpp32

8 bit input/output port (P0) pins

Low-order address bits when interfacing with external memory

 P0.7/ AD7

33  P0.6/ AD6

34  P0.5/ AD5

35  P0.4/ AD4

36  P0.3/ AD3

37  P0.2/ AD2

38  P0.1/ AD1

39  P0.0/ AD0

40 Supply voltage; 5V (up to 6.6V) Vcc

Infrared LED:

Page 17: Digital Visitor Counter Using 8051 Microcontroller

Description:

An IR LED, also known as IR transmitter, is a special purpose LED that

transmits infrared rays in the range of 760 nm wavelength. Such LEDs are

usually made of gallium arsenide or aluminium gallium arsenide. They,

along with IR receivers, are commonly used as sensors.

The appearance is same as a common LED. Since the human eye cannot

see the infrared radiations, it is not possible for a person to identify

whether the IR LED is working or not, unlike a common LED. To overcome

this problem, the camera on a cellphone can be used. The camera can

show us the IR rays being emanated from the IR LED in a circuit.

Pin Diagram:

Page 18: Digital Visitor Counter Using 8051 Microcontroller

Light Emitting Diodes:

Page 19: Digital Visitor Counter Using 8051 Microcontroller

Description:

Light emitting diodes (LEDs) are semiconductor light sources. The light

emitted from LEDs varies from visible to infrared and ultraviolet regions.

They operate on low voltage and power. LEDs are one of the most

common electronic components and are mostly used as indicators in

circuits. They are also used for luminance and optoelectronic applications.

Based on semiconductor diode, LEDs emit photons when electrons

recombine with holes on forward biasing. The two terminals of LEDs are

anode (+) and cathode (-) and can be identified by their size. The longer

leg is the positive terminal or anode and shorter one is negative terminal.

The forward voltage of LED (1.7V-2.2V) is lower than the voltage supplied

(5V) to drive it in a circuit. Using an LED as such would burn it because a

high current would destroy its p-n gate. Therefore a current limiting

resistor is used in series with LED. Without this resistor, either low input

voltage (equal to forward voltage) or PWM (pulse width modulation) is

used to drive the LED. Get details about internal structure of a LED.

Pin Diagram:

Page 20: Digital Visitor Counter Using 8051 Microcontroller

Program :

Page 21: Digital Visitor Counter Using 8051 Microcontroller

// Program to make a bidirectional visitor counter using IR sensor

#include <reg51.h>

#define msec 1

unsigned int num=0;

sbit dig_ctrl_4=P1^3; //declare the control pins of seven segments

sbit dig_ctrl_3=P1^2;

sbit dig_ctrl_2=P1^1;

sbit dig_ctrl_1=P1^0;

unsigned int digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};

unsigned int dig_1,dig_2,dig_3,dig_4,test=0;

unsigned char dig_disp=0;

sbit up=P3^5; //up pin to make counter count up

sbit down=P3^6; //down pin to make counter count down

void init() // to initialize the output pins and Timer0

{

up=down=1;

dig_ctrl_4 = 0;

dig_ctrl_3 = 0;

dig_ctrl_2 = 0;

dig_ctrl_1 = 0;

TMOD=0x01;

TL0=0xf6;

TH0=0xFf;

IE=0x82;

TR0=1;

}

Page 22: Digital Visitor Counter Using 8051 Microcontroller

void delay() //To provide a small time delay

{

TMOD=0x01;

TL0=0x36;

TH0=0xF6;

TR0=1;

while(TF0==0);

TR0=0;

TF0=0;

}

void display() interrupt 1 // Function to display the digits on seven segment. For more details refer seven segment multiplexing.

{

TL0=0x36;

TH0=0xf6;

P2=0xFF;

dig_ctrl_1 = dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_4 = 0;

dig_disp++;

dig_disp=dig_disp%4;

switch(dig_disp)

{

case 0:

P2= digi_val[dig_1];

dig_ctrl_1 = 1;

break;

Page 23: Digital Visitor Counter Using 8051 Microcontroller

case 1:

P2= digi_val[dig_2];

dig_ctrl_2 = 1;

break;

case 2:

P2= digi_val[dig_3];

dig_ctrl_3 = 1;

break;

case 3:

P2= digi_val[dig_4];

dig_ctrl_4 = 1;

break;

}

}

void main()

{

init();

while(1)

{

if(up==0&&down==1) //check if up pin is pressed

{

test++;

num=test;

dig_4=num%10;

num=num/10;

dig_3=num%10;

Page 24: Digital Visitor Counter Using 8051 Microcontroller

num=num/10;

dig_2=num%10;

dig_1=num/10;

if(test==9999)

test=0;

}

if(up==1&&down==0) //check if down pin is pressed

{

test--;

num=test;

dig_4=num%10;

num=num/10;

dig_3=num%10;

num=num/10;

dig_2=num%10;

dig_1=num/10;

if(test==0)

test=9999;

}

}

}

Uses :

Page 25: Digital Visitor Counter Using 8051 Microcontroller

Used to count the visitors of an auditorium, hall, offices, malls,

sports etc.

Used as integral part of security System in high confidential areas.

Used in Parking Lot.

Used in Elevator to prevent the maximum limit of weight.

Advantages :

High precision and accuracy can be achieved through it.

Since it is bidirectional, it can count in both directions peoples

entering and exiting the place.

Since it is compact it can be easily implemented anywhere.

It is also cost effective.

Conclusion :

Page 26: Digital Visitor Counter Using 8051 Microcontroller

Thus the project entitled “Bidirectional Visitor Counter” helps to measure

the visitor entering and exiting a particular passage or way. The circuit

counts both entering and exiting visitors and displays the number of

visitors present inside the hall. Visitor counting is not limited to the

entry/exit point of a company but has a wide range of applications that

provide information to management on the volume and flow of people

throughout a location. The visitor helps to maximize the efficiency and

effectiveness of employees, floor area and sales potential of an

organization.

The circuit may also be enhanced with a wide counting range of above

three digits by modifying software section of the system. It can also be

enhanced for long and accurate sensing range using a laser torch instead

of IR transmission circuit. Thus the circuit can be used to monitor visitor

flow in effective manner, where the visitors have to counted and

controlled.