60
A Project report on BI-DIRECTIONAL VISITORS COUNTER Submitted in partial fulfillment for the award of the degree of BACHELOR OF TECHNOLOGY IN ELECTRONICS & COMMUNICATION ENGINEERING Submitted By I.VENKATA SURIBABU (08A31A0440) S.SHAHBAZ NAWAZ (08A31A0462) P.VENKATESH (08A31A0455) K.VENU BABU (08A31A0444) Under the esteemed guidance of Mr. K. RAGHURAM Assoc. Professor DEPARTMENT OF ELECTRONICS AND COMMUNICATIONS ENGINEERING PRAGATI ENGINEERING COLLEGE

Bi-directional Visitors Counter

Embed Size (px)

Citation preview

Page 1: Bi-directional Visitors Counter

A Project report on

BI-DIRECTIONAL VISITORS COUNTER

Submitted in partial fulfillment for the award of the degree of

BACHELOR OF TECHNOLOGY

IN

ELECTRONICS & COMMUNICATION ENGINEERING

Submitted

By

I.VENKATA SURIBABU (08A31A0440)

S.SHAHBAZ NAWAZ (08A31A0462)

P.VENKATESH (08A31A0455)

K.VENU BABU (08A31A0444)

Under the esteemed guidance of

Mr. K. RAGHURAM

Assoc. Professor

DEPARTMENT OF ELECTRONICS AND COMMUNICATIONS ENGINEERING

PRAGATI ENGINEERING COLLEGE

(Approved by AICTE & Affiliated to JNT University, Kakinada)

(1-378, ADB ROAD, SURAMPALEM- 533 437, NEAR PEDDAPURAM, E.G.DIST., A.P. )

SURAMPALEM – 533437

Page 2: Bi-directional Visitors Counter

CERTIFICATE

This is to certify that the project work entitled BI-DIRECTIONAL VISITORS COUNTER is

a Record of bonafied work carried out by I.VENKATA SURIBABU (08A31A0440),

S.SHAHBAZNAWAZ (08A31A0462), P.VENKATESH (08A31A0455), and K.VENUBABU

(08A31A0444) in partial fulfillment of the requirements for the award of degree of BACHELOR

OF TECHNOLOGY IN ELECTRONICS AND COMMUNICATION ENGINEERING during

the year 2011-2012 under my guidance.

PROJECT INTERNAL GUIDE

Mr. K. RAGHURAM Assoc. Professor

Page 3: Bi-directional Visitors Counter

ACKNOWLEDGEMENT

We avail this opportunity to thank the persons with whom, we have been associated in this

successful completion of the project. It has been an experience of great pleasure and satisfaction

to us while performing this project.

We wish to convey my thanks to PRAGATI ENGINEERING COLLEGE for providing an

opportunity for me to undertake graduate program in engineering and to do our project work.

We wish to record our deep gratitude and indebtedness to our Head of Department

Mr.V.Prashanth and our guide Mr. K.RAGHURAM Associate Professor, Pragati Engineering

College.

Lastly we express our sincere thanks to everyone who has helped directly and indirectly for

the successful completion of our project work.

I.VENKATA SURIBABU (08A31A0440)

S.SHAHBAZ NAWAZ (08A31A0462)

P.VENKATESH (08A31A0455)

K.VENU BABU (08A31A0444)

Page 4: Bi-directional Visitors Counter

TABLE OF CONTENTS

Chapter 1 Page No

INTRODUCTION

1.1 Abstract ………………………………………………….……… 1

1.2 Components Used.……….……………..…..…………….…...... 2

Chapter 2

LITERATURE

2.1 Operation of Circuit Diagram………..………………………… 3

Chapter 3

HARDWARE DETAILS

3.1 Microcontroller Unit……….…...………………………………… 7

3.2 LDR Sensor Unit ………………………………………………… 16

3.3 JK Flip Flop Unit………………………….………………………. 16

3.4 Comparator Unit...................................................................... 18

3.5 Seven Segment Display ………………………………………….. 18

3.6 Power Supply Unit………………………………………....……… 24

Chapter 4

SOFTWARE DETAILS

4.1 Keil Software………………………………….…………………… 30

4.2 Flow chart………………………….……..…………………….….. 33

4.3 Source program…………………………………………………… 34

4.4 Hex File…………………………………………………………….. 36

Page 5: Bi-directional Visitors Counter

Chapter 5

5.1 Applications……………….……………………………………….. 39

5.2 Conclusion………………………………...………………………… 39

5.2 Future Enhancement………………………………………………. 40

5.4 References…………………………………………………………… 40

Page 6: Bi-directional Visitors Counter

LIST OF FIGURES

Figure no. figure page no.

Fig.2.1.1 block diagram 3

Fig.2.1.2 circuit diagram 4

Fig.2.1.3 Pin configuration of L14F1 and 2N3904 4

Fig.2.1.4 power supply circuit 6

Fig.3.1.1 functional block diagram 9

Fig.3.1.2 pin diagram of micro controller 11

Fig.3.1.3 oscillator connections 14

Fig.3.1.4 external clock drive configuration 14

Fig.3.3.1 jk flip flop 17

Fig.3.3.2 functional table of jk flip flop 17

Fig.3.5.1 seven segment display 18

Fig.3.5.2 diode placement in a seven segment display 19

Fig.3.5.3 common anode internal wiring 19

Fig.3.5.4 common cathode internal wiring 20

Fig.3.5.5 pin outs for the mc14511 seven-segment display driver 20

Fig.3.5.6 truth table for the seven-segment display 21

Fig.3.5.7 internal circuitry and logic gates for 7 seg display 22

Fig.3.5.8 seven segment display with display driver 22

Fig.3.5.9 0-9 counting circuit 23

Fig.3.6.1 block diagram of power supply 24

Fig.3.6.2 power supply of circuit diagram 25

Page 7: Bi-directional Visitors Counter

Fig.3.6.3 (a) bridge rectifier 26

Fig.3.6.3 (b) Current flow during positive half cycle 26

Fig.3.6.3 (c) Current flow during negative half cycle 27

Fig.3.6.4 LM7805 29

Fig 4.2.1 flow chart 33

. CHAPTER-1

INTRODUCTION

1.1 ABSTRACT

Visitor counting is simply a measurement of the visitor traffic entering and exiting

offices, malls, sports venues, etc. Counting the visitors helps to maximize the efficiency and

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

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. A primary method for counting the visitors involves hiring human auditors

to stand and manually tally the number of visitors who pass by a certain location. But human-

based data collection comes at great expense.

Here is a low-cost microcontroller based visitor counter that can be used to know the

number of persons at a place. Two IR transmitter-receiver pairs are used at the passage: one pair

comprising IR transmitter IR TX1 and receiver phototransistor T1 is installed at the entry point

of the passage, while the other pair comprising IR transmitter IR TX2 and phototransistor T2 is

installed at the exit of the passage. The IR signals from the IR LEDs should continuously fall on

the respective phototransistors, so proper orientation of the transmitters and phototransistors is

necessary. Two similar sections detect interruption of the IR beam and generate clock pulse for

Page 8: Bi-directional Visitors Counter

the microcontroller. The microcontroller controls counting and displays the number of persons

present inside the hall.

1.2 COMPONENTS USED

Semiconductors: IC1 - LM324 quad op-amp IC2 - 74LS76 J-K flip-flop IC3 - AT89C52 microcontroller IC4 - 7805 5V regulator T1, T2 - L14F1 npn phototransistor T3, T4 - 2N3904 npn transistor IR TX1, IR TX2 - IR transmitting LED BR1 - 1A bridge rectifier DIS1-DIS3 - LTS543 CC 7-segment display

Resistors (all ¼-watt, ±5% carbon): R1, R2 - 68-ohm R3, R4 - 6.8-kilo-ohm R5, R6 - 100-ohm R7, R8, R10, R11 - 10-kilo-ohm R9 - 4.7-kilo-ohm R12-R32 - 220-ohm VR1, VR2 - 20-kilo-ohm preset RNW1 - 10-kilo-ohm resistor network

Capacitors: C1, C2 - 0.2µF ceramic disk C3, C4 - 33pF ceramic disk C5 - 10µF, 16V electrolytic C6 - 470µF, 25V electrolytic C7 - 0.1µF ceramic disk

Miscellaneous: XTAL - 12MHz crystal X1 - 230V primary to 7.5V, 250mA secondary transformer

Page 9: Bi-directional Visitors Counter

S1 - Push-to-on switch S2 - On/off switch

Chapter-2

LITERATURE

2.1 circuit description

Fig. 1 shows the transmitter-receiver set-up at the entrance-cum-exit of the passage along with block diagram. Two similar sections detect interruption of the IR beam and generate clock pulse for the microcontroller. The microcontroller controls counting and displays the number of persons present inside the hall.

Fig. 2.1.1: Transmitter-receiver set-up at the entrance-cum-exit of the passage

Fig. 2 shows the circuit of the microcontroller-based visitor counters, wherein the transmitter and the receiver form the IR detection circuit. Control logic is built around transistors, operational

Page 10: Bi-directional Visitors Counter

amplifier LM324 (IC1) and flip-flop (IC2). When nobody is passing through the entry/exit point, the IR beam continuously falls on phototransistor T1. Phototransistor T1 conducts and the high voltage at its emitter drives transistor T3 into saturation, which makes pin 3 of comparator N1 low and finally output pin 1 of comparator N1 is high.

Circuit Diagram:

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

Now if someone enters the place, first the IR beam from IR TX1 is interrupted and then the IR beam from IR TX2. When the beam from IR TX1 is interrupted, phototransistor T1 and transistor T3 cut-off and pin 3 of comparator N1 goes high.

Page 11: Bi-directional Visitors Counter

Fig.2.1.3: Pin configuration of L14F1 and transistor 2N3904

The low output (pin 1) of comparator N1 provides negative trigger pulse to pin 1 of J-K flip-flop IC2 (A). At this moment, the high input at ‘J’ and ‘K’. Pins of flip-flop IC2 (A) toggles its output to low. On the other hand, the low input at ‘J’ and ‘K’ pins of IC2(B) due to clock pin 1 of IC2(A) and ‘J’ input (pin 9) and ‘K’ input (pin 12) of IC2(B) are connected to pin 1 of comparator N1. The negative-going pulse is applied to clock pin 6 of IC2 (B) when the person interrupts the IR beam from IR TX2. There is no change in the output of IC2 (B) flip-flop. This triggers the external interrupt INT0 (pin 12) of microcontroller AT89C52.

The AT89C52 is an 8-bit microcontroller with 8 KB of flash-based program memory, 256 bytes of RAM, 32 input/output lines, three 16-bit timers/counters, on-chip oscillator and clock circuitry. A 12MHz crystal is used for providing clock.

Ports 0, 1 and 2 are configured for 7-segment displays. Port-0 pin is externally pulled up with 10-kilo-ohm resistor network RNW1 because port- 0 is an 8-bit, open-drain, bidirectional, input/output (I/O) port. Port-1 and port-2 are 8-bit bidirectional I/O ports with internal pull-ups (no need of external pull-ups).

Port pins 3.0 and 3.1 are configured to provide the set pulse to J-K flip-flops IC2 (A) and IC2(B), respectively. External interrupts INT0 and INT1 receive the interrupt pulse when the person interrupts the IR beams. Resistor R9 and capacitor C5 provide power-on-reset pulse to the microcontroller. Switch S1 is used for manual reset. When the microcontroller is re-set , t h e flip-flops are brought in ‘set’ state through the microcontroller at software run time by making their ‘set’ pin high for a moment.

The value of the counter increments by ‘1’ when the interrupt service routine for INT0 is executed. The output of the corresponding J-K flip-flop is set to ‘high’ again by making its ‘set’

Page 12: Bi-directional Visitors Counter

input pin low through the microcontroller. The micro- controller is configured as a negative-edge triggered interrupt sensor. Similarly, if somebody exits the place, first the IR beam from IR TX2 is interrupted and then the IR beam from IR TX1. When the beam from IR TX2 is interrupted, output pin 7 of comparator N2 goes low. This provides clock pulse to pin 6 of J-KFlip-flop IC2 (B).

At this moment, the high input at ‘J’ and ‘K’ pins of flip-flop IC2(B) toggles its output to low. On the other hand, the low input at ‘J’ and ‘K’ pins of IC2(A) due to clock pin 6 of IC2(B) and ‘J’ input (pin 4) and ‘K’ input (pin 16) of IC2(A) are connected to pin 7 of comparator N2.

The negative-going pulse is applied to clock pin 1 of IC2 (A) when the person interrupts the IR beam from IR TX1. There is no change in the output of IC2 (A) flip-flop. This triggers the external interrupt INT1 (pin 13) of microcontroller AT89C52.The value of the counter decrements by ‘1’ when interrupt service routine for INT1 is executed. The output of the corresponding J-K flip-flop is set to ‘high’ again by making its ‘set’ input pin low through the microcontroller.

The circuit is powered by regulated 5V. Fig. 3 shows the circuit of the power supply. The AC mains is stepped down by transformer X1 to deliver secondary output of 7.5V, 250mA, which is rectified by bridge rectifier BR1, filtered by capacitor C6 and regulated by IC 7805 (IC4). Capacitor C7 bypasses any ripple in the regulated output.

Page 13: Bi-directional Visitors Counter

Fig. 2.1.4: Power supply circuit

CHAPTER 3

HARDWARE DETAILS

3.1 MICROCONTROLLER UNIT 89C52

Introduction:

A Micro controller consists of a powerful CPU tightly coupled with memory, various I/O

interfaces such as serial port, parallel port timer or counter, interrupt controller, data acquisition

Page 14: Bi-directional Visitors Counter

interfaces-Analog to Digital converter, Digital to Analog converter, integrated on to a single

silicon chip.

The Major Features:

Compatible with MCS-52 products

8k Bytes of in-system Reprogrammable flash memory

Fully static operation: 0HZ to 24MHZ

Three level programmable clock

128 * 8 –bit timer/counters

Eight interrupt sources

Programmable serial channel

Low power idle power-down modes

AT89C52 is 8-bit micro controller, which has 8KB on chip flash memory, which is just

sufficient for our application. The on-chip Flash ROM allows the program memory to be

reprogrammed in system or by conventional non-volatile memory Programmer. Moreover

ATMEL is the leader in flash technology in today’s market place and hence using AT 89C52 is

the optimal solution.

AT89C52 MICROCONTROLLER ARCHITECTURE:

The 89C52 architecture consists of these specific features:

Eight –bit CPU with registers A (the accumulator) and B

Sixteen-bit program counter (PC) and data pointer (DPTR)

Eight- bit stack pointer (PSW)

Eight-bit stack pointer (Sp)

Page 15: Bi-directional Visitors Counter

Internal ROM or EPROM (8751) of 0(8031) to 8K (89c52)

Internal RAM of 256 bytes:

Thirty –two input/output pins arranged as four 8-bit ports:p0-p3

Two 16-bit timer/counters: T0 and T1

Full duplex serial data receiver/transmitter: SBUF

Control registers: TCON, TMOD, SCON, PCON, IP, and IE

Two external and three internal interrupts sources & Oscillator and clock circuits.

Types of memory:

The 89C52 have three general types of memory. They are on-chip memory, external

Code memory and external Ram. On-Chip memory refers to physically existing memory on the

micro controller itself. External code memory is the code memory that resides off chip. This is

often in the form of an external EPROM. External RAM is the Ram that resides off chip. This

often is in the form of standard static RAM or flash RAM.

Page 16: Bi-directional Visitors Counter

Fig 3.1.1: Functional block diagram of micro controller

a) Code memory

Code memory is the memory that holds the actual 89c52 programs that is to be run. This

memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have

4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory

is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA.

Page 17: Bi-directional Visitors Counter

b) Internal RAM

The 89c52 have a bank of 128 of internal RAM. The internal RAM is found on-chip. So

it is the fastest Ram available. And also it is most flexible in terms of reading and writing.

Internal Ram is volatile, so when 89c52 is reset, this memory is cleared. 128 bytes of internal

memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains

8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These

bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are

numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB

and CLR.

Flash memory is a nonvolatile memory using NOR technology, which allows the user to

electrically program and erase information. Flash memory is used in digital cellular phones,

digital cameras, LAN switches, PC Cards for notebook computers, digital set-up boxes,

embedded controllers, and other devices.

Pin Description

Vcc: (Pin 40): Supply voltage.

GND: (Pin 20): Ground.

Port 0: (Pins 32 to 39):

Port 0 is a 8-bit open drain bi-directional I/O port. When 1’s are written to port 0 pins,

these pins can be used as high impedance inputs. As output port each pin can sink eight TTL

inputs. Port 0 can also be configured to multiplex lower order address/data bus while accessing

external data memory and program. Port 0 also receives the code bytes during Flash

programming and outputs the code bytes during program verification which require external

pull-ups

Port 1: (Pins 1 to 8):

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. This port output buffers

can sink/source four TTL inputs. When 1’s are written to this port pins they are pulled high by

Page 18: Bi-directional Visitors Counter

the internal pull-ups and can be used as inputs. Port 1 also receives the lower order address bytes

during Flash programming and verification.

Fig 3.1.2 - Pin diagram of AT89c52

Port 2: (Pins 21 to 28):

Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. This port output buffers

can also sink/source four TTL inputs. When 1’s are written to this port they are pulled high by

the internal pull-ups and can be used as inputs. This port emits higher order address byte during

fetches from external memory and during access to external 16-bit address memory. It also

receives the higher order address bits and some control signals during Flash programming and

verification.

Page 19: Bi-directional Visitors Counter

Port 3: (Pins 10 to 17):

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. It can also sink/source four

TTL inputs. When 1’s are written to this port pins, they are pulled high by the internal pull-ups

and can access as input. Port 3 pins also have individual functions as listed below:

Port Pin Alternate Functions

P3.0 RXD (serial input port)

P3.1 TXD (serial output port)

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

P3.6 WR (external data memory with write strobe)

P3.7 RD (external data memory read strobe)

Port 3 also receives some control signals for Flash programming and verification.

RST: (Pin 9):

Reset input. A high on this pin for two machine cycles with oscillator running will reset the

device.

ALE/PROG: (Pin 30):

Address Latch Enable pin latches the lower order address byte during the access with

external memory. This pin is also the program pulse input (PROG) during Flash programming.

In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency and

can be used for external timing or clocking purposes. ALE pin can be disabled by setting ‘0’ in

Page 20: Bi-directional Visitors Counter

SFR location 8EH. With this bit set ALE pin is active only with MOVX or MOVC instructions.

Setting the ALE – disable pin has no effect if the microcontroller is in external execution mode.

PSEN: (Pin 29):

Program Store Enable is the read strobe to external program memory. When the AT89c52

is executing code from external program memory, PSEN is activated twice each machine cycle,

except that two PSEN activations are skipped during each access to external data memory.

EA/VPP: (Pin 31):

External Access Enable EA pin must be strapped to ground to enable the device to fetch

code from external program memory locations starting at 0000H up to FFFFH.

EA pin should be strapped to Vcc for internal program executions.

This pin also receives 12 volt programming enable voltage (Vpp) during Flash Programming and

for parts that require 12 volts.

XTAL 1: (Pin 19):

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL 2: (Pin 18):

It is the output from the inverting oscillator amplifier.

OSCILLATOR CHARACTERISTICS:

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that

can be configured for use as an on-chip oscillator. Either a quartz crystal or ceramic resonator

may be used. To drive the device from an external clock source, XTAL2 should be left

unconnected while XTAL1 is driven. There are no requirements on the duty cycle of the external

clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop,

but minimum and maximum voltage high and time low specifications must be observed.

Page 21: Bi-directional Visitors Counter

Fig 3.1.3: Oscillator Connections Fig 3.1.4: External Clock Drive Configuration

REGISTERS:

In the CPU, registers are used to store information temporarily. That information could

be a byte of data to be processed, or an address pointing to the data to be fetched. The vast

majority of 8051 registers are 8–bit registers.

D7 D6 D5 D4 D3 D2 D1 D0

The most widely used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4, R5, R6,

R7, DPTR (data pointer), and PC(program counter). All of the above registers are 8-bits, except

DPTR and the program counter. The accumulator, register A, is used for all arithmetic and logic

instructions.

SFR’s (Special Function Registers):

In the 8051, registers A, B, PSW and DPTR are part of the group of registers commonly

referred to as SFR (special function registers). The SFR can be accessed by the names (which is

much easier) or by their addresses. For example, register A has address E0h, and register B has

been ignited the address F0H, as shown in table.

Page 22: Bi-directional Visitors Counter

The following two points should note about the SFR addresses.

1. The Special function registers have addresses between 80H and FFH. These addresses are

above 80H, since the addresses 00 to 7FH are addresses of RAM memory inside the 8051.

2. Not all the address space of 80H to FFH is used by the SFR. The unused locations 80H to

FFH are reserved and must not be used by the 8051 programmer.

Dual Data Pointer Registers:

To facilitate accessing both internal and external data memory, two banks of 16-bitData

Pointer Registers are provided: DPO at SFR address locations 82H-83H and DPI at84H-85H. Bit

DPS = 0 in SFRAUXR1 selects DPO and DPS = 1 selects DPI. The user should always initialize

the DPS bit to the appropriate value before accessing the respective Data Pointer Register.

Memory Organization:-MCS-51 devices have a separate address space for Program and Data

Memory. Up to 64K bytes each of external Program and Data Memory can be addressed.

Program Memory: If the EA pin is connected to GND, all program fetches are directed to

external memory. On the AT89S.51, if EA is connected to VCC, program fetches to addresses

0000H through IFFFH are directed to internal memory and fetches to addresses 1000H through

FFFFH are to external memory.

Data Memory: The AT89c52 implements 128 bytes of on-chip RAM. The upper 128 bytes are

accessible via direct and indirect addressing modes. Stack operations are examples of indirect

addressing, so the 128 bytes of data RAM are available as stack space.

Special Function Registers: A map of the on-chip memory area called the Special Function

Register (SFR) space is shy. Few SFRs such as Accumulator, B register, PSW, Stack Pointer,

Data Pointer, Interrupt Priority, Interrupt Priority, Timer 0, Timer 1, 4 Ports etc have fixed

addresses in on chip RAM.

Page 23: Bi-directional Visitors Counter

Interrupts:

The AT89S51 has a total of five interrupt vectors: two external interrupts (INTO and 1NT1), three

timer interrupts (Timers 0 and 1), and the serial port interrupt. Each of these interrupt sources can

be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE

also contains a global disable bit, EA, which disables all interrupts at once. Note that bit position

1E.6 and IE.5 is unimplemented. User software should not write a 1 to this bit position, since it

may be used in future AT89 products. The Timer0 and Timer 1 flags, TFO and TF1, are set at

S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the

next cycle.

3.2 IR transmitter and receiver pair:

IR Transmitter-receiver circuit consist of LED’s .The IR Transmitting LED emits the Infra

red rays which exists in the electromagnetic spectrum at a wavelength 940nm that is longer

than visible light. So, it cannot be seen but detected.IR detecting LED is a photo detector which

senses the luminescent power falling upon it and converts the variation of this IR signal power

into a correspondingly varying electric current. Generally the dark colors absorb more light than

clear, so dark LED is the detector. The Transmitter and the receiver LED have very narrow

emission and detection angles, so they must be kept at a 1/8 to ¼ inch apart maximum.

3.3 JK flip flop unit

Flip flop: The basic building block for sequential circuit is a flip flop. Flip flops are

combined together to form counters, shift registers and various memory devices. Both latches

and flip-flops are similar .Both are bi stable logic circuits and can reside in any of the two stable

states due to a feedback arrangement. The main difference between them is in the methods used

for changing the state. There are two types for changing the states. They are:

1) Synchronous System 2) Edge triggering System

JK flip flop is the extension of RS flip-flop .As RS flip flop is having the disadvantage of

the race condition when both R and S are in logic high state, this JK flip flop will be useful to

eradicate this race condition. The following are the block diagram and the pin diagram of 74ls76

JK flip-flops

Page 24: Bi-directional Visitors Counter

Fig 3.3.1: j-k flip-flop

The functional table of the flip-flop is given by

Fig 3.3.2: functional table of jk flip-flop

Page 25: Bi-directional Visitors Counter

3.4 Comparator unit

Comparator is the device which will compares the inputs applied at the two input pins of

the operational amplifier and gives difference between the inputs as the output. The operational

amplifier used in our circuit is LM324 quad op-amp

3.5 Seven segment Display

Binary numbers are necessary, but very hard to read or interpret.

What is available to display binary to decimal information? A seven-segment L.E.D. display.

A seven-segment display may have 7, 8, or 9 leads on the chip. Usually leads 8 and 9 are

decimal points. The figure below is a typical component and pin layout for a seven segment

display.

Fig 3.5.1: seven segment display

Page 26: Bi-directional Visitors Counter

7 SEGMENT DISPLAY

The light emitting diodes in a seven-segment display are arranged in the figure below.

Fig.3.5.2 diode placement in a seven segment display, no decimal

There are two types of displays available,

Common anode

Common cathode.

The wiring for a common anode is shown below.

Fig: 3.5.3 common anode internal wiring

Page 27: Bi-directional Visitors Counter

The wiring for the common cathode is shown below.

Fig: 3.5.4 common cathode internal wiring

To convert the binary numbers to signals that can drive the L.E.D.s in the display you need a

display driver. In the lab we use an MC14511 chip. The pinouts are shown below.

Fig: 3.5.5 pin outs for the mc14511 seven-segment display driver

Page 28: Bi-directional Visitors Counter

A, B, C, and, D are the binary inputs.

a, b, c, d, e, f, and g are the driver signals to the display elements.

LT is the Light Test control, turns all segments on, active low.

BL blanks all the segments when activated, active low.

LE is the latch enable control.

The truth table shown below is used to confirm that the digital signal sent to the display lights up the correct segment.

Fig: 3.5.6 truth table for the seven-segment display

Page 29: Bi-directional Visitors Counter

The internal circuitry and logic gates for the display are shown below.

Fig: 3.5.7 internal circuitry and logic gates for 7 seg display

The specific seven-segment display used in lab is an LN513RK. The schematic below is similar

to the one you will use in lab.

Fig: 3.5.8 seven segment display with display driver

To have the driver convert the binary input to signals ready for the display, tie pin 3, LT, and pin

4, Bl, to VCC. Connect pin 5, LE, to ground. In this configuration whatever the binary inputs at

Page 30: Bi-directional Visitors Counter

A-D are will be converted and the display will show the decimal equivalent.

COUNTING 0-9

Fig: 3.5.9 0-9 counting circuit

The start of this circuit is the MC14161 binary counter. The function generator is connected to

the clock input to start the counting cycle. The MC14012 NAND gate monitors the output of the

binary counter. When the count equals 9 the output of the NAND gate sends a signal to the load

control, LD, on the counter to load the values on P1-P4, in this case the number zero. As the

counter is incrementing from 0-9 the driver signal is constantly updating the display and turning

on and off the appropriate segments.

If need be you could use a 555 timer circuit in place of the function generator

Page 31: Bi-directional Visitors Counter

3.6 Power Supply Unit

The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronic circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. A D.C power supply which maintains the output voltage constant irrespective of A.C mains fluctuations or load variations is known as “Regulated D.C Power Supply”.

For example a 5V regulated power supply system as shown below:

Fig 3.6.1: Block diagram of Power supply

Transformer:

A transformer is an electrical device which is used to convert electrical power from one

electrical circuit to another without change in frequency.

Transformers convert AC electricity from one voltage to another with little loss of power.

Transformers work only with AC and this is one of the reasons why mains electricity is AC.

Step-up transformers increase in output voltage, step-down transformers decrease in output

voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains

voltage to a safer low voltage. The input coil is called the primary and the output coil is called

the secondary. There is no electrical connection between the two coils; instead they are linked by

an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the

Page 32: Bi-directional Visitors Counter

middle of the circuit symbol represent the core. Transformers waste very little power so the

power out is (almost) equal to the power in. Note that as voltage is stepped down current is

stepped up. The ratio of the number of turns on each coil, called the turn’s ratio, determines the

ratio of the voltages. A step-down transformer has a large number of turns on its primary (input)

coil which is connected to the high voltage mains supply, and a small number of turns on its

secondary (output) coil to give a low output voltage

Fig 3.6.2: Power Supply Circuit Diagram

RECTIFIER:

A circuit which is used to convert alternating current to direct current is known as

RECTIFIER. The process of conversion ac to dc is called “rectification”

TYPES OF RECTIFIERS:

1 Half wave Rectifier

2 Full wave rectifier: 1. Centre tap full wave rectifier.

2. Bridge type full bridge rectifier.

Page 33: Bi-directional Visitors Counter

Full-wave Rectifier: From the above comparison we came to know that full wave bridge

rectifier as more advantages than the other two rectifiers. So, in our project we are using full

wave bridge rectifier circuit.

Bridge Rectifier: A bridge rectifier makes use of four diodes in a bridge arrangement to achieve

full-wave rectification. This is a widely used configuration, both with individual diodes wired as

shown and with single component bridges where the diode bridge is wired internally.

A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig(a)

to achieve full-wave rectification. This is a widely used configuration, both with individual

diodes wired as shown and with single component bridges where the diode bridge is wired

internally.

Fig 3.6.3(a): Bridge rectifier

Operation:

During positive half cycle of secondary, the diodes D2 and D3 are in forward biased

while D1 and D4 are in reverse biased as shown in the fig(b). The current flow direction is

shown in the fig (b) with dotted arrows.

Page 34: Bi-directional Visitors Counter

Fig 3.6.3(b): Current flow during positive half cycle

During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward

biased while D2 and D3 are in reverse biased as shown in the fig(c). The current flow direction

is shown in the fig (c) with dotted arrows.

Fig 3.6.3(c): Current flow during negative half cycle

Filter:

A Filter is a device which removes the a.c component of rectifier output but allows the d.c component to reach the load

Capacitor Filter:

We have seen that the ripple content in the rectified output of half wave rectifier is 121%

or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples

is not acceptable for most of the applications. Ripples can be removed by one of the following

methods of filtering.

(a) A capacitor, in parallel to the load, provides an easier by –pass for the ripples voltage

though it due to low impedance. At ripple frequency and leave the d.c.to appears the load.

Page 35: Bi-directional Visitors Counter

(b) An inductor, in series with the load, prevents the passage of the ripple current (due to

high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)

(c) Various combinations of capacitor and inductor, such as L-section filter section

filter, multiple section filter etc. which make use of both the properties mentioned in (a) and (b)

above. Two cases of capacitor filter, one applied on half wave rectifier and another with full

wave rectifier.

Filtering is performed by a large value electrolytic capacitor connected across the DC

supply to act as a reservoir, supplying current to the output when the varying DC voltage from

the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then

discharges as it supplies current to the output. Filtering significantly increases the average DC

voltage to almost the peak value (1.4 × RMS value).

To calculate the value of capacitor(C),

C = ¼*√3*f*r*Rl Where,

f = supply frequency,

r = ripple factor,

Rl = load resistance

Note: In our circuit we are using 1000µF hence large value of capacitor is placed to

reduce ripples and to improve the DC component.

REGULATED POWER SUPPLY DESCRIPTION:

A variable regulated power supply, also called a variable bench power supply, is one

where you can continuously adjust the output voltage to your requirements. Varying the output

of the power supply is the recommended way to test a project after having double checked parts

placement against circuit drawings and the parts placement guide.

Page 36: Bi-directional Visitors Counter

This type of regulation is ideal for having a simple variable bench power supply. Actually this is

quite important because one of the first projects a hobbyist should undertake is the construction

of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V,

it's much handier to have a variable supply on hand, especially for testing.

Most digital logic circuits and processors need a 5-volt power supply. To use these parts we need

to build a regulated 5-volt source. Usually you start with an unregulated power supply ranging

from 9 volts to 24 volts DC. To make a 5 volt power supply, we use a LM7805 voltage regulator

IC (Integrated Circuit).

The IC is shown below.

Fig 3.6.4: LM7805

The LM7805 is simple to use. You simply connect the positive lead of your unregulated

DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead

to the Common pin and then when you turn on the power, you get a 5 volt supply from the

Output pin.

Page 37: Bi-directional Visitors Counter

CHAPTER 4

SOFTWARE DETAILS

4.1. KEIL SOFTWARE:

Keil development tools for the 8051 Microcontroller Architecture support every level of

software developer from the professional applications engineer to the student just learning about

embedded software development. The industry-standard Keil C Compilers, Macro Assemblers,

Debuggers, Real-time Kernels, Single-board Computers, and Emulators support all 8051

derivatives and help you get your projects completed on schedule.

Simulation:

The µVision Simulator allows you to debug programs using only your PC using

simulation drivers provided by Keil and various third-party developers. A good simulation

environment, like µVision, does much more than simply simulates the instruction set of a

microcontroller. It simulates your entire target system including interrupts, startup code, on-chip

peripherals, external signals, and I/O.

This software is used for execution of microcontroller programs. Keil development tools

for the MC architecture support every level of software developer from the professional

applications engineer to the student just learning about embedded software development. The

industry-standard keil C compilers, macro assemblers, debuggers, real, time Kernels, Single-

board computers and emulators support all microcontroller derivatives and help you to get more

projects completed on schedule. The keil software development tools are designed to solve the

complex

The problems facing by embedded software developers are.

When starting a new project, simply select the microcontroller you the device database

and the µvision IDE sets all compiler, assembler, linker, and memory options for you.

Page 38: Bi-directional Visitors Counter

Numerous example programs are included to help you get started with the most popular

embedded devices.

The Keil µ Vision debugger accurately simulates on-chip peripherals (PC, CAN,

UART, SPI, Interrupts, I/O ports, A/D converter, D/A converter and PWM modules) of

your device. Simulation helps you understand h/w configurations and avoids time wasted

on setup problems. Additionally, with simulation, you can write and test applications

before target h/w is available.

When you are ready to begin testing your s/w application with target h/w, use the

MON51, MON390, MONADI, or flash MON51 target monitors, the ISD51 In-System

Debugger, or the ULINK USB-JTAG adapter to download and test program code on

your target system.

Keil procedure description

1) Click on the Keil µVision Icon on Desktop

2) Click on the Project menu from the title bar

3) Then Click on New Project

4) Save the Project by typing suitable project name with no extension in u r own folder sited in

either C:\ or D:\

5) Then Click on SAVE button above.

6) Select the component for u r project. i.e. Atmel……

7) Click on the + Symbol beside of Atmel

8) Select AT89C52 as shown below

9) Then Click on “OK”

10) Then Click either YES or NO………mostly “NO”

11) Now your project is ready to USE

12) Now double click on the Target1, you would get another option “Source group 1” as shown

in next page.

Page 39: Bi-directional Visitors Counter

13) Click on the file option from menu bar and select “new”

14) The next screen will be as shown in next page, and just maximize it by double clicking on its

blue boarder.

15) Now start writing program in either in “C” or “ASM”

16) For a program written in Assembly, then save it with extension “. ASM” and for “C” based

program save it with extension “ .C”

17) Now right click on Source group 1 and click on “Add files to Group Source”

18) Now you will get another window, on which by default “C” files will appear.

19) Now select as per your file extension given while saving the file

20) Click only one time on option “ADD”

21) Now Press function key F7 to compile. Any error will appear if so happen.

22) If the file contains no error, then press Control+F5 simultaneously.

23) The new window is as follows

24) Then Click “OK”

25) Now Click on the Peripherals from menu bar, and check your required port as shown in fig

below

26) Drag the port a side and click in the program file.

27) Now keep Pressing function key “F11” slowly and observe.

28) You are running your program successfully

Page 40: Bi-directional Visitors Counter

4.2 FLOW CHART:

Page 41: Bi-directional Visitors Counter

Fig: 4.2.1 flow chart

4.3 SOURCE CODE#include <AT89x52.h>

int i=0,j,k,l,m,a[10]={63,6,91,79,102,109,125,7,127,111};

int p2,p1,p0;

void enter (void) interrupt 0

{

i++;

if(i>999) i=999;

P3_1=0;

for(m=0;m<=1000;m++);

P3_1=1;

}

void exit (void) interrupt 2

{

i--;

if(i<0) i=0;

P3_0=0;

for(m=0;m<=1000;m++);

P3_0=1;

}

Page 42: Bi-directional Visitors Counter

void main()

{

IE = 133;

TCON = 5;

P3_0=1;

P3_1=1;

i=0;

while(1)

{

j=i%10;

k=i/10;

l=i/100;

k=k-l*10;

P2=a[j];

P0=a[k];

P1=a[l];

}

}

Page 43: Bi-directional Visitors Counter

4.4 HEX CODE

:100A1000021C00001408003F0006005B004F006647

:0A0A2000006D007D0007007F006FED

:0300030002099A55

:10099A00C0E0C0D0051DE51D7002051CD394E7E533

:1009AA001C648094834006751C03751DE7C2B175EB

:1009BA0024007525000525E52570020524B4E9F50E

:0C09CA00E524B403F0D2B1D0D0D0E0326C

:030013000209D609

:1009D600C0E0C0D0E51D151D7002151CC3E51C64E2

:1009E6008094805006751C00751D00C2B0752400E9

:1009F6007525000525E52570020524B4E9F5E524ED

:0A0A0600B403F0D2B0D0D0D0E0323B

:1009290075A885758805D2B0D2B1E4F51CF51DAE60

:100939001CAF1D7C007D0A1208128C1E8D1FAE1C77

:10094900AF1D7C007D0A1208128E208F21AE1CAFCC

:100959001D7C007D641208128E228F237C007D0A83

:10096900120800C3E5219FF521E5209EF520E51F2A

:1009790025E02408F808E6F5A0E52125E02408F893

:1009890008E6F580E52325E02408F808E6F59080D7

:010999009EBF

:0300000002089D56

:0C089D00787FE4F6D8FD7581250208E4A0

:10080000EF8DF0A4A8F0CF8CF0A428CE8DF0A42E0C

:02081000FE22C6

Page 44: Bi-directional Visitors Counter

:10081200C2D5EC30E709B2D5E4C39DFDE49CFCEE01

:1008220030E715B2D5E4C39FFFE49EFE120848C329

:10083200E49DFDE49CFC800312084830D507C3E424

:060842009FFFE49EFE2270

:1008A900020929E493A3F8E493A34003F68001F233

:1008B90008DFF48029E493A3F85407240CC8C33350

:1008C900C4540F4420C8834004F456800146F6DF1F

:1008D900E4800B0102040810204080900A10E47E95

:1008E900019360BCA3FF543F30E509541FFEE49314

:1008F900A360010ECF54C025E060A840B8E493A3DB

:10090900FAE493A3F8E493A3C8C582C8CAC583CA05

:10091900F0A3C8C582C8CAC583CADFE9DEE780BEBD

:010A2A0000CB

:10084800BC000BBE0029EF8DF084FFADF022E4CC94

:10085800F875F008EF2FFFEE33FEEC33FCEE9DEC5D

:10086800984005FCEE9DFE0FD5F0E9E4CEFD22EDA3

:10087800F8F5F0EE8420D21CFEADF075F008EF2FED

:10088800FFED33FD4007985006D5F0F222C398FDDE

:050898000FD5F0EA227B

:00000001FF

Page 45: Bi-directional Visitors Counter

Chapter 5

5.1 Applications

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 following are the applications of this bi directional visitor counter circuit. They are:

1) Libraries2) Movie theaters

3) Parks4) Stadiums5) Seminar halls6) Colleges and schools7) Offices8) Courts Etc……………,

5.2 Conclusion

So that by using this project we can reduce the human effort in counting the number of persons entering and number of persons staying in an enclosed area. The cost of implementing is reasonable and all the components required are readily available in the market and the circuit is easy to build.

Human may commit errors in counting the number of persons. But by using this circuit these errors can be rectified. The power consumption of this circuit is also very less.

Page 46: Bi-directional Visitors Counter

5.3 Future Enhancement

The drawback of this project is the persons entering in to the room or any enclosed area should be in the serial manner. This project will be failed if the persons entering in to the room are in the parallel manner.

This project can be enhanced by implementing further so that we can count number of persons entering in to the enclosed area in parallel manner.

5.4 References

Text books:

1) THE 8051 MICROCONTROLLER AND EMBEDED SYSTEMS second

edition by M.ALI MAZIDI,J.G.MAZIDI,R.D.MC KINLAY

2) THE 8051 MICRO CONTROLLER third edition by KENNETH AYALA

3) ELECTRONICS AND CIRCUIT DEVICES by GODSE-GODSE

Websites:

1) Wikipedia

2) www.datasheet.catalog.com

3) www.engineersgarage.com