Sunteți pe pagina 1din 4

Construction

Microcontroller-based
Bidirectional Visitor
Counter
UMAR
SUNIL K

 Akshay Mathur, Kuldeep


Singh Nagla

V
isitor counting is simply a
measurement of the visitor
traffic entering and exiting
offices, malls, sports venues, etc.
Counting the visitors helps to maxi-
mise the efficiency and effectiveness of
employees, floor area and sales poten- Fig. 1: Transmitter-receiver set-up at the entrance-cum-exit of the passage
tial of an organisation.
Visitor counting is not limited to the entry/exit point of a company but passage along with block diagram.
has a wide range of applications that Two similar sections detect interrup-
Parts List provide information to management tion of the IR beam and generate clock
Semiconductors:
on the volume and flow of people pulse for the microcontroller. The
IC1 - LM324 quad op-amp
IC2 - 74LS76 J-K flip-flop throughout a location. A primary microcontroller controls counting and
IC3 - AT89C52 method for counting the visitors in- displays the number of persons present
microcontroller volves hiring human auditors to stand inside the hall.
IC4 - 7805 5V regulator and manually tally the number of visi- Fig. 2 shows the circuit of the
T1, T2 - L14F1 npn phototransis-
tor tors who pass by a certain location. But microcontroller-based visitor coun-
T3, T4 - 2N3904 npn transistor human-based data collection comes at ter, wherein the transmitter and the
IR TX1, IR TX2 - IR transmitting LED great expense. receiver form the IR detection circuit.
BR1 - 1A bridge rectifier Here is a low-cost microcontroller- Control logic is built around transis-
DIS1-DIS3 - LTS543 CC 7-segment
based visitor counter that can be used tors, operational amplifier LM324 (IC1)
display
to know the number of persons at a and flip-flop (IC2).
Resistors (all ¼-watt, ±5% carbon):
R1, R2 - 68-ohm place. All the components required are When nobody is passing through
R3, R4 - 6.8-kilo-ohm readily available in the market and the the entry/exit point, the IR beam
R5, R6 - 100-ohm circuit is easy to build. continuously falls on phototransistor
R7, R8, R10, Two IR transmitter-receiver pairs T1. Phototransistor T1 conducts and
R11 - 10-kilo-ohm
R9 - 4.7-kilo-ohm
are used at the passage: one pair the high voltage at its emitter drives
R12-R32 - 220-ohm comprising IR transmitter IR TX1 and transistor T3 into saturation, which
VR1, VR2 - 20-kilo-ohm preset receiver phototransistor T1 is installed makes pin 3 of comparator N1 low and
RNW1 - 10-kilo-ohm resistor at the entry point of the passage, while finally output pin 1 of comparator N1
network
the other pair comprising IR transmit- is high.
Capacitors: ter IR TX2 and phototransistor T2 is Now if someone enters the place,
C1, C2 - 0.2µF ceramic disk
C3, C4 - 33pF ceramic disk installed at the exit of the passage. The first the IR beam from IR TX1 is inter-
C5 - 10µF, 16V electrolytic IR signals from the IR LEDs should rupted and then the IR beam from IR
C6 - 470µF, 25V electrolytic continuously fall on the respective TX2. When the beam from IR TX1 is
C7 - 0.1µF ceramic disk phototransistors, so proper orientation interrupted, phototransistor T1 and
Miscellaneous: of the transmitters and phototransistors transistor T3 cut-off and pin 3 of com-
XTAL - 12MHz crystal is necessary. parator N1 goes high.
X1 - 230V primary to 7.5V,
250mA secondary trans- The low output (pin 1) of compara-
former
Circuit description tor N1 provides negative trigger pulse
S1 - Push-to-on switch Fig. 1 shows the transmitter-receiver to pin 1 of J-K flip-flop IC2(A). At this
S2 - On/off switch set-up at the entrance-cum-exit of the moment, the high input at ‘J’ and ‘K’

7 8 • J a n ua ry 2 0 0 7 • e l e c t ro n i c s f o r yo u w w w. e f y m ag . co m
Construction

Fig. 2: Circuit of the microcontroller-based visitor counter

w w w. e f y m ag . co m e l e c t ro n i c s f o r yo u • J a n ua ry 2 0 0 7 • 7 9
Construction

Fig. 3: Power supply circuit

pins of flip-flop set, the


IC2(A) toggles its flip-flops are
output to low. On brought in
the other hand, ‘set’ state
the low input at through the
‘J’ and ‘K’ pins microcontroller
Fig. 4: Pin
of IC2(B) due to at software run
configuration clock pin 1 of time by making
of L14F1 and IC2(A) and ‘J’ in- their ‘set’ pin
transistor 2N3904
put (pin 9) and high for a mo-
‘K’ input (pin 12) of IC2(B) are con- ment.
nected to pin 1 of comparator N1. The The value
negative-going pulse is applied to clock of the counter
pin 6 of IC2(B) when the person inter- increments by Fig. 5: An actual-size, single-side PCB for the microcontroller-based visitor
rupts the IR beam from IR TX2. There ‘1’ when the counter (Fig. 2) including its power supply (Fig. 3)
is no change in the output of IC2(B) interrupt ser-
flip-flop. This triggers the external vice routine for
interrupt INT0 (pin 12) of microcon- INT0 is execut-
troller AT89C52. ed. The output
The AT89C52 is an 8-bit micro- of the corre-
controller with 8 kB of flash-based sponding J-K
program memory, 256 bytes of RAM, flip-flop is set
32 input/output lines, three 16-bit to ‘high’ again
timers/counters, on-chip oscillator by making its
and clock circuitry. A 12MHz crystal is ‘set’ input pin
used for providing clock. low through
Ports 0, 1 and 2 are configured the microcon-
for 7-segment displays. Port-0 pin is troller. The mi-
externally pulled up with 10-kilo-ohm cro-controller is
resistor network RNW1 because port- configured as a
0 is an 8-bit, open-drain, bidirectional, negative-edge-
input/output (I/O) port. Port-1 and triggered inter-
port-2 are 8-bit bidirectional I/O ports rupt sensor.
with internal pull-ups (no need of ex- Similarly, if
ternal pull-ups). somebody exits
Port pins 3.0 and 3.1 are configured the place, first
to provide the set pulse to J-K flip-flops the IR beam
IC2(A) and IC2(B), respectively. Exter- from IR TX2
nal interrupts INT0 and INT1 receive is interrupted
the interrupt pulse when the person in- and then the
terrupts the IR beams. Resistor R9 and IR beam from
capacitor C5 provide power-on-reset IR TX1. When Fig. 6: Component layout for the PCB
pulse to the microcontroller. Switch S1 the beam from
is used for manual reset. IR TX2 is interrupted, output pin provides clock pulse to pin 6 of J-K
When the microcontroller is re- 7 of comparator N2 goes low. This flip-flop IC2(B).

8 0 • J a n ua ry 2 0 0 7 • e l e c t ro n i c s f o r yo u w w w. e f y m ag . co m
Construction
At this moment, the high input ing J-K flip-flop is set to ‘high’ again by 3) is shown in Fig. 5 and its component
at ‘J’ and ‘K’ pins of flip-flop IC2(B) making its ‘set’ input pin low through layout in Fig. 6.
toggles its output to low. On the other the microcontroller.
hand, the low input at ‘J’ and ‘K’ pins The circuit is powered by regu- Software
of IC2(A) due to clock pin 6 of IC2(B) lated 5V. Fig. 3 shows the circuit of The software for the visitor counter
and ‘J’ input (pin 4) and ‘K’ input (pin the power supply. The AC mains is is written in ‘C’ language and
16) of IC2(A) are connected to pin 7 of stepped down by transformer X1 to compiled using C51 Keil compiler.
comparator N2. deliver secondary output of 7.5V, The demo version of this compiler
The negative-going pulse is ap- 250mA, which is rectified by bridge is available for free on the
plied to clock pin 1 of IC2(A) when the rectifier BR1, filtered by capacitor C6 website ‘www.keil.com.’ It can
person interrupts the IR beam from IR and regulated by IC 7805 (IC4). Ca- compile programs up to 2 kB only,
TX1. There is no change in the output pacitor C7 bypasses any ripple in the which is sufficient for writing most
of IC2(A) flip-flop. This triggers the regulated output. programs.
external interrupt INT1 (pin 13) of EFY note. The source code and
microcontroller AT89C52. The value Construction other relevant files of this article
of the counter decrements by ‘1’ when An actual-size, single-side PCB for the have been included in this month’s
interrupt service routine for INT1 is ex- microcontroller-based visitor counter EFY-CD.
ecuted. The output of the correspond- (Fig. 2) including its power supply (Fig.

visitor.c
#include <AT89x52.h> i—; i=0;
int i=0,j,k,l,m,a[]={63,6,91,79,102,109,125,7,127,111}; if(i<0) i=0; while(1)
void enter (void) interrupt 0 P3_0=0; {
{ for(m=0;m<=1000;m++); j=i%10;
i++; P3_0=1; k=i/10;
if(i>999) i=999; } l=i/100;
P3_1=0; void main() k=k-l*10;
for(m=0;m<=1000;m++); { P2=a[j];
P3_1=1; IE = 133; P0=a[k];
} TCON = 5; P1=a[l];
void exit (void) interrupt 2 P3_0=1; }
{ P3_1=1; } 

w w w. e f y m ag . co m e l e c t ro n i c s f o r yo u • J a n ua ry 2 0 0 7 • 8 1

S-ar putea să vă placă și