This article describes the design and working of a bidirectional visitor counter. The main intention is to design a system wherein the number of persons entering or leaving a room is displayed on a screen. When a person enters the room, count would be increased, whereas on leaving, the count would decrease. IR sensing mechanism is used to sense the presence of visitors and the whole counting operation is done by a microcontroller. But, before going to know about this circuit, get an idea about how to interface a 7 segment LED Display to 8051 Microcontroller as we use use this concept in this project.
Bidirectional Visitor Counter Circuit Principle:
The circuit works on the principle of IR sensing. Two sets of IR sensors consisting of an IR LED and photo transistor are placed at two ends. Output from each sensor is fed to the microcontroller. In normal operation, IR light from the LED would fall on the photo transistor and the latter would conduct. The output from the sensor would be a logic low signal in this case. In case of any interruption (due to any person crossing the path), the photo transistor would cease to conduct or conduct less and the output from the sensor would be a logic high signal. The transition from low to high, for each sensor pair is detected by the microcontroller and accordingly the count would be increased or decreased.
Do you know how to Measure Frequency using Frequency Counter?
Circuit Diagram of Bidirectional Visitor Counter:
Here is the list of components and their corresponding values used in this circuit.
- R1, R3 – 760 Ohms
- R2, R4 – 3K
- R5 – 10K
- C1 – 10uF, electrolyte
- C2, C3 – 15pF
- X1 – 12MHz crystal
- U1 – AT89C51
- U4 – 2-Digit 7 segment display
- D1, D2 – IR LED
- Q1, Q2 – IR Phototransistor
Related Post – 2 Digit Up/Down Counter Circuit Working and Applications
The heart of the circuit design lies in designing the microcontroller interface. Here we use the microcontroller AT89C51 which is an 8051 family microcontroller. The microcontroller AT89C51 is interfaced to the IR sensor pairs at two ports pins – P1.0 and P1.1 respectively. The 2-Digit 7 segment display is interfaced to the microcontroller at ports P0 and P2.
Another important aspect of the design involves designing the oscillator circuit and the reset circuit. The oscillator circuit is designed by selecting a 12MHz quartz crystal and two ceramic capacitors-each 15pF. The reset circuit is designed by selecting a resistor of 10K and an electrolyte capacitor of 10uF to ensure a reset pulse width of 100ms and reset pin voltage drop of 1.2V.
The sensor circuit is designed by selecting appropriate value of resistors for both the LED and the phototransistor. Since here the source voltage is 5V and IR LED forward voltage drop is about 1.2V, the value of resistor (at on current of 5mA) is calculated to be about 760 Ohms. The phototransistor used here is Silicon NPN transistor QSC112 with maximum collector of 4mA. Since here we are using the phototransistor in switching mode, the required collector resistor should be greater than 1.25K (Vcc/Ic = 5/4). Here we choose a 5K resistor.
How to Operate Bidirectional Visitor Counter Circuit?
When the system is powered, the compiler initially initializes the stack pointer and all other variables. It then scans the input ports (PortP1.0 first). In the meantime, when there is no interruption between the IR LED and the phototransistor of the first sensor pair, the output of the phototransistor is always at low voltage. In other words port P1.0 is at logic low level. Now when a transition takes place, i.e. a logic high level is received at port P1.0, the compiler sees this as an interruption to sense the passage of a person or an object between the IR LED and the phototransistor. As per the program, the count value is increased and this value is displayed on the 2-Digit Counter. Now the compiler starts scanning the other input pin-P1.1. Similar to the first sensor pair, for this sensor pair also the phototransistor conducts in absence of any interruption and P1.1 is at logic low level. In case of an interruption, the pin P1.1 goes high and this interruption is perceived by decreasing the value of count.
The program ensures that the scanning of both the port pins is done at certain delays so as to avoid confusion of reading. For instance port P1.0 is scanned for two or three interruptions so as to ensure the count value is above 1 or 2.
Applications of Bidirectional Visitor Counter Circuit:
- This 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 theoretical circuit and may require few changes in practical implementation.
- 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.
Note: Read the post – Mini Projects for more engineering project circuits.