Sie sind auf Seite 1von 105

AUTOMATIC ROOM LIGHT CONTROLLER WITH

BIDIRECTIONAL VISITOR COUNTER

MINI PROJECT REPORT

Carried out in the partial fulfillment of the requirements for the award of
B. Tech Degree of Mahatma Gandhi University, Kottayam

Submitted by

Ms. AFIYA M RAJ


Mr. ALWIN SAM
Ms. ANSU RACHEL ISSAC
Ms. KAVYA KRISHNAN. K
Ms. SHARANYA. S

Under the Guidance


Of

Er. REMYA KAMALAS


Lecturer in ECE Department

Caarmel Engineering College

DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
DEC-MAY 2013
Caarmel Engineering College
Perunad, Pathanamthitta

CERTIFICATE

Certified that this is the bonafide report of the mini project work
Titled “AUTOMATIC ROOM LIGTH CONTROLLER WITH BIDIRECTECTIONAL VISITOR
COUNTER” submitted by

Ms. AFIYA M RAJ (2010-2014 Batch, Register No.10003143)


Mr. ALWIN SAM (2010-2014 Batch, Register No.10003148)
Ms. ANSU RACHEL ISSAC (2010-2014 Batch, Register No.10003151)
Ms. KAVYA KRISHNAN. K (2010-2014 Batch, Register No.10003167)
Ms. SHARANYA. S (2010-2014 Batch, Register No.10003187)

in the partial fulfillment of the requirements for the award of B. Tech Degree in Electronics &
Communication Engineering of M.G University, Kottayam.

Guide Prof. Ajay V.G


Er. Remya Kamalas Head of the Department
Lecturer in ECE department Department of ECE
Caarmel Engineering College Caarmel Engineering College
Perunad, Kerala Perunad, Kerala

Presented to the panel of examiners of Mahatma Gandhi University for


evaluation during June 2013

Internal Examiner External Examiner


ACKNOWLEDGEMENT

We owe our heartfelt gratitude to The GOD Almighty for all blessings he has showered
upon us during this humble endeavor.

We take this opportunity to thank the Management of Caarmel Engineering College,


Pathanamthitta for extending us with adequate facility.

We would like to express thanks to The Principal for all the facilities extended to us in
accomplishing the project.

We express our sincere thanks to The HOD, Department of ECE, for all his unparallel
guidance, relevant suggestions and motivation.

We are greatly indebted to our Project Guide Er. Remya Kamalas, Lecturer,
Department of ECE, for all facilities extended to us in accomplishing this project.

Finally, we offer our deep felt gratitude to our lecturers, friends and family members
without whom this project wouldn’t have been a reality.

Thanking You…………..
ABSTRACT

This Project “Automatic Room Light Controller with Visitor Counter using Microcontroller”
is a reliable circuit that takes over the task of controlling the room lights as well us counting number of
persons/ visitors in the room very accurately. When somebody enters into the room then the counter is
incremented by one and the light in the room will be switched ON and when any one leaves the room
then the counter is decremented by one. The light will be only switched OFF until all the persons in
the room go out. The total number of persons inside the room is also displayed on the LCD displays.

The PIC16F887 microcontroller does the above job. It receives the signals from the IR
sensors and this signal is operated under the control of software which is stored in ROM.
Microcontroller continuously monitor the Infrared Receivers.
CONTENTS

1) INTRODUCTION
2) HARDWARE DESCRIPTION
 PIC16F887 Microcontroller
 LCD Display
 IR pairs
 Relay
 Power supply Module

3) CIRCUIT DIAGRAM AND DESCRIPTION


 Circuit Diagram
 Block Diagram
 Working

4) SOFTWARE DESCRIPTION
 MP Lab
 Hi-Tech C
 Flowchart
 Program
 PCB Design and Layout

5) ADVANTAGES AND APPLICATION


6) FUTURE ENHANCEMENT
7) CONCLUSION
8) BIBILOGRAPHY
AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

INTRODUCTION

The project title is “AUTOMATIC ROOM LIGHT CONTROLLER WITH BIDIRECTIONAL


VISITER COUNTER”

Electricity is one of the most important resources in this century. We should conserve the
electricity. But many times we come outside the room and forget to turn off the lights/fan, thus the
electricity is wasted.

To overcome this we are going to implement a project called “Automatic room light controller
with bidirectional visitor counter”. This project has 2 modules. First module is “Bidirectional Visitor
counter” and the other module is “Automatic room light controller”. Main concept behind this project is to
measure and display the number of persons entering in any room like seminar hall, conference room. And
when number of persons inside the room is zero, power supply inside the room can be cut using a relay
interface. This will help to save electricity. LCD display placed outside the room displays number of person
inside the room. Also if at all one wants to know the number of people present in room so as not to have
congestion, this circuit proves to be helpful.

DEPT. OF ECE 1 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

HARDWARE DESCRIPTION

The main parts of this circuit are:

 Micro-controlling unit PIC16F887


 LCD display
 IR pair
 Relay
 Power supply module

 PIC 16F887 MICROCONTROLLER


This powerful yet easy-to-program (only 35 single word instructions) CMOS FLASH-based 8-bit
microcontroller packs Microchip's powerful PIC® architecture into a 40 or 44-pin package. The PIC16F887
features 256 bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 14 channels of
10-bit Analog-to-Digital (A/D) converter, 1 capture/compare/PWM and 1 Enhanced capture/compare/PWM
functions, a synchronous serial port that can be configured as either 3-wire Serial Peripheral Interface
(SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus and an Enhanced Universal Asynchronous
Receiver Transmitter (EUSART). All of these features make it ideal for more advanced level A/D
applications in automotive, industrial, appliances or consumer applications

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from
the PIC1640[1] originally developed by General Instrument’s Microelectronics Division. The name PIC
initially referred to “Peripheral Interface Controller”.

It is available in different configuration via 8bit, 16bit, 32bit with instruction set as given below:

Under 8 bit comes: PIC10xxxx, PIC12xxxx, PIC16xxxx, PIC18xxxx. (12 bit instruction set)

Under 16 bit comes: PIC24H, DSPIC30, DSPIC33. (14 bit instruction set)

Under 32 bit comes: PIC32xxxx. (16 bit instruction set)

PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide
availability, large user base, extensive collection of application notes, availability of low cost or free
development tools , and serial programming (and re-programming with flash memory) capability.

Special Microcontroller Features:

High-Performance RISC CPU:

• Only 35 Instructions to Learn:


- All single-cycle instructions except branches
• Operating Speed:
- DC – 20 MHz oscillator/clock input
- DC – 200 ns instruction cycle
• Interrupt Capability
• 8-Level Deep Hardware Stack
• Direct, Indirect and Relative Addressing modes

• Precision Internal Oscillator:

DEPT. OF ECE 2 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

- Factory calibrated to ±1%


- Software selectable frequency range of
8 MHz to 31 kHz
- Software tunable
- Two-Speed Start-up mode
- Crystal fail detect for critical applications
- Clock mode switching during operation for
Power savings
• Power-Saving Sleep mode
• Wide Operating Voltage Range (2.0V-5.5V)
• Industrial and Extended Temperature Range
• Power-on Reset (POR)
• Power-up Timer (PWRT) and Oscillator Start-up
Timer (OST)
• Brown-out Reset (BOR) with Software Control
Option
• Enhanced Low-Current Watchdog Timer (WDT)
with On-Chip Oscillator (software selectable
nominal 268 seconds with full prescaler) with
software enable
• Multiplexed Master Clear with Pull-up/Input Pin
• Programmable Code Protection
• High Endurance Flash/EEPROM Cell:
- 100,000 write Flash endurance
- 1,000,000 write EEPROM endurance
- Flash/Data EEPROM retention: > 40 years
• Program Memory Read/Write during run time
• In-Circuit Debugger (on board)

Low-Power Features:
• Standby Current:
- 50 nA @ 2.0V, typical
• Operating Current:
- 11μA @ 32 kHz, 2.0V, typical
- 220μA @ 4 MHz, 2.0V, typical
• Watchdog Timer Current:
- 1μA @ 2.0V, typic

Peripheral Features:
• 24/35 I/O Pins with Individual Direction Control:
- High current source/sink for direct LED drive
- Interrupt-on-Change pin
- Individually programmable weak pull-ups
- Ultra Low-Power Wake-up (ULPWU)
• Analog Comparator Module with:
- Two analog comparators
- Programmable on-chip voltage reference
(CVREF) module (% of VDD)
- Fixed voltage reference (0.6V)
- Comparator inputs and outputs externally
accessible
- SR Latch mode
- External Timer1 Gate (count enable)

DEPT. OF ECE 3 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

• A/D Converter:
- 10-bit resolution and 11/14 channels
• Timer0: 8-bit Timer/Counter with 8-bit
Programmable Prescaler
• Enhanced Timer1:
- 16-bit timer/counter with prescaler
- External Gate Input mode
- Dedicated low-power 32 kHz oscillator
• Timer2: 8-bit Timer/Counter with 8-bit Period
Register, Prescaler and Postscaler
• Enhanced Capture, Compare, PWM+ Module:
- 16-bit Capture, max. resolution 12.5 ns
- Compare, max. resolution 200 ns
- 10-bit PWM with 1, 2 or 4 output channels,
programmable “dead time”, max. frequency
20 kHz
- PWM output steering control
• Capture, Compare, PWM Module:
- 16-bit Capture, max. resolution 12.5 ns
- 16-bit Compare, max. resolution 200 ns
- 10-bit PWM, max. frequency 20 kHz
• Enhanced USART Module:
- Supports RS-485, RS-232, and LIN 2.0
- Auto-Baud Detect
- Auto-Wake-Up on Start bit
• In-Circuit Serial Programming TM (ICSPTM) via Two
Pins
• Master Synchronous Serial Port (MSSP) Module
supporting 3-wire SPI (all 4 modes) and I2C™
Master and Slave Modes with I2C Address Mask

DEPT. OF ECE 4 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

PINDIAGRAM OF PIC 16F887

DEPT. OF ECE 5 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 LCD DISPLAY

One of the most common devices attached to a microcontroller is an LCD display. Some of the most
common LCDs used are 16x2 and 20x2 displays. This means 16characters per line by 2 lines and 20
characters per line by 2 lines, respectively. In recent years the LCD is finding widespread use replacing
LED’s. This is due to the following reasons

1. Declining prices
2. Ability to display numbers, characters and graphics.
3. Incorporation of a refreshing controller into the LCD.
4. Ease of programming.

Fortunately, a very popular standard exists which allows us to communicate with the vast majority of
LCDs regardless of their manufacturer. The standard is referred to asHD44780U, which refers to the
controller chip which receives data from an external source (in this case, the PIC16F887) and communicates
directly with the LCD. The 44780standard requires 3 control lines as well as either 4 or 8 I/O lines for the
data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-
bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data
bus). If an 8-bit data bus is used the LCD will require a total of 11data lines (3 control lines plus the 8 lines
for the data bus).

Table 2.1: Pin Configuration of LCD

1) Important Signals
The following pins are important to LCD’s while programming

1.1) Enable (EN)


The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data.
To send data to the LCD, your program should make sure this line is low (0) and then set the other two
control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1)
and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD),
and end by bringing it low (0) again.

DEPT. OF ECE 6 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

1.2) Register Select (RS)


The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command
or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is
text data which should be displayed on the screen. For example, to display the letter "T" on the screen you
would set RS high.
1.3) Read/Write (R/W)
The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is
being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD.
Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will
almost always be low. Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation
selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3,
DB4, DB5, DB6, and DB7.Above are the quite simple schematic. The LCD panel's Enable and Register
Select is connected to the Control Port. The Control Port is an open collector / open drain output. While
most Parallel Ports have internal pull-up resistors, there is a few which don't. Therefore by incorporating the
two 10K external pull up resistors, the circuit is more portable for a wider range of computers, some of
which may have no internal pull up resistors.

We make no effort to place the Data bus into reverse direction. Therefore we hard wire the R/W line
of the LCD panel, into write mode. This will cause no bus conflicts on the data lines. As a result we cannot
read back the LCD's internal Busy Flag which tells us if the LCD has accepted and finished processing the
last instruction. This problem is overcome by inserting known delays into our program. The 10k Pot controls
the contrast of the LCD panel.

Table 2.2: Control Codes of LCD

DEPT. OF ECE 7 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 IR PAIR
Infrared radiation is the portion of electromagnetic spectrum having wavelengths longer than visible
light wavelengths, but smaller than microwaves, i.e., the region roughly from 0.75µm to 1000 µm is the
infrared region. Infrared waves are invisible to human eyes. The wavelength region of 0.75µm to 3 µm is
called near infrared, the region from 3 µm to 6 µm is called mid infrared and the region higher than 6 µm is
called far infrared. IR is widely used as sensor for detecting various parameters. In this project we use an IR
pair as human sensing unit. We use a break beam IR sensor. This type of sensors consists of a pair of light
emitting and light detecting elements. Infrared source transmits a beam of light towards a remote IR receiver
creating an “electronic fence”. Once a beam is broken/ interrupted due to some opaque object, output of
detector changes and associated electronic circuitry takes appropriate actions.

Figure 3.1

Principle:

IR LED emits infrared radiation. This radiation illuminates the surface in front of LED. Surface reflects
the infrared light. Depending on reflectivity of the surface, amount of light reflected varies. This reflected
light is made incident on reverse biased IR sensor. When photons are incident on reverse biased junction of
this diode, electron-hole pairs are generated, which results in reverse leakage current. Amount of electron-
hole pairs generated depends on intensity of incident IR radiation. More intense radiation results in more
reverse leakage current. This current can be passed through a resistor so as to get proportional voltage. Thus
as intensity of incident rays varies, voltage across resistor will vary accordingly.

This voltage can then be given to OPAMP based comparator. Output of the comparator can be read by
uC. Alternatively, we can use on-chip ADC in microcontroller to measure this voltage and perform
comparison in software. Here we regulated the voltage of IR receiver to +5v using suitable resistor and
directly gave the IR output to microcontroller’s input

IR LED and IR sensor:

IR LED is used as a source of infrared rays. It comes in two packages 3mm or 5mm. 3mm is better as it is
requires less space. IR sensor is nothing but a diode, which is sensitive for infrared radiation. This infrared
transmitter and receiver are called as IR TX-RX pair or simply IR PAIR.

Figure 3.2

DEPT. OF ECE 8 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

RELAY

A relay is an electromechanical device that is actuated by an electrical current. The current flowing in
one circuit causes the opening or closing of another circuit. Highly sophisticated relays are utilized to protect
electric power systems against trouble and power blackouts as well as to regulate and control the generation
and distribution of power. In the home, relays are used in different appliances like refrigerators, washing
machines and dishwashers, and heating and air-conditioning controls. Every relay contains a sensing unit,
the electric coil, which is powered by AC or DC current. When the applied current or voltage exceeds a
threshold value, the coil activates the armature, which operates either to close the open contacts or to open
the closed contacts. When a power is supplied to the coil, it generates a magnetic force that actuates the
switch mechanism. The magnetic force is, in effect, relaying the action from one circuit to another. The first
circuit is called the control circuit while the second is called the load circuit.

There are three important functions of a relay: On/Off Control, Limit Control and Logic
Operation.
On/Off Control: Example: Air conditioning control, used to limit and control a “high power” load, such as
a compressor
Limit Control: Example: Motor Speed Control, used to disconnect a motor if it runs slower or faster than
the desired speed
Logic Operation: Example: Test Equipment, used to connect the instrument to a number of testing points
on the device under test

There are two basic types of relays: Electromechanical and Solid State. Electromechanical
relays have moving parts, whereas solid state relays have no moving parts.

Relay Board: - The relay board is what powers the switching mechanics on our electronic devices. It contains a
power supply circuit, regulatory circuitry and of course the relays that we need to turn parts or all of our device
(or devices) on and off – or to switch them between states. Normally speaking, the relays on our relay board will
be solid state, unlike the mechanical relays that we may see in larger electrical applications (like, for example,
the switch you throw to turn off a phased power relay, or the breakers in our home’s circuitry). Solid state relays
are reliable over a longer term than electro mechanical relays thanks to the simple fact that they have no moving
parts (hence the name solid state), which means of course that nothing can seize up or break off and prevent
successful operation. The SSR on our relay board contain a transistor or a number of transistors, through which
the switch of state is made.

The basic function of the relays on our relay board is to flick between one or several poles. This is
done by throwing contacts between them (“pole” and “throw” are the electrical switching terms we’re interested
in here). Most of the terminology describing the state of the contacts in our relay board is compressed into
acronymic form: NO (Normally Open); NC (Normally Closed); and Change Over or Double Throw (referred to
either as CO or DT, both of which mean the same thing).

A Normally Open contact is one that is usually disconnected – so in its resting or inactive state the contact is
open. A Normally Closed contact has the opposite characteristic: in its resting state the circuit is connected and
active because the relay has closed on the contact. A Change Over or Double Throw contact connects two linked
circuits – one Normally Open and the other Normally Closed. The switch on our relay board throws the pole
between the Normally Open and the Normally Closed circuit when the switch is activated. The functions of the
switches on our relay board depend (naturally) on our application. In general terms they are commonly used to
increase power where there is a weak power source (amplification, usually of a signal); to isolate a controlled and
controlling circuit from each other; to switch to a standby power state; to implement a time delay; or to control
logic within our electronic circuitry. A series of Normally Open contacts on a relay board is equal to AND; a
parallel connection of Normally Open contacts becomes OR.

Here we use a single channel relay board. This is a small and easy to use 1 channel relay board. Use it to
control one 240V power appliances directly from microcontrollers or low voltage circuits. Perfect for

DEPT. OF ECE 9 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

switching 240V appliances- lights, fans, etc, and even high power motors. The board uses a high quality
onboard relay, which can handle a maximum of 7A/240 V AC or 7A/24V DC. Each relay has three
connections-Common, normally Open, Normally Closed brought out in 3 pin screw terminals which makes
it easy to make and remove connections. The board has a power indication and a relay status LED, to ease
debugging. The board can accept inputs within a wide range of voltage from 4V to 12V.

Figure 4.1: 1- channel relay board

Features:
* Input supply 12 VDC @ 42 mA
* Relay specification 5 A @ 240 VAC
* Trigger level 2 ~ 5 VDC
* Burg connector for connecting power and trigger voltage
* LED indicates relay status
* 3-pin burg stick for 12V supply, ground and input connection
* Screw terminal connector for easy relay output connection

In this board BC547B transistor is used to drive relay and diode 1N4148 is used to protect transistor from
the back e.m.f generated by the coil in relay.

DEPT. OF ECE 10 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 POWER SUPPLY

Power is used in everyday life. Ever since the basic ideas of power were thought up by Nikola Tesla
and others, then implemented in today's power system, people have been craving power. People need power
to run their homes, cars, computers, etc. To be able to manipulate power is vital to today's society. Power is
defined as (Voltage)*(Current) the current within this equation comes in two flavors AC and DC. Every
circuit designed today needs power to be applied for the circuit to function. DC is the basis for most circuit
designs that goes into everyday products. If a circuit has no power a circuit would not be able to perform its
desired function. A variable DC power supply, seen in every electronics lab, on the market today very
costly. These lab power supplies are very good for testing a circuit in the lab but not useful to be used in a
product application. These power supplies can be very bulky and not very mobile. There is a need for a
power supply that is cheap, reliable, efficient, and small. Thus we use power supply module with voltage
regulators for desired dc voltage supply. In this project we use two voltage regulators for obtaining +5V and
+12V for providing power for various components like PIC controller, LCD, IR transmitters and Relay.

Voltage regulators

To regulate the voltage of IC and to give positive output a regulator is used. The regulators used in this
project are LM7805 and LM7812.

Figure 5.1: voltage regulator

General description

The LM78XX series of three-terminal positive regulators are available in the TO-220 package and with
several fixed output voltages, making them useful in a wide range of applications. Each type employs
internal current limiting, thermal shut down and safe operating area protection, making it essentially
indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although
designed primarily as fixed voltage regulators, these devices can be used with external components to obtain
adjustable voltages and currents.

Features:
 Output Current up to 1A
 Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V
 Thermal Overload Protection
 Short Circuit Protection
 Output Transistor Safe Operating Area Protection

By using a power 12V – 5V dual power supply module we can obtain 12V and 5V DC power supply using
a single circuit. The circuit uses two ICs 7812(IC1) and 7805 (IC2) for obtaining the required voltages. The
AC mains voltage will be stepped down by the transformer , rectified by bridge and filtered by capacitor to
obtain a steady DC level .The 7812 regulates this voltage to obtain a steady 12V DC. The output of the 7812
will be regulated by the 7805 to obtain a steady 5V DC at its output. In this way both 12V and 5V DC are
obtained. Such a circuit is very useful in cases when we need two DC voltages for the operation of a circuit.

DEPT. OF ECE 11 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

CIRCUIT DIAGRAM AND DESCRIPTION

 CIRCUIT DIAGRAM

DEPT. OF ECE 12 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 BLOCK DIAGRAM

DEPT. OF ECE 13 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 WORKING OF THE CIRCUIT

In this circuit PIC16F887 is used as the micro controlling unit which controls the sensing circuit, LCD
display and switching circuit which turns light on and off. The input is given to pin RC0 and RC1 and output
is taken from the port D of PIC16F887. A power supply board consisting two voltage regulators LM7805
and LM 7812 provides regulated power supply for all units in the circuit. The sensing unit consists of two IR
pairs for the detection of people entering and leaving the room. Its output is given as the microcontroller
input. The LCD display consists of LCD board and 16*2 LCD display. It displays the count and is controlled
by PIC16F887. The switching unit consists of a single channel relay board which is controlled by the
microcontroller output and when turned on drives the device (in this case a light bulb) connected to it.

The PIC16F887 is constantly checking the sensing unit output for detection of people entering and
leaving the room. The sensing unit consists of 2 pairs of transmitter and receiver placed on the door frame,
in-front of each other. RC0 represents receiver1 (RX1) output and RC1 represents receiver2 (RX2) output.
When a person enters the room, the TX1-RX1 pair gets cut thus RC0 goes low first and then TX2-RX2 pair
gets cut and RC1 goes low, thus sensing a person entering the room. Then the microcontroller PIC16F887
increment the count and sends count to LCD unit for display. Also the controller turns on the relay thus
turning on the light of the room connected to the relay. When a person leaves the room TX2-RX2 gets cut
first thus RC1 goes low first .Then TX1-RX1 gets cut and RC0 goes low thus sensing a person leaving the
room. The microcontroller decrements the count and display the count via LCD display. When the count
becomes zero ie, when last person leaves the room, microcontroller turns the relay off thus switching off the
light of the room connected to the relay. All of this is done automatically; all we have to do is switch on the
circuitry. This will prevent unwanted wastage of electricity and will give us count of person in the room.

DEPT. OF ECE 14 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

SOFTWARE DESCRIPTION

 MPLAB X IDE v1.51

MPLAB IDE is a software program that is used to develop applications for Microchip microcontrollers
and digital signal controllers. This development tool is called an Integrated Development Environment, or
IDE, because it provides a single integrated “environment” to develop code for embedded microcontrollers.
MPLAB X IDE is the latest integrated development environment from Microchip Technology. It is the
upgrade from MPLAB IDE v8.xx and previous versions.

DEPT. OF ECE 15 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 HITECH C

HI-TECH C PRO compilers enabled with Omniscient Code Generation (OCG), whole program
compilation technology, to facilitate more intelligent, state of-the-art code generation and enhance product
usability. Omniscient Code Generation has been developed to read and process all C source modules in one
step and can deliver denser code, improve RAM utilization and reduce interrupt latency. HI-TECH C PRO
compilers can also be operated in Lite mode with no memory restrictions or time limits. It supports all
devices; however OCG optimizations are not available. HI-TECH Software has provided this freeware
compiler. Rather than relying completely on the linker to uncover errors in independently compiled
modules, an OCG compiler completes the initial stages of compilation for each module separately, but
defers object code generation until the point at which a view of the whole program is available. Information
gathered from a global view of the program can be used to provide better detection of potential errors in the
user's code and to better optimize the output. HI-TECH C compilers can deliver denser code, improve RAM
utilization and reduce interrupt latency.

Features:

 Support for all PIC® MCU devices


 Unlimited memory usage
 Automatically handles memory banking without requiring special qualifiers
 Includes Microchip-compatible peripheral library
 Can identify inconsistent definitions across modules
 Multiple Interrupt Handling Schemes (where applicable)
 Built-in cycle accurate delay routine
 Automatic generation of configuration words (where applicable)
 Warn if potential runtime stack overflow detected
 Automatically analyzes user assembly and object code files
 Eliminates the need for many non-standard C qualifiers and compiler options
 Potential number of printf configurations ~650
 Operation for printf customization ( Automatic)
 Debuggable library routines
 Fully integrates into MPLAB® IDE and is compatible with all Microchip
 debuggers and emulators
 Runs on: Windows® XP, Vista & Vista64, Linux and Mac® OS X

DEPT. OF ECE 16 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 FLOW CHART

DEPT. OF ECE 17 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 PROGRAM

#include <htc.h>

#include "lcd.h
"
__CONFIG(FOSC_XT & WDTE_OFF & LVP_OFF & PWRTE_OFF);

#define _XTAL_FREQ 4000000//

#define buzzer RA5//

#define buzzer_dir TRISA5//

#define buzzer_sel ANS4

#define buzzerp RB7

#define buzzerp_dir TRISB7

#define buzzern RB4

#define buzzern_dir TRISB4

#define led RE2

#define led_dir TRISE2

#define led_sel ANS7

#define relay RD0

#define relay_dir TRISD0

void sys_init (void);

void main (void)

unsigned char count;

sys_init ();

lcd_cmd (0x80);

display (" Welcome ");

__delay_ms (500);

lcd_cmd (0x01);

DEPT. OF ECE 18 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

lcd_cmd (0x80);

display ("Visitor Counter ");

lcd_cmd (0xC0);

display (" System ");

__delay_ms (1500);

lcd_cmd (0x01);

count = 0x00;

while (1)

{
lcd_cmd (0x80);

display ("Count: ");

calculation1 (count);

if (count != 0x00)

{
relay = 1;
}

else

relay = 0;

if (RC0 == 1)

while (RC0 == 1);

led = 1;

__delay_ms (75);

led = 0;

while(RC1 == 0);

while(RC1 == 1);

count++;

DEPT. OF ECE 19 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

led = 1;

__delay_ms (75);

led = 0;

PORTA = count;

if(count != 0x00)

if (RC1 == 1)

while (RC1 == 1);

led = 1;

__delay_ms (75);

led = 0;

while(RC0 == 0);

while (RC0 == 1);

count--;

led = 1;

__delay_ms (75);

led = 0;

PORTA = count;

DEPT. OF ECE 20 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

void sys_init (void)

ANSEL = 0X00;

ANSELH = 0X00;

TRISC0 = 1;

TRISC1 = 1;

buzzerp_dir = 0;

buzzern_dir = 0;

led_dir = 0;

relay_dir = 0;

led_sel = 0;

buzzerp = 0;

buzzern = 0;

led = 0;

relay = 0;

lcd_init ();

DEPT. OF ECE 21 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 PCB DESIGN AND LAYOUT

Printed Circuit Board (PCB) is piece of art. The performance of an electronic circuit depends on the
layout and the design of PCB. A PCB mechanically supports and connects components by conductive
pathways, etched from copper sheets laminated on to insulated substrate. PCB ape used to rotate electrical
currents and signals through copper tracts which are firmly bonded to an insulating base.

In this project we used separate module and connected them together to work as a system. The PCB layout
of each module is as shown below

 PIC 16F887 LAYOUT

DEPT. OF ECE 22 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 POWER SUPPLY BOARD LAYOUT

DEPT. OF ECE 23 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

 1 CHANNEL RELAY BOARD LAYOUT

DEPT. OF ECE 24 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

ADVANTAGES AND APPLICATION

1. This project can be used in various rooms like seminar hall, where the capacity of room is limited
and should not be exceeded. Project will display the actual number of persons inside the room.

2. Can be used in class rooms, conference room, and study rooms in colleges.

3. This project can also be used in our home because many times we come out of our bedroom and
forgot to turn off the room light.

4. When there is nobody inside the room then lights are turned off, thus this project helps in energy
conservation.

5. Low cost and easily implemented on single doors.

6. Very easy to use.

DEPT. OF ECE 25 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

FUTURE ENHANCEMENT

1. We can send this data to a remote location using mobile or internet.

2. Voice alarm system can be added to indicate that room is full & persons can’t enter inside.

3. We can implement RFID reader. Thus we can not only get the total number of people inside the
room but also we will be able to get their identity using RFID cards.

DEPT. OF ECE 26 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

CONCLUSION

The project “AUTOMATIC ROOM LIGHT CONTROLLER WITH BIDIRECTIONAL VISITOR


COUNTER” has been successfully designed. This device can be implemented in homes, seminar halls, class
rooms, conference room, and study rooms in colleges. This device has been introduced keeping in mind the
energy conservation and thus reducing cost of living.

The device displays the number of people inside the room and automatically switches off lights when last
person leaves the room. It occupies less space on the door frame. More improvement can be done to the
project, one being using a DTMF or Bluetooth module to send data to remote location. Also alarm circuit
can be connected so that when count exceeds a certain value it is turned on, this can prevent overcrowding.
Using RFID sensor we can also identify the person entering and leaving the room. This can be used in class
rooms for automatic attendance marking and updation.

DEPT. OF ECE 27 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

BIBILOGRAPHY

 www.wikipedia.com
 www.google.com
 www.datasheetcatalog.com
 MICROCHIP TECHNOLOGIES

DEPT. OF ECE 28 Caarmel Engineering College


AUTOMATIC ROOM LIGHT CONTROLLER MINIPROJECT REPORT 2013

ANNEXURES

DEPT. OF ECE 29 Caarmel Engineering College

Das könnte Ihnen auch gefallen