bidirectional visitor counter

72
A Project on Bidirectional Visitor Counter Submitted for partial fulfillment of award of BACHELOR OF TECHNOLOGY degree in Electronics & Communication Engineering by Rahul Kumar Verma() Rajeev Ranjan Singh() Rajkumar Singh () Anoop Kumar () H.R. INSTITUTE OF TECHNOLOGY

Upload: rahul-verma

Post on 27-Nov-2014

65 views

Category:

Documents


3 download

DESCRIPTION

Project report

TRANSCRIPT

Page 1: Bidirectional Visitor Counter

A Project on

Bidirectional Visitor Counter

Submitted for partial fulfillment of award ofBACHELOR OF TECHNOLOGY

degree

in

Electronics & Communication Engineering

by

Rahul Kumar Verma()Rajeev Ranjan Singh()Rajkumar Singh ()Anoop Kumar ()

H.R. INSTITUTE OF TECHNOLOGY7th Km Milestone Meerut Road Morta, Ghaziabad(U.P.)

G.B.T.U. LUCKNOW,June, 2011

Page 2: Bidirectional Visitor Counter
Page 3: Bidirectional Visitor Counter

BIDIRECTIONAL VISITOR COUNTER

by

Rahul Kumar Verma ()Rajeev Ranjan Singh ()Rajkumar Singh ()Anoop Kumar ()

Guided byMr. P. S. Kushwaha

Submitted for partial fulfilment of the requirement for the degree of

Bachelor of Technologyin

Electronics & Communication Engineering

H.R. INSTITUTE OF TECHNOLOGY7th Km Milestone Meerut Road Morta, Ghaziabad

G.B.T.U. LUCKNOWJune, 2011

Page 4: Bidirectional Visitor Counter

Table of ContentsDECLARATION.........................................................................................................................iiiCERTIFICATE..........................................................................................................................ivACKNOWLEDGEMENT............................................................................................................vABSTRACT.................................................................................................................................viLIST OF FIGURE....................................................................................................................viiCHAPTER 1...............................................................................................................................1

INTRODUCTION..................................................................................................................11.1 Block Diagram..............................................................................................................21.2 Sensor arrangement at the way..................................................................................2

CHAPTER 2...............................................................................................................................3SENSORS...............................................................................................................................3

2.1 IR Transmitter.............................................................................................................32.2 Photo-transistors...........................................................................................................32.3 Symbol and typical view of photo-transistor:............................................................42.4 Features:........................................................................................................................4

CHAPTER 3...............................................................................................................................5LOGIC CONTROL CIRCUIT...............................................................................................5

3.1 Comparators...............................................................................................................53.2 Pin Diagram of LM324:..............................................................................................63.3 General description on LM324...................................................................................63.4 Features:......................................................................................................................63.5 Typical Applications:..................................................................................................7

CHAPTER 4...............................................................................................................................8FLIP-FLOP.............................................................................................................................8

4.1 JK Flip-flop:................................................................................................................84.2 Symbol for JK flip-flop:..............................................................................................84.3 Equation and Truth table.............................................................................................94.4 Pin Diagram of Dual JK flip-flop IC 74LS76:...........................................................10

CHAPTER 5.............................................................................................................................12MICROCONTROLLER AT89C52......................................................................................12

5.1 Features:...................................................................................................................125.2 Pin configuration of Microcontroller AT89C52:......................................................135.3 Block Diagram of Atmel 89C52 Microcontroller......................................................145.4 Pin Description of Microcontroller AT89C52:.........................................................155.6 Interrupts..................................................................................................................185.7 Oscillator Characteristics...........................................................................................195.8 Programming the Flash.............................................................................................205.9 Programming Algorithm:...........................................................................................215.10 Data Polling............................................................................................................215.11 Ready/Busy..............................................................................................................215.12 Program Verify........................................................................................................225.13 Chip Erase................................................................................................................225.14 Programming Interface:...........................................................................................22

CHAPTER 6.............................................................................................................................23

Page 5: Bidirectional Visitor Counter

DISPLAY..............................................................................................................................236.1 Seven segment display..............................................................................................23

CHAPTER 7.............................................................................................................................25POWER SUPPLY.................................................................................................................25

CHAPTER 8.............................................................................................................................26CIRCUIT DIAGRAM..........................................................................................................26

8.1 Circuit Diagram..........................................................................................................28CHAPTER 9.............................................................................................................................29

ALGORITHM, FLOWCHART & PROGRAMMING........................................................299.1 Algorithm...................................................................................................................299.2 Flow chart.................................................................................................................30

CHAPTER 10...........................................................................................................................33PCB DESIGN AND FABRICATION..................................................................................33

10.1 Protel for windows PCB 1.5 capabilities...............................................................3310.2 PCB fabrication.......................................................................................................34

CHAPTER 11...........................................................................................................................37RELAY.................................................................................................................................37

11.1 Introduction.............................................................................................................3711.2 Main Feature..........................................................................................................3811.3 Application..............................................................................................................3811.4 Contact Rating......................................................................................................3911.5 Performance (at Initial Value)...............................................................................39

CHAPTER 12...........................................................................................................................40ULN2003..............................................................................................................................40

12.1 DESCRIPTION......................................................................................................4012.2 Features.................................................................................................................4012.3 Description.............................................................................................................4112.4 Diagram...................................................................................................................4112.5 Pin Configuration....................................................................................................4212.6 Maximum Rating....................................................................................................42

CHAPTER 13...........................................................................................................................43CONCLUSION.....................................................................................................................43

REFERENCES..........................................................................................................................44

Page 6: Bidirectional Visitor Counter

DECLARATION

I hereby declare that this submission is my own work and that, to the best of my knowledge and belief, it contains no material previously published or written by another person nor material which to a substantial extent has been accepted for the award of any other degree or diploma of the university or other institute of higher learning except where due acknowledgement has been made in text.

Signature: Signature:Name: Rahul Kumar Verma Name: Rajeev Ranjan SinghRoll No.: Roll No.: Date: Date:

Signature: Signature:Name: Rajkumar Singh Name: Anoop KumarRoll No.: Roll No.: Date: Date:

Page 7: Bidirectional Visitor Counter

CERTIFICATE

Certified that Rahul Kumar Verma, Rajeev Ranjan Singh, Rajkumar Singh, Anoop Kumar has

carried out the research work presented in this project entitled “Bidirectional Visitor

Counter” for the award of Bachelor of Technology from Gautam Buddh Technical University,

Lucknow under my supervision. The project embodies result of original work and studies

carried out by Student himself and the contents of the project do not form the basis for the

award of any other degree to the candidate or to anybody else.

Prof. Sukhbir Singh Mr.Bhaskar GuptaH.O.D. SUPERVISOR LecturerDepartment Of Electronics & Department of Electronics&Communication Engineering Communication EngineeringH.R.Institute Of Technology H.R.Institute Of Technology

P.S. Kushwaha

(Project Guide) External Examiner

ii

Page 8: Bidirectional Visitor Counter

ACKNOWLEDGEMENT

All praise to almighty God, who provided us this opportunity to work under our beloved & respected teachers for making us able to complete the present study successfully.It gives us a great sense of pleasure to present the report of B. Tech project under taken during B.TECH final year.I owe special debt of gratitude to our respected teacher “Prof. Sukhbir Singh (HOD of ECE department), H.R. Institute of Technology Ghaziabad for his constant support & guidance throughout the course of my work.His sincerity, throughout & preservance have been a constant source of inspiration for me.I am thankful to my project guide “Mr. P.S. Kushwaha” for his invaluable guidance constructive suggestions, practical help through securitization and affectionate attitude throughout the period of project enabled us to face this challenge.I am also thankful to every one whom I could not mention here but who directly or indirectly supported me to face this challenge.Lastly but not the least my warmest thanks goes to my parents who helped me by their constructive views during some time or other in life.

Signature: Signature:Name: Rahul Kumar Verma Name: Rajeev Ranjan SinghRoll No.: Roll No.: Date: Date:

Signature: Signature:Name: Rajkumar Singh Name: Anoop KumarRoll No.: Roll No.: Date: Date:

iii

Page 9: Bidirectional Visitor Counter

ABSTRACT

Microcontroller/Microprocessor is the most versatile device in the world. It’s once a creature of science fiction is today a reality. In real sense it is a device which allows human beings to implement their intelligence in machines. 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. All the components required are readily available in the market and the circuit is easy to build.The final result of this project is a thorough design for an autonomous visitor counter including a detailed test plan for the use by subsequent design teams.

iv

Page 10: Bidirectional Visitor Counter

LIST OF FIGUREFigure 1.0.1 Schematic View.....................................................................................................1Figure1.0.2 Block Diagram.........................................................................................................2Figure1.0.3 Sensor arrangement.................................................................................................2Figure 3. 0.1 Input/Output references.........................................................................................5Figure 3.2 Pin Diagram of LM324.............................................................................................6Figure 3.3 Typical Application...................................................................................................7Figure 4.1 JK flip flop symbol....................................................................................................8Figure 4.2 Logic Symbol............................................................................................................9Figure 4.3 State Table...............................................................................................................10Figure 4.4 IC 74LS76...............................................................................................................10Figure 4.5Logic Diagram..........................................................................................................11Figure 5.1 Pin Diagram of AT89C52.......................................................................................13Figure 5.2 Architecture.............................................................................................................14Figure 5.3P1.0,P1.1 function....................................................................................................15Figure 5.4 P3.0-P3.8 Fnction....................................................................................................16Figure 5.5 Interrupt Enable (IE) Register.................................................................................18Figure 5.6 Interrupt Switching..................................................................................................19Figure 5.7 Interrupt Source.......................................................................................................19Figure 5.8 Oscillator connection...............................................................................................20Figure 5.0.9 Programming mode..............................................................................................20Figure 6.1 A Typical 7-segment display component, with decimal point................................23Figure 6.2 The individual segment of a seven-segment display...............................................23Figure 7.1 Power Supply...........................................................................................................25Figure 8.1Schematic Diagram of Bidirectional Visitor Counter..............................................28Figure 11.1 Internal architecture of relay................................................................................37Figure 11.2 Relay......................................................................................................................38Figure 12.1 ULN Device Driver...............................................................................................40Figure 12.2 Drivers...................................................................................................................41Figure 12.3 ULN pin configuration..........................................................................................42

v

Page 11: Bidirectional Visitor Counter

CHAPTER 1

INTRODUCTION

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.

Figure 1.0.1 Schematic View

Page 12: Bidirectional Visitor Counter

1.1 Block Diagram

1.2 Sensor arrangement at the way

SensorsLogic

Control Circuit

Micro-controllerAT89C52

Display

PowerSupply +5V

Figure1.0.2 Block Diagram

Page 13: Bidirectional Visitor Counter

Figure1.0.3 Sensor arrangement

CHAPTER 2

SENSORS

Enter

Exit

IR TX1

IR TX2 RX2

RX1

Page 14: Bidirectional Visitor Counter

The block shows the sensor arrangement at the entrance cum exit passage. Here a pair of IR

transmitter – receiver is used as sensor. Photo transistors are used as IR receiver, since it has

sensitivity to receive IR rays.

2.1 IR Transmitter

Infrared (IR) radiation is electromagnetic radiation of a wavelength longer than that of visible

light, but shorter than that of microwaves. The name means "below red" (from the Latin infra,

"below"), red being the color of visible light with the longest wavelength. Infrared radiation

has wavelengths between about 750 nm and 1 mm, spanning five orders of magnitude. A

longer wavelength means it has a lower frequency than red, hence "below". Objects generally

emit infrared radiation across a spectrum of wavelengths, but only a specific region of the

spectrum is of interest because sensors are usually designed only to collect radiation within a

specific bandwidth.

Remote controls and IrDA devices use infrared light-emitting diodes (LEDs) to emit infrared

radiation which is focused by a plastic lens into a narrow beam. The receiver uses a silicon

photodiode to convert the infrared radiation to an electric current. It responds only to the

rapidly pulsing signal created by the transmitter, and filters out slowly changing infrared

radiation from ambient light. IR does not penetrate walls and so does not interfere with other

devices in adjoining rooms.

2.2 Photo-transistors

Phototransistors are examples of photodiode-amplifier combinations integrated within a single

silicon ship. These combinations are put together in order to overcome the major fault of

photodiodes: unity gain. Many applications demand a greater output signal from photodiode

can

always be amplified through use of an external op-amp or other circuitry, this approach is

often not as practical or as cost effective as the use of phototransistors.

The phototransistor can be viewed as a photodiode whose output photocurrent is fed into the

base of a conventional small signal transistor. While not required for operation of the device

Page 15: Bidirectional Visitor Counter

as a photo detector, a base connection is often provided allowing the designer the option of

using base current to bias the transistor. The typical gain of a phototransistor can range from

100 to over 1500.

2.3 Symbol and typical view of photo-transistor:

Figure2.1 Figure2.2

2.4 Features:

Low-cost visible and near-IR photo detector.

Available with gains from 100 to over 1500.

Moderately fast response times.

Available in a wide range of packages including epoxy-coated, transfer-molded, cast,

hermetic, and in chip form.

Usable with almost any visible or near-infrared light source such as IREDs; neon;

fluorescent, incandescent bulbs; lasers; flame sources; sunlight; etc.

Same general electrical characteristics as familiar signal transistors.

CHAPTER 3

LOGIC CONTROL CIRCUIT

Page 16: Bidirectional Visitor Counter

Here the logic control circuit consists of two circuits, a op-amp comparator and a flip-flop circuit.

3.1 Comparators

A comparator is a device which compares two voltages or currents and switches its output to

indicate which is larger. A standard op-amp operating without negative feedback is used as a

comparator. When the non-inverting input (V+) is at a higher voltage than the inverting input

(V-), the high gain of the op-amp causes it to output the most positive voltage it can. When

the non-inverting input (V+) drops below the inverting input (V-), the op-amp outputs the

most negative voltage it can. Since the output voltage is limited by the supply voltage. Here

the operational amplifier LM 324 is used as comparator.

Inputs Output

- > + Negative

+ > - Floating

Figure 3. 0.4 Input/Output references

Page 17: Bidirectional Visitor Counter

3.2 Pin Diagram of LM324:

Figure 3.5 Pin Diagram of LM324

3.3 General description on LM324

The LM324 consists of four independent high-gain,internally frequency-compensated

operational amplifiers designed specially to operate from a single power supply over a

wide range of voltages.

In linear mode, the input common-mode voltage range includes ground and the output voltage

can also swing to ground, even though operated from only a single power supply voltage.

The unity gain crossover frequency and the input bias current are temperature-compensated.

3.4 Features:

Internally frequency-compensated for unity gain

Large DC voltage gain: 100 dB

Wide bandwidth (unity gain): 1 MHz (temperature-compensated)

Wide power supply range Single supply:

3VDC to 30VDC or dual supplies: +/-1.5VDC to +/-15VDC.

Very low supply current drain: essentially independent of supply voltage

(1mW/op amp at +5 VDC )

Page 18: Bidirectional Visitor Counter

Low input biasing current: 45nADC (temperature-compensated)

Low input offset voltage: 2 mVDC and offset current: 5nADC

Differential input voltage range equal to the power supply voltage

Large output voltage: 0VDC to VCC – 1.5 VDC swing

3.5 Typical Applications:

Figure 3.6 Typical Application

Page 19: Bidirectional Visitor Counter

CHAPTER 4

FLIP-FLOP

A flip-flop is a kind of bistable multivibrator, an electronic circuit which has two stable states

and thereby is capable of serving as one bit of memory. Today, the term flip-flop has come to

generally denote non-transparent (clocked or edge-triggered) devices, while the simpler

transparent ones are often referred to as latches. A flip-flop is controlled by (usually) one or

two control signals and/or a gate or clock signal. The output often includes the complement as

well as the normal output. As flip-flops are implemented electronically, they require power

and ground connections.

4.1 JK Flip-flop:

The JK flip-flop augments the behavior of the SR flip-flop by interpreting the S = R = 1

condition as a "flip" or toggle command. Specifically, the combination J = 1, K = 0 is a

command to set the flip-flop; the combination J = 0, K = 1 is a command to reset the flip-flop;

and the combination J = K = 1 is a command to toggle the flip-flop, i.e., change its output to

the logical complement of its current value. Setting J = K = 0 does NOT result in a D flip-

flop, but rather, will hold the current state. To synthesize a D flip-flop, simply set K equal to

the complement of J. The JK flip-flop is therefore a universal flip-flop, because it can be

configured to work as an SR flip-flop, a D flip-flop or a T flip-flop.

4.2 Symbol for JK flip-flop:

Figure 4.7 JK flip flop symbol

Page 20: Bidirectional Visitor Counter

A circuit symbol for a JK flip-flop, where > is the clock input, J and K are data inputs, Q is

the stored data output, and Q' is the inverse of Q.

Figure 4.8 Logic Symbol

4.3 Equation and Truth table

The characteristic equation of the JK flip-flop is:

And the corresponding truth table is:

Page 21: Bidirectional Visitor Counter

J K Qnext Comments

0 0 Hold State

0 1 0 Reset

1 0 1 Set

1 1 ToggleFigure 4.9 State Table

4.4 Pin Diagram of Dual JK flip-flop IC 74LS76:

Figure 4.10 IC 74LS76

Page 22: Bidirectional Visitor Counter

Figure 4.11Logic Diagram

Page 23: Bidirectional Visitor Counter

CHAPTER 5

MICROCONTROLLER AT89C52

The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8Kbytes

of Flash programmable and erasable read only memory (PEROM). The device is

manufactured using Atmel’s high-density nonvolatile memory technology and is compatible

with the industry-standard 80C51 and 80C52 instruction set and pin out. The on-chip Flash

allows the program memory to be reprogrammed in-system or by a conventional nonvolatile

memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip,

the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-

effective solution to many embedded control applications.

5.1 Features:

• Compatible with MCS-51™ Products

• 8K Bytes of In-System Reprogrammable Flash Memory

• Endurance: 1,000 Write/Erase Cycles

• Fully Static Operation: 0 Hz to 24 MHz

• Three-level Program Memory Lock

• 256 x 8-bit Internal RAM

• 32 Programmable I/O Lines

• Three 16-bit Timer/Counters

• Eight Interrupt Sources

• Programmable Serial Channel

• Low-power Idle and Power-down Modes

Page 24: Bidirectional Visitor Counter

5.2 Pin configuration of Microcontroller AT89C52:

Figure 5.12 Pin Diagram of AT89C52

Page 25: Bidirectional Visitor Counter

5.3 Block Diagram of Atmel 89C52 Microcontroller

Figure 5.13 Architecture

Page 26: Bidirectional Visitor Counter

5.4 Pin Description of Microcontroller AT89C52:

Port 0

Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight

TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance

inputs.

Port 0 can also be configured to be the multiplexed low order address/data bus during

accesses to external program and data memory. In this mode, P0 has internal pull-ups.

Port 0 also receives the code bytes during Flash programming and outputs the code bytes

during program verification. External pull-ups are required during program verification.

Port 1:

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

sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being

pulled low will source current (IIL) because of the internal pull-ups.

In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input

(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as

shown in the following table.

Figure 5.14P1.0,P1.1 functionPort 1 also receives the low-order address bytes during Flash programming and verification.

Port 2:

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

sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the

Page 27: Bidirectional Visitor Counter

internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being

pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-

order address byte during fetches from external program memory and during accesses to

external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2

uses strong internal pull-ups when emitting 1s. During accesses to external data memory that

use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function

Register. Port 2 also receives the high-order address bits and some control signals during

Flash programming and verification.

Port 3:

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can

sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being

pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of

various special features of the AT89C51, as shown in the following table. Port 3 also receives

some control signals for Flash programming and verification.

Figure 5.15 P3.0-P3.8 Fnction RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets

the device.

Page 28: Bidirectional Visitor Counter

ALE/PROG

Address Latch Enable is an output pulse for latching the low byte of the address during

accesses to 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 may be used for external timing or clocking purposes. Note, however, that one

ALE pulse is skipped during each access to external data memory. If desired, ALE operation

can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only

during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the

ALE-disable bit has no effect if the microcontroller is in external execution mode.

PSEN:

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:

External Access Enable. EA must be strapped to GND in order to enable the device to fetch

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

however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should

be strapped to VCC for internal program executions. This pin also receives the 12-volt

programming enable voltage

(VPP) during Flash programming when 12-volt programming is selected.

XTAL1:

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

XTAL2:

Output from the inverting oscillator amplifier.

5.5 Data Memory

Page 29: Bidirectional Visitor Counter

The AT89C52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel

address space to the Special Function Registers. That means the upper 128 bytes have the

same addresses as the SFR space but are physically separate from SFR space. When an

instruction accesses an internal location above address 7FH, the address mode used in the

instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR

space. Instructions that use direct addressing access SFR space.

5.6 Interrupts

The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1),

three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are all

shown in Figure below. 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 Table shows that bit position

IE.6 is unimplemented.

Figure 5.16 Interrupt Enable (IE) Register

Page 30: Bidirectional Visitor Counter

In the AT89C51, bit position IE.5 is also unimplemented. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and Timer 1 flags, TF0 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. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.

Figure 5.17 Interrupt Switching

Figure 5.18 Interrupt Source

5.7 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, as shown in Figure below. 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 low time

specifications must be observed.

Page 31: Bidirectional Visitor Counter

Figure 5.19 Oscillator connection

5.8 Programming the Flash

The AT89C52 is normally shipped with the on-chip Flash memory array in the erased state

(that is, contents = FFH) and ready to be programmed. The programming interface accepts

either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The Low-

voltage programming mode provides a convenient way to program the AT89C52 inside the

user’s system, while the high-voltage programming mode is compatible with conventional

third party Flash or EPROM programmers. The AT89C52 is shipped with either the high-

voltage or low-voltage programming mode enabled. The respective top-side marking and

device signature codes are listed in the following table.

Figure 5.0.20 Programming mode

Page 32: Bidirectional Visitor Counter

The AT89C52 code memory array is programmed byte-by-byte in either programming mode.

To program any nonblank byte in the on-chip Flash Memory, the entire memory must be

erased using the Chip Erase Mode.

5.9 Programming Algorithm:

Before programming the AT89C52, the address, data and control signals should be set up

according to the Flash programming mode. To program the AT89C52, take the following

steps.

1. Input the desired memory location on the address lines.

2. Input the appropriate data byte on the data lines.

3. Activate the correct combination of control signals.

4. Raise EA/VPP to 12V for the high-voltage programming mode.

5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write

cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5,

changing the address and data for the entire array or until the end of the object file is reached.

5.10 Data Polling

The AT89C52 features Data Polling to indicate the end of a write cycle. During a write cycle,

an attempted read of the last byte written will result in the complement of the written data on

PO.7. Once the write cycle has been completed, true data is valid on all outputs, and the next

cycle may begin. Data Polling may begin any time after a write cycle has been initiated.

5.11 Ready/Busy

The progress of byte programming can also be monitored by the RDY/BSY output signal.

P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled

high again when programming is done to indicate READY.

Page 33: Bidirectional Visitor Counter

5.12 Program Verify

If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read

back via the address and data lines for verification. The lock bits cannot be verified directly.

Verification of the lock bits is achieved by observing that their features are enabled.

5.13 Chip Erase

The entire Flash array is erased electrically by using the proper combination of control signals

and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. The chip

erase operation must be executed before the code memory can be reprogrammed.

5.14 Programming Interface:

Every code byte in the Flash array can be written, and the entire array can be erased, by using

the appropriate combination of control signals. The write operation cycle is self timed and

once initiated, will automatically time itself to completion.

Page 34: Bidirectional Visitor Counter

CHAPTER 6

DISPLAY

The circuit comprises three seven segment displays to represent the number of visitors

present.

6.1 Seven segment display

Figure 6.21 A Typical 7-segment display component, with decimal point

A seven segment display, as its name indicates, is composed of seven elements. Individually

on or off, they can be combined to produce simplified representations of the Hindu-Arabic

numerals. Often the seven segments are arranged in an oblique, or italic, arrangement, which

aids readability.

Figure 6.22 The individual segment of a seven-segment display

Page 35: Bidirectional Visitor Counter

In a simple LED package, each LED is typically connected with one terminal to its own pin

on the outside of the package and the other LED terminal connected in common with all other

LEDs in the device and brought out to a shared pin. This shared pin will then make up all of

the cathodes (negative terminals) OR all of the anodes (positive terminals) of the LEDs in the

device; and so will be either a "Common Cathode" or "Common Anode" device depending

how it is constructed. Hence a 7 segment plus DP package will only require nine pins to be

present and connected.

Page 36: Bidirectional Visitor Counter

CHAPTER 7

POWER SUPPLY

Figure 7.23 Power Supply

The entire circuit is powered up by a power supply circuit, which is shown above. The circuit

comprises following components,

1. Step-down transformer of 9V/500mA

2. Bridge rectifier

3. A Positive 5 V regulator IC

4. Filter capacitors.

The AC supply of 220V is step-downed to 9V by the step-down transformer. And the 9v is

now given to bridge rectifier to convert the AC source to DC source. The bridge rectifier

consists of four diodes, which two of them comprises forward bias and other two of them

reverse bias during the positive half cycle of AC voltage. And vice versa during the negative

half cycle of the AC source. After rectification, the 9v DC is given to regulator IC 7805. The

positive voltage regulator IC 7805, provides a constant 5v DC to the load. Since the output

may be pulsated DC, the filters circuit filters the AC components present in the output to

provide a pure DC.

Page 37: Bidirectional Visitor Counter

CHAPTER 8

CIRCUIT DIAGRAM

The circuit shows the microcontroller based bidirectional visitor counter, wherein the

transmitter and the receiver form the IR detection circuit. Control logic is built around

transistors, operational amplifier LM324 (IC1) and flip-flop (IC2).

The IR transmitter-receiver setup at the entrance-cum-exit of the passage is shown at the

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. When nobody is passing through the entry/exit point, the

IR beam continuously falls on phototransistor T1. Phototransistor T1 conducts and the high

voltage as 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.

Now if someone inters the place, first the IR beam from IR TX1 is interrupted and then the IR

beam from IR TX1 is interrupted, phototransistor T1 and transistor T3 cut-off and pin 3 of

comparator N1 goes high. The low output (pin1) of comparator N1 provides negative trigger

pulse to pin 1 of J-K flip-flop IC(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 pin1 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 us an 8-bit microcontroller with 8 kb of flash based program memory, 256

bytes of RAM, 32 input/output lines, three 16 bits timers/counters, on-chip oscillator and

clock circuitry. A 12MHz crystal is used fro 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

Page 38: Bidirectional Visitor Counter

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 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 reset, the 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’ input pin

low through the microcontroller 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-K flip-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) flip-flop. This triggers the

external interrupt INT1 (pin 13) of microcontroller AT89C52. The value of the counter

decrements by ‘1’ when interrupt service routing 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.

Page 39: Bidirectional Visitor Counter

8.1 Circuit Diagram

Figure 8.24Schematic Diagram of Bidirectional Visitor Counter

Page 40: Bidirectional Visitor Counter

CHAPTER 9

ALGORITHM, FLOWCHART & PROGRAMMING

9.1 Algorithm

Step 1 : Start the process

Step 2 : Select ports 0, 1, 2 as output ports for displaying the count value in 7-segment

display

Step 3 : Select port 3 also as output port for providing set pulse to flip-flop

Step 4 : When external interrupt INT0 occurred, increment the count by 1.

Step 5 : When external interrupt INT1 occurred, decrement the count by 1.

Step 6 : Continue the process, whenever the interruption occurs.

Page 41: Bidirectional Visitor Counter

9.2 Flow chartSTART

Ext-interrupt occurred!INT0 or INT1

Send data to display the count in 7-segment via the ports 0, 1, 2

Select Ports 0, 1, 2 as output ports for 7-segment display

Select Port 3 as output port for providing set- pulse to

flip-flop

Increment the count by 1

Decrement the count by 1

Figure 9.1 Flow Chart

Page 42: Bidirectional Visitor Counter

9.3 Program Coding

The program coding for this bidirectional visitor counter circuit is written in ‘C’ language and

is compiled using C51 Keil compiler.

Program:

#include <AT89x52.h>

int i=0,j,k,l,m,a[ ]=[63,6,91,79,102,109,125,7,127,111];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 2i--;if(i<0) i=0;P3_0=0;for(m=0;m<=1000;m++);P3_0=1;void main()IE = 1333;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: Bidirectional Visitor Counter

if (i==0) P3_7=0; P3_6=0; else if (i>=1 && i<=10) P3_7=0; P3_6=1; else if (i>=11) P3_7=1;

P3_6=1;

Page 44: Bidirectional Visitor Counter

CHAPTER 10

PCB DESIGN AND FABRICATION

10.1 Protel for windows PCB 1.5 capabilities

Protel for windows PCB is a complete PCB layout environment with many attractive features

for productive design work. You can use Protel for windows PCB as a stand-alone manual

board layout. When combined with the schematics capture package, Protel for windows PCB

becomes the backbone of fully automated, end to end design system that features a high

degree of design automation and integration. However you use Protel for windows PCB, you

will appreciate its helps of use and the high degree of flexibility built into this proven PCB

design system.

PCB generates through hole and design and SND design of up to sixteen signal layers, plus

four mid layer power planes and four mechanical drawing layers. Board size can be as big as

100 inches (or 81 cm) square. Placement accuracy is to 1/1,000,000 inch (.001 mil or .00025

mm). Metric/imperial grid system allows you to work accurately in both measurement system

and the gird can be “toggled” Between metric and imperial modes as you design by pressing

Q.

A PCB design is a series of layers which correspond to the individual “tools” used to create

the board such as the top and bottom signal layers independently and some operations, such as

track placement and layers dependent – you must first select the layers and then place the

track. PCB print/plot options also reflect this requirement for “layered” design.

PCB design differs from other drawing tasks in its requirements for extreme precision.

As a result, PCB is more of a “placing” environment than a freehand “drawing” environment.

Another fundamental difference is connectivity – PCB’s ability to recognize connection

between track segments, tracks and component pads, etc. for example, PCB allows you to

Page 45: Bidirectional Visitor Counter

move a component without breaking its track to pad connections. You will be using

connectivity on several levels as you design with PCB.

10.2 PCB fabrication

The proposed PCB has been carefully designed by considering all the aspects such as the

overall circuit functionality, size requirements, electromagnetic interface, etc. once the PCB

pattern is photographed and reproduce on clear plastic sheet. The plastic sheet is placed over

a copper glass epoxy or phenolic board, the assembly is injected to undergo a photochemical

process and the resulting copper coated board consists of printed tracks which interconnect

the components as per the schematic design. The basic material used for making printed

circuit board is copper clad phenolic resin laminate. For general use, fuse boards are single

sided.

The procedure for making PCB is as follows,

The board has to be cut to the required size and the copper surface has to be cleaned.

The drawing of the circuit through which conduction takes place is made on the copper

surface using resist inks.

Then the uncovered copper areas are etched away in chemical bath.

The resist ink is removed to expose copper conducting areas.

Degreasing and cleaning the board are necessary to ensure that the areas take solder

readily.

Layout starts with an experimental design of components position and connections are

required.

Connections on a PCB should cross and sketching is usually done when components

positions are to be altered. Tracking of the PCB plane has to be made after having

arrived at a suitable layout.

The copper surface should be cleaned and dried before sketching the circuit in the

board.

Page 46: Bidirectional Visitor Counter

After tracking the pattern on the copper surface, this pattern then painted with resist

marker pen. It is allowed to dry for about 15 minutes.

The board is then transferred to an etching bath. This consists of a solution of ferric

chloride kept in a plastic tray.

The board is placed in the path such that the copper surface is kept facing upwards.

This process is to be continued until all the tracks of copper have disappeared from the

surface.

After etching, the board is removed and washed under running water to remove traces

of chemicals.

Finally it is dried with soft cloth. The rest should be done is drilling.

The points to be considered while drilling are,Drilling should carryout such that the

copper side is upper most. The use of a sharp drill is a must.

A hard material under the board prevents the points of the drill from tearing up a lump

out of the back of the board, when the drill breaks through.

To prevent the drill running of its correct position while drilling, the point to be drilled

has to be spotted with the center punch.

Vertical drill stand is best suited for drilling PCB’s. This should ensure square holes.

Due to small size drill is used breakage rate can be high.

The original tracking will be helpful for making the components positions

on the plan side of the board, which acts a guide for components assembly.

Page 47: Bidirectional Visitor Counter

10.3 PCB Layout for Bidirectional Visitor Counting Circuit:

Figure 10.1 PCB layout

Page 48: Bidirectional Visitor Counter

CHAPTER 11

RELAY

11.1 Introduction

A relay is an electrically operated switch. Many relays use an electromagnet to operate a

switching mechanism mechanically, but other operating principles are also used. Relays are

used where it is necessary to control a circuit by a low-power signal (with complete electrical

isolation between control and controlled circuits), or where several circuits must be controlled

by one signal. The first relays were used in long distance telegraph circuits, repeating the

signal coming in from one circuit and re-transmitting it to another. Relays were used

extensively in telephone exchanges and early computers to perform logical operations.

Figure 11.25 Internal architecture of relay

A type of relay that can handle the high power required to directly control an electric motor is

called acontactor. Solid-state relays control power circuits with no moving parts, instead using

a semiconductor device to perform switching. Relays with calibrated operating characteristics

and sometimes multiple operating coils are used to protect electrical circuits from overload or

Page 49: Bidirectional Visitor Counter

faults; in modern electric power systems these functions are performed by digital instruments

still called "protective relays"

Figure 11.26 Relay

11.2 Main Feature

1. 92/8 gold silver alloy on silver palladium contact type is suitable for low level switching

application.

2. Small size and light weight can provide high density P. C. Board mounting .

3. 2.54gmm Terminal Pitch.

4. Low Coil Power Consumption of GS-T Type and high Coil Power Consumption of GS-D

type are available to meet user’s selection.

5. Employment of suitable plastic materials to be applied to high temperature and various

chemical solution.

6. Plastic epoxy resin sealed type for washing procedure.

11.3 Application

Telecommunication, domestic appliances, office machine,audio equipment, Remote Control,

etc.

Page 50: Bidirectional Visitor Counter

11.4 Contact Rating

Nominal Load (Resistive Load Cosf=1)

Contact Capacity ..................1A at 120VAC.

2A at 24VDC.

Rated Carrying Current........2A.

Max. Allowable Current .......2A.

Max. Allowable Voltage ........AC 120V, DC 24V.

Max. Allowable Power Force.50 VA, 30W.

Min. Switching Load.............DC 1V, 1mA.

Contact Material ....................Ag Alloy.

Contact Form..........................DPDT.

11.5 Performance (at Initial Value)

Contact Resistance................100mΩ

Max.@100mA,6VDC

Operate Time.........................GS-D 6 mSec. Max.

GS-T 8 mSec. Max

Release Time..........................4 mSec. Max.

Dielectric Strength :

Between Coil & Contact........1,000VAC at 50/60 Hz for one minute.

Between Contacts ..................500VAC at 50/60 Hz for one minute.

Surge Resistance .....................1,500V (between coil & contact 1.2x50Sec.)

Insulation Resistance ............100 MegaΩ Min. at 500VDC.

Page 51: Bidirectional Visitor Counter

CHAPTER 12

ULN2003

12.1 DESCRIPTION

The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It

consists of seven NPN darlington pairs that features high-voltage outputs with common-

cathode

clamp diode for switching inductive loads. The collector-current rating of a single darlington

pair is 500mA. The darlington pairs may be parrlleled for higher current capability.

Applications include relay drivers, hammer drivers, lampdrivers, display drivers(LED gas

discharge),line drivers, and logic buffers. The ULN2003 has a 2.7kΩ series base resistor for

each darlington pair for operation directly with TTL or 5V CMOS devices.

Figure 12.27 ULN Device Driver

12.2 Features

Seven darlingtons per package

Output current 500 mA per driver (600 mApeak)

Page 52: Bidirectional Visitor Counter

Output voltage 50 V

Integrated suppression diodes for inductive loads

Outputs can be paralleled for higher current

TTL/CMOS/PMOS/DTL Compatible inputs

Inputs pinned opposite outputs to simplify layout

12.3 Description

The ULN2001, ULN2002, ULN2003 and ULN 2004 are high voltage, high current darlington

arrays each containing seven open collector darlington pairs with common emitters. Each

channel rated at 500 mA and can withstand peak currents of 600 mA. Suppression diodes are

included for inductive load driving and the inputs are pinned opposite the outputs to simplify

board layout.

The versions interface to all common logic families:

– ULN2001 (general purpose, DTL, TTL,PMOS, CMOS)

– ULN2002 (14-25V PMOS)

– ULN2003 (5V TTL, CMOS)

– ULN2004 (6-15V CMOS, PMOS)

These versatile devices are useful for driving awide range of loads including solenoids, relays

DC motors, LED displays filament lamps, thermal printheads and high power buffers.The

ULN2001A/2002A/2003A and 2004A are supplied in 16 pin plastic DIP packages with a

copper leadframe to reduce thermal resistance. They are available also in small outline

package (SO-16) as ULN2001D1/2002D1/2003D1/2004D1.

12.4 Diagram

Figure 12.28 Drivers

Page 53: Bidirectional Visitor Counter

12.5 Pin Configuration

Figure 12.29 ULN pin configuration

12.6 Maximum Rating

Page 54: Bidirectional Visitor Counter

CHAPTER 13

CONCLUSION

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.