Sie sind auf Seite 1von 37

Chapter -1

INTRODUCTION
This main objective of this project is to use Infrared frequency signal to control
(on/off) the Home Appliances. This Project is REMOTE CONTROLLED SWITCH
BOARD, which is used to switch on/off the Home Appliances by using a standard
Remote control. The system is used to switch on/off up to eight electrical devices. All
the above processes are controlled by the PIC16F84A 8-bit Microcontroller. The
Microcontroller receives the Infrared Signal from the receiver and it decodes and
switch on/off the appropriate Device. The Range of the system is up to 10 meters. The
project can switch on/off electrical devices of maximum load current of 5Amperes.
High power loads can also be connected by changing the Relay and the devices will
come to the original state after the power failure. The Microcontroller is used receive
the Infrared signal from the Transmitter, the received signal is processed by the
Microcontroller and according to the signal the corresponding device is switched
On/off.

1.1 OBJECTIVES
1. To switch on/off the Home Appliances by using a standard Remote control.
2. The system is used to switch on/off up to eight electrical devices.
3. The system should work within a range of 10 meters.
4. High power loads can also be connected by using relays of appropriate value.
5. The system should work on any remote supporting Phillips RC5 protocol.

1.2 BLOCK DIAGRAM OF INFRARED REMOTE CONTROL


SWITCH

TV
REMOTE

SWITCHING
TRANSISTOR

TSOP1738

Power supply
PIC16F84A
MICROCONTROLLER

RELAYS
DRIVER

RELAYS

LOAD OFF
INDICATOR

LOAD ON
INDICATOR

Fig 1.1: Block Diagram of the IR remote control switch

1.3 BACKGROUND
INFRARED REMOTE CONTROL
An infra-red remote control is a component of an electronics device, most commonly
a television set, used for operating the device wirelessly from a short line-of-sight
distance. Since infrared (IR) remote controls use light, they require line of sight to
operate the destination device. The signal can, however, be reflected by mirrors, just
like any other light source..Infrared receivers also tend to have a more or less limited
operating angle, which mainly depends on the optical characteristics of the
phototransistor.
2

INFRA-RED
Infrared (IR) light is electromagnetic radiation with a wavelength between 0.7 and
300 micrometers, which equates to a frequency range between approximately 1 and
430 THz. IR wavelengths are longer than that of visible light, but shorter than that of
terahertz radiation microwaves. Infrared imaging is used extensively for military and
civilian purposes. Military applications include target acquisition, surveillance, night
vision, homing and tracking. Non- military uses include thermal efficiency analysis,
remote temperature sensing, short-ranged wireless communication, spectroscopy, and
weather forecasting. Infrared astronomy uses sensor- equipped telescopes to penetrate
dusty regions of space, such as molecular clouds; detect objects such as planets, and
to view highly red-shifted objects from the early days of the universe.

RC-5 protocol
The RC-5 protocol was developed by Philips in the late 1980s as a semi-proprietary
consumer IR (infrared) remote control communication protocol for consumer
electronics. he advantage of the RC-5 protocol is that (when properly followed) any
CD handset (for example) may be used to control any brand of CD player using the
RC-5 protocol. The handset contains a keypad and a transmitter integrated circuit (IC)
driving an IR LED. The command data is a Manchester coded bit stream modulating a
36 kHz carrier The IR signal from the transmitter is detected by a specialized IC with
an integral photo-diode, and is amplified, filtered, and demodulated so that the
receiving device can act upon the received command. RC-5 only provides a one-way
link, with information traveling from the handset to the receiving unit.

Chapter -2
LITERATURE SURVEY
2.1 WHAT IS INFRARED?
Infrared is a energy radiation with a frequency below our eyes sensitivity, so we
cannot see it. Even that we cannot "see" sound frequencies, we know that it exist, we
can listen them.

Fig 2.1: Infrared Radiation


Even that we cannot see or hear infrared, we can feel it at our skin temperature
sensors. When you approach your hand to fire or warm element, you will "feel" the
heat, but you can't see it. You can see the fire because it emits other types of radiation,
visible to your eyes, but it also emits lots of infrared that you can only feel in your
skin.

2.2 INFRARED IN ELECTRONICS


Infra-Red is interesting, because it is easily generated and doesn't suffer
electromagnetic
Interference, so it is nicely used to communication and control, but it is not perfect,
some other light emissions could contain infrared as well, and that can interfere in this
communication. The sun is an example, since it emits a wide spectrum or radiation.
The adventure of using lots of infra-red in TV/VCR remote controls and other
applications, brought infra-red diodes (emitter and receivers) at very low cost at the
market.
From now on you should think as infrared as just a "red" light. This light can means
something to the Receiver, the "on or off" radiation can transmit different meanings.
Lots of things can generate infrared, anything that radiate heat do it, including out
body, lamps, stove, oven, friction your hands together, even the hot water at the
faucet.
To allow a good communication using infra-red, and avoid those "fake" signals, it is
Imperative to use a "key" that can tell the receiver what is the real data transmitted
and what is fake. As an analogy, looking eye naked to the night sky you can see
hundreds of stars, but you can spot easily a far away airplane just by its flashing
strobe light. That strobe light is the "key", the "coding" element that alerts us.

Similar to the airplane at the night sky, our TV room may have hundreds of tinny IR
sources, our body, and the lamps around, even the hot cup of tea. A way to avoid all
those other sources, is generating a key, like the flashing airplane. So, remote controls
use to pulsate its infrared in a certain frequency. The IR receiver module at the TV,
VCR or stereo "tunes" to this certain frequency and ignores all other IR received. The
best frequency for the job is between 30 and 60 kHz, the most used Is around 36 kHz.
So, remote controls use the 36 kHz (or around) to transmit information. Infrared light
emitted by IR Diodes is pulsated at 36 thousand times per second, when transmitting
logic level "1" and silence for "0".

2.3 IR GENERATION
To generate a 36 kHz pulsating infrared is quite easy, more difficult
is to receive and identify this frequency. This is why some
companies produce infrared receives, that contains the filters,
decoding circuits and the output shaper, that delivers a square
wave, meaning the existence or not of the 36kHz incoming pulsating
infrared.
It means that those 3 dollars small units, have an output pin that
goes high (+5V) when there is a pulsating 36kHz infrared in front of
it, and zero volts when there is not this radiation.

Fig 2.2: IR generations


A square wave of approximately 27uS (microseconds) injected at the base of a
transistor, can drive an infrared LED to transmit this pulsating light wave. Upon its
presence, the
Commercial receiver will switch its output to high level (+5V).
If you can turn on and off this frequency at the transmitter, your receiver's output will
indicate when the transmitter is on or off.
5

Those IR demodulators have inverted logic at its output, when a burst of IR is sensed
it drives its output to low level, meaning logic level = 1.

Fig 2.3: IR logic levels


The TV, VCR, and Audio equipment manufacturers for long use infra-red at their
remote Controls. To avoid a Philips remote control to change channels in a Panasonic
TV, they use different codification at the infrared, even that all of them use basically
the same transmitted frequency, from 36 to 50 kHz. So, all of them use a different
combination of bits or how to code the transmitted data to avoid interference.

2.4 RC-5 PROTOCOL


A key feature of RC5 is the use of data-dependent rotations; one of the goals of RC5
was to prompt the study and evaluation of such operations as a cryptographic
primitive. RC5 also consists of a number of modular additions and exclusive OR
(XOR)s. The general structure of the algorithm is a Feistel-like network. The
encryption and decryption routines can be specified in a few lines of code. The key
schedule, however, is more complex, expanding the key using an essentially one-way
function with the binary expansions of both and the golden ratio as sources of
"nothing up my sleeve numbers". The tantalizing simplicity of the algorithm together
with the novelty of the data-dependent rotations has made RC5 an attractive object of
study for cryptanalysts. The RC5 is basically denoted as RC5-w/r/b where w=word
size in bits, r=number of rounds, b=number of 8-bit byte in the key.
Various remote control systems are used in electronic equipment today. The RC5
control protocol is one of the most popular and is widely used to control numerous
home appliances, entertainment systems and some industrial applications including
utility consumption remote meter reading, contactless apparatus control, telemetry
data transmission, and car security systems. Philips originally invented this protocol
and virtually all Philips remotes use this protocol. Following is a description of the
RC5.
When the user pushes a button on the hand-held remote, the device is activated and
sends
Modulated infrared light to transmit the command. The remote separates command
data into packets. Each data packet consists of a 14-bit data word, which is repeated if
the user continues to push the remote button. The data packet structure is as follows:

2 start bits,
1 control bit,
5 address bits
6 command bits.

The start bits are always logic 1 and intended to calibrate the optical receiver
automatic gain control loop. Next, is the control bit. This bit is inverted each time the
user releases the remote button and is intended to differentiate situations when the
user continues to hold the same button or presses it again. The next 5 bits are the
address bits and select the destination device. A number of devices can use RC5 at the
same time. To exclude possible interference, each must use a different address. The 6
command bits describe the actual command. As a result, a RC5 transmitter can send
the 2048 unique commands. The transmitter shifts the data word, applies Manchester
encoding and passes the created
One-bit sequence to a control carrier frequency signal amplitude modulator. The
amplitude modulated carrier signal is sent to the optical transmitter, which radiates the
infrared light. In RC5 systems the carrier frequency has been set to 36 kHz. Figure
below displays the RC5 protocol

Fig 2.4: RC 5 Wave forms

2.5 DECODING IR SIGNAL WITH A MICROCONTROLLER


To receive this signal using a microcontroller follows the timing from the figure
below. Note that the Infrared Receiver invert the bit signal, low level means bit ON.

Fig 2.5: Decoding IR Signal


During inactivity (no Infrared present) the output of the Infrared receiver is UP (bit
zero). You can connect the IR receiver output to any input port pin or interrupt pin of
your microcontroller, and keep polling it or prepare the interrupt routine to trigger
your reading after the first low level sensed. When you press a key at the remote, it
transmits the train of pulses, and your microcontroller will receive bit #1 first. It will
be sensed right after the middle of the bit when it changes from high to low level to
means bit "1". This is the first time that your microcontroller will "see" the incoming
IR signal. You don't need to decode those first two bits, not even the CHK bit (except
if you want to control as the TV do and described above), so you can skip those 3 bits
and start to receive the ADDRESS bits. To do that, you need to skip 2.75 bits time,
and you will be exactly at the middle of The right level of the first ADDRESS bit to
be read (non inverted level).
So,
Upon sensing the first low level, your software should wait 4.752 milliseconds and
then start to read the next 11 bits spaced 1.728ms each. The first 5 bits are Address
and the next 6 bits are Command, logic correct level, LOW = 0, HIGH = 1. At your
bit reading routine use an available microcontroller port pin and generate a fast pulse
UP and DOWN, then use one scope channel to display this pulse, and the other scope
channel to show the incoming signal from the receiver. Press and hold key number
ZERO at the remote, and sync the scope to show a complete wave form, don't worry
with timing. The fast 11 pulses should always be in place of those RED down arrows
at the figure. It means that the "bit reading" software routine will reading exactly in
the middle of the correct bit level

Fig 2.6: Correct level of First Address Bit


Your software will need to have two timing delays, the first to wait 4.752ms and the
second to wait 1.728ms. Adjust the timing loop from the 4.752ms until the first fast
pulse happens exactly as indicated above. Then adjust the 1.728 ms timing delay in
such way that the last fast pulse (#11) bit reading happens exactly at the middle of the
low part of the last bit (#14).
Check all other bits and fast pulses, they should be all matching ok. Small errors
would be
Accepted since the reading would be happening in the middle of the bit, few errors for
more or less is not a problem, but it is better to be the most possible in the middle of
the low level of each bit. This is why you should adjust your 1.728ms timing routine
looking at the last data bit and fast pulse, if they match somehow ok, all the other bits
should be ok too. Remember that any other remote key will generate a different
pattern and it can confuse you. Use always key number ZERO for this software
calibration.
Once you find the correct timing delays, you can replace the FAST pulse instructions
with NOPS (check your chip instruction set to keep the same clock count wasted), or
keep the fast pulse there just for fun, so you will be able to recheck it in case of
problems.
Here few examples of the complete waveform (14 bits) at the Receiver Output:

Fig 2.7: Right commands in hexadecimal


Red: AGC pulses (ON)
Blue: Check bit (flipping)
White: Address (00)
Green: Command

Chapter -3
DESIGN OVERVIEW
3.1CIRCUIT DESCRIPTION
Here is a versatile remote controlled appliance switch that can ON or OFF any
appliance connected to it using a TV remote. IR remote sensor TSOP 1738 is used for
receiving the signal. Normally when no signal is falling on pin3, the output of it will
be high. When a signal of 38 KHz from the TV remote falls on the pin3 its output
goes low. This sends a pulse at pin 6 of PIC16F84A which is the microcontroller. The
high output is amplified to drive the relay .For the next signal the outputs of IC3
(ULN2803APG) toggles state. Result, we get a relay toggling on each press on the
remote. Any appliance connected to this circuit can be switched ON or OFF.
3.2 CIRCUIT DIAGRAM

Fig 3.1: Circuit diagram for the IR Remote Control

10

Chapter -4
CIRCUIT COMPONENETS

4.1 PIC16F84A (MICROCONTROLLER)


The PIC16F84A belongs to the mid-range family of the PICmicro microcontroller
devices. The program memory contains 1K words, which translates to 1024
instructions, since each 14-bit program memory word is the same width as each
device instruction. The data memory (RAM) contains 68 bytes. Data
EEPROM is 64 bytes.
There are also 13 I/O pins that are user-configured on a pin-to-pin basis. Some pins
are multiplexed with other device functions. These functions include:
External interrupt
Change on PORTB interrupts
Timer0 clock input

Fig 4.1: block diagram for PIC16F84A microcontroller


11

(a) PIN DISCRIPTION

Fig 4.2: pin diagram


RA0 to RA4
RA is a bidirectional port. That is, it can be configured as an input or an output. The
number following RA is the bit number (0 to 4). So, we have one 5-bit directional port
where each bit can be configured as Input or Output.
RB0 to RB7
RB is a second bidirectional port. It behaves in exactly the same way as RA, except
there are 8 - bits involved.
VSS and VDD
these are the power supply pins. VDD is the positive supply, and VSS is the negative
supply, or 0V. The maximum supply voltage that you can use is 6V, and the minimum
is 2V
OSC1/CLK IN and OSC2/CLKOUT
these pins is where we connect an external clock, so that the microcontroller has some
kind of timing.
MCLR
This pin is used to erase the memory locations inside the PIC (i.e. when we want to
re-program it). In normal use it is connected to the positive supply rail.
INT
this is an input pin which can be monitored. If the pin goes high, we can cause the
program to restart, stop or any other single function we desire. We won't be using this
one much.
T0CK1
this is another clock input, which operates an internal timer. It operates in isolation to
the main clock. Again, we won't be using this one much either.

12

Fig 4.3: pin out description


(b)DATA MEMORY ORGANIZATION
The data memory is partitioned into two areas. The first is the Special Function
Registers (SFR) area, while the second is the General Purpose Registers (GPR) area.
The SFRs control the operation of the device. Portions of data memory are banked.
This is for both the SFR area and the GPR area. The GPR area is banked to allow
greater than 116 bytes of general purpose RAM. The banked areas of the SFR are for
the registers that control the peripheral functions. Banking requires the use of control
bits for bank selection. These control bits are located in the STATUS Register. Figure
2-2 shows the data memory map organization. Instructions MOVWF and MOVF can
move values from the W register to any location in the register file (F), and viceversa. The entire data memory can be accessed either directly using the absolute
address of each register file or indirectly through the File Select Register (FSR)
(Section 2.5). Indirect addressing uses the present value of the RP0 bit for access into
the banked areas of data memory. Data memory is partitioned into two banks which
contain the general purpose registers and the special function registers. Bank 0 is
selected by clearing the RP0 bit (STATUS<5>). Setting the RP0 bit selects Bank 1.
Each Bank extends up to 7Fh (128 bytes). The first twelve locations of each Bank are
reserved for the Special Function Registers. The remainder are General Purpose
Registers, implemented as static RAM.
13

Fig 4.4: data memory Organization

High Performance RISC CPU Features:


Only 35 single word instructions to learn
All instructions single-cycle except for program Branches which are two-cycle
Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle
1024 words of program memory
68 bytes of Data RAM
64 bytes of Data EEPROM
14-bit wide instruction words
8-bit wide data bytes
15 Special Function Hardware registers
Eight-level deep hardware stack
Direct, indirect and relative addressing modes
Four interrupt sources:
- External RB0/INT pin
- TMR0 timer overflow
- PORTB<7:4> interrupt-on-change
- Data EEPROM write complete

Peripheral Features:

13 I/O pins with individual direction control


High current sink/source for direct LED drive
- 25 mA sink max. per pin
- 25 mA source max. per pin
TMR0: 8-bit timer/counter with 8-bit programmable prescaler

14

Special Microcontroller Features:

10,000 erase/write cycles Enhanced FLASH Program memory typical


10,000,000 typical erase/write cycles EEPROM Data memory typical
EEPROM Data Retention > 40 years
In-Circuit Serial Programming (ICSP) via two pins
Power-on Reset (POR), Power-up Timer (PWRT), Oscillator Start-up Timer (OST)
Watchdog Timer (WDT) with its own On-Chip RC Oscillator for reliable operation
Code protection
Power saving SLEEP mode
Selectable oscillator options
CMOS Enhanced FLASH/EEPROM Technology:

Low power, high speed technology


Fully static design
Wide operating voltage range:
- Commercial: 2.0V to 5.5V
- Industrial: 2.0V to 5.5V
Low power consumption:
- < 2 mA typical @ 5V, 4 MHz
- 15 mA typical @ 2V, 32 kHz
- < 0.5 mA typical standby current @ 2V

4.2 ULN2803APG (HIGH VOLTAGE AND CURRENT TRANSISTOR ARRAY)


The ULN2803APG is a high-voltage, high-current Darlington transistor array. The
device consists of eight npn Darlington pairs that feature high-voltage outputs with
common-cathode clamp diodes for switching inductive loads. The collector-current
rating of each Darlington pair is 500 mA. The Darlington pairs may be connected in
parallel for higher current capability.
Applications include relay drivers, hammer drivers, lamp drivers, display drivers
(LED and gas discharge), line drivers, and logic buffers. The ULN2803A has a 2.7k series base resistor for each Darlington pair for operation directly with TTL or 5-V
CMOS devices.

Features
500mA rated collector current.
Inputs compatible with various type of inputs.
Relay driver application.

15

Fig 4.5: logic diagram

Fig 4.6: schematic (each Darlington pair)

4.3 RELAY
A relay is an electrically operated switch. Many relays use an electromagnet to
mechanically operate a switch, but other operating principles are also used, such as
solid- state relays. Relays are used where it is necessary to control a circuit by a lowpower signal (with complete electrical isolation between control and controlled
circuits), or where several circuits must be controlled by one signal. The rst relays
were used in long distance telegraph circuits as appliers they repeated the signal
coming in from one circuit and re-transmitted it on another circuit. Relays were used
extensively in telephone exchanges and early computers to perform logical
operations.

16

It basically is a switching device. On providing a definite specified DC voltage across


the induction coil, it gets magnetized and causes the switch (the middle one) to flip its
position from where it was previously to the other pin, causing the device attached
across it to turn on. But we had a problem, we were provided with only 12 volt relay
(it operated on 12 V) and the microcontroller gave 5V.So we used a BJT transistor in
Common emitter mode to amplify5V to 12 V. We finally attached our device across the
relay to get it working when the relay received 12 V, otherwise not.

Fig 4.7: relay

Fig 4.8: the relay contacts are close by electro-magnetism created by the coil
The appliance to be controlled is connected between the pole of the relay and neutral
terminal of mains. It gets connected to live terminal of AC mains via normally opened
(N/O) contact when the relay energises.
In short we can say relay is like a switch which is necessary to control a circuit

4.4 TSOP 1738


17

The TSOP 17XX series are miniaturized receivers for infrared remote control
systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package
is designed as IR filter. The demodulated output signal can directly be decoded by a
microprocessor. TSOP 17XX is the standard IR remote control receiver series,
supporting all major transmission codes. Here XX refers to the frequency of the
infrared carrier signal on which the code is modulated, which is 38 KHz in our case. It
has three pins .GND and Vcc are connected to the power supply with VCC as 5V and
Vout which becomes 0V, or GND when the demodulated bit received is high i.e. 5V and
vice versa.

Fig 4.9: the TSOP 1738

Features

Photo detector and preamplifier in one package


Internal filter for PCM frequency
Improved shielding against electrical field disturbance
TTL and CMOS compatibility
Output active low
Low power consumption
High immunity against ambient light
Continuous data transmission possible (up to 2400 bps)
Suitable burst length .10 cycles/burst

18

4.5 TRANSFORMER (230/12V)


A transformer is a device that transfers electrical energy from one
circuit to another through inductively coupled conductorsthe
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)

19

Fig 4.10: transformer

4.6 CRYSTAL OSCILLATOR


Most microprocessors and microcontrollers have two oscillator pins
labelled XTAL1 and XTAL2 to connect to an external quartz crystal,
RC network or even a Ceramic resonator. In this application the
Crystal Oscillator produces a train of continuous square wave pulses
whose frequency is controlled by the crystal which in turn regulates
the instructions that controls the device. For example, the master
clock and system timing.
A crystal oscillator is an electronic oscillator circuit that uses the mechanical
resonance of a vibrating crystal of piezoelectric material to create an electrical signal
with a very precise frequency. This frequency is commonly used to keep track of time
to provide a stable clock signal for digital integrated circuits, and to stabilize
frequencies for radio transmitters and receivers. The most common type of
piezoelectric resonator used is the quartz crystal, so oscillator circuits incorporating
them became known as crystal oscillators, but other piezoelectric materials including
Polycrystalline ceramics are used in similar circuits .
Quartz crystals are manufactured for frequencies from a few tens of kilohertz to
hundreds of megahertz. More than two billion crystals are manufactured annually.
Most are used for consumer devices such as wristwatches, clocks, radios, computers,
and cell phones. Quartz crystals are also found inside test and measurement
equipment, such as counters, signal generators, and oscilloscopes.

20

Fig 4.11: crystal oscillator

4.7 DIODE
In electronics, a diode is a two-terminal electronic component with asymmetric
conductance it has low resistance to current in one direction, and high resistance in
the other. A semiconductor diode, the most common type today, is a crystalline piece
of semiconductor material with a pn junction connected to two electrical terminals. A
vacuum tube diode has two electrodes, a plate (anode) and a heated cathode.

4.8 DIODE BRIDGE


A diode bridge is an arrangement of four (or more) diodes in a bridge circuit
configuration that provides the same polarity of output for either polarity of input.
When used in its most common application, for conversion of an alternating current
(AC) input into a direct current (DC) output, it is known as a bridge rectifier. A bridge
rectifier provides full-wave rectification from a two-wire AC input, resulting in lower
cost and weight as compared to a rectifier with a 3-wire input from a transformer with
a centre-tapped secondary winding.

21

Fig 4.12: Diode Bridge

4.9 CAPACITOR
A capacitor is a passive two-terminal electrical component used to store energy
electrostatically in an electric field. The forms of practical capacitors vary widely, but
all contain at least two electrical conductors separated by a dielectric. The conductors
can be thin films, foils or sintered beads of metal or conductive electrolyte, the
nonconducting dielectric acts to increase the capacitors charge capacity. A dielectric
can be glass, ceramic, plastic film, air, vacuums, paper, mica, oxide layer. Capacitors
are widely used as parts of electrical circuits in many common electrical devices.
Unlike a resistor, an ideal capacitor does not dissipate energy. Instead, a capacitor
stores energy in the form of an electrostatic field between its plates.

Fig 4.13: electrolytic capacitor

22

Fig 4.14: Solid electrolyte, resin-dipped 10 F 35 V tantalum capacitors the + sig


indicates the positive lead

Fig 4.15: Charge separation in a parallel-plate capacitor causes an internal


Electric field. A dielectric (orange) reduces the field and increases
The capacitance.

4.10 LM7805 (VOLTAGE REGULATOR)


Voltage Regulator (LM7805), having three legs, converts varying input voltage and
produces a constant regulated output voltage. The LM7805 typically has the ability to
drive current up to 1A the component has three legs: Input leg which can hold up to
36VDC Common leg (GND) and an output leg with the regulator's voltage. For
maximum voltage regulation, adding a capacitor in parallel between the common leg
and the output is usually recommended. This eliminates any high frequency AC
voltage that could otherwise combine with the output voltage.
A voltage regulator is designed to automatically maintain a constant voltage level. A
voltage regulator may be a simple "feed-forward" design or may include
negative control loops. It may use an electromechanical mechanism, or electronic
components. Depending on the design, it may be used to regulate one or
more AC or DC voltage

23

Electronic voltage regulators are found in devices such as computer power


supplies where they stabilize the DC voltages used by the processor and other
elements. In automobile alternators and central power station generator plants, voltage
regulators control the output of the plant. In a distribution system, voltage regulators
may be installed at a substation or along distribution lines so that all customers
receive steady voltage independent of how much power is drawn from the line.

Fig 4.16: voltage regulator

Fig 4.17: Circuit design for a simple electromechanical voltage regulator.

4.11 RESISTOR
A resistor is a passive two-terminal electrical component that implements electrical
resistance as a circuit element. Resistors act to reduce current flow, and, at the same
time, act to lower voltage levels within circuits. In electronic circuits resistors are
used to limit current flow, to adjust signal levels, bias active elements, terminate
transmission lines among other uses.
High-power resistors that can dissipate many watts of electrical power as heat may be
used as part of motor controls, in power distribution systems, or as test loads for
generators.
Fixed resistors have resistances that only change slightly with temperature, time or
Operating voltage. Variable resistors can be used to adjust circuit elements or as
sensing devices for heat, light, humidity, Force or chemical activity.

24

Fig 4.18: Resistors with wire leads for through-hole mounting

Series and parallel connection of resistors


In a series configuration, the current through all of the resistors is the same, but the
voltage across each resistor will be in proportion to its resistance. The potential
difference (voltage) seen across the network is the sum of those voltages, thus the
total resistance can be found as the sum of those resistances.

Fig 4.19: Series connection


The parallel equivalent resistance can be represented in equations by two vertical lines
"||" (as in geometry) as a simplified notation. Occasionally two slashes "//" are used
instead of "||", in case the keyboard or font lacks the vertical line symbol. For the case
of two resistors in parallel, this can be calculated using:

Fig 4.20: parallel connection

4.12 LED
A light emitting diode (LED) is essentially a PN junction opto-semiconductor that
emits a monochromatic (single color) light when operated in a forward biased
direction.
LEDs convert electrical energy into light energy. They are frequently used as "pilot"
lights in electronic appliances to indicate whether the circuit is closed or not.

25

Fig 4.21: LED

LED connection

Fig 4.22: LED


connection

Chapter -5

CIRCUIT DESIGNING
5.1 PCB Design and Construction
ASSEMBLY
26

Use the component overlay on the PCB to place the components in the following
order. Do not insert any ICs until after the TESTING section.
1. Resistors and diodes.
2. IC sockets
3. Resistor networks. Note that RP2 is inserted inside the IC1 IC socket. The small dot
at one end of the network denotes pin 1 which is the square pad.
4. Ceramic resonator, capacitors and IR module. The lens bump of the IR module
faces outwards.
5. Three switches 2 SPDT and a zippy tact switch
6. DC power jack and 7805 regulator. Use needle nosed pliers to bend the leads of the
regulator. It does not require a heatsink. Screw down onto to PCB.
7. LEDs
8. Electrolytic capacitors. Make sure you insert them the correct way around.
9. Terminal blocks. Note the terminal blocks do NOT slide together. Also make sure
the wire entry side faces out from the PCB.
10. Relays
TESTING
Finally after you have inspected your work connect 12V DC centre positive from a
plug pack. The power LED should light. Use a multimeter to measure the 5V output
from the regulator. Easiest way to do this is across pins 10 and 20 of the IC1 socket
(pin 20 = positive). If all is well you can remove the power and insert the ICs. Take
care that none of the IC leads are bent under when inserting them into their sockets.
Connect a 12V supply again. Put the slide switches in the momentary (MOM)
position and press button 1 on the remote control unit. Relay 1 should operate and
LED 1 should light. Release the button and the relay should release. Check each of
the other relays in turn by pressing the other buttons. Buttons 13 and 14 have no affect
in momentary mode. Now put the slide switches in the toggle (TOG) position. Now
press and release button 1 on the remote control unit. Relay 1 should operate and stay
operated. LED 1 should also be on. Press each of the other buttons 2 to 12 in turn and
note that each relay and its LED is on. At this point all the relays and LEDs should be
on. Now press button 13. All Group 1 relays (1-4) should release and LEDs 1-4
should be off. Pressing button 14 should release all Group 2 (5-8) relays and turn off
their M associated LEDs 5-8.

27

28

Fig 5.1: PCB Layout Track Side

Fig 5.2: PCB Layout Components Side

29

5.2 WORKING OF CIRCUIT


The Infra-Red Remote control circuit described here used here for any simple ONOFF function. The circuit is free from ambient light interference and works up to a
range of 10 meters.
The 38 kHz infra-red (IR) rays energized by a remote control are received a infrared
Receiver module SM0038 of the circuit. Pin1 is connected to ground, pin2 is
connected to supply through a 47k resistor and the output is taken from pin3. The
output is given to the pin6 of the microcontroller (PIC16F84A) for processing. The IC
ULN2803APG amplifies the signal which drives the relay. The appliance connected
to the relay does operate due to signal from the remote control.
The 12V to the relay circuit and the 5V to the microcontroller circuit is provided by
the rectifier circuit. This circuit consists of an IC LM7805 which constantly gives an
output of 5V for an input in the range of (9-12V). It has a transformer which steps
down the 220V to 12V and a bridge rectifier which converts the ac to dc.
IC2 is an infrared receiver which amplifies filters and demodulates the code supplied
by the transmitter. The top trace in Fig.3 shows the modulated signal from the
handheld transmitter, while the lower trace is the demodulated signal at the output of
IC2. The modulation is at about 36 kHz and represents a high level
Note that the output of IC2 is inverted compared to the transmitted code.
The remote control coding that we are using is called the "Philips RC5" code. It
comprises 14bits of information, including two start bits, a toggle bit, five address bits
and six command bits.
The two start bits are transmitted first (makes sense, doesn't it?), followed by the
toggle bit. This toggle bit changes each time the same button is pressed on the
transmitter. If the button is simply held down, the transmission repeats at 113.778ms
intervals and the toggle bit remains either high or low. The state of the toggle bit
allows the receiver to distinguish between whether a button is being held down
continuously or has been pressed more than once.
The address bits are for selecting the type of equipment to be used. For example,
address 0 (00000) is for a TV set. Address 1 (00001) is for TV2 or a second TV set.
The two addresses we are using are for Satellite 1 and 2 at addresses 8 (01000) and 10
(01010).
IC1 (the PIC microcontroller) is used to decode the demodulated signal from IC2. It
does everything from the remote control decoding to driving the outputs. It also does
away with the need for a specialised IC and can be programmed to operate with
existing commercial remote controls.
In operation, IC1 monitors its pin 2 inputs for a remote control signal. When a signal
arrives, it detects the start bits and then monitors the demodulated signal at regular
intervals to provide the code sequence.
30

The timing is controlled by dividing down the signal from a 4MHz crystal (X1) to
obtain 1.8ms intervals this is the spacing between each bit in the remote control
sequence. The decoded signal appears at pin 1 of IC1 and is used to drive the
Acknowledge LED (LED11) via a 220 resistor.
IC1 can be forced to display its remote control status by connecting pin 1 to the 5V
supply (TP2) via a 220 test Resistor at power up. This will set pins 18 & 17 to
provide a tracer signal and a stop and start level for the code respectively.
The tracer shows when the code level is monitored for each of the 14 bits in the code.
When in this mode, the 0 and 1 outputs are prevented from operating normally.
Normal operation is restored by switching off the supply for a few seconds, removing
the 220W test resistor and reapplying power.

Chapter -6
PROGRAMMING THE MICROCONTROLLER
6.1 SOFTWARE
MPLAB IDE
MPLAB is a free integrated development environment for the development
of embedded applications on PIC and dsPIC microcontrollers, and is developed
by Microchip Technology. MPLAB X is the latest edition of MPLAB, and is
developed on the Net Beans platform. MPLAB and MPLAB X support project
management, code editing, debugging and programming of Microchip 8-bit, 16-bit
and 32-bit PIC microcontrollers.
A development system for embedded controllers is a system of programs running on a
Desktop PC to help write, edit, debug and program code the intelligence of
embedded systems applications into a microcontroller. MPLAB IDE runs on a PC
and contains all the components needed to design and deploy embedded systems
applications.
The PIC16F84A is shipped with the 2K bytes of on-chip PEROM code memory array
in the erased state (i.e., contents = FFH) and ready to be programmed. The code
memory array is programmed one byte at a time. Once the array is programmed, to reprogram any non-blank byte, the entire memory array needs to be erased electrically.
Internal Address Counter: The PIC16F84A contains an internal PEROM address
counter which is always reset to 000H on the rising edge of RST and is advanced by
applying a positive going pulse to pin XTAL1. To program the PIC16F84A, the
following sequence is recommended.

31

1. Power-up sequence: Apply power between VCC and GND pins. Set RST and
XTAL1 to GND.
2. Set pin RST to H Set pin P3.2 to H
3. Apply the appropriate combination of H or L logic levels to pins P3.3, P3.4,
P3.5, and P3.7 to select one of the programming operations.
Programming the PIC in assembly language is no exception but it is more difficult to
Work with than high-level languages, like BASIC and C++.
Assembly language uses a one-to-one correspondence of mnemonic words with
The binary machine codes that the processor uses to code the instructions. The user
writes the program using the mnemonic words called the source program and gives
this to the program on the PC called the assembler which converts it into the
machine code of the PIC in the form of a list of hexadecimal numbers. This set of
numbers is called the object program. The user then writes the object program into
the PIC in the downloading process of programming the PIC. When this is done, the
PIC is ready to run its new program.

6.2 PROGRAM
[PROGRAM FOR REMOTE CONTROL]
$mod51
INPUT EQU P3.2; Port3, Bit2 is used as input. The demodulated signal
OUTPUT EQU P1
with active low level is connected to this pin
OP1 EQU P1.2
OP2 EQU P1.3
OP3 EQU P1.4
OP4 EQU P1.5
OP5 EQU P1.6
OP6 EQU P1.7
DSEG; this is internal data memory
ORG 20H; Bit addressable memory
FLAGS: DS 1 CONTROL BIT
FLAGS.0; toggles with every new keystroke
NEW BIT FLAGS.1; Bit set when a new command has been received
COMMAND: DS 1; Received command byte
SUBAD: DS 1; Device sub address
TOGGLE: DS 1; Toggle every bit
ANS: DS 1;
ADDR: DS 1
STACK: DS 1; Stack begins here
CSEG; Code begins here
32

[PROCESSOR INTERRUPT AND RESET VECTORS]


$mod51
ORG 00H; Reset
JMP MAIN
ORG 0003H; External Interrupt0
JMP RECEIVE
[Interrupt 0 routine]
RECEIVE:
cpl p3.7
MOV 2, #255; Time Loop (3/4 bit time)
DJNZ 2, $; Waste Time to sync second bit MOV 2, #255; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
Mov 2,#145 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
clr a
mov r6,#07h
pol1: mov c,Input
rlc a
Mov 2,#255 ; Waste time for next BIT
Djnz 2,$
Mov 2,#255 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
Mov 2,#255 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
Mov 2,#114 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
djnz r6,pol1
MOV SUBAD, A
mov r6,#06h
pol2:
mov c,Input
rlc a
Mov 2,#255 ; Waste time for next BITDjnz 2,$
Mov 2,#255 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
Mov 2,#255 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
Mov 2,#114 ; Time Loop (3/4 bit time)
Djnz 2,$ ; Waste Time to sync second bit
djnz r6,pol2
Mov COMMAND, A ; Save Command at IRData memory
MOV A, SUBAD
MOV ADDR, A
ANL A, #0FH
MOV SUBAD, A
CJNE A,#03H,ZXC1
MOV A, COMMAND
33

CPL A
MOV COMMAND,A
AJMP ASZ
ZXC1: MOV A, SUBAD
CJNE A, #00H,ANSS
AJMP ASZ
ASZ: MOV A, ADDRANL A,#20H
MOV TOGGLE,A
CJNE A, ANS,ANSS
AJMP WAR
ANSS: JMP ANS1
WAR:
MOV A, COMMAND
MOV R0, A
XRL A, #01H; device 1
JNZ CH1
CPL OP1; Light 1
AJMP GO
CH1: MOV A, R0
XRL A, #02H ; device 2
JNZ CH2
CPL OP2; Light 1
AJMP GO
CH2: MOV A, R0
XRL A, #03H ; device 3
JNZ CH3
CPL OP3; Light 1
AJMP GOCH3: MOV A, R0
XRL A, #04H; device 4
JNZ CH4
CPL OP4; Light 1
AJMP GO
CH4: MOV A, R0
XRL A, #05H; device 5
JNZ CH5
CPL OP5; Light 1
AJMP GO
CH5: MOV A, R0
XRL A,#06H ; device 6
JNZ CH6
CPL OP6; Light 1
AJMP GO
CH6: MOV A, R0
XRL A, #0CH ; all devices off
JNZ go
MOV OUTPUT,#0FFH
AJMP GO
GO:
MOV ANS,TOGGLE
MOV A, ANS
CPL ACC.5MOV ANS,A
34

SETB NEW; Set flag to indicate the new command


ANS1:
RETI
[Main routine. Program execution starts here.]
MAIN:
MOV SP, #60H
MOV OUTPUT, #0FFH; Switch off all devices
SETB EX0; Enable external Interrupt0
CLR IT0; triggered by a high to low transition
SETB EA
MOV ANS, #00H; clear temp toggle bit
CLR NEW
LOO:
JNB NEW, LOO
CLR NEW
AJMP LOO
END

Chapter -7
CONCLUSION AND FUTURE WORK

7.1 CONCLUSION
Hereby we come to an end of or project IR remote control switch board. This
project gives us an idea of RC5 Protocol and the microcontroller PIC16F84A. This
project can be used anywhere either at home or offices. This is also cost efficient.
Thus by this attempt of ours the ON/OFF processes of many devices was successfully
carried out by just using a TV remote.

7.2 FUTURE WORK


1. We plan to attach timer system to our devices, so that they can be turned on for a
fixed duration and then turned off.
2. We plan to controlled devices like fan which have other features like regulating
speed, not only turning on and off.

35

Chapter -8
BIBLIOGRAPHY
8.1 REFERENCES
[1]

www.wikipedia.com

[2]

www.google.com

[3]

www.atmel.com

[4]

www.coolcircuit.com

[5]

www.circuitvalley.com

[6]

http://archive.siliconchip.com.au/cms/A_30626/article.html

8.2 DATASHEETS

PIC16F84A

TSOP 1738

ULN2803APG

36

37

Das könnte Ihnen auch gefallen