You are on page 1of 37

Automatic room light controller with visitor counter

Chapter 1 INTRODUCTION
1.1 ABOUT EMBEDDED SYSTEMS:
An embedded system is a computer system designed to do one or a few dedicated and/or specific functions often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a generalpurpose computer, such as a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded systems control many devices in common use today. Embedded systems are controlled by one or more main processing cores that are typically either microcontrollers or digital signal processors (DSP). The key characteristic, however, is being dedicated to handle a particular task. They may require very powerful processors and extensive communication, for example air traffic control systems may usefully be viewed as embedded, even though they involve mainframe computers and dedicated regional and national networks between airports and radar sites (each radar probably includes one or more embedded systems of its own). Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In general, "embedded system" is not a strictly definable term, as most systems have some element of extensibility or programmability. For example, handheld computers share some elements with embedded systems such as the operating systems and microprocessors that power them, but they allow different applications to be loaded and peripherals to be connected. Moreover, even systems that do not expose programmability as a primary feature generally need to support software updates. On a continuum from "general purpose" to "embedded", large application systems will have subcomponents at most points even if the system as a whole is "designed to perform one or a few dedicated functions", and is thus appropriate to call "embedded".

Automatic room light controller with visitor counter

1.2 ABOUT OUR PROJECT: Our project mainly deals with controlling the number of lights in a room according to the number of light present in the room. We used the concept of embedded systems in our project. We use a micro-controller to control the automatic counter of persons who are entering and leaving, making the system to be both flexible and accurate. In our project the counter is displayed using a LCD display, and the counter is counted using two IR sensors one at the entrance side and other at the exit side. When a person enters at the entrance side the count is incremented by one and when a person exits from the exit side the count decrements by one. The number of lights that are ON at a time depends on the number of persons that are present in that room. At any instance of time the number of persons present in that room is shown in the LCD display.

Automatic room light controller with visitor counter

Chapter 2 BLOCK DIAGRAM

Power supply

LCD Display

Entry pair LED

microcontroller
Exit pair

Automatic room light controller with visitor counter

2.1 Important components: Hardware:


1. Microcontroller 2. Lcd 3. IR sensor 4. Led 5. Power supply

Software:
1. Keil software 2. Embedded c

Automatic room light controller with visitor counter

Chapter 3 SCHEMATIC DIAGRAM


SPI _M I SO SPI _M OSI SPI _SC K

5V R1 10k
I 2C _D AT A

10K SIP 9
I 2C _C LK

J2 R2 4 6 2 15

5V C1 0.1uF

40

31

U2 1A-OP 2A-OP 3A-OP 4A-OP 10uF/25V FET_OP C2 DIM_OP 1 2 3 4 5 6 7 8 9 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST

SW1
1

P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7

39 38 37 36 35 34 33 32

7 8 9 10 11 12 13 14

EA/ VPP

VC C

IR PAIRS
3 R6 10K D5 1 5 16 LED RESISTOR

9 8 7 6 5 4 3 2

LCD
R19

RX1

30 ALE/PROG 29 PSEN

R7 8.2K

RXD TXD ADC_CS ADC_MOSI ADC_MISO ADC_CLK RLY-1 RLY-2

10 11 12 13 14 15 16 17 19

P3.0/RXD P3.1/TXD P3.2/INTO P3.3/INT1 P3.4/TO P3.5/T1 P3.6/WR P3.7/RD XTAL1

R21

D6

RESISTOR LED P2.7/A15 P2.6/A14 P2.5/A13 P2.4/A12 P2.3/A11 P2.2/A10 P2.1/A9 P2.0/A8 28 27 26 25 24 23 22 21 LED4 LED3 LED2 RX2 RX1 D7

RX2

R20

33PF C3 C6 33PF

Y1 18 XTAL2

AT89C51
GN D

LED R22

RESISTOR D10

20

11.0592M hz

RESISTOR LED

5V

5V R13 150E D1 LED4 LED R14 150E D2 LED3 LED R16 150E D3 LED2 LED

LED CKT

SW6 SW7 SW SLIDE-SPST D8 BRIDGE 3 1 U11 SW SLIDE-SPST 12V


GN D GN D

LM7812
VOUT 3

U12 1

LM7805
VOUT 3

5V

12V

5V

VIN

VIN

R33 220E J15 CON2 D9 J16 CON2 J17 CON2 J18 CON2 J19 CON2 J20 CON2

J21 1 2 PBT SW 2

C19 1000uF/35V

C20 10uF/25V C21 1000uF/35V C22 10uF/25V C23 0.1uF

1 2

1 2

1 2

1 2

1 2

POWER SUPPLY

1 2

3MM

Title <Title> Size A3 Date: Document Number <Doc> Tuesday, June 14, 2011 Sheet 1 of 1 Rev <RevCode>

Automatic room light controller with visitor counter

Chapter 4 WORKING PRINCIPLE


The 40th pin of the micro-controller is given to the power supply given +5v and 20th pin is grounded. The input from the entry IR sensor pair is given to the 1 st pin of the microcontroller whereas the input from the exit IR pair is given to the 2nd pin. The three rows of LEDs are connected to the first three pins of port 2 (2.0, 2.1, 2.2). The LCD display is connected to the 8 pins of port 0. Initially when the system is started the LCD display shows VACANT and there is a continues amount of energy transferred between transmitter and receiver of the IR sensor pair. When a person enters into the room there is an obstruction between the IR transmitter and the IR receiver at the entry side. This obstruction signal is given as input to microcontroller which increments the counter and this is displayed on the LCD display and according to the count the LEDs will glow. When a person leaves the room there is an obstruction between the IR transmitter and the IR receiver at the exit side. This signal is taken as input to micro-controller which decrements the counter and this is displayed on the LCD display and according to the count the LEDs will glow.

Automatic room light controller with visitor counter

Chapter 5 HARDWARE 5.1 Microcontroller:


A microcontroller (sometimes abbreviated C, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and

programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to

the microprocessors used in personal computers or other general purpose applications. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, and toys. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems. Some microcontrollers may use Four-bit words and operate at clock rate frequencies as low as 4 kHz, for low power consumption (milliwatts or microwatts). They will generally have the ability to retain functionality while waiting for an event such as a button press or other interrupt; power consumption while sleeping (CPU clock and most peripherals off) may be just nanowatts, making many of them well suited for long lasting battery applications. Other microcontrollers may serve performance-critical roles, where they may need to act more like a digital signal processor (DSP), with higher clock speeds and power consumption The micro controller used in our project is 89S52 microcontroller manufactured by Atmel company

Automatic room light controller with visitor counter

5.1.1 89S52 microcontroller:


Important features of 89S52 : Compatible with MCS-51 Products 8K 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 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Watchdog Timer Dual Data Pointer Fast Programming Time Green (Pb/Halide-free) Packaging Option The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industrystandard 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 AT89S52 is a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications.

Automatic room light controller with visitor counter

5.1.2 Architecture of 89S52:

The architecture of 89S52 us similar to that of a 8051 micro-controller the only difference is that in the flash memory. 89S52 contains 8kb flash memory where as 8051 has only 4kb EPROM. The 89S52 micro-controller is widely used 8 bit micro-controller because of this advantage.

Automatic room light controller with visitor counter

5.1.3 Pin diagram:


It is a 40 pin microcontroller which is similar to that of an 8051 microcontroller. The pin diagram is as follows:

Pin Description
VCC Supply voltage. GND Ground. Port 0 Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pullups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification. Port 1 Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the inter-nal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input

10

Automatic room light controller with visitor counter

(P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification.

Port pin P1.0 P1.1 P1.5 P1.6 P1.7

Alternate Functions T2 (external count input to Timer/Counter 2), clock-out T2EX (Timer/Counter 2 capture/reload trigger and direction control) MOSI (used for In-System Programming) MISO (used for In-System Programming) SCK (used for In-System Programming)

Port 2 Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3 Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 receives some control signals for Flash programming and verification. Port 3 also serves the functions of various special features of the AT89S52

11

Automatic room light controller with visitor counter

as shown in the following table.

Port pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7

Alternate features RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) RD (external data memory read strobe)

RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. ALE/PROG Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped dur-ing each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to exter-nal data memory. EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note,

12

Automatic room light controller with visitor counter

however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier.

5.1.4 Special Function Register (SFR) Memory:


Special Function Registers (SFR s) are areas of memory that control specific functionality of the 8051 processor. For example, four SFRs permit access to the 8051s 32 input/output lines. Another SFR allows the user to set the serial baud rate, control and access timers, and configure the 8051s interrupt system.

Accumulator:
The Accumulator, as its name suggests is used as a general register to accumulate the results of a large number of instructions. It can hold 8-bit (1-byte) value and is the most versatile register. The R registers: The R registers are a set of eight registers that are named R0, R1. Etc. up to R7. These registers are used as auxiliary registers in many operations. The B registers: The B register is very similar to the accumulator in the sense that it may hold an 8-bit (1-byte) value. Two only uses the B register 8051 instructions: MUL AB and DIV AB.

Data Pointer:
The Data pointer (DPTR) is the 8051s only user accessible 16-bit (2Bytes) register. The accumulator, R registers are all 1-Byte values. DPTR, as the name suggests, is used to point to data. It is used by a number of commands, which allow the 8051 to access external memory.

Program counter & Stack pointer:


The program counter (PC) is a 2-byte address, which tells the 8051 where the next instruction to execute is found in memory. The stack pointer like all registers except DPTR and PC may hold an 8-bit (1-Byte) value.

Memory:
Special Function Registers (SFRs) are areas of memory that control specific functionality of the 8051 processor. For example, four SFRs permit access to the 8051s 32 input/output lines. Another SFR allows the user to set the serial baud rate, control and access timers, and configure the 8051s interrupt system.

13

Automatic room light controller with visitor counter

Timer 2 Registers:
Control and status bits are contained in registers T2CON and T2MOD for Timer 2 . The register pair (RCAP2H , RCAP2L) are the Capture / Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode .

Interrupt Registers:
The individual interrupt enable bits are in the IE register . Two priorities can be set for each of the six interrupt sources in the IP register.

Symbol EA

Position

IE.7

ET2 ES ET1 EX1 ET0 EX0

IE.6 IE.5 IE.4 IE.3 IE.2 IE.1 IE.0

Function Disables all interrupts. If EA=0,no interrupt is acknowledged. If EA=1, each interrupt source is individually enabled or disabled by setting or clearing its enable bit. Reserved Timer 2 interrupt enable bit Serial port interrupt enable bit Timer 1 interrupt enable bit External interrupt 1 enable bit Timer 0 interrupt enable bit External interrupt 0 enable bit

Timer 2:
Timer 2 is a 16-bit Timer / Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has three operating Modes : capture , auto-reload ( up or down Counting ) , and baud rate generator . The modes are selected by bits in T2CON. Timer2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency. In the Counter function , the register is incremented in response to a 1-to-0 transition at its corresponding external input pin , T2 .When the samples show a high in one cycle and a low in the next cycle, the count is incremented . Since two machine cycles (24 Oscillator periods ) are required to recognize 1-to-0 transition , the maximum count rate is 1 / 24 of the oscillator frequency . To ensure that a given level is sampled at least once before it changes , the level should be held for at least one full machine cycle.

14

Automatic room light controller with visitor counter

5.2 LCD:
A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating properties of liquid crystals (LCs). LCs do not emit light directly. They are used in a wide range of applications, including computer

monitors, television, instrument panels, aircraft cockpit displays, signage, etc. They are common in consumer devices such as video players, gaming devices, clocks,

watches, calculators, and telephones. LCDs have displaced cathode ray tube (CRT) displays in most applications. They are usually more compact, lightweight, portable, less expensive, more reliable, and easier on the eyes. They are available in a wider range of screen sizes than CRT and plasma displays, and since they do not use phosphors, they cannot suffer image burn-in. LCDs are more energy efficient and offer safer disposal than CRTs. Its low electrical power consumption enables it to be used in battery-powered electronic equipment. It is an electronically-modulated optical device made up of any number of pixels filled with liquid crystals and arrayed in front of a light (backlight) or reflector to produce images in color or monochrome. The earliest discovery leading to the development of LCD technology, the discovery of liquid crystals, dates from 1888. By 2008, worldwide sales of televisions with LCD screens had surpassed the sale of CRT units.

5.2.1 Types of LCD:


1. Passive-matrix addressed LCDs 2. active-matrix addressed LCDs The type of LCD we used is a passive-matrix addressed LCD. Its working is given by

15

Automatic room light controller with visitor counter

Working of passive-matrix addressed LCD:

Each row or column of the display has a single electrical circuit. The pixels are addressed one at a time by row and column addresses. This type of display is called passivematrix addressed because the pixel must retain its state between refreshes without the benefit of a steady electrical charge. As the number of pixels (and, correspondingly, columns and rows) increases, this type of display becomes less feasible. Very slow response times and poor contrast are typical of passive-matrix addressed LCDs.

Working of active-matrix addressed LCD:

Layer1: Polarizing filter film with a vertical axis to polarize light as it enters. Layer2: Glass substrate with ITO electrodes. The shapes of these electrodes will determine the shapes that will appear when the LCD is turned ON. Vertical ridges etched on the surface are smooth. Layer3: Twisted nematic liquid crystal. Layer4: Glass substrate with common electrode film (ITO) with horizontal ridges to line up with the horizontal filter. Layer5: Polarizing filter film with a horizontal axis to block/pass light.

16

Automatic room light controller with visitor counter

Layer6: Reflective surface to send light back to viewer. (In a backlit LCD, this layer is replaced with a light source.)

5.2.2 Pin description:


In this project we used a 16*2 LCD display which means it contains 16 characters in each row and 2 rows in all. It is a 16 pin IC whose pin description is shown below:

17

Automatic room light controller with visitor counter

5.2.3 Advantages:

Very compact and light Low power consumption No geometric distortion Little or no flicker depending on backlight technology Not affected by screen burn-in No high voltage or other hazards present during repair/service Can be made in almost any size or shape No theoretical resolution limit Movies can be seen in HD quality

18

Automatic room light controller with visitor counter

5.3 IR Sensor:
5.3.1 Infrared:
Infrared (IR) light is electromagnetic radiation with a wavelength longer than that of visible light, measured from the nominal edge of visible red light at 0.74 micrometers, and extending conventionally to 300 micrometers. These wavelengths correspond to a frequency range of approximately 1 to 400THz, and include most of the thermal radiation emitted by objects near room temperature. Microscopically, IR light is typically emitted or absorbed by molecules when they change their rotational-vibrational movements. Sunlight at zenith provides an irradiance of just over 1 kilowatt per square meter at sea level. Of this energy, 527 watts is infrared radiation, 445 watts is visible light, and 32 watts is ultraviolet radiation.

Infrared sensor is made by using two components those are mainly IR emitter and IR phototransistor

19

Automatic room light controller with visitor counter

The circuit diagram of an IR sensor is given below :

5.3.2 IR Emitter:
An IR emitter is basically an IR range LED which is made up of gallium arsenide which emits near-infrared energy of about 880 nm. This LED produces continues amount of IR light that is produced from the voltage applied to the LED. This electrical energy is converted into light energy.

5.3.3 IR Phototransistor:
An IR phototransistor is a kind of transistor by which the voltage at the base of the transistor where the voltage is varied according to the amount of light hitting the transistor. Hence it acts as a variable current source. Greater amount of IR light cause greater currents to flow through the collector-emitter leads. As shown in the diagram below, the phototransistor is wired in a similar configuration to the voltage divider. The variable current traveling through the resistor causes a voltage drop in the pull-up resistor. This voltage is measured as the output of the device

5.3.4 Specifications:

IR TX RX size: 5mm diameter package IR LED current rating: 30mA nominal, 600mA pulse loading at 1% duty cycle IR LED wavelength: 940nM Photodiode peak response wavelength: 940nM

20

Automatic room light controller with visitor counter

5.4 LED:
LED's are special diodes that emit light when connected in a circuit. They are frequently used as "pilot" lights in electronic appliances to indicate whether the circuit is closed or not. As a clear (or often colored) epoxy case enclosed the heart of an LED, the semi-conductor chip.

5.4.1 Symbol Of LED:

5.4.2 Cross sectional view of LED:

5.4.3 Working of LED:


The most important part of a light emitting diode (LED) is the semi-conductor chip located in the center of the bulb as shown. The chip has two regions separated by a junction. The p region is dominated by positive electric charges, and the n region is dominated by negative electric charges. The junction acts as a barrier to the flow of electrons between the p and the n regions. Only when sufficient voltage is applied to the semi-conductor chip, can the current flow and the electrons cross the junction into the p region.

21

Automatic room light controller with visitor counter

In the absence of a large enough electric potential difference (voltage) across the LED leads, the junction presents an electric potential barrier to the flow of electrons. When sufficient voltage is applied to the chip across the leads of the LED, electrons can move easily in only one direction across the junction between the p and n regions. In the p region there are many more positive than negative charges. In the n region the electrons are more numerous than the positive electric charges. When a voltage is applied and the current starts to flow, electrons in the n region have sufficient energy to move across the junction into the p region. Once in the p region the electrons are immediately attracted to the positive charges due to the mutual Coulomb forces of attraction between opposite electric charges. When an electron moves sufficiently close to a positive charge in the P region, the two charges "re-combine". Each time an electron recombines with a positive charge; electric potential energy is converted into electromagnetic energy. For each recombination of a negative and a positive charge, a quantum of electromagnetic energy is emitted in the form of a photon of light with a frequency characteristic of the semi-conductor material (usually a combination of the chemical elements gallium, arsenic and phosphorus). Only photons in a very narrow frequency range can be emitted by any material.

5.4.4 Color of LED:


LED's that emit different colors are made of different semi-conductor materials, and require different energies to light them. The color of an LED is determined by the semiconductor material, not by the coloring of the 'package' (the plastic body). LEDs of all colors are available in uncolored packages which may be diffused (milky) or clear (often described as 'water clear'). The colored packages are also available as diffused (the standard type) or transparent.

22

Automatic room light controller with visitor counter

Color

Wavelength [nm] Voltage [V]

Semiconductor material

Infrared

> 760

V < 1.9

Gallium arsenide (GaAs) Aluminium gallium arsenide (AlGaAs)

Aluminium gallium arsenide (AlGaAs) 610 < < 760 1.63 < V < 2.03 Gallium arsenide phosphide (GaAsP) Aluminium gallium indium phosphide (AlGaInP) Gallium(III) phosphide (GaP)

Red

Gallium arsenide phosphide (GaAsP) Orange 590 < < 610 2.03 < V < Aluminium gallium indium 2.10 phosphide (AlGaInP) Gallium(III) phosphide (GaP)

Gallium arsenide phosphide (GaAsP) Yellow 570 < < 590 2.10 < V < Aluminium gallium indium 2.18 phosphide (AlGaInP) Gallium(III) phosphide (GaP)

Indium gallium nitride (InGaN) / Gallium(III) nitride (GaN) Green 500 < < 570 1.9[47] < V < 4.0 Gallium(III) phosphide (GaP) Aluminium gallium indium phosphide (AlGaInP) Aluminium gallium phosphide (AlGaP)

Blue

450 < < 500

2.48 < V <

Zinc selenide (ZnSe) Indium gallium nitride (InGaN)

23

Automatic room light controller with visitor counter

3.7

Silicon carbide (SiC) as substrate Silicon (Si) as substrate (under development)

Violet

400 < < 450

2.76 < V < 4.0

Indium gallium nitride (InGaN)

Purple

multiple types

2.48 < V < 3.7

Dual blue/red LEDs, blue with red phosphor, or white with purple plastic

Diamond (235 nm) Boron nitride (215 nm) Ultraviolet < 400 3.1 < V < 4.4 Aluminium nitride (AlN) (210 nm) Aluminium gallium nitride (AlGaN) Aluminium gallium indium nitride (AlGaInN) (down to 210 nm)

White

Broad spectrum

V = 3.5

Blue/UV diode with yellow phosphor

24

Automatic room light controller with visitor counter

5.5 Power supply block:


5.5.1 Block diagram:
Bridge Rectifier Positive Charge Capacitor Positive Voltage Regulator IC 7805 +5 Volts LPF

Step Down Transformer

As we all know any invention of latest technology cannot be activated without the source of power. So it this fast moving world we deliberately need a proper power source which will be apt for a particular requirement. All the electronic components starting from diode to Intel ICs only work with a DC supply ranging from _+5v to _+12. We are utilizing for the same, the cheapest and commonly available energy source of 230v-50Hz and stepping down, rectifying, filtering and regulating the voltage. This will be dealt briefly in the forthcoming sections.

5.5.2Step down transformer:


When AC is applied to the primary winding of the power transformer it can either be stepped down or up depending on the value of DC needed. In our circuit the transformer of 230v/15-0-15v is used to perform the step down operation where a 230V AC appears as 15V AC across the secondary winding. One alteration of input causes the top of the transformer to be positive and the bottom negative. The next alteration will temporarily cause the reverse. The current rating of the transformer used in our project is 2A. Apart from stepping down AC voltages, it gives isolation between the power source and power supply circuitries.

5.5.3 Bridge rectifier:


In the power supply unit, rectification is normally achieved using a solid state diode. Diode has the property that will let the electron flow easily in one direction at proper biasing condition . As AC is applied to the diode, electrons only flow when the anode and cathode is negative. Reversing the polarity of voltage will not permit electron flow. A commonly used circuit for supplying large amounts of DC power is the bridge rectifier. A bridge rectifier of four diodes (4*IN4007) are used to achieve full wave rectification. Two diodes will conduct during the negative cycle and the other two will conduct during the positive half cycle. The DC voltage appearing across the output terminals

25

Automatic room light controller with visitor counter

of the bridge rectifier will be somewhat less than 90% of the applied rms value. Normally one alteration of the input voltage will reverse the polarities. Opposite ends of the transformer will therefore always be 180 deg out of phase with each other.

For a positive cycle, two diodes are connected to the positive voltage at the top winding and only one diode conducts. At the same time one of the other two diodes conducts for the negative voltage that is applied from the bottom winding due to the forward bias for that diode. In this circuit due to positive half cycleD1 & D2 will conduct to give 10.8v pulsating DC. The DC output has a ripple frequency of 100Hz. Since each altercation produces a resulting output pulse, frequency = 2*50 Hz. The output obtained is not a pure DC and therefore filtration has to be done.

5.5.4Filtering unit:
Filter circuit which is usually capacitor acting as a surge arrester always follow the rectifier unit. This capacitor is also called as a decoupling capacitor or a bypassing capacitor, is used not only to short the ripple with frequency of 120Hz to ground but also to leave the frequency of the DC to appear at the output. A load resistor R1 is connected so that a reference to the ground is maintained. C1R1 is for bypassing ripples. C2R2 is used as a low pass filter, i.e. it passes only low frequency signals and bypasses high frequency signals. The load resistor should be 1% to 2.5% of the load.

1000f/25v 10f/25v O,1f

: for the reduction of ripples from the pulsating. : for maintaining the stability of the voltage at the load side. : for bypassing the high frequency disturbances.

5.5.5 Voltage regulator:


The voltage regulators play an important role in any power supply unit. The primary purpose of a regulator is to aid the rectifier and filter circuit in providing a constant DC voltage to the device. Power supplies without regulators have an inherent problem of changing DC voltage values due to variations in the load or due to fluctuations in the AC liner voltage. With a regulator connected to the DC output, the voltage can be maintained within a close tolerant region of the desired output. IC7805 is used in this project for providing +5v DC supply.

26

Automatic room light controller with visitor counter

Chapter 6 SOFTWARE 6.1 KEIL:


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 .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 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. 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 your 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 .Now after going through the concept of compiler and cross compilers lets we start with Keil C cross compiler.

6.1.1 Keil C 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 you with software development tools for the 8051microcontrollers. With these tools, you can generate embedded applications for the multitude of 8051 derivatives.

27

Automatic room light controller with visitor counter

Keil provides following tools for 8051 development 1. 8051 Optimizing C Cross Compiler 2. 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.

6.1.2 8051 project development cycle:


These are the steps to develop 8051 project using keil Create source files in C or assembly. Compile or assemble source files. Correct errors in source files. Link object files from compiler and assembler.

28

Automatic room light controller with visitor counter

6.2 Embedded C:
The program that is written on a micro controller by using either assembly level programming or by embedded C. By comparing both assembly language and embedded C, writing in embedded C is easy since it is written in simple C language. Most C programmers are spoiled because they program in environments where not only is there a standard library implementation, but there are frequently a number of other libraries available for use. The cold fact is, that in embedded systems, there rarely are many of the libraries that programmers have grown used to, but occasionally an embedded system might not have a complete standard library, if there is a standard library at all. Few embedded systems have capability for dynamic linking, so if standard library functions are to be available at all, they often need to be directly linked into the executable. Oftentimes, because of space concerns, it is not possible to link in an entire library file, and programmers are often forced to "brew their own" standard c library implementations if they want to use them at all. While some libraries are bulky and not well suited for use on microcontrollers, many development systems still include the standard libraries which are the most common for C programmers. C remains a very popular language for micro-controller developers due to the code efficiency and reduced overhead and development time. C offers low-level control and is considered more readable than assembly. Many free C compilers are available for a wide variety of development platforms. The compilers are part of an IDEs with ICD support, breakpoints, single-stepping and an assembly window. The performance of C compilers has improved considerably in recent years, and they are claimed to be more or less as good as assembly, depending on who you ask. Most tools now offer options for customizing the compiler optimization. Additionally, using C increases portability, since C code can be compiled for different types of processors.

29

Automatic room light controller with visitor counter

6.2.1 C compilers for embedded systems:


Perhaps the biggest difference between C compilers for embedded systems and C compilers for desktop computers is the distinction between the "platform" and the "target". The "platform" is where the C compiler runs -- perhaps a laptop running Linux or a desktop running Windows. The "target" is where the executable code generated by the C compiler will run -- the CPU in the embedded system, often without any underlying operating system.

The GCC compiler is the most popular C compiler for embedded systems. GCC was originally developed for 32-bit Princeton architecture CPUs. So it was relatively easily ported to target ARM core microcontrollers such as XScale and Atmel AT91RM9200; Atmel AVR32 AP7 family; MIPS core microcontrollers such as the Microchip PIC32; and Freescale 68k/ColdFire processors. The people who write compilers have also (with more difficulty) ported GCC to target the Texas Instruments MSP430 16-bit MCUs; the Microchip PIC24 and dsPIC 16-bit Microcontrollers; the 8-bit Atmel AVR microcontrollers; the 8-bit Freescale 68HC11 microcontrollers. Other microcontrollers are very different from a 32-bit Princeton architecture CPU. Many compiler writers have decided it would be better to develop an independent C compiler rather than try to force the round peg of GCC into the square hole of 8-bit Harvard architecture microcontroller targets: SDCC - Small Device C Compiler for the Intel 8051, Maxim 80DS390, Zilog Z80, Motorola 68HC08, Microchip PIC16, Microchip PIC18 There are some highly respected companies that sell commercial C compilers. You can find such a commercial C compiler for practically every microcontroller, including the above-listed microcontrollers. Popular microcontrollers not already listed (i.e.,

microcontrollers for which the only known C compiler is a commercial C compiler) include the Cypress M8C MCUs; Microchip PIC10 and Microchip PIC12 MCUs; etc.

30

Automatic room light controller with visitor counter

Chapter 7 SOURCE CODE


#include <AT89X52.H> #include <lcd.h> sbit out = P1^1; sbit in = P1^0; sbit row1 = P2^0; sbit row2 = P2^1; sbit row3 = P2^2; void dispcount(unsigned int count); unsigned int count=0; void main() { init_lcd(); row1=row2=row3=1; while(1) { if(in==1) { count++; while(in==1); }

31

Automatic room light controller with visitor counter

if(out==1) { if(count<=0) count=0; if(count>0) count--; while(out!=0); } dispcount(count); if(count<=0) row1=row2=row3=1; if(count>0 && count<=20) row1=0; if(count>20 && count<=40) row1=row2=0; if(count>40 && count<=50) row1=row2=row3=0; } }

void dispcount(unsigned int count) { unsigned int n,r,i;

32

Automatic room light controller with visitor counter

unsigned int a[5]={0,0,0,0,0}; unsigned int d=0; unsigned int c=5; n = count; cmd_lcd(0xC5); delay_ms(1); if(count>0) { while(n!=0) { r = n%10; a[--c]=r; d = n/10; n = d; } for(i=0;i<=4;i++) { data_lcd(a[i]+0x30); delay_ms(1); } data_lcd(' '); delay_ms(1); }

33

Automatic room light controller with visitor counter

if(count<=0) { cmd_lcd(0xc5); delay_ms(1); display_lcd("VACANT"); } }

34

Automatic room light controller with visitor counter

Chapter 8 APPLICATIONS AND SCOPE FOR FUTURE WORK 8.1 Applications


These are mainly used in various environments such as Cinema halls Auditoriums Offices

These can be used in home appliances also by replacing the LEDs with electrical appliances such as fans.

8.2 Future Scope


This project can be further improved by using some additional devices like LDR which will be used so that the system is not activated under sun light so that this can be used in every aspect as well. This project can be further modified so that we can use the project with different electrical appliances such as fans.

35

Automatic room light controller with visitor counter

CONCLUSION
From this project we can understand that by using micro-controller based applications we can provide automatic switching of devices so that we can reduce the time of regularly switching the devices. The accuracy of the switching also increases by using automatic circuits provided by using micro-controller. This project gives us one of the best ways of minimizing the human effort and increasing the efficiency of the circuit. This project is also helps in providing the number of people present in the room at any instant of time giving us the advantage of knowing the density of the meeting. This project can be used in so many ways so that we can change the device which we are using, so that we can use it for more than one purpose by just changing small amount of code.

36

Automatic room light controller with visitor counter

REFERENCES www.google.co.in www.wikipedia.org www.wikibooks.com www.8051projects.net


The 8051 Micro controller and Embedded Systems - Muhammad Ali Mazidi, Janice Gillispie Mazidi Introduction to Embedded Systems Raj Kamal, TMS, 2002 Embedded System Design A Unified Hardware/Software Introduction - Frank Vahid, Tony D. Givargis, John Wiley, 2002.

37

You might also like