You are on page 1of 65

Generated by Foxit PDF Creator © Foxit Software

http://www.foxitsoftware.com For evaluation only.


AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Chapter 1

Introduction

Department of E&C Page1 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

1. INTRODUCTION

This Project “Automatic Room Light Controller with Visitor Counter using
Microcontroller” is a reliable circuit that takes over the task of controlling the room lights
as well us counting number of persons/ visitors in the room very accurately. When
somebody enters into the room then the counter is incremented by one and the light in the
room will be switched ON and when any one leaves the room then the counter is
decremented by one. The light will be only switched OFF until all the persons in the
room go out. The total number of persons inside the room is also displayed on the seven
segment displays. 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 AT89c251 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
are obstructed , this obstruction is sensed by the Microcontroller.

Department of E&C Page2 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

1.1 Block Diagram

2 X 16
LCD
IR IR
SENSOR SENSOR 89C52
Microcontro
ller

POWER
SUPPLY
COUNTER

1.2 Components used


1. Switches
• Transistors
• Relays

2. Regulators
3. 89c51 microcontroller
4. Sensors
5. Capacitors
6. Diodes
7. Potentiometer
8. Bulb
9. Master PCB

Department of E&C Page3 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

1.3 Circuit Diagram

Department of E&C Page4 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Chapter 2

89C52
Microcontroller

Department of E&C Page5 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

89C52 MICROCONTROLLER

2. INTRODUCTION

The Intel 89C52 is Harvard architecture, single chip microcontroller (µC) which was
developed by Intel in 1980 for use in embedded systems. Intel's original versions were
popular in the 1980s and early 1990s, but has today largely been superseded by a vast
range of faster and/or functionally enhanced 8051-compatible devices manufactured by
more than 20 independent manufacturers including Atmel, Infineon Technologies
(formerly Siemens AG), Maxim Integrated Products (via its Dallas Semiconductor
subsidiary), NXP (formerly Philips Semiconductor), Nuvoton (formerly Winbond), ST
Microelectronics, Silicon Laboratories (formerly Cygnal), Texas Instruments and Cypress
Semiconductor. Intel's official designation for the 8051 family of µCs is MCS 51.Intel's
original 8051 family was developed using NMOS technology, but later versions,
identified by a letter C in their name (e.g., 80C51) used CMOS technology and were less
power-hungry than their NMOS predecessors. This made them more suitable for battery-
powered devices.

The ISSI IS89C52 is a high-performance microcontroller fabricated using high-density


CMOS technology. The CMOS IS89C52 is functionally compatible with the industry
standard 80C51 microcontrollers. The IS89C52 is designed with 8-Kbytes of Flash
memory, 258 x 8 RAM; 32 programmable I/O lines; a serial I/O port for either
multiprocessor communications, I/O expansion or full duplex UART; three 16-bit
timer/counters; an eight-source, two-priority-level, nested interrupt structure; and an on-
chip oscillator and clock circuit. The IS89C52 can be expanded using standard TTL
compatible memory.

Department of E&C Page6 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

2.1 Block Diagram of 89C52

Figure 2.1

Department of E&C Page7 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

2.2 FEATURES

• 80C51 based architecture


• 8-Kbytes of on-chip Reprogrammable Flash Memory
• 256 x 8 RAM •
• Three 16-bit Timer/Counters
• Full duplex serial channel Boolean processor
• Four 8-bit I/O ports, 32 I/O lines
• Memory addressing capability – 64K ROM and 64K RAM
• Program memory lock – Lock bits (3)
• Power save modes: – Idle and power-down
• Eight interrupt sources
• Most instructions execute in 0.3 µs
• CMOS and TTL compatible
• Maximum speed: 40 MHz @ Vcc = 5V
• Industrial temperature available
• Packages available: – 40-pin DIP – 44-pin PLCC – 44-pin PQFP

Department of E&C Page8 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

2.3 PIN DISCRIPTION

89c51 PIN OUT

• Power - Vcc, Vss


• Reset - RST
• Crystal - XTAL[1,2]
• External device interfacing
EA, ALE, PSEN, WR, RD
• I/O Port
P0 [7; 0], P1 [7:0], P2 [7:0], P3
• P3 is shared with control lines
Serial I/O RxD, TxD,
external interrupts INT0, INT1
Counter control T0, T1

Department of E&C Page9 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

2.4 BASIC CIRCUIT -THAT MAKES 89C51 WORKS.

EA/VP Pin

The EA on pin 31 is tied high to make the 8051 executes program from Internal ROM

Reset Circuit

Figure 2.4

Department of E&C Page10 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

RESET is an active High input When RESET is set to High, 8051 goes back to the power
on state.
The 8051 is reset by holding the RST high for at least two machine cycles and then
returning it low.

Power-On Reset

- Initially charging of capacitor makes RST High


- When capacitor charges fully it blocks DC.

Manual reset

-closing the switch momentarily will make RST High.

After a reset, the program counter is loaded with 0000H but the content of on-chip RAM
is not affected.

Register Content Register Content


Program counter 0000h IP XXX00000b
Accumulator 00h IEv 0XX00000b
B register 00h All timer registers 00h
PSW 00h SCON 00h
SP 07h SBUF 00h
DPTR 0000h PCON (HMOS) 0XXXXXXXbv
All ports FFh PCON (CMOS)v 0XXX0000b

Department of E&C Page11 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

2.5 Oscillator Circuit

The 8051 uses the crystal for precisely that: to synchronize it’s operation. Effectively, the
8051 operates using what are called "machine cycles." A single machine cycle is the
minimum amount of time in which a single 8051 instruction can be executed. Although
many instructions take multiple cycles.

8051 has an on-chip oscillator. It needs an external crystal that’s decides the operating
frequency of the 8051.

This can be achieved in two ways,

• The crystal is connected to pins 18 and 19 with stabilizing capacitors. 12 MHz


(11.059MHz) crystal is often used and the capacitance ranges from 20pF to
40pF.
• The oscillator can also be a TTL clock source connected with a NOT gate as
shown

Figure 2.5

Department of E&C Page12 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

2.6 How fast 89C51 works?

A cycle is, in reality, 12 pulses of the crystal. That is to say, if an instruction takes one
machine cycle to execute, it will take 12 pulses of the crystal to execute. Since we know
the crystal is pulsing 11,059,000 times per second and that one machine cycle is 12
pulses, we can calculate how many instruction cycles the 8051 can execute per second:

11,059,000 / 12 = 921,583

Why is such an oddball crystal frequency?

11.0592 MHz crystals are often used because it can be divided to give you exact clock
rates for most of the common baud rates for the UART, especially for the higher speeds
(9600, 19200). Despite the "oddball" value, these crystals are readily available and
commonly used.

Department of E&C Page13 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

CHAPTER 3

Interfacing
LCD, RELAYS,
Transistors and LDRs

Department of E&C Page14 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

3.1 INTERFACING WITH LCD

3.1.1 Introduction

The most commonly used Character based LCDs are based on Hitachi's HD44780
controller or other which are compatible with HD44580. In this tutorial, we will discuss
about character based LCDs, their interfacing with various microcontrollers, various
interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with these
simple looking LCDs which can give a new look to your application.

3.1.2. Pin Description

The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line
LCDs which have only 1 controller and support at most of 80 characters, whereas LCDs
supporting more than 80 characters make use of 2 HD44780 controllers.

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two
pins are extra in both for back-light LED connections). Pin description is shown in the
table below.

Figure 3.1.2: Character LCD type HD44780 Pin diagram

Department of E&C Page15 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Pin No. Name Description


Pin no. 1 VSS Power supply (GND)
Pin no. 2 VCC Power supply (+5V)
Pin no. 3 VEE Contrast adjust
0 = Instruction input
Pin no. 4 RS
1 = Data input
0 = Write to LCD module
Pin no. 5 R/W 1 = Read from LCD
module
Pin no. 6 EN Enable signal

Pin no. 7 to14 D0 to D7 Data

3.1.3 EXPLATION OF LCD

Most projects you create with the 8051 CPU require some form of display. The most
common way to accomplish this is with the LCD (Liquid Crystal Display). LCDs have
become a cheap and easy way to get text display for embedded system Common displays
are set up as 16 to 20 characters by 1 to 4 lines.

Department of E&C Page16 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

PIN EXPLANATION

• 8 data pins D7:D0


Bi-directional data/command pins.
Alphanumeric characters are sent in ASCII format.

• RS: Register Select


RS = 0 => Command Register is selected
RS = 1 => Data Register is selected

• R/W: Read or Write


0 => Write, 1 => Read

• E: Enable (Latch data)


Used to latch the data present on the data pins.
A high-to-low edge is needed to latch the data.

3.1.4 INTERFACING LCD TO 8051


The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data
bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit
data bus.
• If a 4-bit data bus is used, the LCD will require a total of 7 data lines.
• If an 8-bit data bus is used, the LCD will require a total of 11 data lines.

The three control lines are EN, RS, and RW.

Note that the EN line must be raised/lowered before/after each instruction sent to the
LCD regardless of whether that instruction is read or write text or instruction. In short,
you must always manipulate EN when communicating with the LCD. EN is the LCD's
way of knowing that you are talking to it. If you don't raise/lower EN, the LCD doesn't
know you're talking to it on the other lines.

Department of E&C Page17 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

3.1.5 CIRCUIT DIAGRAM OF INERFACING LCD WITH


MICROCONTROLLER

3.1.6 ALGORITHUM TO SEND DATA ON LCD

1. Make R/W low

2. Make RS=0; if data byte is command

RS=1; if data byte is data (ASCII value)

3. Place data byte on data register

4. Pulse E (HIGH to LOW)

5. Repeat the steps to send another data byte

Department of E&C Page18 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

3.2 INTERFACING OF TRANSISTOR WITH 8051

The diagram above showing typical microcontroller interface circuit using NPN
transistor; the RB resistor is used to control the current on base terminal that make
transistor OFF and ON (saturate); while the RC resistor is the current limiter for the
load. if the load operate with the same voltage as the supplied power (Vcc) you can by
pass the RC (not use).

Notice the diode (also known as the clamp diode) in the inductive load circuit is needed
to protect the transistor again the EMF (Electromotive Force) voltage generated by the
inductor component when the transistor is switched on and off rapidly, this voltage is
oppose the source voltage. The diode will act as a short circuit to the high voltage
generated by the inductor component, you can use any general purpose diode with
capable on handling minimum 1 A of current such as 1N4001, 1N4002, etc.

Department of E&C Page19 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

3.3 INTERFACING OF LDR

LDR is nothing but the light dependent resistor whose resistance varies or swings depend
on the intensity of light falls on it. So The LDR's resistance can reach 1M in dark
conditions and 100 ohms in full brightness. So there will be instaneous variations from
voltage level to VCC to GND by making use of following circuit.

Here Vcc can be connected to 12V so if u can make use of LDR = 1k you can get the
voltage around 5V across it.

When u connect a LDR to a d.c. power source via a


resistance, u will get a analog output voltage which has to be connected to a ADC which
converts that analog voltage to a corresponding digital output accessible by the 8051.

3.3.1Block diagram of interfacing of 89c52 to LDR

Signal
LDR conditioning ADC 89C52
ckt

3.3.2 CIRCUIT DIAGRAM OF INTERFACING WITH LDR

Department of E&C Page20 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

3.4 INTERFACING OF RELAY TO MICROCONTROLLER

Relays are devices which allow low power circuits to switch a relatively high
Current/Voltage ON/OFF. For a relay to operate a suitable pull-in & holding current
should be passed through its coil. Generally relay coils are designed to operate from a
particular voltage often its 5V or 12V.

The function of relay driver circuit is to provide the necessary current (typically 25
to 70ma) to energize the relay coil.

3.4.1 Circuit Diagram

Figure 1

Figure 1 shows the basic relay driver circuit. As you can see an NPN transistor BC547
is being used to control the relay. The transistor is driven into saturation (turned ON)
when a LOGIC 1 is written on the PORT PIN thus turning ON the relay. The relay is
turned OFF by writing LOGIC 0 on the port pin.

A diode (1N4007/1N4148) is connected across the relay coil, this is done so as to protect
the transistor from damage due to the BACK EMF generated in the relay's inductive coil

Department of E&C Page21 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

when the transistor is turned OFF. When the transistor is switched OFF the energy stored
in the inductor is dissipated through the diode & the internal resistance of the relay coil

As you can see we have used a pull up resistor at the base


of the transistor. AT8951/52/55 has an internal pull up resistor of 10k so when the pin is
pulled high the current flows through this resistor so the maximum output current is
5v/10K = 0.5ma, the DC current gain of BC547 is 100 so the maximum collector current
we can get is 0.5ma x 100 = 50ma, but most of the relays require more than 70ma-130ma
current depending on the relay that we have used, 0.5ma of base current is not suitable
enough for turning ON the relay, so we have used an external pull up resistor. When the
controller pin is high current flows through the controller pin i.e. 5v/10k=0.5ma as well
as through the pull up resistor. We have used 4.7k pull up resistor so 5v/4.7k=1.1ma so
maximum base current can be 0.5ma + 1.1ma=1.6ma i.e. collector current =1.6ma x 100
= 160ma which is enough to turn ON most of the relays.

NOTE: This relay driver circuit is to be used only with controllers for using this circuit
with other digital IC's like LM 555 use a resistor should be used between that IC's
output & the base of transistor. No need of pull up resistor in that case.

Department of E&C Page22 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

CHAPTER 4

Switches

Department of E&C Page23 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4 Switches

• Transistors
• Relays

4.1 Bipolar Transistor

4.1.1 Introduction

In the Diode tutorials we saw that simple diodes are made up from two pieces of
semiconductor material, either Silicon or Geranium to form a simple PN-junction and we
also learnt about their properties and characteristics. If we now join together two
individual diodes end to end giving two PN-junctions connected together in series, we
now have a three layer, two junctions, three terminal device forming the basis of a
Bipolar Junction Transistor, or BJT for short. This type of transistor is generally
known as a Bipolar Transistor, because its basic construction consists of two PN-
junctions with each terminal or connection being given a name to identify it and these are
known as the Emitter, Base and Collector respectively.

The word Transistor is an acronym, and is a combination of the words Transfer Varistor
used to describe their mode of operation way back in their early days of development.
There are two basic types of bipolar transistor construction, NPN and PNP, which
basically describes the physical arrangement of the P-type and N-type semiconductor
materials from which they are made. Bipolar Transistors are "CURRENT" Amplifying or
current regulating devices that control the amount of current flowing through them in
proportion to the amount of biasing current applied to their base terminal. The principle
of operation of the two transistors types NPN and PNP, is exactly the same the only
difference being in the biasing (base current) and the polarity of the power supply for
each type.

Department of E&C Page24 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4.1.2 Bipolar Transistor Construction

The construction and circuit symbols for both the NPN and PNP bipolar transistor are
shown above with the arrow in the circuit symbol always showing the direction of
conventional current flow between the base terminal and its emitter terminal, with the
direction of the arrow pointing from the positive P-type region to the negative N-type
region, exactly the same as for the standard diode symbol.

4.1.3 NPN Transistors

In the previous tutorial we saw that the standard Bipolar Transistor or BJT, comes in
two basic forms. An NPN (Negative-Positive-Negative) type and a PNP (Positive-
Negative-Positive) type, with the most commonly used transistor type being NPN
Transistors. We also learnt that the transistor junctions can be biased in one of three
different ways - Common Base, Common Emitter and Common Collector. In this
tutorial we will look more closely at the "Common Emitter" configuration using NPN
Transistors and an example of its current flow characteristics is given below.

Department of E&C Page25 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4.1.4 NPN Transistor Configuration

Figure 4.1.3

Note: Conventional current flow.

We know that the transistor is a "CURRENT" operated device and that a large current
(Ic) flows freely through the device between the collector and the emitter terminals.
However, this only happens when a small biasing current (Ib) is flowing into the base
terminal of the transistor thus allowing the base to act as a sort of current control input.
The ratio of these two currents (Ic/Ib) is called the DC Current Gain of the device and is
given the symbol of hfe or nowadays Beta, (β). Beta has no units as it is a ratio. Also, the
current gain from the emitter to the collector terminal, Ic/Ie, is called Alpha, (α), and is a
function of the transistor itself. As the emitter current Ie is the product of a very small
base current to a very large collector current the value of this parameter α is very close to
unity, and for a typical low-power signal transistor this value ranges from about 0.950 to
0.999.

Department of E&C Page26 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4.1.5 PNP Transistors

PNP Transistors are the exact opposite to the NPN Transistors device we looked at
previously. Basically, in this type of transistor construction the two diodes are reversed
with respect to the NPN type, with the arrow, which also defines the Emitter terminal this
time pointing inwards in the transistor symbol. Also, all the polarities are reversed which
means that PNP Transistors "sink" current as opposed to the NPN transistor which
"sources" current. Then, PNP Transistors use a small output base current and a negative
base voltage to control a much larger emitter-collector current. The construction of a PNP
transistor consists of two P-type semiconductor materials either side of the N-type
material as shown below.

4.1.6 PNP Transistor Configuration

Note: Conventional current flow.

PNP Transistors have very similar characteristics to their NPN bipolar cousins, except
that the polarities (or biasing) of the current and voltage directions are reversed for any
one of the possible three configurations looked at in the first tutorial, Common Base,
Common Emitter and Common Collector. Generally, PNP Transistors require a negative
(-ve) voltage at their Collector terminal with the flow of current through the emitter-
collector terminals being Holes as opposed to Electrons for the NPN types. Because the
movement of holes across the depletion layer tends to be slower than for electrons, PNP
transistors are generally more slower than their equivalent NPN counterparts when
operating.

Department of E&C Page27 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4.1.7Transistor Matching

You may think what is the point of having PNP Transistors, when there are plenty of
NPN Transistors available?. Well, having two different types of transistors PNP & NPN,
can be an advantage when designing amplifier circuits such as Class B Amplifiers that use
"Complementary" or "Matched Pair" transistors or for reversible H-Bridge motor control
circuits. A pair of corresponding NPN and PNP transistors with near identical
characteristics to each other are called Complementary Transistors for example, a
TIP3055 (NPN), TIP2955 (PNP) are good examples of complementary or matched pair
silicon power transistors. They have a DC current gain, Beta, (Ic / Ib) matched to within
10% and high Collector current of about 15A making them suitable for general motor
control or robotic applications.

4.1.8 Identifying PNP Transistors

We saw in the first tutorial of this Transistors section, that transistors are basically made
up of two Diodes connected together back-to-back. We can use this analogy to determine
whether a transistor is of the type PNP or NPN by testing its Resistance between the three
different leads, Emitter, Base and Collector. By testing each pair of transistor leads in
both directions will result in six tests in total with the expected resistance values in Ohm's
given below.

1. Emitter-Base Terminals - The Emitter to Base should act like a normal diode and
conduct one way only.

2. Collector-Base Terminals - The Collector-Base junction should act like a normal


diode and conduct one way only

3. Emitter-Collector Terminals - The Emitter-Collector should not conduct in either


direction.

Department of E&C Page28 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4.2 RELAY

4.2.1Introduction

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.

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. For further information about switch contacts and the terms used to
describe them please see the page on switches.

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.

Department of E&C Page29 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

The supplier's catalogue should show you 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 you must connect a protection diode across the relay coil.

4.2.2 CIRCUIT SYMBOL FOR RELAY

The relay's switch connections are usually labelled 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.
• Connect to COM and NO if you want the switched circuit to be on when the
relay coil is on.
• Connect to COM and NC if you want the switched circuit to be on when the
relay coil is off.

Circuit Symbol for Relay

4.2.3 What does a relay do?

A relay is used to indirectly control power on/off to high current draw applications. This
allows you to use a low current carrying switch to control high amperage equipment
without using much more expensive switches and extensive runs of large gage wire.
Relays also are often remote mounted keeping hi current cables/wires away from the
user. Think about it... a worker at a power distribution facility doesn't run outside, drive
to the dam 25 miles away then throw a giant switch every time he needs to route power

Department of E&C Page30 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

somewhere. He merely throws a switch which activates a remote relay controlling the
power. No need to be right there, no need to run costly heavier gage wires to the worker's
location On a much smaller scale, you are using relays everyday you drive your rig for
everything from headlights to cooling fans.

4.2.4 Choosing a relay

You need to consider several features when choosing a relay:

1. Physical size and pin arrangement


If you are choosing a relay for an existing PCB you will need to ensure that its
dimensions and pin arrangement are suitable. You 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. You can
use Ohm's law to calculate the current:

supply voltage
Relay coil current =
coil resistance

4. For example: A 12V supply relay with a coil resistance of 400 passes a current
of 30mA. This is OK for a 555 timer IC (maximum output current 200mA), but it
is too much for most ICs and they will require a transistor to amplify the current.
5. Switch ratings (voltage and current)
The relay's switch contacts must be suitable for the circuit they are to control. You
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".

Department of E&C Page31 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6. Switch contact arrangement (SPDT, DPDT etc)


Most relays are SPDT or DPDT which are often described as "single pole
changeover" (SPCO) or "double pole changeover" (DPCO). For further
information please see the page on switches.

4.2.5 Protection diodes for relays

Transistors and ICs must be protected from the brief high voltage produced when a relay
coil is switched off. The diagram shows how a signal diode (eg 1N4148) is connected
'backwards' across the relay coil to provide this protection.

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.

Department of E&C Page32 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

4.2.6 Advantages and Disadvantage of relays

Advantages of relays:

• Relays can switch AC and DC, transistors can only switch DC.
• Relays can switch high voltages, transistors cannot.
• Relays are a better choice for switching large currents (> 5A).
• Relays can switch many contacts at once.

Disadvantages of relays:

• Relays are bulkier than transistors for switching small currents.


• Relays cannot switch rapidly (except reed relays), transistors can switch many
times per second.
• Relays use more power due to the current flowing through their coil.
• Relays require more current than many ICs can provide, so a low power
transistor may be needed to switch the current for the relay's coil.

4.2.7 Uses of Relay

To control hi current circuits that your existing fuse box can't handle.
For example, I use a relay to control power to my c.b. linear which uses a 25 amp fuse.
High current headlights often come with a relay bundle to keep from frying your original
headlight harness while letting your original headlight circuit act as the switching control.
Fog lights are a good candidate for the 'Simple Relay Circuit'.

Department of E&C Page33 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

CHAPTER 5

Diodes, Capacitors
and Resistors

Department of E&C Page34 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

5.1 Diodes
5.1.1 Introduction
In electronics a diode is a two-terminal electronic component that restricts current flow
chiefly to one direction. The term usually refers to a semiconductor diode, the most
common type today, which is a crystal of semiconductor connected to two electrical
terminals, a P-N junction. A vacuum tube diode, now little used, is a vacuum tube with
two electrodes; a plate and a cathode.

The most common function of a diode is to allow an electric current in one direction
(called the forward direction) while blocking current in the opposite direction (the
reverse direction). Thus, the diode can be thought of as an electronic version of a check
valve. This unidirectional behavior is called rectification, and is used to convert
alternating current to direct current, and remove modulation from radio signals in radio
receivers.

However diodes can have more complicated behavior than this simple on-off action, due
to their complex non-linear electrical characteristics, which can be tailored by varying the
construction of their P-N junction. These are exploited in special purpose diodes that
perform many different functions. Diodes are used to regulate voltage (Zener diodes),
electronically tune radio and TV receivers (varactor diodes), generate radio frequency
oscillations (tunnel diodes), and produce light (light emitting diodes).

Diodes were the first semiconductor electronic devices. The discovery of crystals'
rectifying abilities was made by German physicist Ferdinand Braun in 1897. The first
semiconductor diodes, called cat's whisker diodes were made of crystals of minerals such
as galena. Today most diodes are made of silicon, but other semiconductors such as
germanium are sometimes used.

Department of E&C Page35 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Electronic Symbol

5.1.2 Semiconductor diodes

Most diodes today are based on semiconductor p-n junctions. In a p-n diode,
conventional current is from the p-type side (the anode) to the n-type side (the cathode),
but not in the opposite direction. Another type of semiconductor diode, the Schottky
diode, is formed from the contact between a metal and a semiconductor rather than by a
p-n junction.

In this discussion the term diode and rectifier will be used interchangeably; however, the
term diode usually implies a small signal device with current typically in the milliamp
range; and a rectifier, a power device, conducting from1 to 1000 amps or even higher.
Many diodes or rectifiers are identified as 1NXXXX. A semiconductor diode consists of
a PN junction and has two (2) terminals, an anode (+) and a cathode (-). Current flows
from anode to cathode within the diode. A diode and schematic representation are shown
below.

5.1.3 Ideal Diode as a Switch

An ideal diode is like a light switch in your home. When the switch is closed, the
circuit is completed; and the light turn’s on. When the switch is open, there is no current
and the light is off.
This can be shown as:

Department of E&C Page36 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

However, the diode has an additional property; it is unidirectional, i.e. current flows in
only one direction (anode to cathode internally).When a forward voltage is applied, the
diode conducts; and when a reverse voltage is applied, there is no conduction. A
mechanical analogy is a rat chat, which allows motion in one direction only.

An ideal diode characteristic would be:

However, a typical diode characteristic is more like the following:

5.1.4 I-V CHARACTERSTICS OF DIODE

Department of E&C Page37 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Characteristics of diode

Forward Voltage Drop, Vf

Notice that the diode conducts a small current in the forward direction up to a
threshold voltage, 0.3 for germanium and 0.7 for silicon; after that it conducts as we
might expect. The forward voltage drop, Vf, is specified at a forward current, If.

Leakage current

In the reverse direction there is a small leakage current up until the reverse breakdown
voltage is reached. This leakage is undesirable, obviously the lower the better, and is
specified at a voltage less the than breakdown; diodes are intended to operate below their
breakdown voltage.

Current Rating

The current rating of a diode is determined primarily by the size of the diode chip, and
both the material and configuration of the package, Average Current is used, not RMS
current. A larger chip and package of high thermal conductivity are both conducive to a
higher current rating.

Switching

The switching speed of a diode depends upon its construction and fabrication. In
general the smaller the chip the faster it switches, other things being equal. The chip
geometry, doping levels, and the temperature at nativity determine switching speeds . The
reverse recovery time, trr, is usually the limiting parameter; trr is the time it takes a diode
to switch from on to off.

Department of E&C Page38 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

5.1.5 Diode Specifications

The very minimal diode specifications are:


(a)Maximum reverse voltage
(b)Rated forward current
(c)Maximum forward voltage drop
(d)Maximum leakage current
(e)Package style
(f)Maximum reverse recovery time

5.1.6 Applications

Radio demodulation

The first use for the diode was the demodulation of amplitude modulated (AM) radio
broadcasts. The history of this discovery is treated in depth in the radio article. In
summary, an AM signal consists of alternating positive and negative peaks of voltage,
whose amplitude or “envelope” is proportional to the original audio signal. The diode
(originally a crystal diode) rectifies the AM radio frequency signal, leaving an audio
signal which is the original audio signal, minus atmospheric noise. The audio is extracted
using a simple filter and fed into an audio amplifier or transducer, which generates sound
waves.

Power conversion

Rectifiers are constructed from diodes, where they are used to convert alternating current
(AC) electricity into direct current (DC).

Department of E&C Page39 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Over-voltage protection

Diodes are frequently used to conduct damaging high voltages away from sensitive
electronic devices. They are usually reverse-biased (non-conducting) under normal
circumstances. When the voltage rises above the normal range, the diodes become
forward-biased (conducting).

Logic gates

Diodes can be combined with other components to construct AND and OR logic gates.
This is referred to as diode logic.

Temperature measurements

A diode can be used as a temperature measuring device, since the forward voltage drop
across the diode depends on temperature, as in a Silicon band gap temperature sensor.
From the Shockley ideal diode equation given above, it appears the voltage has a positive
temperature coefficient (at a constant current) but depends on doping concentration and
operating temperature (Size 2007). The temperature coefficient can be negative as in
typical thermistors or positive for temperature sense diodes down to about 20 Kelvin’s.

Current steering

Diodes will prevent currents in unintended directions. To supply power to an electrical


circuit during a power failure, the circuit can draw current from a battery. An
Uninterruptible power supply may use diodes in this way to ensure that current is only
drawn from the battery when necessary. Similarly, small boats typically have two circuits
each with their own battery/batteries: one used for engine starting; one used for
domestics. Normally both are charged from a single alternator, and a heavy duty split
charge diode is used to prevent the higher charge battery (typically the engine battery)
from discharging through the lower charged battery when the alternator is not running.

Department of E&C Page40 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

5.2 CAPACITOR

5.2.1 Introduction
Electronic Symbol

A capacitor or condenser is a passive electronic component consisting of a pair of


conductors separated by a dielectric. When a voltage potential difference exists between
the conductors, an electric field is present in the dielectric. This field stores energy and
produces a mechanical force between the plates. The effect is greatest between wide, flat,
parallel, narrowly separated conductors.

Capacitors are widely used in electronic circuits to


block the flow of direct current while allowing alternating current to pass, to filter out
interference, to smooth the output of power supplies, and for many other purposes. They
are used in resonant circuits in radio frequency equipment to select particular frequencies
from a signal with many frequencies.

Unit

An ideal capacitor is characterized by a single constant value, capacitance, which is


measured in farads.

Farad: This is the ratio of the electric charge on each conductor to the potential
difference between them.

Department of E&C Page41 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

5.2.2Types of Capacitor

1. Non-polarized fixed capacitor


2. Polarized fixed capacitor

Non-polarized fixed capacitor

A non-polarized ("non polar") capacitor is a type of capacitor that has no implicit polarity
-- it can be connected either way in a circuit. Ceramic, mica and some electrolytic
capacitors are non-polarized. You'll also sometimes hear people call them "bipolar"
capacitors.

Polarized fixed capacitor

A polarized ("polar") capacitor is a type of capacitor that have implicit polarity -- it can
only be connected one way in a circuit. The positive lead is shown on the schematic (and
often on the capacitor) with a little "+" symbol. The negative lead is generally not shown
on the schematic, but may be marked on the capacitor with a bar or "-" symbol. Polarized
capacitors are generally electrolytics.

5.2.3Applications
Capacitors have many uses in electronic and electrical systems. They are so common that
it is a rare electrical product that does not include at least one for some purpose.

• Capacitor is used as an energy storage


• Capacitor are used in pulse powered and weapons
• Capacitors are used in power conditioning
• Capacitors are used as noise filter
• Capacitors are used in tuned circuits
• Capacitors are used in also sensing the object
• Capacitors are used in Hazards and in safety products

Department of E&C Page42 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

5.3 POTENTIOMETER
5.3.1 Introduction

A potentiometer (colloquially known as a "pot") is a three-terminal resistor with a


sliding contact that forms an adjustable voltage divider.[1] If only two terminals are used
(one side and the wiper), it acts as a variable resistor or rheostat. Potentiometers are
commonly used to control electrical devices such as volume controls on audio equipment.
Potentiometers operated by a mechanism can be used as position transducers, for
example, in a joystick.

Potentiometers are rarely used to directly control significant


power (more than a watt). Instead they are used to adjust the level of analog signals (e.g.
volume controls on audio equipment), and as control inputs for electronic circuits. For
example, a light dimmer uses a potentiometer to control the switching of a TRIAC and so
indirectly control the brightness of lamps.

Potentiometers are sometimes provided with


one or more switches mounted on the same shaft. For instance, when attached to a
volume control, the knob can also function as an on/off switch at the lowest volume.

ELECTRONIC SYMBOL

(Europe)

(US)

5.3.2 Types of Potentiometer


1. Linear taper potentiometer
2. Logarithmic potentiometer
3. Digital potentiometer

Department of E&C Page43 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Linear taper potentiometer

A linear taper potentiometer (uses the letter 'B' in the designation e.g. 100kB) has a
resistive element of constant cross-section, resulting in a device where the resistance
between the contact (wiper) and one end terminal is proportional to the distance between
them. Linear taper describes the electrical characteristic of the device, not the geometry
of the resistive element. Linear taper potentiometers are used when an approximately
proportional relation is desired between shaft rotation and the division ratio of the
potentiometer; for example, controls used for adjusting the centering of (an analog)
cathode-ray oscilloscope.

Logarithmic potentiometer

A logarithmic taper potentiometer (uses the letter A in the designation eg 100kA)has a


resistive element that either 'tapers' in from one end to the other, or is made from a
material whose resistivity varies from one end to the other. This results in a device where
output voltage is a logarithmic (or inverse logarithmic depending on type) function of the
mechanical angle of the pot.

Most (cheaper) "log" pots are actually not logarithmic, but use two regions of different
resistance (but constant resistivity) to approximate a logarithmic law. A log pot can also
be simulated with a linear pot and an external resistor. True log pots are significantly
more expensive.

Logarithmic taper potentiometers are often used in connection with audio amplifiers.

Digital potentiometer

A digital potentiometer is an electronic component that mimics the functions of analog


potentiometers. Through digital input signals, the resistance between two terminals can
be adjusted, just as in an analog potentiometer.

Department of E&C Page44 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

5.3.3 Potentiometer applications

Potentiometers are widely used as user controls, and may control a very wide variety of
equipment functions. The widespread use of potentiometers in consumer electronics has
declined in the 1990s, with digital controls now more common. However they remain in
many applications, such as volume controls and as position sensors.

Audio control

One of the most common uses for modern low-power potentiometers is as audio control
devices. Both linear pots (also known as "faders") and rotary potentiometers (commonly
called knobs) are regularly used to adjust loudness, frequency attenuation and other
characteristics of audio signals.

The 'log pot' is used as the volume control in audio amplifiers, where it is also called an
"audio taper pot", because the amplitude response of the human ear is also logarithmic. It
ensures that, on a volume control marked 0 to 10, for example, a setting of 5 sounds half
as loud as a setting of 10. There is also an anti-log pot or reverse audio taper which is
simply the reverse of a log pot. It is almost always used in a ganged configuration with a
log pot, for instance, in an audio balance control.

Potentiometers used in combination with filter networks act as tone controls or


equalizers.

Television

Potentiometers were formerly used to control picture brightness, contrast, and color
response. A potentiometer was often used to adjust "vertical hold", which affected the
synchronization between the receiver's internal sweep circuit (sometimes a multivibrator)
and the received picture signal.

Department of E&C Page45 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Transducers

Potentiometers are also very widely used as a part of displacement transducers because of
the simplicity of construction and because they can give a large output signal.

Potentiometer as Voltage Divider

The potentiometer can be used as a voltage divider to obtain a manually adjustable output
voltage at the slider (wiper) from a fixed input voltage applied across the two ends of the
pot. This is the most common use of pots.

The voltage across RL can be calculated by:

If RL is large compared to the other resistances (like the input to an operational


amplifier), the output voltage can be approximated by the simpler equation:

Department of E&C Page46 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Chapter 6

Power Supply

Department of E&C Page47 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6. Power supply

6. Introduction

Circuit Diagram

Figure 6

Components used

• DC Battery
• Full Wave Rectifier
• Diodes
• Capacitors
• Voltage Regulator
• Transformer

Department of E&C Page48 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.1 TRANSFORMER

6.1.1 Introduction

A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors—the transformer's coils. A varying current in the
first or primary winding creates a varying magnetic flux in the transformer's core, and
thus a varying magnetic field through the secondary winding. This varying magnetic field
induces a varying electromotive force (EMF) or "voltage" in the secondary winding. This
effect is called mutual induction.

If a load is connected to the secondary, an electric current will flow in the secondary
winding and electrical energy will be transferred from the primary circuit through the
transformer to the load. In an ideal transformer, the induced voltage in the secondary
winding (VS) is in proportion to the primary voltage (VP), and is given by the ratio of the
number of turns in the secondary (NS) to the number of turns in the primary (NP) as
follows:

By appropriate selection of the ratio of turns, a transformer thus allows an alternating


current (AC) voltage to be "stepped up" by making NS greater than NP, or "stepped down"
by making NS less than NP.

Department of E&C Page49 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.1.2 Basic principles

The transformer is based on two principles: firstly, that an electric current can produce a
magnetic field (electromagnetism) and secondly that a changing magnetic field within a
coil of wire induces a voltage across the ends of the coil (electromagnetic induction).
Changing the current in the primary coil changes the magnetic flux that is developed. The
changing magnetic flux induces a voltage in the secondary coil.

Figure 6.1.2

An ideal transformer

An ideal transformer is shown in the adjacent figure. Current passing through the primary
coil creates a magnetic field. The primary and secondary coils are wrapped around a core
of very high magnetic permeability, such as iron, so that most of the magnetic flux passes
through both primary and secondary coils.

Department of E&C Page50 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.1.3 Induction law

The voltage induced across the secondary coil may be calculated from Faraday's law of
induction, which states that:

Where VS is the instantaneous voltage, NS is the number of turns in the secondary coil and
Φ equals the magnetic flux through one turn of the coil. If the turns of the coil are
oriented perpendicular to the magnetic field lines, the flux is the product of the magnetic
flux densityB and the area A through which it cuts. The area is constant, being equal to
the cross-sectional area of the transformer core, whereas the magnetic field varies with
time according to the excitation of the primary. Since the same magnetic flux passes
through both the primary and secondary coils in an ideal transformer the instantaneous
voltage across the primary winding equals

Taking the ratio of the two equations for VS and VP gives the basic equation for stepping
up or stepping down the voltage

Department of E&C Page51 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.1.4 Applications

• A major application of transformers is to increase voltage before transmitting


electrical energy over long distances through wires. Wires have resistance and so
dissipate electrical energy at a rate proportional to the square of the current
through the wire. By transforming electrical power to a high-voltage (and
therefore low-current) form for transmission and back again afterward,
transformers enable economic transmission of power over long distances.
Consequently, transformers have shaped the electricity supply industry,
permitting generation to be located remotely from points of demand. All but a tiny
fraction of the world's electrical power has passed through a series of transformers
by the time it reaches the consumer.
• Transformers are also used extensively in electronic products to step down the
supply voltage to a level suitable for the low voltage circuits they contain. The
transformer also electrically isolates the end user from contact with the supply
voltage.
• Signal and audio transformers are used to couple stages of amplifiers and to
match devices such as microphones and record players to the input of amplifiers.
Audio transformers allowed telephone circuits to carry on a two-way conversation
over a single pair of wires. A balun transformer converts a signal that is
referenced to ground to a signal that has balanced voltages to ground, such as
between external cables and internal circuits.

Department of E&C Page52 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.2 Voltage regulator


6.2.1 Introduction
Electronic symbol for Voltage regulator

A voltage regulator is an electrical regulator designed to automatically maintain a


constant voltage level.

It may use an electromechanical mechanism, or passive or active electronic components.


Depending on the design, it may be used to regulate one or more AC or DC voltages.

6.2.2Circuit diagram of voltage regulator

Department of E&C Page53 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.2.3Measures of regulator quality

The output voltage can only be held roughly constant; the regulation is specified by two
measurements:

• Load regulation is the change in output voltage for a given change in load
current (for example: "typically 15mV, maximum 100mV for load currents
between 5mA and 1.4A, at some specified temperature and input voltage").
• Line regulation or input regulation is the degree to which output voltage
changes with input (supply) voltage changes - as a ratio of output to input change
(for example "typically 13mV/V"), or the output voltage change over the entire
specified input voltage range (for example "plus or minus 2% for input voltages
between 90V and 260V, 50-60Hz").

Other important parameters are:

• Temperature coefficient of the output voltage is the change in output voltage


with temperature (perhaps averaged over a given temperature range), while...
• Initial accuracy of a voltage regulator (or simply "the voltage accuracy") reflects
the error in output voltage for a fixed regulator without taking into account
temperature or aging effects on output accuracy.
• Dropout voltage - the minimum difference between input voltage and output
voltage for which the regulator can still supply the specified current. A Low
Drop-Out (LDO) regulator is designed to work well even with an input supply
only a Volt or so above the output voltage.
• Absolute Maximum Ratings are defined for regulator components, specifying
the continuous and peak output currents that may be used (sometimes internally
limited), the maximum input voltage, maximum power dissipation at a given
temperature, etc.

Department of E&C Page54 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

6.2.4 Explanation of Power Supply Circuit

A half-wave rectifier will only give one peak per cycle and for this and other reasons is
only used in very small power supplies. A full wave rectifier achieves two peaks per
cycle and this is the best that can be done with single-phase input. For three-phase inputs
a three-phase bridge will give six peaks per cycle and even higher numbers of peaks can
be achieved by using transformer networks placed before the rectifier to convert to a
higher phase order.

To further reduce this ripple, a capacitor-input filter can be used.


This complements the reservoir capacitor with a choke (inductor) and a second filter
capacitor, so that a steadier DC output can be obtained across the terminals of the filter
capacitor. The choke presents high impedance to the ripple current.

A more usual alternative to a filter, and essential if the


DC load is very demanding of a smooth supply voltage, is to follow the reservoir
capacitor with a voltage regulator. The reservoir capacitor needs to be large enough to
prevent the troughs of the ripple getting below the voltage the DC is being regulated to.
The regulator serves both to remove the last of the ripple and to deal with variations in
supply and load characteristics. It would be possible to use a smaller reservoir capacitor
(these can be large on high-current power supplies) and then apply some filtering as well
as the regulator, but this is not a common strategy. The extreme of this approach is to
dispense with the reservoir capacitor altogether and put the rectified waveform straight
into a choke-input filter.

Department of E&C Page55 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Chapter 7

Sensors (LDRs)

Department of E&C Page56 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

LIGHT DEPENDENT RESISTOR


7.1 Introduction
Electronic Symbol

INTRODUCTION

LDR are also known as photo resistor

A photo resistor or light dependent resistor or cadmium sulfide (CdS) cell is a resistor
whose resistance decreases with increasing incident light intensity. It can also be
referenced as a photoconductor.

A photo resistor is made of a high resistance semiconductor. If light falling on the device
is of high enough frequency, photons absorbed by the semiconductor give bound
electrons enough energy to jump into the conduction band. The resulting free electron
(and its hole partner) conduct electricity, thereby lowering resistance.

A photoelectric device can be either intrinsic or extrinsic. An intrinsic semiconductor has


its own charge carriers and is not an efficient semiconductor, e.g. silicon. In intrinsic
devices the only available electrons are in the valence band, and hence the photon must
have enough energy to excite the electron across the entire band gap. Extrinsic devices
have impurities, also called dopants, and added whose ground state energy is closer to the
conduction band; since the electrons do not have as far to jump, lower energy photons
(i.e., longer wavelengths and lower frequencies) are sufficient to trigger the device. If a
sample of silicon has some of its atoms replaced by phosphorus atoms (impurities), there
will be extra electrons available for conduction. This is an example of an extrinsic
semiconductor.

Department of E&C Page57 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

7.2 Plot for a LDR

As the name suggests, a light dependant resistor (LDR)is a component whose resistance
changes when the amount of light falling on it (called the light intensity) changes. All you
need to remember is that the resistance goes down as the amount of light goes up.
Resistance decreases as light intensity increases, light is low, dark is high (resistance).

The LDR can be used in a circuit to automatically switch lights on at night (see relay).

Department of E&C Page58 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

7.3 Applications

Photo resistors come in many different types. Inexpensive cadmium sulfide cells can be
found in many consumer items such as camera light meters, street lights, clock radios,
alarms, and outdoor clocks.

They are also used in some dynamic compressors together with a small incandescent
lamp or light emitting diode to control gain reduction.

Lead sulfide and indium antimonide LDRs are used for the mid infrared spectral region.
Ge: Cu photoconductors are among the best far-infrared detectors available, and are used
for infrared astronomy and infrared spectroscopy.

Department of E&C Page59 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Chapter 8

Program Code for


Project

Department of E&C Page60 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Visiting Counter With Device Control

8.1 Connections of LCD to 89C52


LCD_PORT = P1
RS = P3.2
RW = P3.1
EN = P3.0
LDR_1 = P3.4
LDR_2 = P3.5
D_S = P3.3

Figure 8.1

Department of E&C Page61 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

8.2 Program Code for whole System


#include <AT89c52.H>
#include<lcd.h>
#define LDR_1 P3_4
#define LDR_2 P3_5
#define D_S P2_0
#define ON 0
#define OFF 1
Void visit count (void);
Void show counts (void);
Unsigned int COUNT;
Void main ()
{
init_lcd ();
print_lcd ("COUNTS:");
COUNT = 0;
D_S = 0;
LDR_1 = LDR_2 = 1;
lcd_cmd_dis (0x04, 0);

while (1)
{
lcd_cmd_dis (0x8A, 0);
visit count ();
}
}
Main () End

Department of E&C Page62 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

8.3 Program Code for counter


void visit count (void)
{
bit c1, c2;
if (!((LDR_1 == ON)&&(LDR_2 == ON)))
{
if (LDR_1 == ON)
{
c1=0;
MSdelay(10);
If (LDR_2 == ON)
{
c2=0;
if ((c1==0 && c2==0)&&(COUNT >=0))
{++COUNT;
show counts ();
}
}
}
If ((LDR_2 == ON) && (COUNT > 0))
{
c1=1;
MSdelay (10);
If (LDR_1 == ON)
{
c2=1;
if ((c1==1&&c2==1)&&(COUNT > 0))
{
--COUNT;
}

Department of E&C Page63 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

else
COUNT = 0;
show counts ();
}
}
}
}
Main () End

8.4 Program Code for LCD Display


Void show counts (void)
{
unsigned int temp, count,i;
unsigned char ASCII;
if (COUNT == 0)
D_S = 0;
If (COUNT > 0)
D_S = 1;
Count=COUNT;
For (i=0; i<=3; i++)
{
temp = count %10;
ASCII = temp | 0x30;
count /= 10;
lcd_cmd_dis (ASCII, 1);
}
MSdelay (10);
}
Main () End

Department of E&C Page64 2008-2009


Lovely Institute of Technology, Phagwara
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR COUNTER

Bibliography

www.google.com
www.wikipedia.com
www.doctronics.co.uk
www.technologystudent.com
www.8051projects.net
www.williamson-labs.com
www.atmel.com
www.electronics-tutorials.com
www.101science.com
www.electronis.howstuffworkls.com
www.allaboutcircuits.com
www.kpsec.freeuk.com
www.tech-faq.com

Department of E&C Page65 2008-2009


Lovely Institute of Technology, Phagwara

You might also like