You are on page 1of 38

1

CHAPTER ONE

1.0       INTRODUCTION

Many times we need to monitor the person/people visiting some place like Seminar hall,
conference room or Shopping mall or temple. This project can be used to count and display
the number of visitors entering inside any conference room or seminar hall. This is
bidirectional counter which means it works in a two way. That means counter will be
incremented if person enters the room and will be decremented a person leaves the room.
LCD displays this value which is placed outside the room. This system is helpful for counting
the number of people in an auditorium or halls for seminar to avoid congestion. Moreover it
can also be used to check the number of people who have come to an event or a museum to
watch a certain exhibit. Microcontroller is a reliable circuit that takes over the task of
counting the number of persons/ visitors in the room very accurately. We will be showing
both the in count i.e. number of people entering the room and out count i.e. number of people
exiting the room on a16x2 Alphanumeric LCD. An IR sensor isused to monitor the person
entering and exiting the room. The microcontroller does the above job. I receives the signals
from the sensors and this signal is operated under the control software which is stored in
ROM. Microcontroller 89s52 continuously monitor the Infrared Receivers. When any object
pass through the IR Receiver’s then the IR Rays falling on the receiver are obstructed, this
obstruction is sensed by the Microcontroller.

1.1       BACKGROUND STUDY

In recent times, the number of visitors to protected and recreational areas has almost doubled
during the past ten years throughout the whole world (Horne et al., 1998). Now it is estimated
that about five hundred million visits are made annually to national parks and other
recreational areas. This assumptions based on different ways of estimating the number of
visits. Earlier, the estimates were based on trail logs, examination of footprints and
deterioration of the trails, various permits and best estimates made by personnel working in
the areas. However, the lack of uniformity in the world countries development and
consequently the lack of uniformity in data keeping practices have made it difficult to
estimate correctly the number of visitors to places designated as public in the individual
countries and the world at large. This makes reliable visitor counting not only difficult, but at
2

the same time extremely challenging. During the past two years, appreciable efforts have
begun to count visitors to public areas more systematically and consistently. Some counters
were already in use in the mid-1990s, but insufficient use was made of them. More accurate
estimation of the number of visitors was made considerably easier by the publication of a
manual on visitor counting in Finnish (Horne et al., 1998), which has been widely applied in
practice. Other good manuals on visitor counting have been published, for example, in
Scotland and the United States (e.g. Dales et al., 1993 and Yuan et al., 1995).The problem
has been and still is to some extent the lack of systematic and sufficiently reliable visitor
statistics.

Reliable estimates of the number of visitors are extremely important for planning and
managing the use of the areas in question. On the basis of such estimates, it is possible to gain
clearer picture of the use of the area and the sites where visitor traffic is heaviest. Information
on visitor numbers help the people responsible for managing the areas to control the flow of
visitors, for example, by directing them to routes that causeless deterioration to vegetation
and landscape. In addition, visitor counts also help to maintain and develop services so that
they better correspond to the real number of visitors to the area (e.g. firewood supply and
waste disposal). Furthermore, reliable visitor statistics are needed, together with other
information gathered from visitor surveys, for evaluating the effectiveness of the area’s own
activities and for monitoring changes.

Visitor counting involves the following distinct stages:

 Careful planning of the visitor count


 Installation of counters in the terrain
 Monitoring of counters in the terrain
 Defining the correction coefficient for the counters
 Counting the number of visits

Visitor counting thus provides statistics on the number of actual visits that have been made to
an area. When this information is combined within formation gained from visitor surveys, it
is possible to estimate the number of visitors, i.e. how many people visit the area.

In a public place such as shopping malls, religious centers and cinemas, data on the number
of visitor is frequently needed for marketing research or statistic purposes. Usually the
3

counting process is done manually by the officers who guard the entrance. If this process is
done for a long period of time, it will be prone to human errors. Same goes to a room such as
laboratory, main hall, mosque or bedroom. With the advent of industrial and business era in
Nigeria and the subsequent establishment of many public areas such as churches, shopping
malls, recreational centers and so on, there is a need to make adequate preparation and plans
for visitor control and management. This will help to keep accurate information on
population density per time, identify potential structural and social risks and effective
decision making on issues related to population.

1.2       PROBLEM STATEMENT

Background reading revealed that the technology of visitor counting had dated back to the
1990s. However, there are some shortcomings present in the existing system. 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.

However, 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. With human handling the manual counting of visitors,
there are tendencies of inefficiencies, misrepresentation, time wastage and unnecessary
financial implications. With this in mind, it is imperative to develop and promote a digital
visitor counter which will be bidirectional in nature and utilise the microcontroller. This will
limit all human interferences to the barest and ensure that the task of keeping data on visitors’
visit is less time-consuming, efficient and almost error free.

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. 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
4

should continuously fall on the respective phototransistors, so proper orientation of the


transmitters and phototransistors is necessary.

A counter system can be design in many ways such as combination of gate logic and
microcontroller. Gate logic is simple and easy but this feature is difficult to vary and becomes
complex if the system needs more improvement in requirements. But, by the using of a
microcontroller, a system can be more complex but easy to design. This system will be
designed on a smaller scale to model the actual system. The model will function exactly as
the actual system will. A sensor will be used to detect a person enter and out from the door
and send signal to microcontroller. This microcontroller will count up and down based on the
programming that been embedded on the PIC. A LCD display will inform the total occupant
inside the laboratory and at the same time will display the counting data when a person enter
or leave the room.

1.3 SCOPE

This project primarily base on modeling of a micro-controller controlled bi-directional visitor


counter system that will:

 Count visitor which enter and leave the room and display total occupant inside the
room
 Implement two IR proximity sensors
 Identify the counter process (count up or countdown)
 Work in a single entrance and single exit room

1.4       OBJECTIVES

The objectives of this project are basically to:

 Design a bi-directional visitor counter controlled by the microcontroller which will


display its statistical output on an LCD screen
 Ensure that the system functions effectively, using an 8 bit microcontroller, IRLED
phototransistor circuits and is powered by a 9V PP3 battery.
 Ensure that the project fulfill all requirements for the award of an Higher National
Diploma in Computer Engineering
5

1.5       PROJECT JUSTIFICATION

Shopping malls, marketing professionals and recently, religious and academic gatherings rely
on visitor statistic to measure their organizational progress in terms of population
(patronization), make effective managerial and operational decisions and optimization of
opportunities e.g. applying for financial aids etc. Over time, different counting procedures
and counters have been employed, among which are beam counters, thermal counter, video
counting etc. However, most of this counting systems are archaic, cannot meet up with the
current demand for faster and more accurate statistics on visitors. Majorly, most counting
procedures depends on human for over 70% operations thus introducing a sizable amount of
errors arising from different procedural inefficiencies.

In view of these and many more, the need for a digital visitor counter which is bi-directional
is imperative as this will alleviate the challenges of human unnecessary interferences with
visitors statistics, save time and money and at the same time giving an efficient output which
can be relied upon in any circumstances except for system malfunctions. The challenge of
erratic power supply to the system has been well considered, hence a coupling of a 9V PP3
battery with the system.
6

CHAPTER TWO

LITERATURE REVIEW

Technological advancement occurring on all fronts of electronics and software engineering


has in many ways simplified the design and construction of various counting systems.
Historically, the first attempt at inventing a system capable of counting based on human
movement was made in the early 1800s however use was made of various component
including valves and pumps which were the only readily available component at that period.
These components have major limitations which include their large and cumbersome nature
thereby making their mass production, a near impossibility. Despite the limitations, this
experiment presents a breakthrough in electronic engineering [D.A smith, 2003].

In 1907, a Russian scientist, Marko Ivanovo successfully designed and constructed an alarm
circuit which he nicknamed, “Ivanovo’s Bells”. In his design, he made use of a photodiode as
source of infrared radiation and a phototransistor to dictate the incoming radiation. He also
incorporated a relay in his design. Once there was an obstruction in the path of infrared rays,
a bell which was connected electrically to the relay would sound. This work to a large
extends, represent a quantum leap in area of semiconductor use and application but still had a
drawback in that, the bell used wore out with time [W.H Dennis 1982].

In a historical experiment which was conducted by a group of American Engineers namely,


Alexander Graham Bell, Scott Stone and Peter Reid, at Bells Laboratory in the year 1935, use
was made of very powerful infrared sensor which could detect infrared radiation coming
from distance of as long as 100meters away. A very powerful infrared diode was used as
source of infrared radiation and it was to work efficiently within limits of experiment
accuracy. This design represent a turning point in area of sensor technology, although this
design had a drawback in that it depend solely on power from an AC mains supply and hence
could not operate without mains supply [W.A John, 1994]

The transistor to battery powered infrared alarms occurred in early 1940s. In 1945, an
infrared security system was design and constructed by a group of 4 th year electronic
engineering student at the Department of Electrical and Electronic Engineering Laboratory of
the prestigious Princeton institute of technology. In this historical experiment, use was made
of purely discrete components including transistors, resistors and capacitors and a 9V dc
battery as power supply source [Paul Horowitz and Winfield Hill, 1995]
7

The first infrared system which made use of an integrated circuit in its operation was
designed and constructed by Prof. Winfield of the department of Electrical Engineering at
Cambridge University in the late 1930s. In his design, he made use of the 555 timer, which
was one of the earliest integrated circuits. This project was by far superior work to previous
works done in the past in that it was very efficient, portable and use of lesser number of
discrete components [Bluestein I, 1995].

The advent of the microcontroller and software programing in late 1970s further brought
advancement to the area of electronics engineering and was widely used for various
applications [McKenzie I. Smith, 1995].

In 1995, Ayuba I.S of the department of electrical engineering, Ahmadu Bello University,
designed an electro industrial counter using a light dependent resistor and infrared emitter
which generate signals whenever a product cut across the infrared radiation.

In 2001, Vaachi T.B Designed and constructed a photosensitive up- down counter using
infrared emitter and photodiode which a clock pulse whenever there is interruption of light
beam from the object sensor and the output of the counter is displayed using the common-
anode seven-segment display.

In 2008, Abdulrahmam Kamal. Kof the department of electrical engineering, Ahmadu Bello
University, Designed and construct a remote monitoring system to operate upon an
interruption of light beam object sensor.

In 2010, Umar Y.EKof the department of electrical engineering, Ahmadu Bello Universit,y
Designed and constructed a 4 digit decimal counter using a CMOS dual-BCD counter to
generate pulses.

In 2011, Salawudeen. A. JKof the department of electrical engineering, Ahmadu Bello


University, Designed and construct a digital visitors counter with security alarm system
which uses BCD to generate pulses.

This project is different from the above literatures with the use of microcontroller and the
inclusion of voice alarm.

2.1 INTRODUCTION
8

In this chapter, a theoretical background of the project is presented and a summary discussion
is outlined on each of the main components and associated software packages used in the
design and construction of the system.

2.2 COMPONENTS’ DESCRIPTION

The following components were used in the design and construction of this project.

i. Diode
ii. Light emitting diode (LED)
iii. Infrared sensor
iv. Switch
v. Transistors
vi. Capacitors
vii. 555 timers (integrated circuit)
viii. Transformer
ix. Voltage regulator
x. Rectifier
xi. Speaker
xii. Voice alarm chip
xiii. ATMEGA8 microcontroller
xiv. Seven segment display

2.2.1 DIODE

Diode is a device that allows current to flow in only one direction. It can therefore be used as
a simple solid state switch in AC circuits when it is conducting.

The I-V characteristics of a p-n diode is shown in fig 2.1


9

Fig 2.1: I –V characteristics of diode

2.2.2 LED (LIGHT EMMITING DIODE)

The LED is a device that emits visible and/or invisible wavelength of light spectrum when a
forward biasing current is passed through it. Most LEDS are constructed of gallium arsenide
phosphide [M.D Abdullah, 2005].

For the purpose of this project a power LED was used. While a suitable efficiency of a LED
can be obtain for as low as a current of 2mA passing through it, the usual design goal is in
vicinity of 10-20mA. During conduction there is a voltage drop of 2V across the LEDs.

2.2.3 INFRARED EMITTING DIODE (INFRARED DIODE)

The infrared emits a narrow band of radiation peaking at a wavelength of about 940nm. It is a
super high output power device and emits an infrared wavelength of suitable intensity.
Summarily the infrared diode has the following properties.

i. Wide beam angle


ii. High output power
iii. Low cost
iv. Pulse are sent at a fixed frequency

The type of infrared diode used in designing this project is the IE-05030HP, because of it
availability and reliability. [W .F John 1994]
10

The circuit symbol for the infrared diode is shown in fig 2.4

Fig 2.4: symbol of infrared diode.

2.2.4 INFRARED SENSOR

The sensor is a device that receives or senses signals coming from the infrared diode and
converts these signals into a form suitable for interpretation by the ATMEGA8
microcontroller.

An infrared sensor, 042-BVI is used in the construction of this project. The sensor is a 3 pin
device and each pin is connected to a separate part of the circuit [Bluestein I, 1999]

The circuit symbol for infrared sensor is shown in fig 2.5

Fig 2.5: symbol of infrared sensor.

2.2.5 SWITCH

A switch is a device used to power a circuit, “ON” or “OFF”. When the switch is closed
(“ON”), current will flow from power supply to the parts of the circuit. This is because the
resistance between the switch contacts is very small. However, when the switch is opened
11

(“OFF”), current does not flow through it due to the very high resistance between the switch
contacts. [A. Wilson, 2001].

A single throw (SPST) switch is used in this project which when closed permits the flow of
current from the power source (PHCN AC mains), through the transformer, rectifier and
voltage regulator and into the ATMEGA8 microcontroller via it input pin.

The circuit symbol for switch is shown in Fig 2.6

Fig 2.6: symbol of switch

2.2.6 TRANSISTOR

A transistor is a device that is used in amplifying, switching and driver application in


electronics circuits and systems. [W.H Dennis, 1982].

A BJT (bipolar junction transistor) has three terminals namely; Collector terminal(C), Base
terminal (B), Emitter terminal(E) and two junctions namely Emitter- Base and Collector-Base
junctions. The I-V characteristics of BJT is shown in Fig 2.7 indicating the saturation and
cut-off regions of operation of operations of the transistor

2.2.7 CAPACITOR

A capacitor is a device that stores electrical energy in the form electrostatic field. It consists
essentially of two conducting surface separated by layer of insulating material (or medium)
called dielectric. The conducting surface may be in the form of either circular or rectangular
plates or may be spherical or cylindrical in shape.

Capacitors are widely used as filters to remove AC signals from variety of circuits, AC
ripples in DC power supplies, AC noise etc. they can also be used as timing components
(together with resistors) in ICs and amplifier circuits.
12

A capacitor’s ability to store charge is called it capacitance (measured in farad). However,


practical capacitors have capacitances of the order of Micro farad, Nano farad, and Pico
farad.

Parallel plate capacitors are used for the construction of this project. The circuit symbol is
shown in Fig 2.9 below.

2.2.9 TRANSFOMER

A transfomer is a static (or stationary) piece of apparatus by means of which electrical power
is one circuit is transform into electrical power of the same frequency in another circuit. It
can raise or lower the voltage in a circuit but with a corresponding decrease in or increase in
current. It operates based on the principle of electromagnetic induction whereby two circuits
are linked together by a common magnetic flux and therefore are in mutual inductive
influence of each other.

In its simplest form, it consist of two coils; the first coil called the primary winding in which
electrical energy is fed from AC mains supply and the second coil is called the secondary
winding from which electrical energy is drawn out.

The other necessary part of the tranfomer are;

i. A container for the core and windings


ii. An insulating medium to insulate the core and the windings from the container.
iii. Suitable bushings (porcelain, oil-filled or capacitor type) for bringing out the
terminals of the winding from the tank.

A step down transformer is used in this project to step down the 220/240V AC mains voltage
at its input to a 12V AC output voltage. The circuit symbol of the transformer is shown in Fig
2.11

Fig 2.11: circuit symbol of a transformer


13

2.2.10 RECTIFIER

The rectifier is a circuit that employs one or more diodes to convert AC voltage into a
pulsating unidirectional DC voltage.

There are different types of rectifier circuits some of which are;

i. Single phase half-wave rectifier


ii. Single phase full-wave rectifier
iii. Three phase half- wave rectifier
iv. Three phase full-wave rectifier
v. Full wave rectifier etc.

A full wave bridge rectifier is used in this project and is made up of four diodes with a
transformer that is not centre tapped and the diodes are arranged in such a way that they form
a bridge.

The circuit symbol of a full wave bridge rectifier is as shown in fig 2.12.

During the positive half cycle, diodes D 2 and D 3 become forward bias (ON) whereas D1 and
D 4 becomes reverse biased. Hence diodes D2 and D3 begin to conduct and D1 and D 4 are
open circuits.

During the negative half cycle, diodes D 1 and D 4 are forward biased (ON) where as D2 and D3
becomes reverse biased. This way, a unidirectional DC voltage is produced at its output. The
figure 2.13a and 2.13b show the input and output waveforms of the rectifier diodes;

2.2.11 REGULATOR

Regulation is the provision of a required voltage at the load despite changes in input voltage.

Integrated circuit technology has simplified the design of a wide variety of power circuits. A
7805 regulator is used in this project.

The 7805 regulator is one of a series of 3 terminal voltage regulators (78xx series) and is
available with a fixed output voltage making it useful in a wide range of applications. These
include local card regulation, instrumentation, HIFI and other solid state electronic
equipment.
14

The 7805 regulator has some features which are listed below:

i. Output current excess of 0.1A


ii. No external current required
iii. Internal thermal overload protection
iv. Output voltage offered in 4% tolerance

The 7805 regulator in standard application is as shown in fig 2.24:

A common ground is required between the input and the output voltages. The input voltage
must remain typically 2.0V above the output voltage even during the low point on the input
ripple voltage.

2.2.12 SPEAKER

A speaker is a device that produces sound energy at its output. It falls into a class of devices
known as transducer. A transducer is a device that converts energy from one form to another.

A speaker is a transducer that converts electrical energy into sound energy. In this project, the
output stage is a speaker connected to a sound driver from voice alarm.

Fig2.15 shows a speaker symbol.

Fig 2.15: Symbol of speaker

2.2.13 555 TIMER IC

The 555 timer/oscillator IC is an analogue integrated circuit that is used for timing and
oscillator applications. To fully understand the operation of the IC we look at its internal
basic component and the major building blocks as shown on fig 2.16 below.
15

Fig 2.16: major building block of 555 timers.

As we can see it has two analogue comparator, S-R flip flop, inverter and discharge
transistor. It also has three identical resistors each of 5KΩ resistance and this is the reason
why it is called 555 timer. These resistors are used as voltage divider network between the
two comparators in the IC. The comp. 1 has a reference voltage of 2/3V cc while the comp. 2
has a reference voltage of 1/3V cc . The comp. 1 is configured in non-inverting mode where it
will be triggered to produce a high output only when the variable input from the threshold (6)
input is above the reference voltage (2/3V cc ). The comp.2 is configured in inverting mode
where it will be triggered to produce a high output only when the variable input from the
trigger (2) input is below the reference voltage (2/3V cc ).

Output of the 555 timer is controlled by threshold (pin 6) and trigger (pin 2). When voltage at
pin 6 is above2/3V cc comp. 1 is high which trigger thee reset (R) input of the flip flop and
hence the out Q of the flip flop is low but since we are using the inverse output Q′ is going to
be high. This input is connected to the inverter which gives low output finally at pin 3 and at
the same time this high input triggers the discharge transistor and sets it to saturation
condition so that any voltage at pin 7 is (discharge) is now allowed to pass from the collector
through the emitter of the transistor to the ground. But when voltage at pin 2 is below1/3V cc
16

comp. 2 is high and this trigger the set (s) input of the flip flop and makes the Q′ low which is
inverted by the inverter to give high input at pin 3 while the discharge transistor is cut-off
since low voltage is at the base, therefore nothing can pass from discharge pin (7) to the
ground. When pin 4 (reset) is not in use, we tie it to pin 8 (supply) of the 555 timer.

The 555 timer/oscillator IC is used as, Monostablemultivibrator, Astablemultivibrator


andBistablemultivibrator.

In this project, 555 timer is used as, Monostablemultivibrator and Astablemultivibrator.

2.2.14 MICROCONTROLLER

A microcontroller belongs to a class of devices which can be programmed using a


programmer and associated software development s, which are installed on a personal
computer (PC) to carry out required task and execute certain instructions.

The microcontroller used in this project is the ATmega8.It is a member of AVR


microcontroller family; it has many features similar to that of ATmega32. But it has reduced
number of features and capabilities, yet it has enough features to work with. If we want to
gather knowledge and simultaneously want to do it in less cost than the budget of ATmega32,
we can think of making projects with ATmega8. In that case, one feature we won’t be able to
realize is the JTAG interface. But rest of the features are available in this IC. Let us see what
one can get from ATmega8.

The pin configuration of ATmega8 is shown in fig 2.17


17

Fig 2.17: pin configuration of ATmega8

The ATmega8 have the following features;

i. Memory: It has 8 Kb of Flash program memory (10,000 Write/Erase cycles


durability), 512 Bytes of EEPROM (100,000 Write/Erase Cycles). 1Kbyte Internal
SRAM
ii. I/O Ports: 23 I/ line can be obtained from three ports; namely Port B, Port C and Port
D.
iii. Interrupts: Two External Interrupt source, located at port D. 19 different interrupt
vectors supporting 19 events generated by internal peripherals.
iv. Timer/Counter: three Internal Timers available, two 8 bit, one 16 bit, Offering various
operating modes and supporting internal or external clocking.
18

v. SPI (Serial Peripheral interface): ATmega8 holds three communication device


integrated. One of them is Serial Peripheral Interface. Four pins are assigned to it to
implement this scheme of communication.
vi. USART: One of the most powerful communication solutions is USART and
ATmega8 supports both synchronous and asynchronous data transfer schemes. It has
three pins assigned for that. In many projects, this module is extensively used for PC-
Micro controller communication.
vii. TWI (Two Wire Interface): Another communication device that is present in
ATmega32 is Two Wire Interface. It allows designers to set up a commutation
between two devices using just two wires along with a common ground connection,
As the TWI output is made by means of open collector Outputs, thus external pull up
resistors are required to make the circuit.
viii. Analogue Comparator: A comparator module is integrated in the IC that provides
comparison facility between two voltages connected to the two inputs of the Analogue
comparator via External pins attached to the micro controller.
ix. Analogue to Digital Converter: Inbuilt analogue to digital converter can convert an
analogue input signal into digital data of 10bit resolution. For most of the low end
application, this much resolution is enough.

2.2.15 SEVEN SEGMENT DISPLAY

A seven segment display is the most basic electronic display device that can display digits
from 0-9. They find wide application in devices that display numeric information like digital
clocks, radio, microwave ovens, electronic meters etc. The most common configuration has
an array of eight LEDs arranged in a special pattern to display these digits. They are laid out
as a squared-off figure ‘8’. Every LED is assigned a name from 'a' to 'h' and is identified by
its name. Seven LEDs 'a' to 'g' are used to display the numerals while eighth LED 'h' is used
to display the dot/decimal.

A seven segment is generally available in ten pin package. While eight pins correspond to the
eight LEDs, the remaining two pins (at middle) are common and internally shorted. These
19

segments come in two configurations, namely, Common cathode (CC) and Common anode
(CA). In CC configuration, the negative terminals of all LEDs are connected to the common
pins. The common is connected to ground and a particular LED glows when its
corresponding pin is given high. In CA arrangement, the common pin is given a high logic
and the LED pins are given low to display a number.

The pin diagram of seven segment display is shown on fig 2.18.

Fig 2.18: pin diagram of seven segment display.


20

CHAPTER THREE

DESIGN PROCEDURE AND ANALYSIS

3.1 INTRODUCTION

This chapter describes in details the selection criteria of component used and the calculations
made to arrive at their respective values. The design can be categorized into hardware and
software design, the hardware design covers the circuitry up to the point where transmission
of digital data begins. Also, the software design is discussed which covers the algorithm, flow
chart development and writing of assembly language program using the ATmega8 instruction
set.

The system may be subdivided into 6 units as outlined below

1. POWER SUPPLY UNIT


2. INFRARED TRANSMITTER UNIT(LED)
3. INFRARED RECIEVER UNIT(SENSOR)
4. SOUND DRIVER(TRANSISTOR STAGE)
5. ATMEGA8 MICROCONTROLLER
6. SEVEN SEGMENT DISPLAY

3.2DESIGN OF POWER SUPPLY UNIT

The power supply unit consists of;

I. A 240/12V 500mA step down transformer


II. A full- wave Bridge Rectifier
III. Capacitor Filter
IV. A voltage Regulator
Fig 3.1 shows the block diagram of power supply unit.
21

Fig. 3.1: Block diagram of a power supply

3.1.2 SELECTION OF TRANSFOMER

The selection of transformer used is dependent on the total maximum current and voltage
rating of component used. The current and voltage rating of basic component used in the
project from their manufacturer’s data sheets are given in table 3.1

Table 3.1 Electrical characteristics of components.

COMPONENTS MAXIMUM CURRENT TYPICAL VOLTAGE


RATING (mA) RATING (V)

IN4148(DIODE) 20 -

IN4001(DIODE) 20 -

BC547(TRANSISTOR) 100 ×2 4.8

INFRARED DIODE 50 -

555 TIMER(IC) 6×4 5

ATMEGA8(IC) 3.6 5.5

TOTAL 317.6mA

Based on the data, a transformer rating of 240/12V 500mA 50Hz was chosen. By making
reference to the elementary theory of the voltage transformer, the following equation can be
derived for a transformer.
22

N 2 E2
K= =
N1 E1
(3.1)

Where; E1 = primary (input voltage)

E2 = Secondary voltage (output voltage)

N1 = number of turns in the primary winding

N2 = number of turns in the secondary winding

K = Voltage transformation ratio (or turns ratio)

Based on the transformer rating K can be evaluated thus;

N 1 240
K= = = 20
N 2 12

Thus, the number of turns of the transformer is 20

The power rating of the transformer can be evaluated using the formula.

P = I rms V rms (3.2)

Where I rms= root mean square value of output current

V rms = root mean square value of output voltage

Therefore; P =500×10−3 ×12= 6W

3.2.2 SELECTION OF BRIDGE RECTIFIER DIODE

In selecting the diodes used in the bridge rectifiers, the Peak Inverse voltage (PIV) and
maximum secondary voltage (Vsm) of the diode were taken into consideration.

The PIV of diode is;

PIV=Vsm (3.3)

PIV=√ 2 ×12=17V

This is the maximum reverse voltage above which breakdown of diode occurs in the reverse
direction. Hence, diodes IN4001 are used as rectifier diodes
23

3.2.3SELECTION OF FILTER CAPACITOR

The capacitor used as filter is selected based on the following calculations;

C
1=¿
I dc
¿ (3.4)
4 f (V ¿¿ SM −V dc )¿

V SM =√ 2V rms = 16.97V

2V SM
V dc = (3.5)
π

16.97
V dc = 2 × =10.8V
3.14

Similarly,

2 I SM
I dc = (3.6)
π

2 ×√2
I dc = × 500 = 450mA
3.14

C
1=¿
450× 10−3
¿ = 400µF
4 ×50 ×(16.97−10.08)

The voltage of the capacitor is;

3
V c = × V dc (3.7)
2

3
Vc = × 10.08 = 15.12V
2

Hence, a capacitor with a rating of 47µF, 16V is suitable as a filter capacitor due to its high
market availability.

3.2.4 REGULATOR SELECTION

Based on the previous analysis, the d.c voltage output of the bridge rectifier diode was
calculated to be 10.08V (i.e. V dc =10.08) and basically all the integrated circuits are powered
by regulated supply voltage of 5V. A 7805 regulator IC which takes a range of +7V to +35V
24

unregulated voltage is chosen. The capacitor C2 connected across the output of regulator IC
as shown in fig 3.2 improve transient response, keeps the impedance low at high frequencies
and it’s very small compared to capacitor filter. A value of 0.1µF is suitable as an output
filter for the voltage regulator. The electrical characteristics which were taken into
consideration when selecting the voltage regulator as obtain from the manufacturer’s data
sheet are shown in the table below.

Table 3.2 Electrical Characteristics of 7805 regulator

CHARACTERISTICS CONDITIONS MIN TYP MAX UNITS


Output Voltage 4.8 5.0 5.2 V
Line Regulation 7.0V≤V ¿≤25V - - 100 mV
8.0V≤V ¿≤15V - - 50 mV
Load Regulation 5.0mA≤ I out ≤ 1.5mA - - 100 mV
250mA≤ I out ≤750mA - - 50 mV
Quiescent Current - - 8.0 mA
Dropout Voltages I out =1.0 A - 2.0 - V
Peak Output Current - 2.2 - A

The circuit diagram of the power supply unit is shown below. Fig. 3.2

U?
TR? 7805
D1 D2
1 3
VI VO
5v
1N4007 1N4007
220V, 50Hz
GND

R?
2.2k C?
C?
2

0.1uF
TRAN-2P3S D3 D4 2200uF
D?
LED
1N4007 1N4007
0v

Fig. 3.2: Circuit Diagram of Power Supply


25

3.3 DESIGN OF INFRARED TRANSMITTER (LED) UNIT


The infrared transmitter unit consists of;
I. Light emitting diodes (LED)
II. 555 timer (AstableMultivibrator)
III. NPN BJT Transistor (driver transistor).

3.3.1 SELECTION OF LEDs

The LEDs and associated resistors were selected based on performance and electrical
characteristic as discussed. Two LEDs were used both for exit and entry transmitter. A
current of 20mA flows from the power supply through a current limiting resistor (R5) as seen
in fig.3.3 and the LED. The resistor’s function is to limit the current flowing into the diode at
its anode to prevent it from blowing the diode. Based on the data sheet of the diode, it is seen
that a forward voltage of 2.1V occurs at the diode terminals.

Using ohms law;

Vs VD
ID = − (3.8)
Rm Rm

Where; Rm = minimum current limiting resistance

I D = maximum forward current

V s = supply voltage

V D = maximum forward diode voltage

Thus for a current of 30mA (maximum forward current of LED);

5−1.7
Rm = −3 = 165Ω
20× 10

Thus the resistor, R5 should not be less than 165Ω i.e. R5 ≥ Rmin

A suitable resistor value of R5 = 330Ω was used as current limiting resistor.


26

3.3.2 SELECTION OF 555 TIMERS (ASTABLE MULTIVIBRATOR)

As discussed earlier, a 555 timer is device that oscillates back and forth. A 555 timer is
selected for use in the transmitter unit as oscillator; it is configured in astable mode as seen in
fig3.3. Resistors R3 and R1, together with capacitor U1 form the timing circuit.

The resistors and capacitor were selected based on the following criteria;

1. The value of capacitor (U1) must be less than 500pF to avoid stray capacitance.
2. The resistors R3 and R1 must not be less than 1kΩ to avoid over current.
3. R3 + R1 must not be more than 3.3MΩ.
4. Maximum frequency that can be achieved is 1MHz
5. Maximum output current is 200mA. [Mal. A. Kabiru, EEEN540 lecture note]

Based on this the value of R15, RV1 and C20 were choose to be 1KΩ, 5KΩ and 0.01µF
respectively.

3.4 DESIGN OF INFRARED RIECIEVER (SENSOR) UNIT

The infrared receiver unit consists of;

I. Infrared sensor
II. 555 Timers (monostablemultivibrator)
III. NPN BJT Transistor (driver transistor)

3.4.1 SELECTION OF INFRARED SENSORS

Infrared sensors were suitable because the light from the transmitter is infrared which is not
visible to human eye and therefore suitable for this work. Associated resistor and capacitors
were selected based on performance and electrical characteristics as discussed earlier.

3.4.2SELECTION OF 555 TIMERS (MONOSTABLE MULTIVIBRATOR)

This unit consists of two timers each for entry and exit sensor respectively, which were
configured in monostable mode at the same timing operation. A monostable is said to have a
single stable state that is the off state. Whenever it is triggered by an input pulse, the
monostable switches to its temporary state. It remains in that state for a period of time
determined by an RC network. It then returns to its stable state. Fig 3.4 shows the circuit
diagram of 555 timers (monostablemultivibrator).
27

5V 5V

R6 R7
U2
U1 10k 10k
3 3
4 R Q 4 R Q

8
Output to the Input driver

8
DC 7 DC 7
Output to Input driver (E

V CC
V CC
5 CV
(Entry) 5 CV

TR TH
2 6 2 TH 6 C
100uf TR
100uf

GND

GND
Input Trigger from Entry Input Trigger from
Exit Sensor
Sensor

1
1
555 Timer for Entry Sensor 555 Timer for Exit Sensor
Fig. 3.5 Circuit diagram of 555 Timer Unit

In fig. 3.4, the duration of the output pulse in seconds can be calculated using the
formula T =1.1 R 6 C
Where R6 and C are timing resistor and capacitor respectively and T is the period of
the output pulse. For proper implementation T was taking to be 1 second, and the value of
capacitor C was picked to be 100µF
Then, T = 1.1R6C = 1
1
R6¿ = 9.09K𝛀
1.1 x 10 0−6
The commercial value of R6 = R7 = 10K𝛀 was used in the design.
The output from the transducer unit served as the trigger to the pin 2 of 555 timers.
Thus, the output of 555 timers is being controlled by the input trigger. The collector of
2N3904 used was connected to a pin of microcontroller and also through 10K𝛀 to Vcc.
The microcontroller used (ATmega8) can sink a current of about 3.6mA maximum.
Thus, by taking the sinking current to 0.5mA, the pull up resistor can be calculated.
5
Therefore, the value of pull up resistor R is R= =10 K 𝛀
0.5 mA

3.4.2 SELECTION OF INPUT DRIVER

This comprises of two NPN BJT transistors (BC547) each for the entry and exit doors
respectively. The output from each of the sensor goes to the base of each transistor through a
network of a resistor and two capacitors. The transistor is used as the switching device that
28

drives the signal that goes to the 555 timer. The network of resistor and capacitor provide
necessary timing and switching.The BC547 was selected as a driver transistor for the 555
timers based on the following procedure;

1. The transistor's maximum collector current Ic(max) must be greater than the load
supply voltage Vs
current Ic. load current Ic =
load resistance RL
2. The transistor's minimum current gain hFE(min) must be at least five times the load
current Ic divided by the maximum output current from the IC. hFE(min) > 5×
load current Ic
max . IC curren
Vc ×hFE
3. Calculate an approximate value for the base resistor: RB =
5 × Ic
where Vc = IC supply voltage (in a simple circuit with one supply this is Vs)
More over; any general purpose low power NPN transistor can be used. For general
use RB = 10KΩ, RC = 1KΩ

3.4.4 DESIGN OF THE MICROCONTROLER (ATMEGA8).

Basic connecting

The current flowing through the reset pin can be calculated as

5
I Rst = = 0.5mA
10000
29

As seen in the figure above, in order to enable the microcontroller to operate properly it is
necessary to provide:

a. Power supply:
b. Reset signal: and
c. Clock signal.

Power supply

Even though this microcontroller can operate at different power supply voltages, why to test
“Murphy’s low”?! A 5V DC is most commonly used. The circuit, shown in the figure, uses a
cheap integrated three-terminal positive regulator LM7805, and provides high-quality voltage
stability and quite enough current to enable the microcontroller and peripheral electronics to
operate normally (enough current in this case means 1Amp).

Reset signal

In order that the microcontroller can operate properly, a logic 0 (0V) must be applied to the
reset pin RS. The push button connecting the reset pin RS to power supply VCC is not
necessary. However, it is almost always provided because it enables the microcontroller safe
return to normal operating conditions ifsomething goes wrong. 5V is brought to this pin, the
microcontroller is reset and program starts execution from the beginning.

Clock signal

Even though the microcontroller has a built-in oscillator, it cannot operate without two
external capacitors and quartz crystal which stabilize its operation and determines its
frequency (operating speed of the microcontroller).

3.4.3 DESIGN OF THE 2 DIGIT 7 SEGMENT DISPLAY


For visual interactivity with the user, the display is incorporated in the design work.
The display provides a visual presentation of the system counter to the user and also enables
the user to see the number of people in the hall.
A common anode arrangement is used since it allows current to be sunk through the
LEDs by the microcontroller. The digits are multiplexed to reduce wiring complexity. The
digits are individually driven by a PNP transistor as shown in.

The current through each segment can is calculated as follows


30

Current through the base of the BC547 PNP transistor is;


5−0.7
I B= = 4.3mA
1000

Current through the collector is;


I C= I B × 𝛽
Where; 𝛽 is the gain of the amplifier =
100
Therefore I C = 4.3×10−3 × 100 = 0.43A
50
Current through segments = × I = 0.5 × 0.43 = 0.215A
100 C
0.215
Current through each segment = = 30.7mA
7

CHAPTER FOUR

CONSTRUCTION, PROGRAM DEVELOPMENT, EXECUTION AND


TESTING

4.1 INTRODUCTION

This chapter describe in details, the construction procedure of system hardware, program
development and execution on the ATmega8 microcontroller, testing of the entire system and
casing of the system hardware.

4.2 CONSTRUCTION PROCEDURE

In the course of designing and constructing this project, the following components with their
respective values and rating were used:

RESISTORS:

RV1 = 5KΩ

R12 = 5.1KΩ
31

R13 = 33Ω

R14 = 100Ω

R6, R7, R9, R15 = 1KΩ

R1, R2, R3, R4, R5, R8, R10, R11 = 10KΩ

DIODES:

D1, D2, D3, D4 – IN4007

D5 – LED

D6.

CAPACITOR:

C9 = 470µF

C12 = 4µF

C13 = 220µF

C1, C4 = 2.2µF

C5, C6 = 1.0µF

C19, C20 = 10nF

C2, C3, C7, C8, C16, C21 = 0.1µF

C10, C11, C14, C15, C17, C18 = 100Nf

TRANSISTORS:

Q1, Q2, Q3, Q4, Q5 – BC547 (NPN BJT)

INTEGRATED CIRCUITS:

ATmega8 (microcontroller)

555 timer (monostablemultivibrator) ×2

555 timer (astablemultivibrator) ×2


32

LM7805 Regulator (3 pin IC)

ISD256 (Voice Alarm chip IC)

TRANSFORMER:

220V/12V, 500mA

OTHERS:

Speaker/Buzzer

Infrared sensor – 042-BV1

Vero boards

Sockets

Connectors

Jumper wires

In the course of the design and construction of this project, the selection of the above
components to reduce bulkiness and complexity was taken into consideration. [Mrs C.O
Alenoghena 2007]

The circuit components were first placed on the bread board taking note of polarities and
numbering of the pins. Tests were conducted at different stages and results were recorded.
This gave room for correction and modifications.

The components were then soldered on a Vero board. For soldering an alloy of 60% tin, 40%
lead was used. The soldering provides two functions; to mechanically bind the components to
the Vero board and to provide electrical continuity between the components on the board.

4.3 COMPONENT LAYOUT

Vero boards were made use of in the design and construction of this project. The main
components like the ATmega8, 555 timers, IC, resistors, capacitors, and transistors were
soldered on the main Vero board while the other components like the transformer, voltage
regulator and active diode were soldered on separate smaller Vero board and connected by
means of wires to the circuitry on the main Vero board. Also, a separate connection goes
33

from the transformer to the power supply. Jumper wires were used to link points which could
not be linked directly with solder wires on the Vero board. The seven segment displays and
speaker were connected by means of separate to the ATmega8, IC and associated circuit
components on the Vero board. After testing, the whole system was housed in a black plastic
casing with holes bored through it for the speaker, the indicator LEDS and nuts.

4.4 PROGRAM DEVELOPMENT ON THE ATMEGA8 MICROCONTROLLER

The program development, implementation and execution were done using MPLAB IDE
(Integrated Development Environment) and interface with Atmel STK500 programmer. This
software allows for code editing, compilation, debugging/simulation and program loading
through an appropriate programming interface. Program development was done using
MPLAB IDE due to ease of use and efficiency, as the microcontrollerworks well with the
integrated environment. For the ATmega8, the compiler used to generate machine codes for it
is called Atmel STK500 compiler. After the codes were written, the compiler was used within
the MPLAB environment to assemble and link the program and after error checking and
debugging, to produce a HEX file containing the machine code instructions for the particular
AVR microcontroller, in this case the ATmega8.

The figure4.2 below shows an Atmel STK500 development board.

Fig 4.2: Atmel STK500 development board.

4.5 PROGRAM LOADING AND EXECUTION ON THE ATMEGA8


MICROCONTROLLER
34

Atmel's AVRs have a two stage, single level pipeline design. This means the next machine
instruction is fetched as the current one is executing. Most instructions take just one or two
clock cycles, making AVRs relatively fast among the eight-bit microcontrollers.

The AVR processors were designed with the efficient execution of compiled C code in mind
and have several built-in pointers for the task.

In-system programing (ISP) was used which basically programs the microcontroller via its
SPI pins. The Atmel STK500 programmer was connected from the PC to its USB serial port
via a USB cable making it possible to interface with the MPLAB IDE software. Thereafter
the program was ran and debugged for error-checking.

4.6 SYSTEM TESTING

The various components were tested using a multimeter to verify that right connections were
made and ensure that there were no short circuits in the design. The diodes and LEDs were
tested to ensure that they conducted in forward direction and they did not in reverse direction.
Also the forward and reverse currents flowing through them were measured using a
multimeter to ensure that they did not exceed the maximum values as stated in their
manufacturers’ data sheets. The output voltage of the regulator was also measured and found
to be in the range of the required output voltage needed to power up the ATmega8 and ICs
(i.e. 4.8-5.4V). the input and output current at the pins of the ATmega8 and ICsboth when
high, ON and low, OFF were each measured and compared with the maximum values as
stated in their manufacturers’ datasheets to ensure that they were within safety limits. The
transistor current- voltage characteristic were also determined and found to comply with the
standard characteristics of transistor operating as switches and driver circuits.

4.7 CASING

This is the final appearance given to the system hardware. The system hardware was housed
in a plastic casing with the following factors taken into consideration

i. Spaced occupied
ii. Portability of the project
iii. Allowance for heat dissipation
iv. Ease of insulation
v. Thermal conductivity
35

The dimensions of the casing are

● Height =

● Length =

● Width =

The Vero board was screwed on the plastic casing. The figure below shows the casing of the
project.

CHAPTER FIVE

CONCLUSION, LIMITATIONS AND RECOMMENDATIONS

5.1 INTRODUCTION

This chapter presents the conclusion that were drawn from this project, some problems
encountered in the course of this work, the precaution taken and some recommendations that
could be useful to prospective designer of this nature.

5.2 CONCLUSION

The person counter with voice alarm has been successfully designed, constructed and tested.

The project has been satisfactorily used to count the number of people entering or leaving a
room and to indicate through voice alarm when the room is empty.

The ATmega8 was successfully programmed to control the operation of the infrared sensor to
receive or sense the reflected infrared radiation from infrared diode due obstruction by person
or object I accordance with the principle of reflection.

The project was found to work efficiently within reasonable limits of experimental accuracy.

The project further gave the opportunity of exploiting the diverse capabilities and possibilities
inherent in ATmega8 microcontroller device in terms of memory, data storage and precise
timing of instructions.

5.3 PROBLEM ENCOUNTERED IN THE PROJECT DESIGN

In the course of constructing this project, some components including the integrated circuits
were destroyed due to wrong connections and excessive currents flowing through them.
36

The program on the ATmega8 had to be debugged several times due to errors encountered
during program implementation.

The problem of obtaining genuine and required Integrated Circuits, infrared transmitter,
infrared receiver and other associated components.

The problem of interfacing of interfacing the MLPAB Integrated Environment and associated
software development tools with the Atmel STK500 programmer.

5.4 PREACAUTIONS

i. A dot type Vero board was used in construction for easy soldering.
ii. During soldering, components were well placed on the Vero board to prevent short-
circuits and wrong connections.
iii. Some sensitive wires were glued to the board to prevent unwanted removal.
iv. The circuit was properly checked for short-circuits and open circuits before being
powered.
v. The current flowing through each component as well as the voltages across each
component were measured using a multimeter in order to make sure excessive
currents that will damage the component do not flow through them.
vi. A socket was used to connect the ICs and ATmega8 to the Vero board in order to
avoid complications in the circuit design, to prevent damage to the pin of the ICs and
ATmega8 and to prevent the ICs and Atmega8 from being damaged.

5.5 RECOMMENDATIONS

In the course of designing and constructing this project it was discovered that this project
could be further enhanced and improved upon in future for the project to be of more use and
benefit to the society.

The following recommendations are proposed:

i. Increasing the distance of the infrared beam with the use of more infrared diodes and
concentrating the rays with the use of lenses, this will require more power.
ii. Incorporating a PC interface so that the number of person can be stored and the result
can be sent to a remote server in this way the project can operated even from distant.
iii. Incorporating a backup battery in case of power failure.
37
38

REFERENCES
1. A Wilson: Electronic Designs: Pitman Publishing Ltd., London, U.K.2001, pp. 39-85
2. Berlin Howard M. The 555 Timer Applications with experiments. Howard W. Sam &
Co. Inc. 1982 pp.27-30.
3. Bluestein I. “sensors magazine” Vol. 13 No. 14, U.K 1995, pp. 25
4. D. A Smith: The fundamentals of Semiconductors. Cambridge University, U.K, 2003.
pp.205
5. http://en. Wikipedia.org/wiki/temp:peripheralinterfacecontroller.
6. Mal. Kabiru A. Electronic Engineering (III). Unpublished Lecture Note, Department
of Electrical and Computer Engineering Ahmadu Bello University, Zaria. 2012.
7. Paul Horowitz and Winfield Hill: The Art of Electronics 2nd Ed. Cambridge
University Press U.K pp.992-993
8. W.F John. The chemistry of semiconductors: Pitman publishing Ltd. U.K 1994 pp. 75
9. W.H. Dennis: Electronics components Butter worth and Co. Ltd. U .K., 1982 pg. 153

You might also like