Project Report3

80
Seminar Report On Automatic Light Control in a room with Person counter Submitted By Anmoldeep Singh Chaddha ECE, 5th Semester Enrollment number – 0411322807 1

Transcript of Project Report3

Page 1: Project Report3

Seminar ReportOn

Automatic Light Control in a room with Person counter

Submitted By

Anmoldeep Singh ChaddhaECE, 5th Semester

Enrollment number – 0411322807

Department of Electronics & Communications EngineeringGuru Tegh Bahadur Institute of Technology

G-8 Area, Rajouri Garden, New Delhi

1

Page 2: Project Report3

CERTIFICATE

This is to certify that report entitled “Automatic light control in a room with visitor counter” which is submitted by Anmoldeep Singh Chaddha in partial fulfillment of the requirement for the award of degree Bachelor Of Technology in Electronics and Communication Engineering to Guru Tegh Bahadur Institute Of Technology, Delhi is a record of the candidates own work carried out by them under my supervision. The matter embodied in this thesis is original and has not been submitted for the award of any other degree.

Date: Project Guide

2

Page 3: Project Report3

ACKNOWLEDGEMENT

We would like to express our gratitude towards our supervisors, Mr. Mukesh Sahu, who has given us much suggestion, support and help. Without their help we could not have presented this dissertion up to the present standard. We would also like to thank Mr.Ramandeep, without whose guidance this project could not have been completed. We also take this opportunity to thank all others who gave us support for the project or in other aspects of our study at Guru Tegh Bahadur Institute of Technology.

Date:

3

Page 4: Project Report3

Abstract

This project “Automatic Light Control in a room with Person counter” is energy

saver project that deals with Automatic Control of lights and fans in a room. It can be

used on a large setup for a wide range of applications besides power conservation like a

theft prevention system in multiplexes as the lights would not go off if anybody is

inside. It can serve other purposes, like of a car parking system by showing the exact

number of cars in the parking and whether there is any space to park.

The heart of this system is the microcontroller. The chip being used is AT89S1 because

of its compatibility with the chip burning kit. It responds and controls to the signals of the

infrared sensors. With the help of reflective sensors we can sense the footsteps of a

visitor going in or out as per the program. The program has been made such that both

infra red sensors, forward and backward reflect the rays and the circuit increments or

decrements the counter. If the visitor has entered, the forward IR sensor will be

interrupted first and then the backward. But if the visitor has left, the backward IR sensor

will be interrupted first and then the forward. Software is written in Embedded C and

then transferred into the blank IC with the help of programmer kit.

The scope of this project is to design an automated system which helps in energy

conservation with convenience and security. The preliminary goal being the sensing of

visitor and likewise changing the count and the status of lights.

4

Page 5: Project Report3

Contents

Chapter Page

TITLE PAGE i

CERTIFICATE ii

ACKNOWLEDGEMENT iii

ABSTRACT iv

CONTENTS v

LIST OF FIGURES vii

LIST OF TABLES viii

Chapter 1 – INTRODUCTION

1.1 Overview

1.2 Functionality

1.3 Functionality of IR Sensors

1.4 Design Flow

Chapter 2 – THEORY

2.1 Hardware components used

2.2 Microcontroller Kit

2.3 Detailed information of peripherals

and related components

Chapter 3 – SOFTWARE DESCRIPTION

5

Page 6: Project Report3

3.1 Overview

3.2 Keil Microvision 3

3.3 Simulation

Chapter 4 – APPLICATIONS AND FUTURE PROSPECTS

4.1 General Applications

Chapter 5 – DIFFICULTIES AND RECTIFIACTIONS

Chapter 6 – REFERENCES

APPENDIX

LIST OF FIGURES

FIG. NO. CHAPTER NO. NAME OF THE FIGURE PAGE

1.1 1 Design Flow

2.1 2 Seven Segment pin diagram

2.2 2 Seven Segment Display IC 2.3 2 Darlington Pair

2.4 2 Transistor BC182

2.5 2 Transistor circuit symbol 2.6 2 NPN Transistor

2.7 2 Diode forward V-I Characteristic

2.8 2 Capacitor

2.9 2 Polarised Capacitor and its circuit symbol

6

Page 7: Project Report3

2.10 2 Resistor and its circuit symbol

2.11 2 Colour bands in a Resistor

4.1 4 Pie Chart showing the saving of power

LIST OF TABLES

TABLE. NO. CHAPTER NO. NAME OF THE TABLE PAGE 2.1 2 The Resistor Colour Code

7

Page 8: Project Report3

Chapter 1

INTRODUCTION

8

Page 9: Project Report3

1.1 Overview

This project, Automatic light control in a room with visitor counter, is an automatic

system which serves the purpose of power conservation, convenience, security and

efficiency.

For making this project, a number of different components are used, like 8051

microcontroller kit, IR sensors, seven segment displays, relays.

These hardware components were joined together in a particular configuration to make a

circuit which was then synchronized and programmed using embedded c.

1.2 Functionality

Initially when the room is empty, all the lights and fans are switched off. But as people

start entering the room, they are switched on automatically. i.e. when the first person

enters, 2 lights and 2 fans are switched on, this is continued till around 8 people are there

in the room. As the number of people in the Room is more than 8, the second set of a

light and fan is switched on automatically. This is continued till the number of people in

the room is 1.

And thus this procedure continues as people keep entering the room, till its maximum

capacity.

1.3 Functionality of IR sensors

When nobody is entering, at that time a signal is being sent from the receiver to the

transmitter, but when somebody enters the room, this signal is interrupted.

When the first pair is interrupted first and second pair after that, this shows the

INCREMENT in the number of people in the room, i.e. somebody is entering.

But when the second pair is interrupted before the first one, this shows the decrement in

the number of people in the room i.e. number of people leaving the room.

9

Page 10: Project Report3

AUTOMATIC ROOM LIGHT

CONTROLLER AND VISITOR COUNTER

I.R SENSOR 1

I.R SENSOR 2

I.R SENSOR 2

I.R SENSOR 1

RELAYS TO SWITCH ON LIGHTS

SEVEN SEGMENT DISPLAY

RELAYS TO SWITCH ON LIGHTS

SEVEN SEGMENT DISPLAY

ENTRY

EXIT

Figure 1.1: Design Flow

The microcontroller does the above job. It receives the signals from the sensors, and this

signal is operated under the control of software which is stored in ROM. Microcontroller

AT89c2051 continuously monitor the LDR’s 1 & 2 (Light Dependent Resistor), when

any object pass through the LDR’s then the light falling on the LDR’s obstructed, this

obstruction is sensed by the Microcontroller.

1.4 Design Flow

10

Page 11: Project Report3

Chapter 2

THEORY

11

Page 12: Project Report3

2.1 Hardware Components Used

The hardware part of the project includes the following peripherals

7 Segments (Common anode)

Relays

IR Sensors

Other hardware components used

General Purpose Printed Circuit Board

Transistors

o AC 188

o BC 547

Resistances

o 100 ohm

o 10 k ohm

o 4.7 k ohm

Diode 4007

Voltage Regulator

Transformer

Capacitor

12

Page 13: Project Report3

2.2 MICROCONTROLLER KIT

8051 Microcontroller Kit is used.

ICs present in the Microcontroller kit

AT89S52 Microcontroller IC

MAX 232 IC

74HC541

Ports Used

Universal Serial Bus

Parallel Port

Serial Port

Other Components

Resistances

Capacitors

Crystal

Connectors

Connecting wires

Power LED

13

Page 14: Project Report3

2.3 Detailed Information of each Peripheral and Related Components

2.3.1 SEVEN SEGMENTS

There are two types of LED 7-segment displays: common cathode (CC) and common

anode (CA). The difference between the two displays is the common cathode has all the

cathodes of the 7-segments connected directly together and the common anode has all the

anodes of the 7-segments connected together. Shown below is a common anode seven

segment.

Figure 2.1: Seven Segment (common anode) pin diagram

As shown in the diagram on the previous page, all the anode segments are connected

together. When working with a CA seven segment display, power must be applied

externally to the the anode connection that is common to all the segments. Then by

applying a ground to a particular segment connection (a-g), the appropriate segment will

light up. An additional resistor must be added to the circuit to limit the amount of current

flowing thru each LED segment.

14

Page 15: Project Report3

The above diagram shows the instance when power is applied to the CA connection and

segments b & c are grounded causing these two segments to light up. A typical pinout for

a seven segment common anode display is also shown along with it.

While making the connections of the SEVEN SEGMENTS we use a Darlington pair with

the common anode

2.3.2 Darlington Pair

15

Page 16: Project Report3

Figure 2.3: Darlington pair

It is made up of two transistors connected together such that the amplified current from

the first is amplified further by the second transistor. This gives the Darlington pair a

very high current gain such as 10000. Darlington pairs are sold as complete packages

containing the two transistors. They have three leads (B, C and E) which are equivalent

to the leads of a standard individual transistor.

We can make up your own Darlington pair from two transistors.

2.3.3 TRANSISTORS

Figure 2.4: Transistor BC182

Function

Transistors amplify current, for example they can be used to amplify the small output

current from a logic IC so that it can operate a lamp, relay or other high current device. In

many circuits a resistor is used to convert the changing current to a changing voltage, so

the transistor is being used to amplify voltage.

A transistor may be used as a switch (either fully on with maximum current, or fully off

with no current) and as an amplifier (always partly on).

The amount of current amplification is called the current gain, symbol hFE.

For further information please see the Transistor Circuits page.

16

Page 17: Project Report3

Types of transistor

There are two types of standard transistors, NPN and PNP, with different circuit

symbols. The letters refer to the layers of semiconductor material used to make the

transistor. Most transistors used today are NPN because this is the easiest type to make

from silicon. If you are new to electronics it is best to start by learning how to use NPN

transistors.

The leads are labeled base (B), collector (C) and emitter (E). These terms refer to the

internal operation of a transistor but they are not much help in understanding how a

transistor is used, so just treat them as labels.

A Darlington pair is two transistors connected together to give a very high current gain.

In addition to standard (bipolar junction) transistors, there are field-effect transistors

which are usually referred to as FETs.

Testing a transistor

17

Figure 2.5 : Transistor circuit symbols

Page 18: Project Report3

Transistors can be damaged by heat when soldering or by misuse in a circuit. When we

suspect that a transistor may be damaged there are an easy way to test it:

1. Testing with a multimeter

Use a multimeter or a simple tester (battery, resistor and LED) to check each pair of leads

for conduction. Set a digital multimeter to diode test and an analogue multimeter to a low

resistance range.

Test each pair of leads both ways

The base-collector (BC) junction should behave like a diode and conduct one way only.

The collector-emitter (CE) should not conduct either way.

The diagram shows how the junctions behave in an NPN transistor. The diodes are

reversed in a PNP transistor but the same test procedure can be used.

Some multimeters have a 'transistor test' function which provides a known base current

and measures the collector current so as to display the transistor's DC current gain hFE.

18

Figure 2.6: NPN Transistor

Page 19: Project Report3

2.3.4 Diodes

Diagram 2.7: Diode forward V-I Characteristic

Function

Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol

shows the direction in which the current can flow. Diodes are the electrical version of a

valve and early diodes were actually called valves.

19

Page 20: Project Report3

Forward Voltage Drop

Electricity uses up a little energy pushing its way through the diode, rather like a person

pushing through a door with a spring.

This means that there is a small voltage across a conducting diode, it is called the

forward voltage drop and is about 0.7V for all normal diodes which are made from

silicon. The forward voltage drop of a diode is almost constant whatever the current

passing through the diode so they have a very steep characteristic (current-voltage graph).

Reverse Voltage

When a reverse voltage is applied a perfect diode does not conduct, but all real diodes

leak a very tiny current of a few µA or less. This can be ignored in most circuits because

it will be very much smaller than the current flowing in the forward direction. However,

all diodes have a maximum reverse voltage (usually 50V or more) and if this is

exceeded the diode will fail and pass a large current in the reverse direction, this is called

breakdown.

 

Rectifier diodes (large current)

Rectifier diodes are used in power supplies to convert alternating current (AC) to direct

current (DC), a process called rectification. They are also used elsewhere in circuits

where a large current must pass through the diode.

All rectifier diodes are made from silicon and therefore have a forward voltage drop of

0.7V. The table shows maximum current and maximum reverse voltage for some popular

rectifier diodes. The 1N4001 is suitable for most low voltage circuits with a current of

less than 1A.

Diodes used in the Project are- 4007 diodes

maximum current-1A

20

Page 21: Project Report3

maximum reverse voltage-1000V

2.3.5 Capacitors

Diagram 2.8: Capacitor

Function

Capacitors store electric charge. They are used with resistors in timing circuits because it

takes time for a capacitor to fill with charge. They are used to smooth varying DC

supplies by acting as a reservoir of charge. They are also used in filter circuits because

capacitors easily pass AC (changing) signals but they block DC (constant) signals.

21

Page 22: Project Report3

Capacitance

This is a measure of a capacitor's ability to store charge. A large capacitance means that

more charge can be stored. Capacitance is measured in farads, symbol F. However 1F is

very large, so prefixes are used to show the smaller values.

Three prefixes (multipliers) are used, µ (micro), n (nano) and p (pico):

µ means 10-6 (millionth), so 1000000µF = 1F

n means 10-9 (thousand-millionth), so 1000nF = 1µF

p means 10-12 (million-millionth), so 1000pF = 1nF

Capacitor values can be very difficult to find because there are many types of capacitor

with different labeling systems.

There are many types of capacitor but they can be split into two groups, polarised and

unpolarised. Each group has its own circuit symbol.

Polarised capacitors (large values, 1µF +)

Examples:       Circuit symbol:   

22

Page 23: Project Report3

Diagram 2.9: Polarised capacitor and its circuit symbol

Electrolytic Capacitors

Electrolytic capacitors are polarised and they must be connected the correct way

round, at least one of their leads will be marked + or -. They are not damaged by heat

when soldering.

There are two designs of electrolytic capacitors; axial where the leads are attached to

each end (220µF in picture) and radial where both leads are at the same end (10µF in

picture). Radial capacitors tend to be a little smaller and they stand upright on the circuit

board.

It is easy to find the value of electrolytic capacitors because they are clearly printed with

their capacitance and voltage rating. The voltage rating can be quite low (6V for

example) and it should always be checked when selecting an electrolytic capacitor. If the

project parts list does not specify a voltage, choose a capacitor with a rating which is

greater than the project's power supply voltage. 25V is a sensible minimum for most

battery circuits.

2.3.6 Resistors

Resistors used in the Project

10k ohm

4.7k ohm

100 ohm

Function

Example:      

23

Page 24: Project Report3

 Circuit symbol:   

Diagram 2.10: Resistor and its circuit symbol

Resistors restrict the flow of electric current, for example a resistor is placed in series

with a light-emitting diode (LED) to limit the current passing through the LED.

Connecting and soldering

Resistors may be connected either way round. They are not damaged by heat when

soldering.

Resistor values - the resistor colour code

Resistance is measured in ohms, the symbol for ohm is an omega .

1 is quite small so resistor values are often given in k and M .

1 k = 1000     1 M = 1000000 .

Resistor values are normally shown using coloured bands.

Each colour represents a number as shown in the table.

Table 2.1: The Resistor Colour Code

24

The Resistor

Colour Code

Colour Number

Black 0

Brown 1

Red 2

Orange 3

Yellow 4

Green 5

Blue 6

Violet 7

Grey 8

White 9

Page 25: Project Report3

Most resistors have 4 bands:

The first band gives the first digit.

The second band gives the second digit.

The third band indicates the number of zeros.

The fourth band is used to shows the tolerance (precision) of the resistor, this may

be ignored for almost all circuits but further details are given below.

Diagram 2.11: Colour bands in a Resistor

This resistor has red (2), violet (7), yellow (4 zeros) and gold bands.

So its value is 270000 = 270 k .

On circuit diagrams the is usually omitted and the value is written 270K.

Small value resistors (less than 10 ohm)

The standard colour code cannot show values of less than 10 . To show these small

values two special colours are used for the third band: gold which means × 0.1 and

silver which means × 0.01. The first and second bands represent the digits as normal.

25

Page 26: Project Report3

For example:

red, violet, gold bands represent 27 × 0.1 = 2.7 

green, blue, silver bands represent 56 × 0.01 = 0.56 

Tolerance of resistors (fourth band of color code)

The tolerance of a resistor is shown by the fourth band of the colour code. Tolerance is

the precision of the resistor and it is given as a percentage. For example a 390 resistor

with a tolerance of ±10% will have a value within 10% of 390 , between 390 - 39 = 351

and 390 + 39 = 429 (39 is 10% of 390).

A special colour code is used for the fourth band tolerance:

silver ±10%,   gold ±5%,   red ±2%,   brown ±1%.

If no fourth band is shown the tolerance is ±20%.

Tolerance may be ignored for almost all circuits because precise resistor values are rarely

required.

Resistor shorthand

Resistor values are often written on circuit diagrams using a code system which avoids

using a decimal point because it is easy to miss the small dot. Instead the letters R, K and

M are used in place of the decimal point. To read the code: replace the letter with a

decimal point, then multiply the value by 1000 if the letter was K, or 1000000 if the letter

was M. The letter R means multiply by 1.

2.3.7 RELAYS

A relay is an electrically operated switch. Current flowing through the coil of the relay

creates a magnetic field which attracts a lever and changes the switch contacts. The coil

current can be on or off so relays have two switch positions and they are double throw

(changeover) switches.

26

Page 27: Project Report3

Relays allow one circuit to switch a second circuit which can be completely separate

from the first. For example a low voltage battery circuit can use a relay to switch a 230V

AC mains circuit. There is no electrical connection inside the relay between the two

circuits, the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it

can be as much as 100mA for relays designed to operate from lower voltages. Most ICs

(chips) cannot provide this current and a transistor is usually used to amplify the small IC

current to the larger value required for the relay coil. The maximum output current for the

popular 555 timer IC is 200mA so these devices can supply relay coils directly without

amplification.

Relays are usually SPDT or DPDT but they can have many more sets of switch contacts,

for example relays with 4 sets of changeover contacts are readily available. Most relays

are designed for PCB mounting but you can solder wires directly to the pins providing

you take care to avoid melting the plastic case of the relay.

The supplier's catalogue shows us the relay's connections. The coil will be obvious and it

may be connected either way round. Relay coils produce brief high voltage 'spikes' when

they are switched off and this can destroy transistors and ICs in the circuit. To prevent

damage we must connect a protection diode across the relay coil.

The relay's switch connections are usually labeled COM, NC and NO:

COM = Common, always connect to this, it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

We Connect to COM and NO if we want the switched circuit to be on when the

relay coil is on.

We Connect to COM and NC if we want the switched circuit to be on when the

relay coil is off.

Choosing a relay

27

Page 28: Project Report3

We need to consider several features when choosing a relay:

1. Physical size and pin arrangement

While choosing a relay for an existing PCB you will need to ensure that its

dimensions and pin arrangement are suitable. We should find this information in

the supplier's catalogue.

2. Coil voltage

The relay's coil voltage rating and resistance must suit the circuit powering the

relay coil. Many relays have a coil rated for a 12V supply but 5V and 24V relays

are also readily available. Some relays operate perfectly well with a supply

voltage which is a little lower than their rated value.

3. Coil resistance

The circuit must be able to supply the current required by the relay coil. We can

use Ohm's law to calculate the current:

Relay coil current   =   supply voltage 

  coil resistance

4. Switch ratings (voltage and current)

The relay's switch contacts must be suitable for the circuit they are to control. We

will need to check the voltage and current ratings. Note that the voltage rating is

usually higher for AC, for example: "5A at 24V DC or 125V AC".

5. Switch contact arrangement (SPDT, DPDT etc)

28

Page 29: Project Report3

Most relays are SPDT or DPDT which are often described as "single pole

changeover" (SPCO) or "double pole changeover" (DPCO).

Protection diodes for relays

Transistors and ICs must be protected from the brief high voltage produced when

a relay coil is switched off.

Current flowing through a relay coil creates a magnetic field which collapses

suddenly when the current is switched off. The sudden collapse of the magnetic

field induces a brief high voltage across the relay coil which is very likely to

damage transistors and ICs. The protection diode allows the induced voltage to

drive a brief current through the coil (and diode) so the magnetic field dies away

quickly rather than instantly. This prevents the induced voltage becoming high

enough to cause damage to transistors and ICs.

29

Page 30: Project Report3

Chapter 3

SOFTWARE DESCRIPTION

30

Page 31: Project Report3

3.1 Overview

Programming software usually provides tools to assist a programmer in writing computer

programs, and software using different programming languages in a more convenient

way. The tools include:

compilers

debuggers

interpreters

linkers

Computer software, or just software is a general term used to describe the role that

computer programs, procedures and documentation play in a computer system.[1]

The term includes:

Application software such as word processors which perform productive tasks for

users.

Firmware which is software programmed resident to electrically programmable

memory devices on board mainboards or other types of integrated hardware

carriers.

Middleware which controls and co-ordinates distributed systems.

System software such as operating systems, which interface with hardware to

provide the necessary services for application software.

Software testing is a domain independent of development and programming. It

consists of various methods to test and declare a software product fit before it can

be launched for use by either an individual or a group.

Computer software is often regarded as anything but hardware, meaning that the "hard"

are the parts that are tangible while the "soft" part is the intangible objects inside the

computer. Software encompasses an extremely wide array of products and technologies

developed using different techniques like programming languages, scripting languages or

even microcode or a FPGA state. The types of software include web pages developed by

31

Page 32: Project Report3

technologies like HTML, PHP, Perl, JSP, ASP.NET, XML, and desktop applications like

Open Office, Microsoft Word developed by technologies like C, C++, Java, or C#.

Software usually runs on an underlying software operating systems such as the Linux or

Microsoft Windows. Software also includes video games and the logic systems of

modern consumer devices such as automobiles, televisions, and toasters.

Relationship to computer hardware

Computer software is so called to distinguish it from computer hardware, which

encompasses the physical interconnections and devices required to store and execute (or

run) the software. At the lowest level, software consists of a machine language specific to

an individual processor. A machine language consists of groups of binary values

signifying processor instructions that change the state of the computer from its preceding

state. Software is an ordered sequence of instructions for changing the state of the

computer hardware in a particular sequence. It is usually written in high-level

programming languages that are easier and more efficient for humans to use (closer to

natural language) than machine language. High-level languages are compiled or

interpreted into machine language object code. Software may also be written in an

assembly language, essentially, a mnemonic representation of a machine language using

a natural language alphabet. Assembly language must be assembled into object code via

an assembler.

Types of software

A layer structure showing where Operating System is located on generally used software

systems on desktops

Practical computer systems divide software systems into three major classes: system

software, programming software and application software, although the distinction is

arbitrary, and often blurred.

32

Page 33: Project Report3

3.2Keil Microvision 3

Keil C is not much different from a normal C program. We have to keep in mind the

ports and other components on chip peripherals and related registers connected to them.

In basic C, all programs have at least one function which is entry point for our application

that function is named as "main" function. Similarly in keil, we have a main function, in

which all our application specific work will be defined.

When we run programs in our PC or computer, we run them as a child program or

process to our Operating System so when we exit our programs (exits main function of

program) we come back to operating system. Whereas in case of embedded C, we do not

have any operating system running in there. So we have to make sure that our program or

main file should never exit. This can be done with the help of simple while(1) or for(;;)

loop as they are going to run infinitely. Following layout provides a skeleton of Basic C

program.

When we are working on controller specific code, then we need to add header file for that

controller. After project is created, add the C file to project. Now first thing we have to do

is adding the header file. All we have to do is right click in editor window, it will show

the correct header file for our project.

Writing Hardware specific code

In hardware specific code, we use hardware peripherals like ports, timers etc. It is very

important to add header file for controller we are using, otherwise we will not be able to

access registers related to peripherals.

KEIL µVISION

33

Page 34: Project Report3

The µVision IDE from Keil combines project management, make facilities, source code

editing, program debugging, and complete simulation in one powerful environment. The

µVision development platform is easy-to-use and it helps us to quickly create embedded

programs. The µVision editor and debugger are integrated in a single application that

provides a seamless embedded project development environment.

µVision3 provides unique features like:

• The Device Database which automatically sets the assembler, compiler, and linker

options for the chip we select. This prevents us from wasting our time configuring the

tools and helps us to get started and to write code faster.

• A robust Project Manager which helps to create several different configurations of

our target from a single project file. Only the Keil µVision3 IDE allows us to create an

output file for simulating, an output file for debugging with an emulator, and an output

file for programming an EPROM--all from the same Project file.

• An integrated Make facility with automatic dependency generation. We don't

have to figure out which header files and include files are used by which source files.

The Keil compilers and assemblers do that automatically.

• Interactive error correction. As your project compiles, errors and warnings appear

in an output window. We may make corrections to the files in your project while

µVision3 continues to compile in the background. Line numbers associated with each

error or warning are automatically resynchronised when we make changes to the source.

µVision3 Debugger

The µVision Debugger from Keil supports simulation using only our PC or laptop, and

debugging using our target system and a debugger interface. µVision includes traditional

features like simple and complex breakpoints, watch windows, and execution control as

well as sophisticated features like trace capture, execution profiler, code coverage, and

logic analyzer.

Viewing Code & Data: The µVision Debugger provides a number of ways to display

variables and program objects.

34

Page 35: Project Report3

• Source Code Windows display our high-level language and assembly program

source code.

• The Disassembly Window shows mixed high-level language and assembly code.

• The Registers Tab of the Project Workspace shows system registers.

• The Symbol Window heir archly displays program symbols in our application.

• The Output Window displays the output of various debugger commands.

• The Memory Window displays up to four regions of code or data memory.

• The Watch Window displays local variables, user-defined watch expression lists,

and the call stack.

Executing Code: µVision offers several ways by which we can control and manipulate

program execution.

• Reset - It is possible to debug reset conditions using the µVision Simulator.

• Run/Stop - Buttons and Commands make starting and stopping program

execution is easy.

• Single-Stepping - µVision supports various methods of single-stepping through

your target program.

• Execution Trace - Execution trace information for each executed instruction is

stored by µVision.

• Breakpoints - Both simple and complex breakpoints are supported by the µVision

Debugger.

Advanced Analysis Tools: Advanced analysis tools are available to helps us test and

debug our embedded applications.

• Code Coverage helps us determine how much of our program has been tested.

• The Performance analyzer shows how functions and code blocks in our program

perform.

• The Execution Profiler shows execution counts and time for each line of code or

instruction.

• The Logic analyzer shows how various signals and variables in our program

change over time.

35

Page 36: Project Report3

3.3 SIMULATION

Simulation capabilities make it possible to test our target system without target hardware.

• Instruction Simulation simulates the exact effects and timing of each MCU

instruction.

• Interrupt Simulation simulates the cause and effect of a system or peripheral

interrupt.

• Peripheral Simulation simulates the effects of on-chip peripherals including

special function regisers.

• Debugger Functions allows us to expand the command scope of the debugger and

create and respond to stimuli.

• Toolbox Buttons are a convenient way for us to connect debugger functions

buttons on the user-interface.

3.3.1 Target Debugging:

Target debug drivers allows us to test programs running on target hardware.

• JTAG Debugging uses external hardware to interface our PC to our target system.

• A Target Monitor interfaces our PC to our target system using RS-232 and

software.

• Flash Programming uses a target interface to download our target program to

Flash memory.

• AGDI Drivers interface the µVision Debugger to third-party hardware or provide

additional debugger features.

So first we have to understand the concept of compilers and cross compilers. After then

we shall learn how to work with keil.

36

Page 37: Project Report3

3.3.2 Concept of compiler:

Compilers are programs used to convert a High Level Language to object code. Desktop

compilers produce an output object code for the underlying microprocessor, but not for

other microprocessors. I.E the programs written in one of the HLL like ‘C’ will compile

the code to run on the system for a particular processor like x86 (underlying

microprocessor in the computer). For example compilers for Dos platform is different

from the Compilers for Unix platform

 

So if one wants to define a compiler then compiler is a program that translates source

code into object code. The compiler derives its name from the way it works, looking at

the entire piece of source code and collecting and reorganizing the instruction. See there

is a bit little difference between compiler and an interpreter. Interpreter just interprets

whole program at a time while compiler analyzes and execute each line of source code in

succession, without looking at the entire program.

 

The advantage of interpreters is that they can execute a program immediately. Secondly

programs produced by compilers run much faster than the same programs executed by an

interpreter. However compilers require some time before an executable program emerges.

Now as compilers translate source code into object code, which is unique for each type of

computer, many compilers are available for the same language.

 

3.3.3 Concept of cross compiler:

A cross compiler is similar to the compilers but we write a program for the target

processor (like 8051 and its derivatives) on the host processors (like computer of x86)

It means being in one environment you are writing a code for another environment is

called cross development. And the compiler used for cross development is called cross

compiler

 

37

Page 38: Project Report3

So the definition of cross compiler is a compiler that runs on one computer but produces

object code for a different type of computer. Cross compilers are used to generate

software that can run on computers with a new architecture or on special-purpose devices

that cannot host their own compilers. Cross compilers are very popular for embedded

development, where the target probably couldn't run a compiler. Typically an embedded

platform has restricted RAM, no hard disk, and limited I/O capability. Code can be edited

and compiled on a fast host machine (such as a PC or Unix workstation) and the resulting

executable code can then be downloaded to the target to be tested. Cross compilers are

beneficial whenever the host machine has more resources (memory, disk, I/O etc) than

the target.  Keil C Compiler is one such compiler that supports a huge number of host and

target combinations. It supports as a target to 8 bit microcontrollers like Atmel and

Motorola etc.

 

3.3.4 Why do we need cross compiler?

There are several advantages of using cross compiler. Some of them are described as

follows

•         By using this compilers not only can development of complex embedded systems

be completed in a fraction of the time, but reliability is improved, and maintenance is

easy.

•         Knowledge of the processor instruction set is not required.

•         A rudimentary knowledge of the 8051’s memory architecture is desirable but not

necessary.

•         Register allocation and addressing mode details are managed by the compiler.

•         The ability to combine variable selection with specific operations improves

program readability.

•         Keywords and operational functions that more nearly resemble the human thought

process can be used.

•         Program development and debugging times are dramatically reduced when

compared to assembly language programming.

38

Page 39: Project Report3

•         The library files that are supplied provide many standard routines (such as

formatted output, data conversions, and floating-point arithmetic) that may be

incorporated into our application.

•         Existing routine can be reused in new programs by utilizing the modular

programming techniques available with C.

•         The C language is very portable and very popular. C compilers are available for

almost all target systems. Existing software investments can be quickly and easily

converted from or adapted to other processors or environments.

 

3.3.5 Keil compiler (a cross compiler):

Keil is a German based Software development company. It provides several development

tools like

•         IDE (Integrated Development environment)

•         Project Manager

•         Simulator

•         Debugger

•         C Cross Compiler , Cross Assembler, Locator/Linker

Keil Software provides us with software development tools for the 8051 family of

microcontrollers. With these tools, you can generate embedded applications for the

multitude of 8051 derivatives. Keil provides following tools for 8051 development

1.     C51 Optimizing C Cross Compiler,

2.     A51 Macro Assembler,

3.     8051 Utilities (linker, object file converter, library manager),

4.     Source-Level Debugger/Simulator,

5.     µVision for Windows Integrated Development Environment.

The keil 8051 tool kit includes three main tools, assembler, compiler and linker.

An assembler is used to assemble your 8051 assembly program

A compiler is used to compile your C source code into an object file

A linker is used to create an absolute object module suitable for your in-circuit emulator.

 

39

Page 40: Project Report3

8051 project development cycle: - these are the steps to develop 8051 project using keil

1. Create source files in C or assembly.

2. Compile or assemble source files.

3. Correct errors in source files.

4. Link object files from compiler and assembler.

5. Test linked application.

40

Page 41: Project Report3

Chapter 4

APPLICATIONS AND FUTURE PROSPECTS

41

Page 42: Project Report3

4.1 General applications

This project, Automatic light control in a room with person counter, can be use in

many different areas, like:

1. Power conservation and its efficient use:

The genius of this idea is the efficient use of power. One of the most crucial

issues in today’s times is energy conservation. In spite of repeated reminders

about “switching off the lights and fans when you leave” it’s hardly done with any

effect.

The usage of an Automatic Room Light Controller and Visitor Counter ensures

both, Optimum usage and Minimum wastage.

A recent survey by “The NTPC” has shown that, if for an average consumer of

electricity, the appliances are switched off as per use; there is a saving of more

than 36% power.

Diagram 4.1: Pie Chart showing the saving of power

42

Page 43: Project Report3

Thus having an automatic control of the appliances is like banking and storing

that electricity for future use. After all, power saved is power generated.

Specific Applications of the Visitor Counter and Display

2. Preventing theft in a commercial complex:

If a showroom of a multiplex shopping centre has an Automatic Room Light

Controller and Visitor Counter installed on every entrance and exit point, the

“Visitor Counter” feature comes into play.

The visitor counter is always updated about the number of people within the

premises, and ensures that no one is hiding inside or is purposely left behind, with

any intentions of crime at heart.

3. Distribution of the exact number of articles:

Exact information of number of people present facilitates proper distribution of

articles be it books, reports or refreshments to the people.

In large capacity arenas, such as auditoriums, or conference halls, it’s difficult to

know the number of people present accurately.

Now, while conducting workshops, presentations or lectures, there is often a

distribution of expensive articles like books or confidential ones like reports and

worksheets. Knowing the exact number required is crucial. It ensures that each

one gets one and only one preventing wastage as well as deficiency.

4. Cross verification of attendance:

Knowledge of the exact number of people present for a lecture or workshop, as

indicated by the visitor counter, in any educational institute eliminates any scope

of a false attendance or “proxy”. With as little effort as glancing at no of people

present as per the display it ensures vigilance and discipline in the classroom.

43

Page 44: Project Report3

Other than that, in Cinema Halls and other events where entry is strictly as per

passes or invitations, like concerts and fests the number of people entered and the

tickets or passes gathered can be cross checked.

5. Preventing being ‘Locked In’ and Risk Management:

The feature that “As long as any one is present inside the premises, all the lights

won’t go off.” along with the visitor counter and display, ensures that the

premises aren’t locked and sealed with anyone already present inside.

From large multiplexes to the washrooms, from shop floors to laboratories, this

application will save people a lot of time, effort and inconvenience. Not to

mention would prevent severe industrial accidents.

6. Visitor alert:

The microchip present, however small, serves a big purpose. By announcing a

recorded message, for example “We welcome you inside, may u have a pleasant

visit.”

Besides welcoming the person stepping inside, it also alerts the ones already

present, the staff, the teachers or the officials. It ensures that everyone can

function more effectively and briskly and any clumsy behavior on part of the staff

can be avoided.

44

Page 45: Project Report3

Chapter 6

DIFFICULTIES AND RECTIFICATION

45

Page 46: Project Report3

The common difficulties faced while making this project were:

1. Lack of uniformity for the “Common Ground”:

The Relay circuit, the Seven Segment circuit, the I.R sensors, and the Micro

controller kit, all have to be connected to the “common ground”.

There was a mismatch between the values of ground given to each and wasn’t

constant for all.

The mistake was observed and corrected.

2. Erroneously giving “Human Ground” to the circuit:

In the Relay circuit, the triggering sound was observed when connections were

made, i.e. one terminal to ground and other to the 5V of micro controller.

Even after the connections were removed, triggering sound was observed. After

much thinking and speculation it was observed that, supplying Human Ground

was causing the triggering.

3. Giving a D.C (12V) supply to 5 Relays simultaneously:

Instead of using a battery or an adapter, we created a Power Source using a Step-

down Transformer, Bridge Rectifier, Capacitor Filter and Voltage Regulator.

That’s how we got a 12volt D.C supply from the domestic 220 volts A.C.

4. Improper Soldering:

Due to flow improper soldering, the 3 legs of the voltage regulator were short

circuited, (as concluded by the use of a multimeter).

It was de-soldered and placed again with legs open wider than before.

46

Page 47: Project Report3

5. Improper placement of the bulbs:

In order to exactly simulate the model, we had put bulbs on the ceiling of the

wooden structure.

Once all of them were placed together, it was difficult to understand which bulb

was illuminated when.

We then took a corrective measure and decided to place the bulbs on the roofs,

and it could be clearly seen that which bulb is being lit and where.

47

Page 48: Project Report3

Chapter 7

REFERENCES

48

Page 49: Project Report3

The references used to for making this project under the guidance of an excellent

faculty, are:

8051 Microcontroller, The: Hardware, Software and Interfacing & Applications

Embedded C (paperback) by Michel J Pont.

Muhammad Ali Mazidi, Janice Gillespie Mazidi, Rollin D. McKinley, “The 8051

Microcontroller and Embedded system”, 2nd Edition, Chapter 12.

www.electronics4u.com/circuitdiagram

www.alldatasheet.com/adc0848.pdf

www.datasheetcatalog.com/lm35.pdf

www.alldatasheet.com/8051.pdf

49

Page 50: Project Report3

APPENDIX - 1

(PROJECT CODE)

50

Page 51: Project Report3

PROJECT CODE

CODE1.h

#include<REGx51.h>

#include “code2.h” // seven segment display

#include “code3.h> //delay funtion

#include “code4.h” // decrement number of lights in the room.

#include “code5.h” //increment number of lights in the room

int ctr = 0;

sbit IR1 = P 3^1; // infrared sensor1 on pin P3^1

sbit IR2 = P 3^0; // infrared sensor2 on pin P3^0

void main (void)

{

while(1) // infinite loop

{

if(IR1 = = 0) // if there is a blockage

{

delay( );

x: if(IR2 = = 0)

{

ctr++ ;

incr_light(ctr );

seg_data(ctr );

51

Page 52: Project Report3

}

else

goto x ;

}

else if (IR2 = = 0)

{

delay( );

y: if(IR1= = 0)

{

ctr-- ;

dec_light(ctr );

seg_data(ctr );

}

else

goto y ;

}

}

}

CODE2.h

#include<Regx51.h>

sbit C1 = P2^0;

sbit C2 = P2^1;

int a,b;

void display(ctr)

{

switch(ctr)

{

52

Page 53: Project Report3

case 1: P0 = 0x06;

break;

case 2: P0 = 0x5B;

break;

case 3: P0 = 0x4F;

break;

case 4: P0 = 0x66;

break;

case 5: P0 = 0x6D;

break;

case 6: P0 = 0x7C;

break;

case 7: P0 = 0x07;

break;

case 8: P0 = 0x7F;

break;

case 9: P0 = 0x67;

break;

default: P0 = 0x3F;

}

}

void seg_data(ctr)

{

if(ctr> = 0 && ctr < =9)

{

C1 = 1;

C2 = 0;

display(ctr);

}

else if (ctr>9)

53

Page 54: Project Report3

{

a=ctr/10;

b=ctr%10;

C1=1;

C2=0;

display(a);

C1=0;

C2=1;

display(b);

}

}

CODE3.h

#include <REGx51>

int i;

void delay(void)

{

for (i=0;i<10000;i++);

}

CODE4.h

#include <REGx51.h>

sbit relay1=P2^3;

sbit relay2=P2^4;

sbit relay3=P2^5;

sbit relay4=P2^6;

sbit relay5=P2^7;

void dec_light( int ctr)

54

Page 55: Project Report3

{

if(ctr>=9 && ctr<=16)

{

relay1=1

relay2=1;

relay3=1;

relay4=0;

relay5=1;

}

else if (ctr>=1 && ctr<=8)

{

relay1=1;

relay2=1;

relay3=0;

relay4=0;

relay5=0;

}

else if (ctr == 0 )

{

relay1=0;

relay2=0;

relay3=0;

relay4=0;

relay5=0;

}

}

CODE5.h

#include<REGx51.h>

void incr_light(int ctr)

55

Page 56: Project Report3

{

while(1)

{

if (ctr>=1 && ctr<=8)

{

relay1=1;

relay2=1;

relay3=0;

relay4=0;

relay5=0;

}

else if(ctr>=9 && ctr<=16)

{

relay1=1;

relay2=1;

relay3=1;

relay4=0;

relay5=1;

}

else if(ctr>16)

{

relay1=1;

relay2=1;

relay3=1;

relay4=1;

relay5=1;

}

}

}

56

Page 57: Project Report3

VALUES FOR SEVEN SEGMENT DISPLAY

Our project uses two seven segment display. Hexadecimal values for seven segment

display are as follows:

h g f e d c b a

0 0 0 1 1 1 1 1 1 0x3F

1 0 0 0 0 0 1 1 0 0x06

2 0 1 0 1 1 0 1 1 0x5B

3 0 1 0 0 1 1 1 1 0x4F

4 0 1 1 0 0 1 1 0 0x66

5 0 1 1 0 1 1 0 1 0x6D

6 0 1 1 1 1 1 0 0 0x7C

7 0 0 0 0 0 1 1 1 0x07

8 0 1 1 1 1 1 1 1 0x7F

9 0 1 1 0 0 1 1 1 0x67

The segments of seven segment display are given on port 0 of the

microcontroller(AT89S52)

57

Page 58: Project Report3

APPENDIX-2

DATASHEETS

58

Page 59: Project Report3

59

Page 60: Project Report3

TEAM 16 (IN INCREASING ORDER OF PCB NOS.)

PCB 9 - DIVYA KALSI

PCB 10 – RICHA SIKKA

PCB 14 – GURVEEN SINGH

PCB 26 – GUNSHEEN KAUR

PCB 32 - ANMOLDEEP SINGH

60