This article outlines the construction and operation of a Bidirectional Visitor Counter that utilizes the 8051 Microcontroller. The primary objective is to create a system capable of tracking the number of individuals entering or exiting a room and displaying this count on a screen.
Whenever an individual enters the room, the count will increment, and when someone exits, the count will decrease. To detect the presence of visitors, an infrared (IR) sensing mechanism is employed, and the entire counting process is managed by a microcontroller.
However, before delving into the details of this circuit, it’s essential to familiarize yourself with the concept of interfacing a 16 x 2 LCD Display to an 8051 Microcontroller, as this concept will be applied in this project.
- Construction and Output Video
- Bidirectional Visitor Counter Circuit Principle
- Circuit Diagram of Bidirectional Visitor Counter
- Circuit Components
- Circuit Design of Bidirectional Visitor Counter using 8051 Microcontroller
- How to Operate Bidirectional Visitor Counter Circuit?
- DOWNLOAD CODE
- Applications of Bidirectional Visitor Counter Circuit
- Limitations of this Circuit
Construction and Output Video
Bidirectional Visitor Counter Circuit Principle
The circuit’s functionality relies on infrared (IR) sensing, where IR Sensors serve as both transmitters and receivers, utilizing an infrared light source and a photo detector like a photo diode or a photo transistor.
In our project, we’ve employed an IR LED as the IR transmitter and a photo diode as the IR receiver. Two sets of IR sensors, each comprising an IR LED and a photo diode, are positioned at both ends of the entrance to a room.
The microcontroller receives output signals from each sensor. Under normal circumstances, the photo diode, being a reflective-type IR sensor, does not receive IR light from the LED. Consequently, the sensor’s output remains at a logic LOW signal.
However, in the event of any interruption, such as a person crossing the sensor’s path, the photo diode starts receiving IR light and becomes conductive. Consequently, the sensor’s output shifts to a logic HIGH signal.
The microcontroller detects the transition from low to high for each sensor pair and accordingly increments or decrements the count.
Circuit Diagram of Bidirectional Visitor Counter
Here is the list of components and their corresponding values used in this circuit. photo transistor
- AT89C51 (8051 based Microcontroller)
- 8051 Programmer
- Push Button
- 10µF Electrolytic Capacitor
- 2 x 10KΩ Resistors (1/4 Watt)
- 11.0592 MHz Crystal
- 2 x 33pF Ceramic Capacitors
- 16 x 2 LCD Display
- 10KΩ Potentiometer
- 2 x IR Sensors (Reflective Type)
- Connecting Wires
- Power Supply
- Keil µVision Software
- Willar Software
Circuit Design of Bidirectional Visitor Counter using 8051 Microcontroller
The core of the circuit design revolves around establishing the microcontroller interface. In this project, we employed the AT89C51 microcontroller, which belongs to the 8051 family of microcontrollers.
The microcontroller AT89C51 is connected to the IR sensor pairs at PORT2 pins – P2.0 and P2.1, respectively. You can refer to the circuit diagram below to see the configuration of the Reflective Type IR Sensor Module used in this project.
To create the sensor circuit, the appropriate resistor values for the LED and Photo Diode are carefully chosen. A 150-ohm current-limiting resistor is placed in series with the IR LED.
The photo diode is connected in reverse bias with a 10K series resistor. This arrangement forms a potential divider, and the output is directed into the non-inverting input of the Operational Amplifier (Op-Amp).
A 10K POT is connected to the inverting input for sensitivity adjustment, allowing you to alter the IR Sensor’s sensitivity. The count data is displayed on a 16 x 2 LCD panel. The data lines of the LCD are linked to the Microcontroller’s PORT1 pins.
The Control Pins, namely RS, RW, and E, are connected to pins P3.6, GND, and P3.7. A 10KΩ POT is employed for contrast adjustment, connected to Pin 3 of the LCD.
Another critical aspect of the design involves creating the oscillator circuit and the reset circuit. The oscillator circuit is established using an 11.0592 MHz quartz crystal and two 33pF ceramic capacitors.
The reset circuit is formed using a 10KΩ resistor and a 10µF electrolyte capacitor to ensure a reset pulse width of 100ms and a reset pin voltage drop of 1.2V.
How to Operate Bidirectional Visitor Counter Circuit?
Let’s delve into the operation of this Bidirectional Visitor Counter featuring an 8051 Microcontroller.
Upon system startup, the microcontroller initializes the stack pointer and all other variables. Subsequently, it scans the input pins (P2.0 and P2.1).
Under normal conditions, when no object obstructs the path of the IR Sensors, the IR LED’s light does not reach the Photo Diode in the first sensor pair, causing the Photo Diode to remain non-conductive.
Consequently, the output of the IR sensors is set to LOW. In other words, ports P2.0 and P2.1 are configured as logic LOW. When an individual stands in front of the IR Sensors, they reflect the IR light emitted by the IR LED, which in turn falls on the Photo Diode.
This action leads to the Photo Diode becoming conductive, resulting in a HIGH output from the sensor. In simpler terms, ports P2.0 and P2.1 are set to logic HIGH.
The microcontroller interprets this transition as a signal that an object or person has passed or entered the area in front of the IR LED and Photo Diode when a transition occurs—specifically, when a logic HIGH signal is first received at port P2.0, followed by port P2.1.
The software then increments the count value accordingly, which is subsequently displayed on the 16 x 2 LCD Display.
If the microcontroller detects logic HIGH at P2.1, followed by logic HIGH at P2.0, it deduces that the person is leaving the room. In such a scenario, the microcontroller follows the programmed logic to decrement the count.
Importantly, the program ensures that count adjustments occur only when both sensors simultaneously detect the presence of a person or object.
Applications of Bidirectional Visitor Counter Circuit
- The Bidirectional Visitor Counter using 8051 Microcontroller circuit can be used domestically to get an indication of number of persons entering a party
- It can be used at official meetings.
- It can be used at homes and other places to keep a check on the number of persons entering a secured place.
- It can also be used as home automation system to ensure energy saving by switching on the loads and fans only when needed.
Limitations of this Circuit
- It is a low range circuit and cannot be implemented at large areas.
- With frequent change in the count value, after a certain time the output may look confusing.