You are on page 1of 57

DEBRE MARKOS UNIVERSITY

COLLEGE OF TECHNOLOGY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINNERING
DESIGN AND SIMULATION OF AUTOMATIC ROOM LIGHT CONTROLLER
WITH VISITOR COUNTER
SEMESTER PROJECT
Industrial control stream
By
Member Name:

ID Number

1. Yeshituaf Assabu..TER/3444/04
2. Yezebalem MeketeTER/2639/04
3. Yibeltal MossuTER/2853/04
4. Yimenu Belay..TER/2474/04
5. Zemen Guadye.TER/2749/04

Advisor: Mr.Joefel

Declaration
This is to certify that the project report entitled design and simulation of automatic
room light controller with visitor counter being submitted by
Member Name:

ID Number

1. Yeshituaf Assabu..TER/3444/04
2. Yezebalem MeketeTER/2639/04
3. Yibeltal MossuTER/2853/04
4. Yimenu Belay..TER/2474/04
5. Zemen Guadye.TER/2749/04
in partial fulfillment for semester project the requirement for awarded of the fourth year
second semester project in electrical engineering. Which is recorded of our own work
carried by us during the academic year 2015 G. C under the supervision and guidance of
Mr. Jofel?
The result embodied in this project report have not been submitted to any other
university or institute for the award of any degree or diploma.

Advisor Name
Head of department
Signature

Acknowledgement
First of all we would like to thank Almighty GOD for his inspiration, indescribable
support to open the way how to work and healthy for us. It's a matter of fact without the
grace of GOD and our parents; we wouldn't have been able to complete the project.
Secondly we would like to thank and take an opportunity to express our sincerest
gratitude to our advisor Mr. Jofel for his encouragement, support, and guidance during
the process of our project staring from up to final submission of project.
Thirdly we would like to express our deepest appreciation and gratitude to our senior
Mr. Abathun Assefa for his indispensable support from motivation up to end of paper.
Our special thank goes to Mis. Andusumilli Lakshmi for her indescribable support
during the documentation. All in all, we found her not only as an academic instructor
but as good mother.
Finally we would like to thank our best friends who motivated while doing this project
by offering their laptop and those who are direct or indirect helps us to complete this
project.

With sincere regard.

Abstract
This project Automatic room light controller with visitor counter is a reliable
circuit that takes over the task of controlling the room light as well as counting number
of persons /visitors in the room very accurately which is installed in the entry of a room
or building to restrict access, provide ease of opening a door. As a result of enhanced
civilization and modernization, the human nature demands more comfort to his life.
The man seeks ways to do things which saves time. So thus, the automatic room are
one of the easily examples that human nature invent to bring comfort and ease in its
daily life. To this end, the researchers design and develop an automatic door with a
room light control system to provide the mentioned needs. This system works on the
principle of breaking an infrared beam of light, sensed by a photodiode. It consists of
two transmitting infrared diodes and two receiving photodiodes. The first one is for
someone coming in and the second one is for someone going out of the room. The
photodiodes are connected to the microcontroller, which give a lower output when the
beam is broken and high output when transmitting normally and the total number of
person in the room is displayed on the seven segments. The general operation of the
work and performance is dependent on the presence of an intruder entering through the
room.

Table of Contents
Declaration..................................................................................................... 1
Acknowledgement.......................................................................................... 2
Abstract.......................................................................................................... 3
CHAPTER ONE................................................................................................ 7
INTRODUCTION.............................................................................................. 7
1.1 Background of the study..........................................................................7
1.3 Objective of the study.............................................................................. 8
1.3.1 General objective...............................................................................8
1.3.2 Specific objective.................................................................................. 8
1.6 Significance of the project........................................................................8
1.7 Framework of the study............................................................................8
Figure 1: Control system frame work..........................................................9
1.8 Scope of the study................................................................................... 9
1.9 Limitations of the project.........................................................................9
1.10 Organization of project.........................................................................10
CHAPTER TWO.............................................................................................. 10
LITERATURE REVIEW..................................................................................... 10
2.1 Introduction........................................................................................... 10
2.2 Detector based control systems............................................................11
2.3 Microprocessor based systems..............................................................11
2.4 Microcontroller based systems..............................................................11
CHAPTER THREE........................................................................................... 11
MATERIALS AND METHODOLOGY..................................................................11
Introduction.................................................................................................. 11
3.1 The design.............................................................................................. 12
Figure 3.1: Block diagram of the automatic room light controller.............12
3.1.1 Hard ware component description......................................................12
3.1.1.1 Power Supply.................................................................................... 13
Figure 3.2 schematic illustrating bridge rectifier......................................13
3.1.1.2 Micro-controller................................................................................14
.................................................................................................................. 14

Figure 3.3 AT89C51 micro-controller........................................................14


Figure 3.5 quartz oscillator.......................................................................15
.................................................................................................................. 16
3.1.1.4 Infrared sensor (TSOP 1738)............................................................17
Figure 3.6 infrared sensor........................................................................17
3.1.1.5 Light dependent resistor (LDR)........................................................17
Figure 3.7 light dependent resistor..........................................................18
3.1.1.6 Analog to digital convertor (ADC).....................................................18
3.1.1.7 Relay Driver Circuit..........................................................................18
Figure 3.8 BC547 transistor......................................................................18
3.1.1.8 Relay................................................................................................ 19
.................................................................................................................. 19
Figure 3.10 Buzzer................................................................................... 19
3.1.2 Software component...........................................................................19
3.1.2.1 Proteus VSM..................................................................................... 20
3.1.2.2 Steps to draw schematic diagram...................................................20
3.1.2.3 Kiel Vision3..................................................................................... 21
3.2 Hardware or Circuit Design Development..............................................22
3.2.1 Relay to microcontroller interface circuit.............................................23
Figure 3.11: Schematic illustrating how to interface micro-controller pin to
a relay coil................................................................................................. 23
3.2.2 Infrared Sensor interface to micro-controller......................................23
3.2.3 Infrared receiver circuit......................................................................23
3.3 Software design development................................................................24
3.3.1 Proteus development..........................................................................24
Figure 3.12 final circuit for automatic room light controller with visitor
counter...................................................................................................... 24
3.3.2 Kiel Vision3.................................................................................... 24
3.3.3 Flowchart for the system software......................................................24
Figure 3.13 Flowchart for system software design....................................25
CHAPTER FOUR............................................................................................ 26
RESULT AND DISCUSSION.............................................................................26
Automatic room light controller with visitor counter system is an application
specific project, which is used to control room light and it also count the
number of visitors. An embedded system is designed which consist of an

AT89C51, IR sensor (transmitter and receiver,) Display, transistor, LDR and


relay............................................................................................................. 26
4.1 Automatic On-Off Switching device for Lighting Load............................26
..................................................................................................................... 27
Figure 4.2 System response schematic of the designed system when LDR
ON............................................................................................................. 27
4.2 Automatic visitor counter.......................................................................27
4.3 Testing and Implementation of C based program using Kiel Software....27
CHAPTER FIVE.............................................................................................. 28
CONCLUSION AND RECOMMENDATION.........................................................28
5.1 Conclusion.............................................................................................. 28
5.2 Recommendations for future work........................................................28
..................................................................................................................... 30
Appendices................................................................................................... 30

List of figures
Figure 1: Control system frame work............................................................................... 7
Figure 3.1: Block diagram of the automatic room light controller................................. 16
Figure 3.2 schematic illustrating bridge rectifier............................................................ 17
Figure 3.3 AT89C51 microcontroller.............................................................................. 19

Figure 3.4 Pin configuration of AT89C51.......................................................................19


Figure 3.5 quartz oscillator..............................................................................................21
Figure 3.5 schematic diagram and pin configuration of seven segment display.............22
Figure 3.6 infrared sensor................................................................................................24
Figure 3.7 light dependent resistor..................................................................................25
Figure 3.8 BC547 transistor............................................................................................ 26
Figure 3.9 relay switch....................................................................................................27
Figure 3.10 schematic diagram of dc motor....................................................................28
Figure 3.11: Schematic illustrating how to interface microcontroller pin to a relay coil 32
Figure 3.12 final circuits for automatic room light controller with visitor counter........35
Figure 3.13 Flowchart for system software design......................................................... 36
Figure 4.1 System response schematic of the designed system when LDR OFF...........39
Figure 4.2 System response schematic of the designed system when LDR ON.............40

Abbreviations
ADC

Analog to Digital convertor

CMOS

Complementary Metal Oxide Semiconductor

COM

common

CPU

central processing unit

IDE

integrated development environment

INTCON

interrupt control

IR

infrared radiation

LCD

liquid crystal display

NO

normally open

NC

normally close

PWM

pulse width modulation

RAM

read and write memory

ROM

read only memory

TSOP

thin small outline package

VSM

virtual system modeling

MCU

microcontroller unit

CHAPTER ONE
INTRODUCTION
1.1 Background of the study
The need for automation has come to stay and this date back to 1500 years when the
first water pump for metal working rolling mills for coinage strips was developed from
then till date the automation world has continued to grow extremely. Automation is the
art of making processes or machines self-acting or self-moving, it also pertains to the
technique of making a device, machine, process or procedure more fully automatic, it is
a self-controlling or self- moving processes. In todays world, there is a continuous

need for automatic appliances. With the increase in standard of living, there is a sense
of urgency for developing circuits that would ease the complexity of life. The energy
crisis is one of the major problems that the world needs to resolve for sustainable
economic development. Electrical energy lighting makes up the largest part of power
consumption in the world particularly through the use of lamps [1]. These lamps are
mainly controlled using ordinary switches that are manually operated. Sometimes the
intensity from outside is sufficient to illuminate the room therefore there is no need to
turn any light ON. Due to busy schedule and competitive world, human beings cannot
spare time to perform their daily activities manually. One of the most common things
that one forgets to do is switching OFF the lights whenever they are not required. This
leads to wastage of electrical power and an increase in the payment for such services
hence the need of some power management to save energy.
The importance of electrical energy is increasing everyday with the impact of
technological advancements [2]. The cost of investment made for generation,
transmission and distribution of electrical energy is quite high. For this reason it has
gained significant importance to use the electrical energy efficiently so as to minimize
the existing losses, to reduce the generation costs and to protect the environment by
reducing the consumption [3]. In most cases, energy waste does not occur because the
lamps are not fitted with energy efficiency systems but mainly because these devices
require manual operation, for instance the use of on/off switches to control the lights.
Energy efficiency systems have thus been a subject of interest to many researchers.
Many of these researchers have made great attempts in automating the energy efficiency
systems to be independent of human support. A few systems have been automated but
use microprocessors which require extra peripherals for the systems to work as
expected. The additional peripherals require more design space making these systems
bulky and more expensive. Microcontrollers have traditionally been programmed using
the low-level assembly language of the target processor [4]. This consists of a series of
instruction in the form of mnemonics. The disadvantage of assembly language is that
microcontrollers from different manufacturers have different assembly languages and
the user is forced to learn a new language every time a new processor is chosen.
Assembly language is also difficult to work with especially during the development,
testing and maintenance of complex projects. The solution to this is to use the high level

programming languages to program microcontrollers. The programming language used


in this work was C programming language due to its portability from one
microcontroller to another. In addition, the use of C simplifies the testing and
maintenance of microcontroller based systems.

In our home, school, colleges or industry we see that lights are kept on even if there are
nobody in the room or area / passage. This happens due to negligence or because we
forgot to turn lights off or when we are in hurry. To avoid all such situations we are
motivated to design project called Automatic room light controller with visitor
counter. This project has two modules, first one is known as Digital Visitor counter
and second module is known as Automatic room light controller. Main concept
behind this project is known as Visitor counter which count the number of persons
entering in any room like seminar hall, conference room, classroom.
1.2 Statement of the problem
Nowadays the wastage of electricity has become a routine thing for us, and the problem
has become frequent at homes, schools, and colleges and even in industries. Sometimes
we notice lights keep on working even in the absence of people in that area. This often
happens in homes, offices and public places due to negligence or by other problem.
Many times we need to monitor the person/people visiting some place like Seminar hall,
conference room or Shopping mall or museum. The we want to address the
aforementioned problem by doing a micro-controller based project that control the room
light and count the number of persons automatically. The study therefore seeks to
address the following question.

What parameters should be considered in the circuitry design part to meet the
specified aim?

What control parameter should be used to efficiently develop automatic room


light control with respect to its input and output relationship?

What are the evaluation parameters used to measure the performance,


acceptability and capabilities of the design before development of automatic
room light controller with visitor counter?

1.3 Objective of the study


1.3.1 General objective
The main objective of this research work is to design and simulate automatic room light
controller with visitor counter by using 8051 micro-controller.

1.3.2 Specific objective


Specifically the study would address the following objective:

To design a circuitry for an automatic On-Off switching device for the lighting
load ON/OFF in order to save electrical energy.

To design a circuitry for an Automatic counter to monitor the number of person


coming in and out the room.

To develop and implement a C based program to control AT89C51 microcontroller using the kiel software.

To integrate the design circuitry and software in order to simulate the function of
a basic automatic room light controller with visitor counter

To simulate the system to evaluate the overall performance by using appropriate


software

1.6 Significance of the project


The design and simulation of automatic room light controller with visitor counter is
used to develop a smart system which provide energy efficient and automatically
controlled room lighting. Moreover, it helps count the number of person present in the
room without human involvement. This project up on completion and successful
implementation play a crucial role in:

Various rooms like seminar hall, conference hall where the capacity of room is
limited and should not be exceeded by displaying the actual number of persons
inside the room

Hotel rooms to monitor the number of persons that enters the room when a
guest lodges, so to make sure they dont exceed number of visitors that are
allowed to lodge in a room

Class rooms, study rooms in colleges, to take count the accurate number of
students in the classroom and control the room light accordingly

Our homes because many times we come out of our bedroom or any other room
and we forgot to turn off the room light

Cinema halls to count the number of person entering inside. So that these places
should not get over crowded to avoid congestion.

To avoid locking in a person inside the room since it can display the number of
person in the LCD display.

1.7 Framework of the study


The control framework used in the study follows the input process output
relationship as shown in Table 1. Sensing devices are connected to the appropriate input
module of the micro-controller while output devices are connected to the designated
output module of the controller. Input & output devices are processed through the
micro-controller to the desired control outcome of the output devices.
Table 1: Control framework
Input
Sensors

Process
Micro-controller

Output
Relay

programming

seven segment

The study is anchored on the system framework as shown in Figure 1 where


input/output devices are connected to the microprocessor modules; system
programming in C-language is accomplished through an interfacing circuit.

Figure 1: Control system frame work

1.8 Scope of the study


The study covers the design, development and simulation of automatic room light
controller with visitor counter system by using micro-controller AT89C51 and c
programming language. However, to implement the physical hardware design there is a
shortage of material and money. The following are the scope of the project to make:
The control appliances must have an electrical interface in order to controlled by
the micro-controller
The receiver and the transmitting section of entrance and exit

must be

synchronized for perfect counting.


The display unit interface must always be monitored
The sensor must be active to count whenever an obstruction of the infrared
Light is blocked
The user to be familiar with numerical counting

1.9 Limitations of the project


Listed below are client-specified limitations:

It is used only when one single person, cuts the rays of the sensor hence it
cannot be used when two person crossing simultaneously

The only person who can communicate with the control module is the person
who is in the receptionist and security units

Only devices with electrical controlling input ports will be possible targets for
the project

If someone goes out from the entrance it would count as one, also if someone
goes comes in through the exit it would decrement one

Machine elements computational design and other mathematical functionality


model are not included in the study

1.10 Organization of project


In this project a clear out line has been provided with descriptions of each chapter are
given below: This report consists of 5 chapters. Chapter 1 gives an overview of the
entire project including statement of the problem, project objective, and project scope.
Chapter 2 reviews and related works with compression with system has been discussed.
Chapter 3 discusses on the design and development of the system selected to construct
automatic room light controller. In chapter 4, the result of each module displayed on
seven segment will be showed in picture and the software of embedded system design
of the final designs program flow is explained in detail. Chapter 5 summarizes
Conclusion and recommendations.

CHAPTER TWO
LITERATURE REVIEW
2.1 Introduction
This chapter reviews some reference from previous project, journal, articles, and
book and data sheets. A brief discussion of each work has been discussed and
critiques and limitation of each work are also explained. It highlights briefly some
of the light control designs that have been made using different control modules that
have been made previously.
2.2 Detector based control systems
It has been reported that lighting consumes more than 2000 terawatt-hours of
electricity globally and 48% of lighting electricity is attributed to the commercial
sector [5]. Various lighting control technologies have been developed for increased
energy efficiency, including daylight harvesting, occupancy sensing and light level
tuning. An excellent way of reducing lighting energy waste while enhancing lighting
quality is through the use of controls; Passive Infrared sensors (PIR) have been used
to eliminate wasted lighting in unoccupied spaces. In addition, manual dimmers
which allow occupants to adjust light levels to their preference are becoming more
affordable and can thus be incorporated into these lighting systems. Lighting
controls have shown to reduce lighting consumption by 50% in existing buildings
and by at least 35% in new construction [6]. It presented a lighting optimization
approach for open plan offices capable of tuning lighting to each occupants
preference. Each luminary was dynamically actuated at different levels to realize
various lighting configurations without any physical rewiring. The study used two
novel features: a versatile `plug and play` wireless networked sensing and actuation
system together with a control method incorporating multiple management
strategies to provide occupantspecific lighting. Although wireless technology has
been identified as promising, this system has exorbitant initial costs, including unit
price and installation. Wayne and Steve studied digital systems and noted that they
can perform the same lighting automation functions that independent, stand-alone
systems perform. They can override the set schedule to match the changes in
operating schedules and monitor occupancy patterns in an area and adjust the

operation of the lighting system as required. Handan

designed an intelligent

lighting control system with adjustable luminance, uniformity, correlated color


temperature (CCT) and duration and transition of different modes, whose control
strategy is based on ergonomic research. It is verified by ergonomic experiments
(study of designing equipment and devices that fit human body, its movements and
cognitive abilities) to be a suitable adjustable system to meet different situation of
human needs. Jinsoo proposed and designed an automatic standby power cutoff
outlet and a zigbee controller with Infra-Red code learning functionality. The
proposed power outlet monitored the power consumption for the predetermined time
and completely cut off the power supply when the monitored power was below the
threshold. Based on the zigbee controller, it plays a role of switches for the power
outlet and dimming lights. Ranjit used an infrared door sensor based on electronic
combinational logic circuit technology to develop an automatic light switching
system. The system was developed with safety environment when switching `ON`
or `OFF` the light during the room occupancy or unoccupancy. Apart from the
safety environment, it also comprises manual switching in case user needs to have
light during the day. Haskew proposed an optimal control strategy for a high voltage
DC light system using a direct current vector control method for different high
voltage dc control requirements, such as active power, reactive power and grid
voltage support control. A limitation of the conventional control mechanism was
analyzed through a theoretical study and computer simulation. In this study, closedloop control evaluation demonstrated that the proposed approach works well for
high voltage dc light system control both within and beyond the physical constraints
of the system, such as rated power and saturation of pulse width modulation
(PWM). The evaluation showed that the conventional control technique could result
in over-voltage and system oscillation. Changhong

designed a street smart

controller with dual functions including timing control and automatic photoelectric
control. The proposed system allowed street lamps to be automatically lit in the
evening, lighting the road for a few hours which was adjustable. After midnight,
when a few vehicles or pedestrians go past, it turned off automatically. It had a
terminal controller that had wake-up function. When the vehicles or pedestrians pass
through, the street lights are switched on by the terminal controller. The waste of

energy is a result of inefficient use of the electrical energy consumed by artificial


light devices such as light bulbs [1]. A system for saving electrical energy by
controlling the intensity of artificial light to a satisfactory level was designed and
took into account the use of the day light when possible with the best effort for
energy saving. An improvement to daylight harvesting and controlled dimming
systems was introduced while counting for over illumination cases. The idea behind
was to count the venetian blinds or curtains in such a way to make use of the
daylight if available. Otherwise it uses the artificial internal building light. The
system used a controller area network as the media of communication with the
sensors and the actuators. Wang and Devaney proposed an intelligent lighting
control system that was based on the CIE gamut standard and the dual-CPU
embedded system architecture. By employing light adjustment of the multi-colored
LED, color control and scene settings of the assembled light the intelligent light
control system with the graphic user interface and the touch control technology it
could be used in entertainment places.

2.3 Microprocessor based systems


The main aim of controlling energy consumption is to conserve resources as well as
reduce operational cost by avoiding wastage. The controls can be simple as
manually turning off a switch but often automated controls ranging from simple
combinational logic circuit to complex timing devices are employed. By moving
through the hierarchy of controls each level of automation and complexity requires
additional expenditure of capital. For instance the automated controls are more
expensive but are more flexible and offer reliable solutions compared to the manual
controls. Thomann and Younger proposed that computers can help energy managers
in the analysis of proposed and present energy systems. By using these computer
based systems, some excellent large scale computer simulation programs have been
written that enable the energy analyst to try alternative arrangement of energy
equipment and controls. Tien-shang and Chun-lin proposed a microprocessor based
dimming controller with both analog and digital interfaces to control dimming
ballasts through traditional toggle switches. The dimming ballasts have high
efficiency and contributes highly in energy saving. Bai and Ku designed a system

for light intensity detection and control using both microprocessor and light sensors.
In this design, the home light control module (HLCM) made up of four blocks; the
Passive Infrared (PIR) sensor circuit, microprocessor and radio frequency module
was installed in every light fixture.

2.4 Microcontroller based systems


A microcontroller is a computer integrated on a single chip. It has the processor,
memory and input/output devices on one chip unlike for a microprocessor whereby
these elements are provided as separate chips and are linked through bus
connections. Since the inception of microcontrollers, many researchers have come
up with various systems with single dedicated functions or embedded applications.
Hengyu

presented a street light controller system based on the AT89S52

microcontroller as the control core. The product combined the following


technologies: a digital clock, a timer, an LCD, a statistics of traffic flowing
magnitude, a photosensitive induction, an infrared control and alarm function. The
system also included a time cut-out function and an automatic control pattern for
even more electricity conserving, namely when vehicles passed by, the lights
switched on automatically and later switched off. The system implemented traffic
flow magnitude statistics without adding any hardware facilitating transportation
condition and information collection. The system also had auto-alarm function
which switched off if any light was damaged and showed the serial number of the
damaged light, thus being easy to be located and replaced. Chau-shing and
Changhua presented a light dimmer system that did not amplify light flicker on
incandescent lamps. The development of this dimmer was motivated by the fact that
the incandescent lamp is very sensitive to voltage fluctuation and the typical R-C
circuit dimmer for incandescent lamps amplifies the light flicker considerably. The
proposed method used 16-bit microcontroller to calculate the fluctuation voltage and
determine the appropriate firing angle for a power switch device in the circuit of the
dimmer. By dynamically adjusting the firing angle to compensate for the voltage,
the proposed dimmer could substantially diminish the light flicker. Most of the
current high power light emitting diode street lighting systems are designed for
illumination without any intelligent control and cannot adjust the illumination status

efficiently [6]. A few of the LED street lighting systems have intelligent control;
however, they can neither automatically detect the illumination management
systems nor adjust the systems manually. This phenomenon had been further
developed to home automation. In Ciubotaru-Petrescu, B., Chiciudean, D., Cioarga,
R., & Stanescu, D. , work problem with the implementation of home automation
systems were considered. Furthermore the possible solutions were devised through
various network technologies. Several issues affecting home automation systems
such as lack of robustness, compatibility issue and acceptability among older and
disabled people were also discussed. Besides, much were treated in papers by
Zungeru which consider the use of infrared rays to count the number of passengers
in a car and also remotely control home appliances via short message services.
Listed above literature review has some sort of drawback and also they have
advantaged technology which will incur cost. All of the journal only viewed that
automation of the room which have bidirectional door and they have limitation on
checking the presence of sufficient light in the room. To overcome this problem
further investigation is necessary. We modify the existing system by adding LDR
which differentiate the presence of sufficient light intensity in the room and great
attention had given to arrangement of the IR sensor. This system has advantages of
incurring low cost and suitable for any room which have either single door or more.

CHAPTER THREE
MATERIALS AND METHODOLOGY
Introduction
This chapter describes the methodologies used for the design of the hardware and
software parts. It begins by giving an overview of the automatic room light controller
and then describes how the specific hardware and the software for the system were
designed.

3.1 The design


This research aimed at designing a micro-controller based light energy and visitor
counter system. To achieve this, sensors that produced digital output were employed. In
this research, two types of sensors namely; LDR sensors and infrared sensors were
used. These sensors were connected directly to the micro-controller pins and acted as
the inputs to the system. For notification purposes, seven segment display was
employed to indicate room occupancy. The display was connected to port 2 and port 3
of AT89C51 micro-controller. A complete block diagram for the system is shown in
Figure 3.1. It is made up of a person counter circuitry, AT89C51 micro-controller, LDR
light sensor, a seven segment display and a relay circuitry. The person counter
comprises a pair of infrared transmitter and receiver which involves a wireless link. The
two sets are directly aligned such that the light pulse from the each transmitter falls on
the receiver. The receiver outputs are interfaced to port 1 of the AT89C51 which under
the control program stored in its memory displays the room occupancy on the seven
segment and makes decision on when to switch on/off the lights through a relay.

Figure 3.1: Block diagram of the automatic room light controller

3.1.1 Hard ware component description


The basic block diagram of the bidirectional visitor counter with automatic light
controller is shown in the above figure. Mainly this block diagram consists of the
following essential blocks.

Power Supply
Entry and Exit sensor circuit
AT 89C51 micro-controller
Relay driver circuit
Buzzer
Seven segment display

3.1.1.1 Power Supply


A regulated dc power supply is an electrical circuit that is designed to convert the 220V
AC mains electricity to a suitable low voltage supply for electronic circuits and other
devices. A regulated power supply can by broken down into a series of blocks, each of
which performs a particular function. +12V and +5V dc power supply were used as
source for different blocks. The main function of this block is to provide the required
amount of voltage to essential circuits. It consists of:
Rectifier unit
Filter
Regulator unit
Rectifier Unit
The Rectifier circuit is used to convert the 220v AC voltage into its corresponding DC
voltage. The efficient circuit used is the full wave Bridge rectifier circuit. The output
voltage of the rectifier is in rippled form, the ripples from the obtained DC voltage are
removed using other circuits available. The circuit used for removing the ripples is
called Filter circuit.

Figure 3.2 schematic illustrating bridge rectifier

Filter
Capacitors are used as filter. The ripples from the DC voltage are removed and pure DC
voltage is obtained. And also these capacitors are used to reduce the harmonics of the
input voltage.
Regulator Unit
Regulator regulates the output voltage to be always constant. The output voltage is
maintained irrespective of the fluctuations in the input AC voltage. As and then the AC
voltage changes, the DC voltage also changes. Thus to avoid this Regulators are used.
3.1.1.2 Micro-controller
Micro-controller is a general purpose device, which integrates a number of components
on to single chip. It has inbuilt central processing unit, both read only memory and
random access memory, parallel digital I/O peripherals to make it as a mini computer.
Micro-controllers are available in different configurations, low cost and Compacts. The
significant part of embedded system development is the designing of hardware and
software for the specific application. Microcontroller AT89C51 is the brain of this
system which takes input from the sensors, make decision based on the stored program
on its memory, control the output unit and having special features like 4KB of Flash
programmable and erasable read only memory (PEROM) and 128 bytes of RAM, 32
programmable I/O lines and eight interrupt sources. The microcontroller consists of a
timer module and an analog to digital converter to accept analogue input for data
processing. To make the data flow between controllers to other devices the serial I/O
port is used. It can be erased and program to a maximum of 1000 times.
AT89C51 microcontroller
The AT89C51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K
bytes of In-System Programmable Flash memory. The device is manufactured using
Atmels high-density nonvolatile memory technology and is compatible with the
industry-standard 80C51 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 In-System
Programmable Flash on a monolithic chip, the Atmel AT89C51 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many

embedded control applications. The AT89C51 provides the following standard features:
4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers,
two 16-bit timer/counters, a five-vector two-level interrupt architecture, a full duplex
serial port, on-chip oscillator, and clock circuitry. In addition, the AT89C51 is designed
with static logic for operation down to zero frequency and supports two software
selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,
timer/counters, serial port, and interrupt system to continue functioning. The Powerdown mode saves the RAM contents but freezes the oscillator, disabling all other chip
functions until the next external Interrupt or hardware reset.

Figure 3.3 AT89C51 micro-controller

Pin configuration:

Figure 3.4 Pin configuration of AT89C51


In 40 pin AT89C51, there are four ports designated as P 1, P2, P3 and P0. All these ports
are 8-bit bi-directional ports, i.e., they can be used as both input and output ports.
Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When
1s are written to these port pins, they are pulled high by the internal pull-ups and can be
used as inputs. These ports are also bit addressable and so their bits can also be accessed
individually.
Port P0 and P2 are also used to provide low byte and high byte addresses, respectively,
when connected to an external memory. Port 3 has multiplexed pins for special
functions like serial communication, hardware interrupts, timer inputs and read/write
operation from external memory.AT89C51 has an inbuilt UART for serial
communication. It can be programmed to operate at different baud rates. Including two
timers& hardware interrupts, it has a total of six interrupts.
Port 0: is a dual-purpose port on pins 32-39 of the 8051 1C. In minimum component
designs, it is used as a general purpose I/O Port. For larger designs with external
memory, it becomes a multiplexed address and data bus.
Port 1: is a dedicated I/O port on pins 1-8. The pins, designated as P1.0. P1.1. P1.2 etc.
are available for interfacing to external devices as required. No alternate functions are

assigned for Port 1 pins; thus they are used solely for interfacing to external devices.
Exceptions are the 8032/8052 ICs. Which use P1.0 and P1.1 either as I/O lines or as
external in outs to the third timer.
Port 2: (pints 21-28) is a dual purpose port serving as general purpose I/O, or as the
high byte of the address bus for designs with external code memory or more than 256
bytes of external data memory.
Port 3: is a dual purpose port on pins 10-17. As well as general purpose I/O, these
pins are multifunctional with each having an alternate purpose related to special features
of the 8051
PSEN: This is an output pin. PSEN stands for program store enable. In an 8031based system in which an external ROM holds the program code, this pin is connected
to the OE pin of the ROM.
VCC: Pin 40 provides supply voltage to the chip. The voltage source is +5V.
GND: Pin 20 is the Ground pin.
XTAL1 and XTAL2: The 8051 has an on-chip oscillator but requires an external clock
to run it. Most often a quartz crystal oscillator is connected to inputs XTALI (pin 19)
and XTAL2 (pin 18). The quartz crystal oscillator connected to XTAL1 AND XTAL2
also needs two capacitors of 30 pF value. One side of each capacitor is connected to the
ground as shown in this figure;

Figure 3.5 quartz oscillator


EA: The 8051 family members, such as the 8751, 89C51, or DS5000. All come with
on-chip ROM to store programs. In such cases, the EA pin is connected to VCC for
giving power to save and erase program from the memory.
RST (RESET): The RST input on pin 9 is the master rest for the 8051. This is used to
reset all the interfacing components as well as microcontroller circuit. When there are
any errors in the equipment for normal operation, RST is low.
ALE: (address latch enable) is an output pin and is active high. When connecting an
8051 to external memory, port 0 provides both address and data. In other words, the
8051 multiplexes address and data through port 0 to save pins. The ALE pin is used for
de-multiplexing the address and data by connecting to the G pin of the 74LS373 chip.
Now we will talk about what other things are inside an AT89C51 MCU.
Registers: In the CPU, registers are used to store information temporarily. That
information could be a byte of data to be processed, or an address pointing to the data to
be fetched. The vast majority of 89C51 register an address pointing to the data to be
fetched. The vast majority of 89C51 registers are 8-bit registers. In the 8051 there is
only one data type: 8 bits. The 8 bits of a register are shown in the diagram from the
MSB (most significant bit) D7 to the LSB (least significant bit) D0. With an 8-bit data
type, any data larger than 8 bits must be broken into 8-bit chunks before it is processed.
The most widely used registers of the 89C51 are A (accumulator), B, R0, R1, R2, R3,
R4, R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the above
registers are 8-bits, except DPTR and the program counter. The accumulator, register A,
is used for all arithmetic and logic instructions.
Features:

4K Bytes of In-System Programmable (ISP) Flash Memory

Endurance: 10,000 Write/Erase Cycles

4.0V to 5.5V Operating Range

Fully Static Operation: 0 Hz to 33 MHz

Three-level Program Memory Lock

128 x 8-bit Internal RAM

32 Programmable I/O Lines

Two 16-bit Timer/Counters

Six Interrupt Sources

Full Duplex UART Serial Channel

Low-power Idle and Power-down Modes

Interrupt Recovery from Power-down Mode

Dual Data Pointer

3.1.1.3 Seven segment display

Figure 3.5 schematic diagram and pin configuration of 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 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.
Features:
1. Common Anode
2. 0.52 Inch Digit Height
3. Continuous Uniform Segments
4. Low power Requirement
5. Excellent Characters Appearance

3.1.1.4 Infrared sensor (TSOP 1738)

Figure 3.6 infrared sensor


An infrared sensor is an electronic device that emits and/or detects infrared radiation in
order to sense some aspect of its surroundings. Infrared sensors can measure the heat of
an object, as well as detect motion. Many of these types of sensors only measure
infrared radiation, rather than emitting it, and thus are known as passive infrared (PIR)
sensors. The TSOP 1738 is a member of IR remote control receiver series. This IR
sensor module consists of a PIN diode and a pre amplifier which are embedded into a
single package. The output of TSOP is active low and it gives +5V in off state. When IR
waves, from a source, with a centre frequency of 38 kHz incident on it, its output goes
low. Lights coming from sunlight, fluorescent lamps etc. may cause disturbance to it
and result in undesirable output even when the source is not transmitting IR signals. A

band pass filter, an integrator stage and an automatic gain control are used to suppress
such disturbances. SOP module has an inbuilt control circuit for amplifying the coded
pulses from the IR transmitter. A signal is generated when PIN photodiode receives the
signals. This input signal is received by an automatic gain control (AGC). For a range
of inputs, the output is fed back to AGC in order to adjust the gain to a suitable level.
The signal from AGC is passed to a band pass filter to filter undesired frequencies. After
this, the signal goes to a demodulator and this demodulated output drives an NPN
transistor. The collector output of the transistor is obtained at pin 3 of TSOP module.
Features:

Photo detector and preamplifier in one package


Internal filter for PCM frequency
Improved shielding against electrical field disturbance
TTL and CMOS compatibility
Output active low
Low power consumption
High immunity against ambient light
Continuous data transmission possible

3.1.1.5 Light dependent resistor (LDR)


LDR is a device which senses the intensity of light. It generates analog signal up on
sensing light intensity. Light dependent resistors or LDRs are often used in circuits
where it is necessary to detect the presence or the level of light. An LDR or photo
resistor is made of any semiconductor material with a high resistance. It has a high
resistance because there are very few electrons that are free and able to move - the vast
majority of the electrons are locked into the crystal lattice and unable to move.
Therefore in this state there is a high LDR resistance. As light falls on the
semiconductor, the light photons are absorbed by the semiconductor lattice and some of
their energy is transferred to the electrons. This gives some of them sufficient energy to
break free from the crystal lattice so that they can then conduct electricity. This results
in a lowering of the resistance of the semiconductor and hence the overall LDR
resistance. The process is progressive, and as more light shines on the LDR
semiconductor, so more electrons are released to conduct electricity and the resistance

falls further. LDRs are very useful components that can be used for a variety of light
sensing applications.

Figure 3.7 light dependent resistor

3.1.1.6 Analog to digital convertor (ADC)


Analog-to-digitals converters are among the most widely used devices for data
acquisition. Digital computers use binary (discrete) values, but in the physical world
everything is analog (continuous).Temperature, Pressure (wind or liquid), humidity, and
velocity are a few examples of physical quantities that we deal with every day. A
physical is converted to electrical (voltage, current) signals using device called a
transducer. Transducers are referred to as sensors. Sensors for temperature, pressure,
light, and many other natural quantities produce an output that is voltage (or
current).Therefore, we need an analog-to-digital convertor to translate the analog
signals to digital numbers so that the microcontroller can read and process them. An
ADC has n-bit resolution where n can be 8,10,12,16 or even 24 bits. The higher
resolution ADC provides a smaller step size. In addition to resolution, conversion time
is another major factor in judging an ADC. Conversion time is defined as the time it
takes the ADC to convert the analog input to a digital (binary) number. The ADC
CHIPS either parallel or serial. In parallel ADC, we have only one pin for data
out.MAX1112 is a serial ADC chip.

3.1.1.7 Relay Driver Circuit


This block has the potential to drive the various controlled devices. In this block mainly
we are using the transistor and the relays. One relay driver circuit we are using to
control the light.
Transistor is a semiconductor device used to amplify and switch electronic signals and
electrical power. It is composed of semiconductor material with at least three terminals
for connection to an external circuit. The selected transistor for our project among
various types is BC547.
A BC547 transistor is a negative-positive-negative (NPN) transistor that is used for
many purposes. Together with other electronic components, such as resistors, coils, and
capacitors, it can be used as the active component for switches and amplifiers. Like all
other NPN transistors, this type has an emitter terminal, a base or control terminal, and a
collector terminal. In a typical configuration, the current flowing from the base to the
emitter controls the collector current. A short vertical line, which is the base, can
indicate the transistor schematic for an NPN transistor, and the emitter, which is a
diagonal line connecting to the base, is an arrowhead pointing away from the base.

Figure 3.8 BC547 transistor


Features

Collector-Emitter Volt (Vice): 45V

Collector Current (Ice): 0.1A

Power Dissipation (Pot): 625mW

Current-Gain-Bandwidth (total): 300MHz

Type: NPN

3.1.1.8 Relay
Relay is an electromagnetic device which is used to isolate two circuits electrically and
connect them magnetically. They are very useful devices and allow one circuit to switch
another one while they are completely separate. They are often used to interface an
electronic circuit (working at a low voltage) to an electrical circuit which works at very
high voltage. For example, a relay can make a 5V DC battery circuit to switch a 230V
AC mains circuit. Thus a small sensor circuit can drive, say, a fan or an electric bulb
a relay switch can be divided into two parts: input and output. The input section has a
coil which generates magnetic field when a small voltage from an electronic circuit is
applied to it. This voltage is called the operating voltage. Commonly used relays are
available in different configuration of operating voltages like 6V, 9V, 12V, 24V etc.
But, we want to use 12v relay .The output section consists of contactors which connect
or disconnect mechanically. In a basic relay there are three contactors: normally open
(NO), normally closed (NC) and common (COM). At no input state, the COM is
connected to NC. When the operating voltage is applied the relay coil gets energized
and the COM changes contact to NO. Different relay configurations are available like
SPST, SPDT, and DPDT etc., which have different number of changeover contacts. By
using proper combination of contactors, the electrical circuit can be switched on or off.

Figure 3.9 relay switch


3.1.1.9 BUZZER
A buzzer or beeper is an audio signaling device which may be mechanical,
electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm
devices, timers and confirmation of user input such as a mouse click or keystroke.

Figure 3.10 Buzzer

3.1.2 Software component


The software used in the project is
Proteus VSM
Kiel Vision3

3.1.2.1 Proteus VSM


ISIS provides the development environment for PROTEUS VSM. This product
combines mixed mode circuit simulation, micro-processor models and interactive
component models to allow the simulation of complete micro-controller based designs.
ISIS provides the means to enter the design in the first place, the architecture for real
time interactive simulation and a system for managing the source and object code
associated with each project. In addition, a number of graph objects can be placed on
the schematic to enable conventional time, frequency and swept variable simulation to
be performed. Proteus VSM combines a superb mixed mode circuit simulator based on
the industry standard SPICE3F5 with animated component models. And it provides an
architecture in which additional animated models may be created by anyone, including
end users. Indeed, many types of animated model can be produced without resort to
coding. It created a range of simulator models for popular micro-controllers and a set of
animated models for related peripheral devices such as LED and LCD displays,
keypads, an RS232 terminal and more. It is possible to simulate complete microcontroller systems and thus to develop the software for them without access to a
physical prototype.
Major Features Of PROTEUS VSM Include:
True Mixed Mode simulation based on Berkeley SPICE3F5 with extensions for
digital simulation and true mixed mode operation.
Support for both interactive and graph based simulation.

CPU Models available for popular microcontrollers such as the PIC and 8051
series.
Interactive peripheral models include LED and LCD displays, a universal matrix
keypad, an RS232 terminal and a whole library of switches, pots, lamps, LEDs
etc.
Virtual Instruments include voltmeters, ammeters, a dual beam oscilloscope and
a 24 channel logic analyzer
Graph Based Analysis types include transient, frequency, noise, distortion, AC
and DC sweeps and Fourier transform. An Audio graph allows playback of
simulated waveforms.

3.1.2.2 Steps to draw schematic diagram

To start the ISIS program, click on the Start button and select Programs,
Proteus 8 Professional and then the ISIS 8 Professional option. The ISIS
schematic editor will then load and run. Along the top of the screen is

the menu bar.


Pick the components you want to use from the device libraries by
selecting the component icon and then using the P button on the
Device Selector. You can use any component with a simulation model
and these parts are indicated at the top right of the schematic preview

before the device is select.


Left Click to enter placement mode, move the mouse to the point you

want to deposit the component and click left again to commit


Edit them - double click on the object or right click and select Edit
Properties from the resulting context menu - in order to assign

appropriate values and properties


Wire the circuit up by clicking on the pins
Delete components by right clicking on the component and selecting

Delete from the resulting context menu.


Move components by clicking left to select and then dragging with the

left button
Having selected the parts we need the next thing is to actually place
them on the drawing area the Editing Window and wire them
together

Animation: Interactive simulations are controlled from a simple VCR like panel that
behaves just like a normal remote control. This control is situated at the bottom right of
the screen.
Press the PLAY button to run the simulation
The STOP button to stop doing a real time simulation. All animation is stopped
and the simulator is unloaded from memory.
PAUSE button suspends the animation which can then be resumed either by
clicking the PAUSE button.
Micro-processor source code can be brought under the control of PROTEUS VSM
using the commands on the Source menu or imported via an object file from favourite
compiler to assign the object code (HEX) to the micro-processor component on the
schematic.

3.1.2.3 Kiel Vision3


The Vision3 IDE is a Windows-based software development platform that
Combines a robust editor, project manager, and makes facility. Vision3 integrates all
tools including the C compiler, macro assembler, linker/locator, and HEX file generator.
Vision3 helps expedite the development process of your embedded applications by
providing the following:

Full-featured source code editor,


Device database for configuring the development tool setting,
Project manager for creating and maintaining your projects,
Integrated make facility for assembling, compiling, and linking your embedded

applications,
Dialogs for all development tool settings,
True integrated source-level Debugger with high-speed CPU and peripheral

simulator,
Advanced GDI interface for software debugging in the target hardware and for
connection to Kiel LINK,

.
The Vision3 IDE offers numerous features and advantages that help quickly and
successfully develop embedded applications. A program has been developed according
to the connections given by the micro controller and required operation of the system is

converted to assembly language from embedded C language using Kiel Vision3. Steps
to Generate Hex File From .C File
Create Project File Folder and Specify Project Name:
To create a new project file select from the Vision3 menu Project New Vision
Project. This opens a standard Windows dialog that asks you for the new project file
name. You should you use a separate folder for each project.
Select Microcontroller from Device Database:
When you create a new project Vision3 asks you to select a CPU for your project. The
Select Device dialog box shows the Vision3 device database. Just select the
microcontroller you use.
Create New Source Files:
You may create a new source file with the menu option File New. This opens an
empty editor window where you can enter your source code. Vision3 enables the C
color syntax highlighting when you save your file with the dialog File Save As
under a filename with the extension *.C.
Add Source Files to Project:
Once you have created your source file you can add this file to your project.
Build Project:
You may translate all source files and link the application with a click on the Build
Target toolbar icon. When you build an application with syntax errors, Vision3 will
display errors and warning messages in the Output Window Build page. A double
click on a message line opens the source file on the correct location in a Vision3 editor
window.
Create HEX File:
Once you have successfully generated your application you can start debugging. After
you have tested your application; it is required to create an Intel HEX file to download
the software into an EPROM programmer or simulator. Vision3 creates HEX files with
each build process when Create HEX files under Options for Target Output is enabled.

3.2 Hardware or Circuit Design Development


The sensor unit consists of infrared diodes which are of two types: A transmitter and a
receiver. The infrared transmitter has the ability to transmit infrared beam but can only
travel in a rectilinear manner or a line of sight, which is received by the infrared
receiver at another end. The circuit has the ability to detect the passage of person
through the entrance and the exit of the gate only if the infrared beam is interrupted
from either side. Each pair of the sensor is separated by a reasonable distance such that
the passage of a person or other moving object cannot obstruct the sensor pair
separation. Also the height of the sensor is considered only the body of the person can
interrupt the light beam of the sensor and not the tires or its windows.
The hardware component of this system is made up of infrared sensors,
AT89C51microcontroller, LDR, relay, seven segment display and light bulb. For
schematic editing, Lab center ISIS which is a component of Proteus VSM was used.

3.2.1 Relay to microcontroller interface circuit


A relay is an electromagnetic switch that opens and closes under the control of another
electrical circuit. Since the relay can control an output circuit of higher voltage than the
input circuit it can be considered as a form of an electrical amplifier. When the microcontroller pin connected to the relay circuit goes high i.e. logic-1, current flows through
the relay coil and the resulting magnetic field attracts an armature that is mechanically
linked to a moving contact. This movement either makes or breaks a connection with a
fixed contact. On the contrary, when the microcontroller pin goes to logic-0, the current
to the coil is switched off and the armature is returned by a force approximately half as
strong as the magnetic force to its relaxed position. Since in this case the coil is
energized with DC, IN4001 diode was connected across the coil to dissipate the energy
from the collapsing magnetic field at deactivation, which would otherwise generate a
spike of voltage and may cause damage to circuit components. The relay switch
connections are usually labeled COM, NC, NO whereby:
i. COM Common, is the moving part of the switch
ii. NC- Normally Closed, COM is connected to this when the relay coil is off

iii. NO- Normally Open, COM is connected to this when the relay coil is on
AT89C51 microcontroller can only provide 25 mA on its pins hence the need of a
transistor to switch larger currents. The BC547 NPN transistor, Figure 3.10 was wired
as a switch and carries the current required for the operation of the relay. When the pin
P1.7 of the microcontroller goes high, the transistor BC547 turns on and current flows
through the relay. The diode connected across the relay contacts is used to protect the
transistor and microcontroller from back electromotive force generated in the relay coil.
The IN4001 also known as freewheeling diode was used as it is a fast switching diode
having a peak forward current of 450 mA (Horowitz, 1989). The switched circuit in this
design was to be ON when the relay coil is energized hence the COM was connected to
No contact otherwise the COM should be connected to NC.

Figure 3.11: Schematic illustrating how to interface micro-controller pin to a relay


coil

3.2.2 Infrared Sensor interface to micro-controller


The Infrared Sensor (IR) works by the piezoelectricity principle whereby certain
crystalline materials have the property to generate a surface electric charge when
exposed to thermal infrared radiation. Human body radiates heat in the form of infrared
radiation which is a maximum at a frequency of about 9.4 m. The presence of human
beings creates a sudden change in the surrounding that is sensed by the piezoelectricity
sensor. The IR sensor requires an initial stabilization of about 10 to 60 seconds in order
to get familiar with the surrounding environment and also function properly. Most of the
motion sensor modules have three pins namely:

i) VCC which is connected to positive power


ii) Output is the sensors output and in this case was connected to a microcontroller pin
to serve the purpose of an input. The sensor s output pin goes high when motion is
sensed and low if no motion is detected.
iii) Ground connected to the negative power
The output of the IR sensor module is monitored through the port 1 of the microcontroller. When motion is sensed, this output is high at about 3.8 V as depicted by the
3.8 V regulators IC on board in the IR detector module used. This voltage was used as a
valid logic high for the microcontroller. However, in order to get a full swing of the
logic voltages, the sensor output was employed to drive the base of BC547 NPN
transistor. The microcontroller here monitors the voltage at the collector of the
transistor. During normal condition, the transistor is cut off and the collector output is at
logic high i.e. +5 V. On sensing motion the high output from the sensor saturates the
transistor and the voltage at the collector drops down to logic low (0.2 V).

3.2.3 Infrared receiver circuit


The Infrared Receiver is used to receive infrared signals from an infrared transmitter
and also used for remote control detection. On the Infrared Receiver which is used to
get the infrared light emitted by the Infrared Emitter lies an IR detector. The IR detector
has a demodulator inside that looks for modulated IR at 38 kHz. The Infrared Receiver
can receive signals well within 10 meters. If more than 10 meters, the receiver may not
get the signals. The TSOP1738 which is a member of infrared remote control receiver
series was used in this study. This module helps us to reduce interference from other
natural IR signals from the environment. The IR sensor module consists of a pin diode
and a preamplifier which are embedded into a single package. Its output is active low in
that it gives +5 V in the off state. When IR waves from a source with a centre frequency
of 38 kHz is incident on it, its output goes low.
A single pole double throw (SPDT) relay is connected to port 1, pin 7 of the micro
controller through a driver transistor. The relay requires 12 volts at a current of around
100mA, which cannot provide by the microcontroller. So the driver transistor is added.
The relay is used to operate the external solenoid forming part of a locking device or for
operating any other electrical devices. Normally there relay remains off. As soon as pin

of the microcontroller goes high, the relay operates which lead to control the bulb if the
output of LDR is low.
3.3 Software design development
3.3.1 Proteus development
By using proteus the simulator model this project was designed and the appropriate
design code was loaded to run the simulation. It is possible to simulate the complete
micro-controller systems and thus to develop the software for them without access to a
physical prototype. The schematics in figure bellow was created using Labcenter ISIS
which is a component of Proteus VSM. Once the application has been installed and
opened, an edit screen appears whose main applications are:
1) Select components from library
2) Place and connect up components
3) Write a test program for the MCU
4) Attach to the MCU and simulate
5) Debug the program if necessary

Figure 3.12 final circuit for automatic room light controller with visitor counter
3.3.2 Kiel Vision3
The Vision3 IDE offers numerous features and advantages that help quickly and
successfully develop embedded applications. This program has been developed
according to the connections given by the micro controller and required operation of the
system is converted to assembly language from embedded C language using Kiel
Vision3.The program code was written in C using killer micro vision. The code
enables the output signals to be received, processed and a message sent to the output. In
the proposed circuit the lines 1, 2 and 3 of PORT1 were configured to act as inputs to
the system while PORT2, PORT3 and line 8 of PORT1 was used for output purposes.

3.3.3 Flowchart for the system software


In order to write the code to control the microcontroller operations, the following
algorithm which is illustrated in figure 3.13 in form of a flow chart was used.
Algorithm
If entrance sensor is interrupted first then the microcontroller will look for exit
sensor , and if it is interrupted then the microcontroller will open door through
the motor, increment the count and switch on the relay, if it is first time
interrupted and output of LDR is low.
If exit sensor is interrupted first then the microcontroller will look for
entrance sensor, and if it is interrupted then the microcontroller will open the
door and decrement the count.
When the last person leaves the room then counter goes to 0 and that time the
microcontroller will close the room and turn off the relay.

Figure 3.13 Flowchart for system software design


3.4 Code development
The program code was written as text file and converted to a machine code using the
integrated development environment (IDE). It is a comprehensive editor, project
manager and design desktop for application development of embedded designs using
8051 microcontrollers. Once the code is compiled, a hex file is obtained which is
burned into the program memory of the micro-controller chip. This process involves the
steps that are described below
i) Kiel software is first opened and name is given to the new micro vision project from
the device list atmel is selected and inside atmel AT89C51is selected.
ii) A new project file is then created and a project directory selected where the necessary
files needed for the project are stored.
iii) A summary of the project parameters is then outlined on the next window

iv) The project is then given a name and a project directory selected where the
necessary files needed for the project are stored.
v) A new file is opened from the file menu where the program code is then written and
saved with .c file extension. A new window with .uvproj file extension opens and
the c file created earlier on is added to the source file on this window.
vi) Once this is complete the project is built by selecting Build option from the
project menu or by pressing F10. If there are no errors in the code a message Build
Successful is displayed. Here the compiler generates a hex file which is burned to the
memory using the micro-controller. Once the application has been installed and opened,
an edit screen appears whose main applications are:
1) Select components from library
2) Place and connect up components
3) Write a test program for the MCU
4) Attach to the MCU and simulate
5) Debug the program if necessary

CHAPTER FOUR
RESULT AND DISCUSSION
Automatic room light controller with visitor counter system is an application
specific project, which is used to control room light and it also count the number of
visitors. An embedded system is designed which consist of an AT89C51, IR sensor
(transmitter and receiver,) Display, transistor, LDR and relay.
4.1 Automatic On-Off Switching device for Lighting Load
Case 1. When there is no person inside the room
When neither the entrance nor exit sensor is pressed the micro-controller
understand that no one has entered the room which results the seven segment value to
be zero and the relay is off.
Case 2. When the light Intensity is High.
When the entrance switch was pressed for the first time and LDR switch was
OFF ,the micro-controller understand that someone want to enter the room and the
intensity of light is sufficient in the room. Which results the motor to rotate clockwise to
open then anticlockwise to close the door with in some time delay and count which
displayed on the seven segments was incremented by one also relay was deactivated
thus, the light in the room deactivate as shown in figure 4.1 bellow.

Figure 4.1 system response schematic of the designed system when LDR off
Case 3 When the Light Intensity is Low
When the entrance switch was pressed for the first time and LDR switch was
ON, the micro-controller understand that someone want to enter the room and the
intensity of light inside the room is in efficient . Which results the motor to rotate
clockwise to open then anticlockwise to close the room with some time delay, count to
be incremented and the relay was activated which turn ON the room light as shown in
figure 4.2 bellow.

Figure 4.2 System response schematic of the designed system when LDR ON

4.2 Automatic visitor counter


In order to count the number of persons accessing the controlled room, a person
counter circuit comprising a pair of infrared transmitter and receiver was used. They
were arranged in a manner such that for one to enter the controlled room, both sets of
sensors must be cut subsequently. If the entrance sensor is traversed first then counter is
incremented indicating that someone has entered the room under surveillance and the

count is shown on the seven segment display as shown in figure 4.3. On the contrary,
when Exit sensor is traversed, then the counter decremented by one which is also shown
on the 7 segment display as shown in figure 4.4.

4.3 Testing and Implementation of C based program using Kiel Software


The software realization of the system is very vital. This is where the fantasy of
the whole idea meets reality. C code were tested and implemented by using the
following steps described in chapter 3.
C code were also implemented. Details of C code (please see appendix 1)
4.4 Integrating the design circuitry and software
Simulation using Proteus virtual system modelling (VSM) whereby the source code file
obtained from the development environment was added to the AT89C51 microcontroller program memory and the simulation initiated. The following steps were
implemented:
1) Select components from library
2) Place and connect up components
3) Write a test program for the MCU
4) Attach to the MCU and simulate
5) Debug the program if necessary
4.5 Simulating the system
By simulating the design circuitry and software the entire system are working
well and it gives the desired objectives. We have seen our work not just on paper but
also evaluated well by using the appropriate software. After carrying out all the paper
design and analysis, the project was working properly.

CHAPTER FIVE
CONCLUSION AND RECOMMENDATION
5.1 Conclusion

A simple, cheap, portable and micro-controller based automatic room light


controller required for saving electrical energy and to change the manual system to
automatic has been designed and simulated.
An entry/exit sensing unit that uses two sets of infrared transmitter and receiver
for determining the number of people accessing the controlled room has also been
designed.
The Kiel Integrated Development Environment has been used to write, develop
and debug codes for the AT89C51 micro-controller with Proteus ISIS being used for
simulating the designed circuits.
The system integrates infrared transmitter and receiver, light intensity detector,
AT89C51 micro-controller, relay control circuit and seven segments as output module.
The designed system managed to acquire three inputs from sensors and based on
the code stored in the micro-controller program memory, count displayed on seven
segments was incremented or decremented with activation or deactivation of relay
driver.
If the pulse from the first set of transmitter-receiver is cut then followed by
insufficient light intensity, this was processed by the micro-controller and registered on
the seven segments as an inward count. Upon which the controlled lights go ON.
When second pair of infrared transmitter - receiver is cut first milliseconds
followed by pair one, an outward count is registered. With the counter being equal or
greater than one, the status of the IR sensor output pin is monitored. Finally, if no one
present in the room seven segments show zero value and relay driver was deactivated.
The time delay transitions for the designed system can also be modified in the
program code for it to suit different user preferences. With achievement of all the
objectives of this research, we can conclude that the system is reliable, compact and
portable hence can be employed in light energy control operations to help limit electric
energy wastage and to count number of person in a room automatically and accurately.

5.2 Recommendations for future work


Though the designed system was able to automate a room, a few developments can be
made on it to be more robust. These involve;
Extending the system to include a room with multiple exits/entrances by
employing several sensors. This arrangement would require installation of
multiple pairs of transmitter-receiver sensors and a logical combination of the
outputs. In addition motion detectors with a higher resolution can be integrated
in the system to improve on the system robustness. This can be achieved by
using detectors with a wider field of view and longer detection distance. This
would be suitable for multiple door access and higher detection rates of
occupants to evolve a more reliable system.
In daytime natural light may be sufficient if the room has a suitable
architectural design and less artificial light would be needed. In such a
situation, photo detectors can be interfaced to the system to provide the user
with override option and also allow one to select the preferred light intensity for
a particular task.
By adding proper power supply this system can be implemented for various
applications Such as fans.

Reference
[1] Matta S. and Mahmud S. (2010). An intelligent light control system for power
saving,in the proceedings of the 36th Annual Conference on IEEE Industrial Electronics
Society, 3316-3321. Glendale. (USA)
[2] Gunturkun, R. (2003). Feedforward and Elman Feedback Harmonics Compensation
Using Artificial Neural Networks. PhD thesis, Graduate School of Natural and Applied
Sciences, Sakarya. Turkey
[3] Dermikol, O. (2006). Measurement and Compensation in with Harmonic and
unbalanced Network. Master thesis, Graduate school of Natural and Applied Sciences,
Sakarya. Turkey
[4] Dogan, I. (2006). Microcontroller Projects in C for the 8051: Newness. Oxford.
[5] Changhong S., Wu Y., Zhang X. and Yang W. (2010). Design of new intelligent
street light control system. 8th IEEE International Conference on Robotics & Control
Systems: 1423-1427, Xiamen.
[6] Niu M. and Qin H. (2012). Design of LED street lamps intelligent control system
based on PIC microcontroller, Hangzou.

Appendices
The software program loaded into the micro controller
/*--------------------------------------------------------------------------------------------------*/
/* Program Name: AUTOMATIC ROOM LIGHT CONTROLLER */
/* Name of Author: INDUSTRIAL CONTROL GROUP 10*/
/* ELECTRICAL AND COMPUTER ENGINEERING DEPARTEMENT*/
/* DEBRE MARKOUS UNIVERSITY */
/* JUNE 2015 */
/*--------------------------------------------------------------------------------------------------*/
/* the code displays status of room occupancy in a controlled room. Based on the count
and status of the infrared sensor output, the lights are switched on and off automatically
and the status of the room occupancy is shown on the seven segment

*/

/*-------------------------------------------------------------------------------------------------*/
#include <reg51.h>

// header file

sbit SENIN=P1^0;

//declaration for enterance sensor

sbit SENOUT=P1^1;

//declaration for exit sensor

sbit LDR=P1^2;

//declaration for LDR sensor

sbit RELAY=P1^7;

//declaration for relay interface

sbit open=P1^4;

// input for Dc motor

sbit close=P1^5;

//input for DC motor

/*-----------------------------------DELAY FUNCTION--------------------------*/
void delay (int a)

{
unsigned int i,j;
for(i=0;i<a;i++)
for(j=0;j<1275;j++);
}
/*-----------------------------------MAIN FUNCTION---------------------------*/
void main ()
{

/*array used for storing hexa code of number 0 to 9 */


int array[]={0xFC,0x60,0xDA,0xF2,0x66,0XB6,0xBE,0xE0,0xFE,0xF6};

int m,n,o;
while(1)

// never ending loop

{
n=0;
while(n<10)
{
m=n/10;
o=n%10;
P2=array[m];
//data pin of P2 are connected to seven segment 1 pin
P3=array[o];
// data pin of P3 are connected to seven segment 2 pin

delay(150);

//call delay function

//code when person enter from out side


if(SENIN==0&&SENOUT==1)
{
n++;

// increment counter ( if person enter )


open=1;

//open motor

close=0;

//close motor

delay(60);

//call delay function

open=0;

//open motor

close=1;

//close motor

delay(60);

//call delay function

open=1;

//stop motor

close=1;

}
//code when person exit from in side
else if(SENIN==1&&SENOUT==0)
{
if(n>0)
{

// decrement count if it is greater than one


n--;
open=1;
close=0;
delay(60);
open=0;
close=1;
delay(60);
open=1;
close=1;

}
else
//when person enter as well as exit from the gate no change happen
{
n=n;
open=1;
close=1;
}
}

if(n>0&&LDR==0)

{
/*relay ON when light intensity is low and count
RELAY=1;

greater than or equal to one*/

}
else if(n>0&&LDR==1)
{
RELAY=0;

//relay OFF when light intensity is sufficient

}
else if(n==0)
{
RELAY=0;
}
else if(n>=10)

//stop when count equal to 10

{
open=1;
close=1;
}

//END OF OUTER WHILE LOOP

//END OF INNER WHILE LOOP

//END OF MAIN FUNCTION


/*----------------------------------------END-----------------------------------------*/

You might also like