Anda di halaman 1dari 36

EMBEDDED BASED AUTOMATIC

AUDITORIUM CONTROLLER
ABSTRACT:
The work on Development of automatic person detection system to control electrical
fan and lights using PIC Microcontroller is a reliable circuit that takes over the task of
controlling the room lights in auditorium very accurately. When somebody enters into the
auditorium then the light in the auditorium will be switched ON and count also incremented by
one when any one leaves the room then count will be decremented by one. If the total count will
be zero, the light will be automatically switched OFF. The PIC 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. Pic Microcontroller 16F887A continuously monitor the
sensors, A IR Sensor is which controls the switching on/off of the light when it detects the any
person entered into the auditorium. The implementation is made simpler by using sensor to
detect person. The system includes IR sensor, microcontroller, LCD display and a 5v power is
supplied to run the system. The system uses a compact circuitry built around pic microcontroller
programs are developed in Embedded C. Flash magic is used for loading programs into
Microcontroller.

EXISTING SYSTEM:
In this existing system, manually controls the Fans, lights in the auditorium. Only the
human can controls Fans, lights in the auditorium. It is quite difficult to switch ON/OFF the fans
lights in each time when the number of people increases in the auditorium.

PROPOSED SYSTEM:
We are proposing to save the power consumption in electrical equipment like fan and
light. It can be also use for the security system in auditorium. This work is in two parts room
light control and automatic fan regulation

BLOCK DIAGRAM:

POWER SUPPLY

LCD DISPLAY
IR SENSOR IN
PIC16F877A
MICRO CONTROLLER

RELAY

LIGHTS

RELAY

FANS

IR SENSOR OUT

HARDWARE REQUIREMENTS:

IR SENSOR
MICROCONTROLLER
POWER SUPPLY UNIT
LCD DISPLAY
DC FAN
LIGHT

SOFTWARE REQUIREMENTS:

EMBEDDED C LANGUAGE
MPLAB IDE

ADVANTAGES:

To save energy through the proposed method.


Where the requirement to check the total person to be entered or exit.

APPLICATIONS:

Seminar halls
Auditorium
Colleges, Schools
Industries

MODULE 1:PIC 16F877A MICRO CONTROLLER


Power Supply for PIC 16F877A Microcontroller
This section describes how to generate +5V DC power supply

The power supply section is the important one. It should deliver constant
output regulated power supply for successful working of the project. A 012V/1 mA transformer is used for this purpose. The primary of this
transformer is connected in to main supply through on/off switch& fuse for
protecting from overload and short circuit protection. The secondary is
connected to the diodes to convert 12V AC to 12V DC voltage. And filtered by
the capacitors, which is further regulated to +5v, by using IC 7805

PIC 16F877A Microcontroller


Peripheral Interface Controller (PIC) is microcontroller developed by Microchip, PIC microcontroller is fast
and easy to implement program when we compare other microcontrollers like 8051. The ease of
programming and easy to interfacing with other peripherals PIC became successful microcontroller.
We know that microcontroller is an integrated chip which consists of RAM, ROM, CPU, TIMERS,
COUNTERS etc. PIC is a microcontroller which also consists of ram, rom, CPU, timers, counter, ADC
(analog to digital converters), DAC (digital to analog converter). PIC also supports the protocols like CAN,

SPI, UART for interfacing with other peripherals. PIC mainly used modified Harvard architecture and also
supports RISC (Reduced Instruction Set Computer) by the above specification RISC and Harvard we can
easily that PIC is faster than the 8051 based controller which is made-up of Von-Newman architecture.

Overview of PIC 16F877a


PIC 16F877 is one of the most advanced microcontroller from Microchip. This controller is widely used for
experimental and modern applications because of its low price, wide range of applications, high quality, and
ease of availability. It is ideal for applications such as machine control applications, measurement devices,
study purpose, and so on. The PIC 16F877 features all the components which modern microcontrollers
normally have. The figure of a PIC16F877 chip is shown below.

PIC 16F877

Features of PIC16F877
The PIC16FXX series has more advanced and developed features when compared to its previous series. The
important features of PIC16F877 series is given below.

General Features
o High performance RISC CPU.
o ONLY 35 simple word instructions.
o All single cycle instructions except for program branches which are two cycles.
o Operating speed: clock input (200MHz), instruction cycle (200nS).

o Up to 3688bit of RAM (data memory), 2568 of EEPROM (data memory), 8k14 of flash memory.
o Pin out compatible to PIC 16C74B, PIC 16C76, PIC 16C77.
o Eight level deep hardware stack.
o Interrupt capability (up to 14 sources).
o Different types of addressing modes (direct, Indirect, relative addressing modes).
o Power on Reset (POR).
o Power-Up Timer (PWRT) and oscillator start-up timer.
o Low power- high speed CMOS flash/EEPROM.
o Fully static design.
o Wide operating voltage range (2.0 5.56)volts.
o High sink/source current (25mA).
o Commercial, industrial and extended temperature ranges.
o Low power consumption (<0.6mA typical @3v-4MHz, 20A typical @3v-32MHz and <1 A typical standby).

Peripheral Features
o Timer 0: 8 bit timer/counter with pre-scalar.
o Timer 1:16 bit timer/counter with pre-scalar.
o Timer 2: 8 bit timer/counter with 8 bit period registers with pre-scalar and post-scalar.
o Two Capture (16bit/12.5nS), Compare (16 bit/200nS), Pulse Width Modules (10bit).

o 10bit multi-channel A/D converter


o Synchronous Serial Port (SSP) with SPI (master code) and I2C (master/slave).
o Universal Synchronous Asynchronous Receiver Transmitter (USART) with 9 bit address detection.
o Parallel Slave Port (PSP) 8 bit wide with external RD, WR and CS controls (40/46pin).
o Brown Out circuitry for Brown-Out Reset (BOR).

Key Features
o Maximum operating frequency is 20MHz.
o Flash program memory (14 bit words), 8KB.
o Data memory (bytes) is 368.
o EEPROM data memory (bytes) is 256.
o 5 input/output ports.
o 3 timers.
o 2 CCP modules.
o 2 serial communication ports (MSSP, USART).
o PSP parallel communication port
o 10bit A/D module (8 channels)

Analog Features
o 10bit, up to 8 channel A/D converter.
o Brown Out Reset function.
o Analog comparator module.

Special Features
o 100000 times erase/write cycle enhanced memory.
o 1000000 times erase/write cycle data EEPROM memory.
o Self programmable under software control.
o In-circuit serial programming and in-circuit debugging capability.
o Single 5V,DC supply for circuit serial programming
o WDT with its own RC oscillator for reliable operation.
o Programmable code protection.
o Power saving sleep modes.
o Selectable oscillator options.

Pin Diagrams
PIC16F877 chip is available in different types of packages. According to the type of applications and usage,
these packages are differentiated. The pin diagrams of a PIC16F877 chip in different packages is shown in the
figure below.

Pin Diagrams of PIC 16F877 Chip

Input/output ports
PIC16F877 has 5 basic input/output ports. They are usually denoted by PORT A (R A), PORT B (RB), PORT C
(RC), PORT D (RD), and PORT E (RE). These ports are used for input/ output interfacing. In this controller,

PORT A is only 6 bits wide (RA-0 to RA-7), PORT B , PORT C,PORT D are only 8 bits wide (RB-0 to RB7,RC-0 to RC-7,RD-0 to RD-7), PORT E has only 3 bit wide (RE-0 to RE-7).

PORT-A

RA-0 to RA-5

6 bit wide

PORT-B

RB-0 to RB-7

8 bit wide

PORT-C

RC-0 to RC-7

8 bit wide

PORT-D

RD-0 to RD-7

8 bit wide

PORT-E

RE-0 to RE-2

3 bit wid

All these ports are bi-directional. The direction of the port is controlled by using TRIS(X) registers (TRIS A used
to set the direction of PORT-A, TRIS B used to set the direction for PORT-B, etc.). Setting a TRIS(X) bit 1 will
set the corresponding PORT(X) bit as input. Clearing a TRIS(X) bit 0 will set the corresponding PORT(X) bit as
output.
(If we want to set PORT A as an input, just set TRIS(A) bit to logical 1 and want to set PORT B as an output,
just set the PORT B bits to logical 0.)
o Analog input port (AN0 TO AN7) : these ports are used for interfacing analog inputs.
o TX and RX: These are the USART transmission and reception ports.
o SCK: these pins are used for giving synchronous serial clock input.
o SCL: these pins act as an output for both SPI and I2C modes.
o DT: these are synchronous data terminals.
o CK: synchronous clock input.
o SD0: SPI data output (SPI Mode).
o SD1: SPI Data input (SPI mode).
o SDA: data input/output in I2C Mode.
o CCP1 and CCP2: these are capture/compare/PWM modules.

o OSC1: oscillator input/external clock.


o OSC2: oscillator output/clock out.
o MCLR: master clear pin (Active low reset).
o Vpp: programming voltage input.
o THV: High voltage test mode controlling.
o Vref (+/-): reference voltage.
o SS: Slave select for the synchronous serial port.
o T0CK1: clock input to TIMER 0.
o T1OSO: Timer 1 oscillator output.
o T1OS1: Timer 1 oscillator input.
o T1CK1: clock input to Timer 1.
o PGD: Serial programming data.
o PGC: serial programming clock.
o PGM: Low Voltage Programming input.
o INT: external interrupt.
o RD: Read control for parallel slave port.
o CS: Select control for parallel slave.
o PSP0 to PSP7: Parallel slave port.
o VDD: positive supply for logic and input pins.
o VSS: Ground reference for logic and input/output pins.

Take a look at the specifications of the PIC 16F87X Series

Architecture of PIC Microcontroller

The PIC microcontroller architecture comprises of CPU, I/O ports, memory organization, A/D
converter, timers/counters, interrupts, serial communication, oscillator and CCP module which
are discussed in detailed below.

Architecture of PIC Microcontroller


CPU (Central Processing Unit)
It is not different from other microcontrollers CPU and the PIC microcontroller CPU consists of
the ALU, CU, MU and accumulator, etc. Arithmetic logic unit is mainly used for arithmetic
operations and to take logical decisions. Memory is used for storing the instructions after
processing. To control the internal and external peripherals, control unit is used which are
connected to the CPU and the accumulator is used for storing the results and further process.
Memory Organization
The memory module in the PIC microcontroller architecture consists of RAM (Random Access
Memory), ROM (Read Only Memory) and STACK.
Random Access Memory (RAM)
RAM is an unstable memory which is used to store the data temporarily in its registers. The
RAM memory is classified into two banks, and each bank consists of so many registers. The
RAM registers are classified into two types: Special Function Registers (SFR) and General
Purpose Registers (GPR).

General Purpose Registers (GPR)

These registers are used for general purpose only as the name implies. For example, if we want
to multiply two numbers by using the PIC microcontroller. Generally, we use registers for
multiplying and storing the numbers in other registers. So these registers dont have any special
function,- CPU can easily access the data in the registers.

Special Function Registers

These registers are used for special purposes only as the name SFR implies. These registers
will perform according to the functions assigned to them , and they cannot be used as normal
registers. For example, if you cannot use the STATUS register for storing the data, these
registers are used for showing the operation or status of the program. So, user cannot change
the function of the SFR; the function is given by the retailer at the time of manufacturing.

Memory Organization
Read Only Memory (ROM)
Read only memory is a stable memory which is used to store the data permanently. In
PICmicrocontroller architecture, the architecture ROM stores the instructions or program,
according to the program the microcontroller acts. The ROM is also called as program memory,
wherein the user will write the program for microcontroller and saves it permanently, and finally
the program is executed by the CPU. The microcontrollers performance depends on the
instruction, which is executed by the CPU.

Electrically Erasable Programmable Read Only Memory (EEPROM)


In the normal ROM, we can write the program for only once we cannot use again themicro
controller for multiple times. But, in the EEPROM, we can program the ROM multiple times.
Flash Memory
Flash memory is also programmable read only memory (PROM) in which we can read, write
and erase the program thousands of times. Generally, the PIC microcontroller uses this type of
ROM.
Stack
When an interrupt occurs, first the PIC microcontroller has to execute the interrupt and the
existing process address. Then that is being executed is stored in the stack. After completing
the execution of the interrupt, the microcontroller calls the process with the help of address,
which is stored in the stack and get executes the process.
I/O Ports

The series of PIC16 consists of five ports such as Port A, Port B, Port C, Port D & Port
E.

Port A is an 16-bit port that can be used as input or output port based on the status of
the TRISA (Tradoc Intelligence Support Activity) register.

Port B is an 8- bit port that can be used as both input and output port.

Port C is an 8-bit and the input of output operation is decided by the status of the TRISC
register.

Port D is an 8-bit port acts as a slave port for connection to the microprocessor BUS.

Port E is a 3-bit port which serves the additional function of the control signals to the
analog to digital converter.

BUS
BUS is used to transfer and receive the data from one peripheral to another. It is classified into
two types such as data bus and address.
Data Bus: It is used for only transfer or receive the data.

Address Bus: Address bus is used to transmit the memory address from the peripherals to the
CPU. I/O pins are used to interface the external peripherals; UART and USART both are serial
communication protocols which are used for interfacing serial devices like GSM, GPS,
Bluetooth, IR , etc.

BUS
A/D converters
The main intention of this analog to digital converter is to convert analog voltage values to digital
voltage values. A/D module of PIC microcontroller consists of 5 inputs for 28 pin devices and 8
inputs for 40 pin devices. The operation of the analog to digital converter is controlled by
ADCON0 and ADCON1 special registers. The upper bits of the converter are stored in register
ADRESH and lower bits of the converter are stored in register ADRESL. For this operation, it
requires 5V of an analog reference voltage.

A/D CONVERTER

Timers/ Counters
PIC microcontroller has four timer/counters wherein the one 8-bit timer and the remaining timers
have the choice to select 8 or 16-bit mode. Timers are used for generating accuracy actions, for
example, creating specific time delays between two operations.
Interrupts
PIC microcontroller consists of 20 internal interrupts and three external interrupt sources which
are associated with different peripherals like ADC, USART, Timers, and so on.
Serial Communication
Serial communication is the method of transferring data one bit at a time sequentially over
a communicationchannel.

USART: The name USART stands for Universal synchronous and Asynchronous
Receiver and Transmitter which is a serial communication for two protocols. It is used for
transmitting and receiving the data bit by bit over a single wire with respect to clock
pulses. The PIC microcontroller has two pins TXD and RXD. These pins are used for
transmitting and receiving the data serially.

SPI Protocol: The term SPI stands for Serial Peripheral Interface. This protocol is used
to send data between PIC microcontroller and other peripherals such as SD
cards, sensors and

shift

registers.

PIC microcontroller support

three

wire

SPI

communications between two devices on a common clock source. The data rate of SPI
protocol is more than that of the USART.

I2C Protocol: The term I2C stands for Inter Integrated Circuit , and it is a serial protocol
which is used to connect low speed devices such as EEPROMS,microcontrollers, A/D
converters, etc. PIC microcontroller support two wire Interface or I2C communication
between two devices which can work as both Master and Slave device.

Serial Communication
Oscillators
Oscillators are used for timing generation. Pic microcontroller consist of external oscillators like
RC oscillators or crystal oscillators. Where the crystal oscillator is connected between the two
oscillator pins. The value of the capacitor is connected to every pin that decides the mode of the
operation of the oscillator. The modes are crystal mode, high-speed mode and the low-power
mode. In case of RC oscillators, the value of the resistor & capacitor determine the clock
frequency and the range of clock frequency is 30KHz to 4MHz.
CCP module
The name CCP module stands for capture/compare/PWM where it works in three modes such
as capture mode, compare mode and PWM mode.

Capture Mode: Capture mode captures the time of arrival of a signal, or in other words,
when the CCP pin goes high, it captures the value of the Timer1.

Compare Mode: Compare mode acts as an analog comparator. When the timer1 value
reaches a certain reference value, then it generates an output.

PWM Mode: PWM mode provides pulse width modulated output with a 10-bit resolution
and programmable duty cycle.

PIC Microcontroller Applications


The PIC microcontroller projects can be used in different applications, such as peripherals,
audio accessories, video games, etc. For better understanding of this PIC microcontroller, the
following project demonstrates PIC microcontrollers operations.

Advantages of PIC Microcontroller:

PIC microcontrollers are consistent and faulty of PIC percentage is very less. The
performance of the PIC microcontroller is very fast because of using RISC architecture.

When comparing to other microcontrollers, power consumption is very less and


programming is also very easy.

Interfacing of an analog device is easy without any extra circuitry

LCD
LCD Introduction

An HD44780 Character LCD is an industry standard liquid crystal display (LCD) display
device designed for interfacing with embedded electronics. These screens come in common
configurations of 8x1 characters, 16x2, and 20x4 among others. The largest such configuration is
40x4 characters, but these are rare and are actually two separate 20x4 screens seamlessly joined
together.
These screens are often found in copiers, fax machines, laser printers, industrial test equipment,
networking equipment such as routers and storage devices, etc. These are not the kind of screens
one would find in a cell phone, portable television, etc. They are limited to text only, with 8
customizable characters.
Character LCDs can come with or without backlights. Backlights can be LED, fluorescent, or
electroluminescent.
Character LCDs use a standard 14-pin interface. If the screen has a backlight, it will have 16
pins. The pinouts are as follows:

1. Ground
2. VCC (+5V)
3. Contrast adjustment
4. Register Select (R/S)
5. Read/Write (R/W)
6. Clock (Enable)
7. Bit 0
8. Bit 1
9. Bit 2
10.Bit 3
11.Bit 4
12.Bit 5
13.Bit 6
14.Bit 7

Character LCDs can operate in 4-bit or 8-bit mode. In 4 bit mode, pins 7 through 10 are unused
and the entire byte is sent to the screen using pins 11 through 14 by sending a nybble at a time.

The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs
which have only one controller and support at most 80 characters, whereas LCDs supporting
more than 80 characters make use of 2 HD44780 controllers. Apart from displaying some simple
static characters you can create animated text scripts and a lot more!

Lets start playing with them, but you will have to wait a little as these things mentioned below
will help you to create your own magical codes

Most LCDs with 1 controller has 14 Pins and 16 Pins (two extra pins are for back-light LED
connections). Pin description is shown in the table below. (We may also have 16 pins in 2
controllers, refer to the datasheet for exact details).

This may not match with the exact pin configuration for your LCD, check application circuit in
datasheet for exact configuration.
We will discuss here 8 bit mode first (that is data transfer through all the 8 data pins), 4 bit mode
will be discussed later on.
Read/Write (RW):
1.) RW= 0, the information is being written on LCD.
2.) RW=1, for reading from LCD. (Only one command that is Get LCD status is read
commands all others are write command)
It is a control line. When RW is low (0), the information on the data bus is being written to the
LCD. When RW is high (1), the program is effectively querying (or reading from) the LCD.
Only one instruction ("Get LCD status") is a read command. All others are write commands--so
RW will be low for majority of the time.

Registers:
There are two very important registers in the LCD. The RS pin is used for their selection.
1.) RS= 0; The Instruction command code register, allows the user to send command such as
clear display, cursor at home, etc.
2.) RS=1; the data register, allow user to send data to be displayed at LCD.

Enable (En) pin: is used to tell the LCD that we are sending it data. A high to low pulse (of
minimum length 450ns) before sending any command/data to LCD.

How many characters can we send to LCD?

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its
extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that
is not used for display can be used as general data RAM. So whatever you send on the DDRAM
is actually displayed on the LCD.
{For LCDs like 1x16, only 16 characters are visible, so whatever you write after 16 chars is
written in DDRAM but is not visible to the user.}

(DDRAM address for 2 line LCD)

How does the ASCII value change to characters?

The answer is CGROM i.e. character generator ROM, is used to convert ASCII values send by
C into 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character. (You can also add your
own characters in the list!!)

How much time should there be in two consecutive Commands/Instructions?

The first method is to create a delay between two consecutive commands or instructions.
(Check the datasheet for exact time of execution of an instruction). This may not be very
appropriate as the delay is not very accurate.

BUSY FLAG (BF): The MSB of the LCD data bus (D7) act as busy flag. When BF = 1
means LCD is busy and will not accept next command or data and BF = 0 means LCD is
ready for the next command or data to process. This flag is internally set by LCD & can
be monitored by C for exact amount of delay.

To read Busy Flag, the conditions RS = 0 and R/W = 1 must be met.

STEPS TO PROGRAM:
1) Initialize the LCD.
2) Select the command or instruction register.
3) Set RW low (to write).
4) Send a high to low pulse on Enable pin.

5) Check if the LCD is busy.


6) Move to instruction or command function.
7) Repeat steps 4-7.

Liquid crystal displays:

The LCD standard requires 3 control lines and 8 I/O lines for the data bus.
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.
The 8 data lines are connected to PORT 1 of 8051 microcontroller. The three control
lines( RS,RW and EN ) are connected to PORT 3.5,3.6 and 3.7 respectively

MODULE 2:IR SENSOR


Infrared IR Sensor Circuit Diagram and Working Principle
An infrared sensor is an electronic device, that emits in order to sense some aspects of

the surroundings. An IR sensor can measure the heat of an object as well as detects the
motion.These types of sensors measures only infrared radiation, rather than emitting it that is
called as a passive IR sensor. Usually in the infrared spectrum, all the objects radiate some form
of thermal radiations. These types of radiations are invisible to our eyes, that can be detected by
an infrared sensor.The emitter is simply an IR LED (Light Emitting Diode) and the detector is
simply an IR photodiode which is sensitive to IR light of the same wavelength as that emitted by
the IR LED. When IR light falls on the photodiode, The resistances and these output voltages,
change in proportion to the magnitude of the IR light received.

Different Types of IR Sensors and Their Applications


IR sensors are classified into different types depending on the applications. Some of the
typical applications of different types of sensors are
The speed sensor is used for synchronizing the speed of multiple motors. The temperature
sensor is used for industrial temperature control. PIR sensor is used for automatic door opening
system and Ultrasonic sensor are used for distance measurement.
IR Sensor Applications
IR sensors are used in various Sensor based projects and also in various electronic
devices which measures the temperature that are discussed in the below.
Radiation Thermometers
IR sensors are used in radiation thermometers to measure the temperature depend upon
the temperature and the material of the object and these thermometers have some of the
following features
Measurement without direct contact with the object

Faster response
Easy pattern measurements
Flame Monitors
These types of devices are used for detecting the light emitted from the flames and to
monitor how the flames are burning. The Light emitted from flames extend from UV to IR
region types. PbS, PbSe, Two-color detector, pyro electric detector are some of the commonly
employed detector used in flame monitors.

Moisture Analyzers
Moisture analyzers use wavelengths which are absorbed by the moisture in the IR region.
Objects are irradiated with light having these wavelengths(1.1 m, 1.4 m, 1.9 m, and 2.7m)
and also with reference wavelengths. The Lights reflected from the objects depend upon the
moisture content and is detected by analyzer to measure moisture (ratio of reflected light at these
wavelengths to the reflected light at reference wavelength). In GaAs PIN photodiodes, Pbs
photoconductive detectors are employed in moisture analyzer circuits.
Gas Analyzers
IR sensors are used in gas analyzers which use absorption characteristics of gases in the
IR region. Two types of methods are used to measure the density of gas such as dispersive and
non dispersive.
Dispersive: An Emitted light is spectroscopically divided and their absorption
characteristics are used to analyze the gas ingredients and the sample quantity.
Non dispersive: It is most commonly used method and it uses absorption characteristics
without dividing the emitted light. Non dispersive types use discrete optical band pass filters,
similar to sunglasses that are used for eye protection to filter out unwanted UV radiation.

This type of configuration is commonly referred to as non dispersive infrared (NDIR)


technology. This type of analyzer is used for carbonated drinks, whereas non dispersive analyzer
is used in most of the commercial IR instruments, for an automobile exhaust gas fuel leakage.
IR Imaging Devices
IR image device is one of the major applications of IR waves, primarily by virtue of its
property that is not visible. It is used for thermal imagers, night vision devices, etc.

Detecting Obstacle with IR (Infrared) Sensor


The basic concept of IR(infrared) obstacle detection is to transmit the IR signal(radiation)
in a direction and a signal is received at the IR receiver when the IR radiation bounces back
from a surface of the object.

MODULE 3:RELAY

RELAY:
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 most have double throw (changeover)
switch contacts .
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.
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.
The animated picture shows a working relay with its coil and switch contacts. You can
see a lever on the left being attracted by magnetism when the coil is switched on. This lever
moves the switch contacts. There is one set of contacts (SPDT) in the foreground and another
behind them, making the relay DPDT.

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

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

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

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

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.

Choosing a relay
You need to consider several features when choosing a relay:
1. Physicalsizeandpinarrangement
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. Coilvoltage
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. Coilresistance
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
coil resistance

Relay coil current =

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".
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.
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.

Relays and transistors compared


Like relays, transistors can be used as an electrically operated switch. For switching small DC
currents (< 1A) at low voltage they are usually a better choice than a relay. However, transistors
cannot switch AC (such as mains electricity) and in simple circuits they are not usually a good
choice for switching large currents (> 5A). In these cases a relay will be needed, but note that a
low power transistor may still be needed to switch the current for the relay's coil! The main
advantages and disadvantages of relays are listed below.
Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC.

Relays can switch higher voltages than standard transistors.

Relays are often 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.

MODULE 4:ELECTRICAL LOADS


An electrical load is an electrical component or portion of a circuit that consumes electric power.[1]
[2]

This is opposed to a power source, such as a battery or generator, which produces power. [2] In

electric power circuits examples of loads are appliances and lights. The term may also refer to
the power consumed by a circuit.
The term is used more broadly in electronics for a device connected to a signal source, whether or
not it consumes power.[2] If an electric circuit has an output port, a pair of terminals that produces an
electrical signal, the circuit connected to this terminal (or its input impedance) is the load. For
example, if a CD player is connected to an amplifier, the CD player is the source and the amplifier is
the load.[2]
Load affects the performance of circuits with respect to output voltages or currents, such as
in sensors, voltage sources, and amplifiers. Mains power outlets provide an easy example: they
supply power at constant voltage, with electrical appliances connected to the power circuit
collectively making up the load. When a high-power appliance switches on, it dramatically reduces
the load impedance.
If the load impedance is not very much higher than the power supply impedance, the voltages will
drop. In a domestic environment, switching on a heating appliance may cause incandescent lights to
dim noticeably.

FAN

The LM35 is precision integrated-circuit temperature sensor, whose output voltage is linearly
proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over
linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large
constant voltage from its output to obtain convenient Centigrade scaling.

The temperature sensor output voltage variation is 10mV/C. The output voltage corresponds to
Temperature inside the CPU. The output voltage of LM35 is fed to PGA by port P0(1). The
amplified voltage is given to ADC. The ADC output is digital form of the input voltage and is
displayed on LCD. The digital output is used to program the PWM. When temperature inside
CPU is at room temperature, the fan is in OFF condition (PWM ON-period=00). Above the room
temperature the CPU fan is turned on. As temperature is increased the ON-period of PWM is
increased and fan speed is increased. The output of PWM module is connected to base of BC547
NPN transistor. The BC547 NPN transistor drives the CPU fan which is provided with 12V dc
Supply.

Anda mungkin juga menyukai