You are on page 1of 69

Chapter-1

INTRODUCTION

1.1 INFRARED REMOTE CONTROL THEORY:

IR is electromagnetic (EM) radiation of wavelengths longer than visible light, but


shorter than RF spanning three orders of magnitude between 750 nm and 1 mm. IrDA, the
Infrared Data Association, champions IR in the electronics sector and most offerings
adhere to the organization's standards, aiding interoperability.

IR remote controls use IR LEDs to emit radiation that's focused by a plastic lens into a
narrow beam. Data is encoded by modulating the beam to provide immunity from other
IR sources such as fluorescent lights.

Thus, the Infrared refers to the energy radiations having frequency below visible
range. These radiations are invisible to human eye but may be perceived as heat signals.
Similarly, these radiations can be easily detected through readily available sensor
modules.

Infra Red Highly Visible Ultra Violet

Figure 1.1: Electromagnetic spectrum

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 contains infrared as well, and that can
interfere in this communication.

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

This infrared light can mean something to the receiver, the "on or off" radiation
can transmit different meanings. Lot 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 used to pulsate 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". 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.

2
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 this frequency is turned on/off at the transmitter, the receiver indicates it


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

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. Some standards were created. In this project we will only
show one of them, the one used by Philips.

Philips adopted or created the RC5 standard that uses fixed bit length and fixed
quantity of bits. In this application RC5 pulse protocol used by Philips TV is decoded
using a microcontroller. In other words, this project develops the IR receiver for the
Philips RC5 protocol and the output has been shown on the hardware through relay
controlled devices corresponding to various channels switched with remote. Also, LEDs
glow corresponding to each output.

In this project we will make a TV receiver for Philips remote control. This remote
control is based on RC5 protocol. This receiver will be an embedded system which can be
used in television sets. The decoding of the RC5 pulse protocol has been done in
assembly level language although we can also use embedded C or Basscom for writing
the program for the microcontroller (We will be using Atmels AT89C51 8-bit
microcontroller). The project also involves the design and development of the Printed
Circuit Board (PCB). This provides the additional benefit that no or minimum wiring has
been done, and hence there are less chances of wear and tear. We have on our part tried to
solder the components as finely as possible.

The further chapters clearly explain the RC5 protocol and our efforts towards its
decoding.

3
1.1 RC5 PROTOCOL:

The RC-5 code from Philips is possibly the most used protocol by hobbyists. The
protocol is well defined for different device types ensuring compatibility with your whole
entertainment system.

Features:
5 bit address and 6 bit command length (7 command bits for RC5X)

Bi-phase coding (aka Manchester coding)

Carrier frequency of 36kHz

Constant bit time of 1.778ms (64 cycles of 36 kHz)

Manufacturer Philips

Modulation:
The protocol uses bi-phase modulation (or so-called Manchester coding) of a 36
kHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol, with
half of the bit time filled with a burst of the 36 kHz carrier and the other half being idle.

A logical zero is represented by a burst in the first half of the bit time. A logical
one is represented by a burst in the second half of the bit time. The pulse/pause ratio of
the 36 kHz carrier frequency is 1/3 or 1/4 which reduces power consumption.

889s 889s 889s 889s

Figure 1.2: Modulation

Protocol:
The figure 3 below shows a typical pulse train of an RC-5 message. This example
transmits command $35 to address $05.

4
1 1 0 0 0 1 0 1 1 1 0 1 0 1

MSB LSB MSB LSB

S S
1 2 Address Command
Figure 1.3
Start bit (Always 1)
The first two pulses are the start pulses, and are both logical "1". Please note that
half a bit time is elapsed before the receiver will notice the real start of the message.
Extended RC-5 uses only one start bit. Bit S2 is transformed to command bit 6,
providing for a total of 7 command bits. The value of S2 must be inverted to get the
7th command bit though!
The 3rd bit is a toggle bit. This bit is inverted every time a key is released and
pressed again. This way the receiver can distinguish between a key that remains
down, or is pressed repeatedly. The next 5 bits represent the IR device address, which
is sent with MSB first.
The address is followed by a 6 bit command, again sent with MSB first.
A message consists of a total of 14 bits, which adds up to a total duration of 25 m sec.
Sometimes a message may appear to be shorter because the first half of the start bit S1
remains idle.
And if the last bit of the message is logic "0" the last half bit of the message is
idle too. As long as a key remains down the message will be repeated every 114ms.
The toggle bit will retain the same logical level during all of these repeated messages.
It is up to the receiver software to interpret this auto repeat feature.

Pre-defined Commands:
Philips has created a beautiful list of "standardized" commands. This ensures the
compatibility between devices from the same brand. A very nice feature, often to be
missed with other brands, is the fact that most devices are available twice in the table
allowing one to have 2 VCRs stacked on top of each other without having trouble
addressing only one of them with the remote control.

The addresses for various devices may be seen in the Table 1.1.
The TV and VCR commands corresponding to the RC5 command may be seen in
the Table 1.2.

5
RC-5 Address Device
$00-0 TV1
$01-1 TV2
$02-2 Teletext
$03-3 Video
$04-4 LV1
$05-5 VCR1
$06-6 VCR2
$07-7 Experimental
$08-8 Sat1
$09-9 Camera
$0A-10 Sat2
$0B-11
$0C-12 CDV
$0D-13 Camcorder
$0E-14
$0F-15
$10-16 Pre-amp
$11-17 Tuner
$12-18 Recorder1
$13-19 Pre-amp
$14-20 CD Player
$15-21 Phono
$16-22 SatA
$17-23 Recorder2
$18-24
$19-25
$1A-26 CDR
$1B-27
$1C-28
$1D-29 Lighting
$1E-30 Lighting
$1F-31 Phone

Table 1.1: The addresses for various devices

RC-5 Command TV Command VCR Command

$00-0 0 0

$01-1 1 1

$02-2 2 2

$03-3 3 3

$04-4 4 4

$05-5 5 5
6
$06-6 6 6

$07-7 7 7

$08-8 8 8

$09-9 9 9

$0A-10 -/-- -/--

$0C-12 Standby Standby

$0D-13 Mute

$10-16 Volume+

$11-17 Volume-

$12-18 Brightness+

$13-19 Brightness-

$20-32 Program+ Program+

$21-33 Program- Program-

$32-50 Fastrewind

$34-52 Fastforward

$35-53 Play

$36-54 Stop

$37-55 Recording

Table 1.2: TV and VCR commands corresponding to the RC5 command

Chapter-2

OVERVIEW OF MICROCONTROLLER (AT89C51)

2.1 MICROPROCESSOR AND MICROCONTROLLER BASICS

The past two decades have seen the introduction of a technology that has radically
changed the way in which we analyze and control the world around us. Born of parallel
development in computer architecture and integrated circuit fabrication, the
7
microprocessor, or computer on a chip, first become a commercial reality in 1971 with
the introduction of 4-bit 4004 by a small, unknown company by the name of Intel
Corporation. Other better established, semiconductor firms soon follow Intels pioneering
technology so that by the late 1970s one could choose from a half dozen or so
microprocessor types.

The microprocessor[1] has been with us for some 15-years now growing from an
awkward 4-bit chip to a robust 32-bit adult. Soon 64 and 128-bit wizards will appear to
crunch numbers, spreadsheets, and CAD CAM. The engineering community became
aware of, enamored with, the 8-bit microprocessor of the middle to late 1970s.

The 1970s also saw the growth of the number of personal computer users from a
handful of hobbyists and hackers to millions of business, industrial, governmental,
defense, educational, and private users now enjoying the advantages of inexpensive
computing.

New technology makes possible, however, a better type of small computer-one


with not only the CPU on the chip, but RAM, ROM, Timer, UARTS, Ports, and other
common peripheral I/O functions also. The microprocessor has become the
microcontroller[4]. A by-product of microprocessor development was the microcontroller.
The same fabrication techniques and programming concepts that make possible the
general purpose microprocessor also yielded the microcontroller.

Microcontrollers are not as well known to the general public, or even the technical
community, as are the more glamorous microprocessor. The public is, however, very well
aware that something is responsible for all of the smart VCRs, clock radios washers,
and dryers, video games, telephones, microwaves, TVs, automobiles, toys, Vending
machines, copiers, elevators, irons, and a myriad of other articles that have suddenly
become intelligent and programmable. Companies are also aware that being
competitive in this age of microchip requires their products, or the machinery they use to
make those products, to have some smarts.

Some manufacturers, hoping to capitalize on our software investment, have


brought our families of microcontrollers that are software compatible with the older
microprocessor. Other, wishing to optimize the instruction set and architecture to improve

8
speed and reduce code size, produce totally new designs that had little in common with
their earlier microprocessors. Both of these trend continue.

Microprocessor:

A Microprocessor[4], as the term has come to be known is a general purpose


digital computer central processing unit (CPU). Although popularly known as a
computer on a chip, the microprocessor is in no sense a complete digital computer.

Figure 1 shows a block diagram of a microprocessor CPU, which contains


arithmetic and logic unit (ALU), a program counter (PC), a stack pointer (SP), some
working registers, a clock timing circuit and interrupt circuits. The microprocessor
contains no RAM, no ROM, and no I/O ports on the chip itself.

The key term in describing the design of microprocessor is general purpose. The
hardware design of a microprocessor CPU is arrange so that a small or very large system
can be configured around the CPU as the application demands. The internal CPU
architecture, as well as the resultant machine level code that operates that architecture, is
comprehensive but as flexible as possible.

Although the addition of external RAM, ROM, and I/O ports make these systems
bulkier and much more expensive, they have the advantage of versatility such that the
designer can decide on the amount of RAM, ROM, and I/O ports needed to fit the task at
hand

Arithmetic
and
logic unit

Accumulator

Working Register(s)

Program Counter Stack Pointer

Clock 9 Interrupt
Circuit Circuit
Figure 2.1: A Block Diagram of a Microprocessor
Microcontroller:
A microcontroller[5] has a CPU (a microprocessor) in addition to a fix amount of
RAM, ROM, I/O ports, and a timer all on a single chip. In other words, the processor,
RAM, ROM, I/O ports, and timer are all embedded together on one chip; therefore,
the designer cannot add any external memory, I/O, or timer to it.
Figure 2 shows the block diagram of a typical microcontroller which is a true
computer on a chip. The design incorporates all of the features found in a
microprocessor CPU: ALU, PC, SP, and registers. It also has added the others features
needed to make a complete computer: RAM, ROM, parallel I/O, serial I/O, counters,
and a clock circuit.

ALU Timer/Counter I/O


Ports

Accumulator
I/O
Registers Ports

Internal RAM Internal ROM


Interrupt
Circuits

Figure 2.2: A block diagram of a Microcontroller


Clock
Circuit
Like Stack Pointer
the microprocessor, a microcontroller is a general purpose device, but one
which is meant to fetch data, perform limited calculations on that data and control it
ProgramThe
environment based on those calculations. Counter
prime use of a microcontroller is to

10
control the operation of machine using a fixed program that is stored in ROM and that
does not change over the life time of the system.

2.2 CHARACTERISTICS FEATURES OF AT89C51


AT89C51 is an 8-bit microcontroller from Atmel Corporation.

Features

Compatible with MCS-51 Products

4K Bytes of In-System Reprogrammable Flash Memory

Endurance: 1,000 Write/Erase Cycles

Fully Static Operation: 0 Hz to 24 MHz

Three-level Program Memory Lock

128 x 8-bit Internal RAM

32 Programmable I/O Lines

Two 16-bit Timer/Counters

Six Interrupt Sources

Programmable Serial Channel

Low-power Idle and Power-down Modes

2.3 BLOCK DIAGRAM OF AT89C51

The AT89C51[6] is a low-power, high-performance CMOS 8-bit microcomputer


with 4K bytes of Flash programmable and erasable read only memory (PEROM). The
device is manufactured using Atmels high-density nonvolatile memory technology and is
compatible with the industry-standard MCS-51 instruction set and pinout. The on-chip
Flash allows the program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a
highly-flexible and cost-effective solution to many embedded control applications.

11
The AT89C51 provides the following standard features: 4K bytes of Flash, 128
bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt
architecture, full duplex serial port, on-chip oscillator and clock circuitry. In addition, the
AT89C51 is designed with static logic for operation down to zero frequency and supports
two software selectable power saving modes. The Idle Mode stops the CPU while
allowing the RAM, timer/counters, serial port and interrupt system to continue
functioning. The Power-down Mode saves the RAM contents but freezes the oscillator
disabling all other chip functions until the next hardware reset.

12
Figure 2.3: Block Diagram of AT89C51
2.4 PIN DESCRIPTION OF AT89C51:

PDIP: Plastic Dual Inline Package.

P1.0 VCC
P1.1 13 PO.O(AD 0)
P1.2 PO.1(AD 1)
P1.3 PO.2(AD 2)

P1.4 PO.3(AD 3)
PO.4(AD 4)
P1.5
P1.6 PO.5(AD 5)
P1.7 PO.6(AD 6)
RST PO.7(AD 7)
(RXD) P3.O EA/VPP
(TXD) P3.O ALE/PROG
PSEN
(INT0) P3.2 P2.7(AD 15)
(INT1) P3.3 P2.6(AD 14)
(T0) P3.4 P2.5(AD 13)
(T1) P3.5
(WR) P3.6 P2.4(AD 12)
(RD) P3.7 P2.3(AD 11)
XTAL2 P2.2(AD 10)
XTAL1 P2.1(AD 9)
GND P2.0(AD 8)
Figure 2.4: Pin diagram of AT89C51

Pin description:

In the AT89C51 there are a total of four ports for I/O operations.
Examining Figure 5, note that of the 40 pins, a total of 32 pins are set aside for the
four ports P0, P1, P2, and P3, where each port takes 8 pins. The rest of the pins are
designated as Vcc, GND, XTAL1, XTAL2, RST, EA, ALE/PEOG, and PSEN.

VCC:
Supply voltage.

GND:
Ground.

I/O port pins and there functions:


The four ports P0, P1, P2, and P3 each use 8 pins, making them 8 bit ports.
All the ports upon RESET are configured as inputs, ready to be used as input
ports. When the first 0 is written to a port, it becomes an output. To reconfigure it
as an input, a 1 must be sent to the port.
Port 0:
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each
pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be
used as high-impedance inputs. Port 0 may also be configured to be the
multiplexed low order address/data bus during accesses to external program and
data memory. In this mode P0 has internal pullups. Port 0 also receives the code

14
bytes during Flash programming, and outputs the code bytes during program
verification. External pullups are required during program verification.

Port 1:
Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they
are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1
pins that are externally being pulled low will source current (IIL) because of the
internal pullups. Port 1 also receives the low-order address bytes during Flash
programming and program verification.

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

Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins
they are pulled high by the internal pullups and can be used as inputs. As inputs,
Port 3 pins that are externally being pulled low will source current (IIL) because
of the pullups. Port 3 also serves the functions of various special features of the
AT89C51 as listed below:

15
Table 2.1
Port 3 also receives some control signals for Flash programming and verification.

RST:
Reset input. A high on this pin for two machine cycles while the oscillator
is running resets the device.

ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming.
In normal operation ALE is emitted at a constant rate of 1/6 the oscillator
frequency, and may be used for external timing or clocking purposes. Note,
however, that one ALE pulse is skipped during each access to external Data
Memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH.
With the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect
if the microcontroller is in external execution mode.

PSEN:
Program Store Enable is the read strobe to external program memory.
When the AT89C51 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.

EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable
the device to fetch code from external program memory locations starting at

16
0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be
internally latched on reset. EA should be strapped to VCC for internal program
executions. This pin also receives the 12-volt programming enable voltage (VPP)
during Flash programming, for parts that require 12-volt VPP.

XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.

XTAL2:
Output from the inverting oscillator amplifier.

Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in
Figure 6. Either a quartz crystal or ceramic resonator may be used. To drive the
device from an external clock source, XTAL2 should be left unconnected while
XTAL1 is driven as shown in Figure 7.
There are no requirements on the duty cycle of the external clock signal,
since the input to the internal clocking circuitry is through a divide-by-two flip
flop, but minimum and maximum voltage high and low time specifications must
be observed.

Figure 2.5: Oscillator Connections Figure 2.6: External Clock Drive Configurations

Idle Mode:
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals
remain active. The mode is invoked by software. The content of the on-chip RAM
and all the special functions registers remain unchanged during this mode.

17
The idle mode can be terminated by any enabled interrupt or by a
hardware reset. It should be noted that when idle is terminated by a hard ware
reset, the device normally resumes program execution, from where it left off, up to
two machine cycles before the internal reset algorithm takes control.
On-chip hardware inhibits access to internal RAM in this event, but access
to the port pins is not inhibited. To eliminate the possibility of an unexpected write
to a port pin when Idle is terminated by reset, the instruction following the one
that invokes Idle should not be one that writes to a port pin or to external memory.

Power-down Mode:
In the power-down mode, the oscillator is stopped, and the instruction that
invokes power-down is the last instruction executed. The on-chip RAM and
Special Function Registers retain their values until the power-down mode is
terminated. The only exit from power-down is a hardware reset. Reset redefines
the SFRs but does not change the on-chip RAM. The reset should not be activated
before VCC is restored to its normal operating level and must be held active long
enough to allow the oscillator to restart and stabilize.

Status of External Pins during Idle and Power-down Modes:

Table 2.2
Other Pin Configurations:

PQFP/TQFP:
PQFP: Plastic Gull Wing Quad Flatpack.
TQFP: Thin Plastic Gull Wing Quad Flatpack.

2.5 8051 ADDRESSING MODES:


An addressing mode refers to how you are addressing a given memory
location. The addressing modes are as follows.
With an example of each:

Immediate Addressing MOV A, #20h


Direct Addressing MOV A, 30h
Indirect Addressing MOV A,@R0
External Direct MOV A,@DPTR
Code Indirect MOV A,@+DPTR

18
Immediate Addressing:
Immediate addressing is so-named because the value to be stored in memory
immediately follows the operation code in memory. That is to say , the instruction
itself dictates what value will be stored in memory.
For example the instruction:
MOV A, #20h
This instruction uses immediate addressing because the Accumulator will
be loaded with the value that immediately follows, in this case 20 (hexadecimal).

Direct Addressing:
Direct addressing is so-named because the value to be stored in memory is
obtained by directly retrieving it from another memory location. For example:
MOV A, 30h
This instruction will read the date out of Internal RAM address30
(hexadecimal) and store it in the Accumulator. Direct addressing is generally fast
since, although the value to be loaded isnt included in the instruction, it is quickly
accessible since it is stored in the 8051s Internal RAM. It is also much more
flexible than Immediate Addressing since the value to be loaded is whatever is
found at the given address-which may be variable.
The obvious question that may arise is, If direct addressing an address
from 80h through FFh refers to SFRs, how can I access the upper 128 bytes of
Internal RAM that are available on the 8052? The answer is:
You cant access them using direct addressing. As stated, if you directly refer to an
address of 80h through FFh you will be referring to an SFR. However, you may
access the 8052s upper 128 bytes of RAM by using the next addressing mode,
indirect addressing.

Indirect Addressing:
Indirect addressing is a very powerful addressing mode which in many
cases provides an exceptional level of flexibility. Indirect addressing is also the
only way to access the extra 128 bytes of Internal RAM found on an 8052.
Indirect addressing appears as follows:
MOV A,@R0
This instructing causes the 8051 to analyze the value of the R0 register.
The 8051 will then load the accumulator with the value from Internal RAM which
is found at address indicated by R0. For example, lets say R0 holds the value 40h
and Internal RAM address 40h holds the value 67h. When the above instruction is
executed the 8051 will check the value of R0. Since R0 holds 40h the 8051 will
get the value out of Internal RAM address 40h (which holds 67h) and store it in
19
the Accumulator. Thus, the Accumulator ends up holding 67h. Indirect never
refers to Internal RAM; it never refers to an SFR. Thus, in a prior example we
mentioned that SFr 99h can be used to write a value to the serial port. Thus one
may think that the following would be a valid solution to write the value1 to the
serial port:
MOV R0,#99h ; Load the address of the serial port
MOV @R0,#01h; Send 01 to the serial portWRONG!!
This is not valid. Since indirect addressing always refers to Internal RAM
these two instructions would write the value 01h to Internal RAM address 99h on
an 8052. On an 8051 these two instructions would produce an undefined result
since the 8051 only has 128 btes of Internal RAM.

External Direct:
It is used to access external memory rather than internal memory. There
are only two commands that use External Direct addressing mode:
MOVXA,@DPTR
MOVX@DPTR,A
As you can see, both commands utilize DPTR. In these instructions, DPTR
must first be loaded with the address of external memory that you wish to read or
write. Once DPTR holds the correct external memory address, the first command
will move the contents of the external memory address into the Accumulator. The
second command will do the opposite: it will allow you to write the value of the
Accumulator to the external memory address pointed to by DPTR.

External Indirect:
This form of addressing is usually only used in relatively small projects
that have a very small amount of external RAM. An example of this addressing
mode is:
MOVX@R0,A
Once again, the value of R0 is first read and the value of the Accumulator
is written to that address in External RAM. Since the value of @R0 can only be
00h through FFh the project would effectively be limited to 256 bytes of External
RAM.

20
Chapter-3

TECHNICAL ASPECTS

3.1 FUNCTIONAL DESCRIPTION OF THE RECEIVER MODEL

The infra-red receiver is an essential element of a remote control unit based on


infra-red. The infrared receiver contains 8 relays that can be controlled by wireless. This
makes the unit very easy to operate and integrate with existing systems. Keys 1 to 8 on
the remote control operate the corresponding relay on the receiver board, i.e. Button 1
operates relay 1, button 2 operates relayModule
RC5 Decoder 2, and etc.The block diagram of the Infrared
receiver developed in this is as shown in the fig 3.1. The various modules of the receiver
IR rays
are as follows: Output control module
IR Sensor Toggle Address Command Output
Schmitt Relay
Module check checking checking Module
Trigger Driver
module module 21 module

Control module
Figure 3.1: Block Diagram of IR receiver

3.1.1 IR Sensor Module:


This block represents the Infra-red sensor which receives the modulated infra-
red rays coming from the remote control transmitter and demodulates and converts
it into an electrical signal for further processing of the information being
transmitted. The IR sensor used for this project is TSOP1738 from VISHAY
Semiconductors.

3.1.2 RC5 Decoder Module:


This block comprises of the microcontroller used for decoding the received
infra-red signal. The microcontroller used for the purpose of the application is
AT89C51. The decoder module may be further divided into sub-blocks- Toggle
check module, Address checking module, Command checking module and the
Control module.
The Toggle checking module checks whether a key has been pressed on the
remote or not. The Address checking module and Command checking module
check for the valid addresses and command statements i.e. they collect the
decoded data into a 5-bit address and a 6-bit command format. The control module
ensures correct functionality among all the components.
3.1.3 Output control module:
The output control module is responsible for proper presentation of the output.
It comprises of the Schmitt trigger and Relay driver. For Schmitt trigger IC
74HC14 when the input is higher than a certain chosen threshold, the output is
high; when the input is below another (lower) chosen threshold, the output is low;
when the input is between the two, the output retains its value. The trigger is so
named because the output retains its value until the input changes sufficiently to
trigger a change. This dual threshold action is called hysteresis, and implies that
the Schmitt trigger has some memory.

22
The benefit of a Schmitt trigger over a circuit with only a single input
threshold is greater stability (noise immunity). With only one input threshold, a
noisy input signal near that threshold could cause the output to switch rapidly back
and forth from noise alone. A noisy Schmitt Trigger input signal near one
threshold can cause only one switch in output value, after which it would have to
move beyond the other threshold in order to cause another switch. A ULN2803 is
an Integrated Circuit (IC) chip with a High Voltage/High Current Darlington
Transistor Array which is ideally suited for interfacing between low-level logic
circuitry and multiple peripheral power loads. This relay driver IC is used to
switch different relays.

3.1.4 Output module:


This module represents the output of the receiver. In case of an actual
television it would represent the change of channel. However, in this project the
output has been shown with the help of LEDs. The lighting up of an LED
corresponds to the selection of that particular channel. Further, the output of relays
may be used to light a bulb or drive a motor and do similar other tasks.
In other words, Relay contact can control any equipment in momentary
mode (On till key pressed) or Latch Mode (Toggle on each key press). Each relay
has indicator LED showing current status. This represents the output of the
receiver.

23
24
3.2 OPERATION/WORKING:
The RC5 code set was developed by Phillips and allows 2048 commands to be
transmitted divided into 32 addressable groups of 64 commands each. The
transmitted code consists of a 14 bit data word of the following structure.

2 run-in bits to adjust the AGC level in the receiver IC

1 check bit

5 system address bits

6 command bits.

The basic timing is derived from a 36KHZ oscillator. The code is transmitted in
bi-phase format. In this system, logic 1 is transmitted as a half bit time without signal,
followed by a half bit time with signal. Logic 0 has exactly the opposite structure. Each
half bit consists of 32 shorter pulses. Each transmitted bit has a length of 1.778 m sec; the
shorter pulses have a pulse width of 6.9444 u sec on time and 20.8332 u sec off time. A
complete data word has a length of 24.889 m sec, and is always transmitted completely. If
the key is held pressed the code is repeated in intervals of 64 bit times (i.e. 113.778 m
sec). The RC5 code thus, makes use of a fixed bit length and fixed quantity of bits. Each
bit is sliced in two halves. The left and right half has opposed levels. If the bit to be
transmitted is one (1), its left side is zero while its right side is one. If the bit to be
transmitted is zero (0), its left side is one while the right side is zero. This can be seen in
the Figure 3

|---+ |
| | |
| | |
| +---|
<----->
1.7778ms
Logic 0
| +---|
| | |
| | |
|---+ |
<----->
1.7778ms
Logic 1

Figure 3.3(a): Logic representation

25

OFF OFF ON ON OFF ON


Bit time
Figure 3.3(b): (This is the right logic, reversed from what you can see at the IR
receiver output.)
It means that the second half of the bit is actually the same meaning of the bit to
be transmitted, as you can see at the shaded blue right side of the bit as on, means bit
transmitted = 1.To measure the correct logic level directly from the Receiver Output, one
should measure at the first half of the bit. The correct interpretation is that it changes level
exactly at the middle of bit time. At the IR Receiver output a bit Zero changes level from
Low to up, while a bit one changes level from Up to Low.
There are a minimum quantity of incoming 27s pulses to the demodulator
understand it is at the right frequency and then drop its output. The quantity of pulses
used at the Philips remotes are 32 pulses per each half of the bit, 64 pulses per bit. So, a
bit "0" to be transmitted it means 32 square pulses of 27s each, then 32 x 27s of
silence. The bit "1" is the opposite, 32 x 27s of silence followed by 32 square pulses
of 27s. To decode the received waveform at the demodulator output observe the
direction of the changing at the middle of the bit, if going down, means bit 0, going up,
means bit 1. It is relatively easier to sample the middle of the first half of the bit, so it
directly gives the bit state.

105ms

ON ON Figure
FLIP 3.4:
OFFTheOFF
14 bitsOFF
of theOFF
RC-5 OFF
systemOFF
above.
OFF OFF OFF OFF OFF
The first two bits, #1 and #2, are called ACG calibration. They are "ON" level, and
Address Command
serve toCHK
calibrate the IR Receivers Auto Gain Control.
In the Philips remotes, the bit #3 is the CHECK bit, every time a key is pressed at
the remote, even pressing repeatedly the same key, this bit flips state. This is an
interesting feature. Suppose number "1" is pressed at the remote (trying to select channel
15 at TV) and holding it for 2 seconds, and then the Infrared signal is blocked with the
hand. The TV would receive two trains of pulses, generated by hand breaking a long train
in two. Other systems would understand transmission of two keys "1" selecting channel

26
"11", but this do not happens in the Philips system. This bit flips state every time a key is
pressed, so blocking the signal with hand doesn't change this bit, so the TV will
understand that still the same key pressed. To select channel "11" key "1" needs to be
pressed really twice.
The next 5 bits, #4 to #8, are used for SYSTEM ADDRESS, or to identify which
kind of device should execute the COMMAND bits. For example, TV set uses
ADDRESS ZERO. Bit #8 is the Less Significant Bit.
The next 6 bits, #9 to #14, are used for COMMAND information to the device
selected at the ADDRESS bits. Bit #14 is the LESS SIGNIFICANT BIT, and it is last
transmitted.
The project uses Atmel micro-controller AT89C51 to receive the infrared signal
from the Philips remote. It is interesting to note that the Infrared Receiver inverts the bit
signal, low level means bit ON. During inactivity (no Infrared present) the output of the
Infrared receiver is UP (bit zero).
The output of the infrared sensor module may be connected to any port pin of the
microcontroller or interrupt pin of the microcontroller, and keep polling it or prepare the
interrupt routine to trigger your reading after the first low level sensed.
When a key is pressed at the remote, it transmits the train of pulses, and
microcontroller receives 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 the
microcontroller will "see" the incoming IR signal.
Upon sensing the first low level, indicating the presence of a bit the
microcontroller needs to be programmed so as to wait for 3.024 ms so as to detect the flip
bit. To read the address and command bits which happen to be the next 11 bits of the
received signal shift them left into a register and store the old and new commands. In this
application the microcontroller has been programmed in assembly language. However,
the microcontroller may even be programmed using embedded C and Basscom which
reduces the size of the code so that it can be well accommodated in the limited on-chip
memory of the microcontroller.
The address is decoded to determine the equipment type. The address for Philips
remote should correspond to 00. However, that is a code 10 at the universal
programmable remote, because of the detection circuit waiting for a falling edge. There
are addresses associated with other devices as shown in the table.

Address Equipment
0 Television

27
2 Tele text
5 Vedeo recorder
7 Experimantal
16 Preamplifier
17 Receiver/tuner
18 Tape/cassette recorder
19 experimental

Table 3.1: Addresses used by various devices


The infrared receiver unit contains 8 relays that can be controlled by wireless. This
makes the unit very easy to operate and integrate with existing systems. Keys 1 to 8 on
the remote control operate the corresponding relay on the receiver printed circuit board,
i.e. button 1 operates relay 1, button 2 operates relay 2, etc. Relay contact can control any
equipment in momentary mode (On till key pressed) or Latch Mode (Toggle on each key
press). Each relay has indicator LED showing current status.
The entire working of the infrared remote control receiver printed circuit board
designed and developed for decoding RC5 pulse protocol used in Philips television may
be summarized as stated below:
At the receiver end the IR receiver module (TSOP1738 of VISHAY
Semiconductors make is used for this purpose in this application) extracts the data
signal from the modulated carrier. The RC5 protocol of Philips IR remote control for
television makes use of Manchester coding for transmission of the data. The Manchester
coding is also referred to as bi-phase coding. The receiver chip (Atmel microcontroller
AT89C51 in this case) decodes this signal and sets the corresponding output high. This
active HIGH output is used to operate a relay via ULN2803 which is an octal transistor
array.
3.3 ALGORITHM FOR THE RECEIVER PROGRAM:

STEP 1: START
STEP 2: Declare and Initialize temporary variables/memory spaces
STEP 3: Define Input port and read IR input at port P3.3
STEP 4: Define P1 as output port
STEP 5: Reset all relays i.e. turn all output switches off initially
STEP 6: CHECK if Infrared signal is received i.e. check if key is pressed on the
remote
STEP 7: Generate time delay to sample the toggle bit
STEP 8: Read the toggle/Flip bit and store it in variable FLIP
STEP 9: Set count=5 to sample 5 address bit next
STEP 10: Generate time delay
STEP 11: Read IR signal in C
STEP 12: Rotate left through C and store the result in accumulator
STEP 13: Decrement count

28
STEP 14: IF count! =200 repeat steps 10 to 14 else go to step 15
STEP 15: Store the address in ADDR
STEP 16: Clear Accumulator
STEP 17: Set count=6 to sample 6 command bits next
STEP 18: Generate time delay
STEP 19: Read Infrared signal in C
STEP 20: Rotate Accumulator left through carry
STEP 21: Decrement count
STEP 22: IF count!=0 repeat steps 18 to 22 else go to step 23
STEP 23: Save the old command in TEMP
STEP 24: Save the new command in CMD
STEP 25: Check for valid address i.e. if address! =0 go to start
STEP 26: Check for valid command i.e. if TEMP=CMD go to start
STEP 27: Check if key is pressed i.e.
X if no then go to start
STEP 28: Compare command, IF it is 01 then set or reset switch 1 accordingly
STEP 29: IF command is 02, then set or reset switch 2 accordingly
STEP 30: IF CMD is 03, then set or reset switch 3 accordingly
STEP 31: IF CMD is 04, thenMove 5 toreset
set or count
switch 4 accordingly
STEP 32: IF CMD is 05, then set or reset switch 5 accordingly
STEP 33: IF CMD is 06, then setSTART
or reset switch 6 accordingly
STEP 34: IF CMD is 07, then set or reset switch 7 accordingly
STEP 35: IF CMD is 08, then set or reset switch 8 accordingly
Generate delay
STEP 36: Check command for all switches, IF true reset all switches
STEP 37: STOP Define variables

3.4 FLOWCHART FOR THE RECEIVER PROGRAM


RLC A
IS
P3.3
=0
Count= count - 1

Generate delay

Is to C
Move P3.3
coun
t= 0

Copy C to Flip

Copy A to ADDR
Clear C

Clear A
Clear ACC.
29

Y
X
Y

Move 6 to count

Generate delay

Read P3.3 to C

RLC A

Count= count - 1

Is
cou
nt =
0

YES

Store old command in


TEMP

Store new command in


CMD 30

Z
Z

Move ADDR to A

Set TEMP=A

Is A
Clear NO START
A=
0

YES
Set C=TOG
Set A = TEMP

RLC A

Is Invalid
START
A= comman
CM d
IsDDA!
NO START
=TEM
P
Clear A
YES

TOG=FLIP

Set C=FLIP

Is Set SW1 START


RLC A high/low
A=
CM
31
DD

P
Q
Q

Is Set SW2
START
A= high/low
CM
DD

Is Set SW3
START
A= high/low
CM
DD

Is Set SW4
START
A= high/low
CM
DD

Is Set SW5
START
A= high/low
CM
DD

Is Set SW6
START
A= high/low
CM
DD 32

R
R

Is Set SW7
START
A= high/low
CM
DD

Is Set SW8
START
A= high/low
Figure 3.5:
CM Flowchart
DD

STOP

Chapter-4

33
DESIGN AND DEVELOPMENT

4.1 INTRODUCTION:

The designing of the project forms the major portion of the project. In the
designing of the project we had to pass through many macro phases. The designing part
broadly consists of writing the program, burning the program in the microcontroller and
the fabrication of the chip. The program is given in the appendix.

4.2 FABRICATION OF THE CARD:


The hardware projects often require the use of strip boards or other pre-fabricated
boards for the implementation of the circuit. However, solder less breadboards are the
fastest and most flexible way to design and experiment. The printed circuit boards provide
for efficient and effective solution to the complexities encountered while using other
boards for circuit realization.
The following steps were used for developing the printed circuit board for this
application:

1) Designing the artwork: The first thing to do is to make the schematic of the circuit
to be realized. This is also known as the artwork. The schematic may be drawn
using PCB CAD layout programs. The Orcad 9.1 suite may be used for drawing
the schematic but it is expensive. The freely available and easy to use software
ExpressPCB was used for designing the schematic.

The ExpressPCB online help is written with beginners in mind, the internet
ordering option is convenient, and its regular updated features was the motivation
behind using this software though it has limited component library. The layout of
the circuit as drawn using ExpressPCB is as shown in Figure 1.

34
Figure 4.1: PCB layout
2) Print out the layout on transparency film. The printer must be of Laser type that
uses toner as the printing method.
3) Cut a blank copper plate to the same dimensions as the artwork. The plate is
polished properly so that the toner is transferred effectively onto it.
4) Now, the paper with the artwork is placed face down onto the copper plate and put
tape over it and place again A4 size paper over the transparency film.
5) Put the pcb into lamination machine around 240 c temp for transfer of toner image
from transparency film into pcb.
6) The copper plate with design stuck onto it is now immersed in soap solution for
almost 20 minutes to loosen the paper.
7) Carefully remove the paper. Be sure not to remove any of the black ink traces
because these are what stop the acid in the etching process. A kind of rubbing
motion was used to remove the paper. Keep the paper wet all the time so that it
separates easily from the copper board.

35
8) Etch the board using a solution of Ammonium Per sulphate. Proper instructions
for the dilution level should be followed. A normal ceramic or glass bowl can be
used as a tank for carrying out the etching.
9) Slowly swirl or rock the bowl around. The liquid must be always moving over the
copper board to get it to etch properly.
10) Remove the board from the etchant and wash any residue from the board.
11) Scrub the black ink off the PCB.
12) Drill out the holes.
13) Mount the components at their respective positions and solder them properly.

Following the above mentioned steps the Printed circuit board for this application was
developed.

Chapter-5

COMPONENT DETAILS

5.1 INTRODUCTION:

In the designing of the project the detail knowledge of the components is very important
for the successful working of the project. In the chapter we desire to give the details of the
macro level components used in the project. The macro level components used are IR Sensor
Module (TSOP 1738), Crystal Oscillator, Voltage Regulator, Relays, Schmitt Inverter and LEDs.
36
5.2 COMPONENTS USED:

5.2.1 IR Sensor Module:

The most common device used for detecting light energy is a photodiode. A
photodiode is similar in many ways to a standard diode, with the exception of its
packaging. A photodiode is packaged in such a way as to allow light to strike the PN
junction.

Figure 5.1 Photodiode

In infrared applications, it is it is common practice to apply a reverse bias to the device.


There will be a reverse current that will vary with the light level. Like all diodes, there is
an intrinsic capacitance that varies with the reverse bias voltage. This capacitance is an
important factor in speed.

The TSOP 17 series are miniaturized receivers for infrared remote control systems. PIN
diode and preamplifiers are assembled on lead frame. The epoxy package is designed as
IR filter.

The demodulated output signal can directly be decoded by microprocessor. TSOP 17 is


the standard IR remote control receiver series, supporting all major transmission codes.

Features

Photo detector and preamplifier in one package.

Internal filter for PCM frequency.

Improved shielding against electric field disturbance.


37
TTL and CMOS compatibility.

Output active low.

Low power consumption.

High immunity against ambient light.

5.2.2 Crystal Oscillator:

Crystal oscillators are oscillators where the primary frequency determining


element is a quartz crystal. Because of the inherent characteristics of the quartz crystal the
crystal oscillator may be held to extreme accuracy of frequency stability. Temperature
compensation may be applied to crystal oscillators to improve thermal stability of the
crystal oscillator.

Crystal oscillators are usually, fixed frequency oscillators where stability and
accuracy are the primary considerations. For example it is almost impossible to design a
stable and accurate LC oscillator for the upper HF and higher frequencies without
resorting to some sort of crystal control. Hence, the reason for using crystal oscillators.

A crystal oscillator is basically a tuned oscillator. It uses a piezoelectric crystal as


a resonant tank circuit. The crystal (usually quartz) provides a high degree of frequency
stability. Therefore, the crystal oscillators are used whenever great stability is required.
Examples are communication transmitters, digital clocks, etc.

Operation

A crystal is a solid in which the constituent atoms, molecules, or ions are packed
in a regularly ordered, repeating pattern extending in all three spatial dimensions.

Almost any object made of an elastic material could be used like a crystal, with
appropriate transducers, since all objects have natural resonant frequencies of vibration.
The resonant frequency depends on size, shape, elasticity, and the speed of sound in the
material.

High-frequency crystals are typically cut in the shape of a simple, rectangular


plate. Low-frequency crystals, such as those used in digital watches, are typically cut in
the shape of a tuning fork.
38
When a crystal of quartz is properly cut and mounted, it can be made to distort in
an electric field by applying a voltage to an electrode near or on the crystal. This property
is known as piezoelectricity. When the field is removed, the quartz will generate an
electric field as it returns to its previous shape, and this can generate a voltage. The result
is that a quartz crystal behaves like a circuit composed of an inductor, capacitor and
resistor, with a precise resonant frequency.

Quartz has the further advantage that its elastic constants and its size change in
such a way that the frequency dependence on temperature can be very low. The specific
characteristics will depend on the mode of vibration and the angle at which the quartz is
cut (relative to its crystallographic axes).[5] Therefore, the resonant frequency of the plate,
which depends on its size, will not change much, either. This means that a quartz clock,
filter or oscillator will remain accurate. For critical applications the quartz oscillator is
mounted in a temperature-controlled container, called a crystal oven, and can also be
mounted on shock absorbers to prevent perturbation by external mechanical vibrations.

Quartz timing crystals are manufactured for frequencies from a few tens of
kilohertz to tens of megahertz. More than two billion (210 9) crystals are manufactured
annually. Most are small devices 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.

5.2.3 Voltage Regulator:

A voltage regulator[7] is a circuit that supplies a constant voltage regardless of


changes in load currents. It should be capable of providing substantial output current.

Voltage regulators are very robust. These can withstand over-current draw due to
short circuits and also over-heating. In both cases, the regulator will cut off before any
damage occurs. The only way to destroy a regulator is to apply reverse voltage to its
input. Reverse polarity destroys the regulator almost instantly.

Voltage regulators are classified as:

1. Series regulator (Linear regulator)


2. Shunt regulator (switching regulator)
39
Series regulator

Series regulator use a power transistor connected in series between the


unregulated DC input and load. Output voltage is controlled by continuous voltage
drop taking place across series pass transistor.

These are known as linear regulators as transistor works in active or linear


region.

Figure 5.2 Series regulator

Shunt regulator

Switching regulator operates the power transistors as a high frequency on/off


switch, so that power transistor does not conduct current continuously. Here desired
current is delivered in periodic pulses.

Figure 5.3 Shunt regulator

IC Voltage Regulator

IC voltage regulators are versatile and relatively inexpensive and are available
with features such as programmable output, current/voltage boosting, internal short circuit
current limiting, thermal shutdown and floating operation for high voltage applications.

40
With the advent of microelectronics, it is possible to incorporate complete voltage
regulator circuits on a single monolithic silicon chip. This gives low cost, high reliability,
reduction in size and excellent performance. Examples of monolithic regulators are
78XX/79XX series and 723 general purpose regulators.

IC voltage regulators are of following types:

Fixed output voltage regulator


Adjustable output voltage regulator

Switching regulator

Special regulator

Three Terminal IC Voltage Regulators

Figure 5.4IC Voltage regulator

Fixed voltage series (78XX/79XX) regulator

41
78XX series are three terminal, positive fixed voltage regulators. There are seven
output voltage options available such as 5, 6, 8,12,15,18 and 24V. In 78XX, the last two
numbers (XX) indicate the output voltage.

These regulators are available in two types of packages.

Metal package (TO- 3type)

Plastic package (TO- 220 types)

Characteristics:

1. VO: The regulated output voltage is fixed at value specified by manufacturer.


2. Vin >= Vo +2

3. Io (max): The load current may vary from zero to rated maximum output current.
IC is always provided with heat sink; otherwise it may not provide rated
maximum output current.

4. Thermal Shutdown: IC has temperature sensor (built in) which turns off the IC
when it becomes too hot.

The IC regulators not only keep the output voltage constant but also reduce the
amount of ripple voltage.

5.2.4 Relays:

A relay is an electrical switch that opens and closes under the control of another
electrical circuit. In the original form, the switch is operated by an electromagnet to open
or close one or many sets of contacts. It was invented by Joseph Henry in 1835. Because a
relay is able to control an output circuit of higher power than the input circuit, it can be
considered to be, in a broad sense, a form of an electrical amplifier.
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

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

Circuit Symbol for Relay

Figure 5.5 Circuit symbol for relay

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.

A simple electromagnetic relay, such as the one taken from a car in the figure, is
an adaptation of an electromagnet. It consists of a coil of wire surrounding a soft iron
core, an iron yoke, which provides a low reluctance path for magnetic flux, a moveable
iron armature, and a set, or sets, of contacts; two in the relay pictured. The armature is
hinged to the yoke and mechanically linked to a moving contact or contacts. It is held in
place by a spring so that when the relay is de-energized there is an air gap in the magnetic
circuit. In this condition, one of the two sets of contacts in the relay pictured is closed,
and the other set is open. Other relays may have more or fewer sets of contacts depending
on their function. The relay in the picture also has a wire connecting the armature to the
yoke. This ensures continuity of the circuit between the moving contacts on the armature,
and the circuit track on the Printed Circuit Board (PCB) via the yoke, which is soldered to
the PCB.
When an electric current is passed through the coil, the resulting magnetic field
attracts the armature and the consequent movement of the movable contact or contacts
either makes or breaks a connection with a fixed contact. If the set of contacts was closed
when the relay was de-energized, then the movement opens the contacts and breaks the
connection, and vice versa if the contacts were open. When the current to the coil is
switched off, the armature is returned by a force, approximately half as strong as the
magnetic force, to its relaxed position. Usually this force is provided by a spring, but
43
gravity is also used commonly in industrial motor starters. Most relays are manufactured
to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage
or high current application, this is to reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil, to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a voltage spike dangerous to circuit components. Some automotive
relays already include that diode inside the relay case. Alternatively a contact protection
network, consisting of a capacitor and resistor in series, may absorb the surge. If the coil
is designed to be energized with AC, a small copper ring can be crimped to the end of the
solenoid. This "shading ring" creates a small out-of-phase current, which increases the
minimum pull on the armature during the AC cycle. By analogy with the functions of the
original electromagnetic device, a solid-state relay is made with a thyristor or other solid-
state switching device. To achieve electrical isolation an optocoupler can be used which is
a light-emitting diode (LED) coupled with a photo transistor.

5.2.5 Schmitt Inverter:

A Schmitt trigger is a comparator circuit that incorporates positive feedback.

When the input is higher than a certain chosen threshold, the output is high; when
the input is below another (lower) chosen threshold, the output is low; when the input is
between the two, the output retains its value. The trigger is so named because the output
retains its value until the input changes sufficiently to trigger a change. This dual
threshold action is called hysteresis, and implies that the Schmitt trigger has some
memory.

The benefit of a Schmitt trigger over a circuit with only a single input threshold is
greater stability (noise immunity). With only one input threshold, a noisy input signal near
that threshold could cause the output to switch rapidly back and forth from noise alone. A
noisy Schmitt Trigger input signal near one threshold can cause only one switch in output
value, after which it would have to move beyond the other threshold in order to cause
another switch.

The Schmitt trigger was invented by US scientist Otto H. Schmitt in 1934 while
he was still a graduate student, later described in his doctoral dissertation (1937) as a

44
"thermionic trigger". It was a direct result of Schmitt's study of nerve propagation in squid
nerves.

The symbol for Schmitt triggers in circuit diagrams is a triangle with a hysteresis
symbol. The symbol depicts a typical hysteresis curve.

Standard Schmitt trigger Inverting Schmitt trigger

Figure 5.6 Standard and Inverting Schmitt Trigger

When the Schmitt trigger is inverting (i.e., when very negative inputs lead to
positive outputs and vice versa), the hysteresis symbol is topbottom mirrored.

Schmitt triggers are typically built around comparators, connected to have positive
feedback instead of the usual negative feedback. For this circuit the switching occurs near
ground, with the amount of hysteresis controlled by the resistances of R1 and R2:

Figure 5.7 Circuit diagram of Schmitt Trigger

The comparator gives out the highest voltage it can, +VS, when the non-inverting
(+) input is at a higher voltage than the inverting (-) input, and then switches to the lowest
45
output voltage it can, VS, when the positive input drops below the negative input. For
very negative inputs, the output will be low, and for very positive inputs, the output will
be high, and so this is an implementation of a "non-inverting" Schmitt trigger.

For instance, if the Schmitt trigger is currently in the high state, the output will be
at the positive power supply rail (+V S). V+ is then a voltage divider between V in and +VS.
The comparator will switch when V +=0 (ground). Current conservation shows that this
requires

Vin/R1 = VS/R2,

And so Vin must drop below (R1/R2)VS to get the output to switch. Once the
comparator output has switched to VS, the threshold becomes +(R1/R2)VS to switch back
to high.

Figure 5.8 Output of Schmitt trigger

So this circuit creates a switching band centred around zero, with trigger levels
(R1/R2)VS. The input voltage must rise above the top of the band, and then below the
bottom of the band, for the output to switch on and then back off. If R1 is zero or R2 is
infinity (i.e., an open circuit), the band collapses to zero width, and it behaves as a
standard comparator. The output characteristic is shown in the picture on the right. The
value of the threshold T is given by (R1/R2)VS and the maximum value of the output M is
the power supply rail.

HEX SCHMITT INVERTER (M74HC14)

Each circuit functions as an inverter, but because of the Schmitt action, it has
different input threshold levels for positive-going (VT+) and negative-going (VT)
signals.

46
These circuits are temperature compensated and can be triggered from the slowest
of input ramps and still give clean, jitter-free output signals.

The M74HC14 is an high speed CMOS HEX Schmitt inverter fabricated with
silicon gate C2mos technology. All inputs have 20% Vcc hysteresis level. This, together
with its Schmitt trigger function, allows it to be used on line receivers with slow rise/fall
input signals.

All inputs are equipped with protection circuits against static discharge and
transient excess voltage.

Figure 5.9 Input and Output Equivalent Circuit

Features

High speed ( tpd=12ns at Vcc = 6V)

Low power dissipation.

High noise immunity.

Symmetrical output impedance.

Balanced propagation delays.

Wide operating voltage range (Vcc= 2V to 6V).

47
5.2.6 Light Emitting Diodes (LEDs):

Light emitting diodes are small but powerful devices in terms of their diverse
applications. LED lights assume greater significance in the context of need for electrical
energy conservation and pollution control world over. These are used as indicators in
various equipments for lighting and decorations at homes, and in flashlights, signboards
and car lights.
LED lights differ from traditional light sources in the way these produce light. In
incandescent bulbs, a tungsten filament is heated by electric current until it glows or emits
light.
In fluorescent lamps, an electric arc excites mercury atoms, which emit UV
radiation. After striking the phosphor coating on the inner side of glass tubes, the UV
radiation is converted into visible light and emitted.
On the other hand, LEDs are diodes made from semiconductor materials. This is
why these are referred to as solid state devices. They rely on indium-gallium nitride to
convert electricity into photons when current flows through it.
An LED is basically a small area source, often with extra optics added to the chip
that shapes its radiation pattern. The specific wavelength or color emitted by the LED
depends on the materials used to make the diode. It depends on the composition and
condition of the semiconducting material used, and can be infrared, visible or near-
ultraviolet.

How does an LED WORK?


Light generates inside the semiconductor chip when current flows across the
junction of different material compositions. An LED consists of two elements of
processed semiconductor material called p-type and n-type semiconductors. These two
elements form a p-n junction when placed in contact with each other. The material
composition of the p- and n-type semiconductors determines the color of light generated.
LED structure
To achieve a high radiance and high quantum efficiency, the LED structure must
provide a means of confining the charge carriers and the stimulated optical emission to
the active region of the p-n junction where radiative recombination takes place. Carrier
confinement is used to achieve a high level of radiative recombination in the active region
of the device, which yields high quantum efficiency. Optical confinement is of importance
for preventing absorption of the emitted radiation by the material surrounding the p-n
junction.

48
To achieve carrier and optical confinement, LED configurations such as
homojunctions and single and double hetrojunctions have been widely investigated. The
most widely used structure is double hetrostructure device because of the two different
alloy layers on each side of the active region.
By means of this sandwich structure of differently composed alloy layers, both the
carriers and the optical field are confined in the central active layer. The band gap
differences of adjacent layers confine the charge carriers, while the difference in the
indices of refraction of adjoining layers confine the optical field to the central active layer.
This dual confinement leads to both high efficiency and high radiance.

Materials used for production


LEDs are usually built on an n-type substrate, with an electrode attached to the p-
type layer deposited on its surface.
Most materials used for LED production have very high refractive indices. This
means most of the light reflects back into the material at the material/air interface.
Therefore light extraction is an important aspect of LED design and production.

Why use LED for lighting


1. Lifetime: As a solid state light source, LEDs have a very long lifetime and are
generally very robust due to no mechanical or moving parts. Good quality LEDs
can last up to 50,000hrs- more than five years of continuous use.
2. Low maintenance: The long lifetime of LEDs reduces the need to replace failed
lamps, and this can lead to significant financial and environmental savings.
3. Efficiency: As a semiconductor device, LEDs are highly efficient. Current device
technology is allowing their performance to be pushed to limits that exceed that of
standard lighting. The directional nature of light produced by LEDs allows the
design of luminaries with higher overall efficiency.
4. Low power consumption: this leads to large energy savings.
5. Brightness: Light outputs of LEDs are constantly being increased, and there are
several products that have higher lumen output than traditional lighting.
6. Heat: Almost 80% of the energy consumed by LEDs is converted into light and
only some of its dissipated as heat.
7. Small form factor: LEDs are very small. Typically, high brightness LED chips
measure 0.3*0.3mm2.
8. Instantaneous switch on: LEDs switch on rapidly, even when cold, and this is a
particular advantage for certain applications such as vehicle brake lights.

49
9. Color: LEDs are available in a broad range of brilliant, saturated colors. White
devices are also available.
Also LED lights are shock resistance, and a solid package of the LEDs can be
designed to focus their light.

Chapter-6

RESULT

6.1 CONCLUSION:

The project is done as the final assignment of the under graduate program. This
project has given as an opportunity to sharpen our edges in the technical field. The
working of this project had passed through various ups and downs. Many a times it
became very difficult to progress but the constant support of the mentor made it possible
to complete the project to the requirement.

50
This project makes the communication possible with the use of infrared rays. We
have developed Philips TV receiver. The transmitter part is contained inside the remote
which is used and the receiver part is placed in the switch board.

While designing the project we have faced many problems especially while
programming the microcontroller. But the biggest hurdle was of tuning the IR transmitter
and the receiver, and the coding part. The range up to which receiver can receive the IR
rays is experimentally found to be 33 feet.

Another problem is that of the relays. In order to operate high power points we
need heavy relays which can alternately damage the microcontroller. So we have used
small relays in order to operate the simple switches.

At the epitome we would like to state that although the project is not flawless, but
undoubtedly we achieved to make the concept of the project clear. From the project one
can come to know how the RC pulse protocol based remote works. As per our knowledge
and hard work we succeeded in achieving the aim of the project.

APPENDIX-A

PROGRAM CODE FOR RECEIVER:


VAR1 equ r7
TEMP equ 10H
COUNT equ 11H
ADDR equ 12H
CMD equ 13H
FLIP bit 00H
TOG bit 01H
IR equ p3.2
SW1 equ p2.7
SW2 equ p2.6
SW3 equ p2.5
SW4 equ p2.4
SW5 equ p2.z
SW6 equ p2.2
SW7 equ p2.1
SW8 equ p2.0
51
Swport equ p2

org 00H
mov swport,#0FFH
mov sp,#50H
clr TOG

main:
jb IR,$
mov c,IR
mov p0.o,c
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,#$
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,$
mov VAR1,#100
djnz VAR1,$
mov c,IR
mov p0.7,c
mov FLIP,c
clr A
mov COUNT,#5
fadd:
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,$
mov VAR1,#140
djnz VAR1,$
mov c,IR
rlc a
djnz COUNT,fadd
mov ADDR,A
clr a
mov COUNT,#6
fcmd:
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,$
mov VAR1,#255
djnz VAR1,$
52
mov VAR1,#140
djnz VAR1,$
mov c,IR
rlc a
djnz COUNT,fcmd
mov TEMP,CMD
mov CMD,a
mov a,ADDR
cjne a,CMD,valid
nvalid:
ljmp main
valid:
clr a
mov c,FLIP
rlc a
mov TEMP,a
clr a
mov c,TOG
rlc a
cjne a,TEMP,valid1
sjmp nvalid
valid1:
mov c,FLIP
mov TOG,c
mov a,CMD
clr c
cjne a,#1,skip1
jb sw1,isset1
setb sw1
ljmp main
isset:
clr sw1
ljmp main
skip1:
cjne a,#2,skip2
jb sw2,isset2
setb sw2
ljmp main
isset2:
clr sw2
ljmp main
skip2:
cjne a,#3,skip3
jb sw3,isset3
setb sw3
ljmp main
isset3:
clr sw3
ljmp main
skip3:
53
cjne a,#4,skip4
jb sw4,isset4
setb sw4
ljmp main
isset4:
clr sw4
ljmp main
skip4:
cjne a,#5,skip5
jb sw5,isset5
setb sw5
ljmp main
isset5:
clr sw5
ljmp main
skip5:
cjne a,#6,skip6
jb sw6,isset6
setb sw6
ljmp main
isset6:
clr sw6
ljmp main
skip6:
cjne a,#7,skip7
jb sw7,isset7
setb sw7
ljmp main
isset7:
clr sw7
ljmp main
skip7:
cjne a,#8,skip8
jb sw8,isset8
setb sw8
ljmp main
isset8:
clr sw8
ljmp main
skip8:
cjne a,#0cH,exit
mov swport,#00H
ljmp main
exit:
ljmp main

END

54
APPENDIX-B
DATA SHEET AT89C51

55
56
57
58
59
60
61
APPENDIX-C
TSOP-1738

62
63
64
65
66
67
REFERENCES

68
[1] Muhammad Ali Mazidi, Janice Gillispie Mazidi, Rolin D. McKinlay, The 8051
Microcontroller and Embedded Systems Using Assembly and C, Prentice Hall, Edition
2008
[2] R. L. Boylestad, L. Nashelsky, Electronics Devices and Circuit Theory, Prentice
Hall, Edition 2005
[3] G. E. Keser, Optical Fiber Communication McGraw Hill, Edition 2007
[4] Kenneth j. Ayala, The 8051 Microcontroller Architecture, Programming and
Applications, West Publishing Company, Edition 2000
[5] Marcus O. Durham, Systems Designs and the 8051, Techno press, second edition
[6] Sunil S. Rao, Switchgear protection and power systems, Khanna publishers, 11 th
edition
[7] D. R. Choudhary, Linear Integrated Circuits, New Age International Publishers, 2nd
edition
[8] Wikipedia.org

[9] The Electronics Club, http://www.kpsec.freeuk.com/

[10] Electronics for You

[11] Data sheets

[12] A primer on remote control technology, Innotech Systems Inc.

[13] Gunter Zeisel, Philippe Thomas, Peter Tomaszewski SGS-THOMSON


MicroeIectronics Munichl Germany, Grenoblel France, AN INTERACTIVE MENU-
DRIVEN REMOTE CONTROL UNIT FOR TV-RECEIVERS AND VC-RECORDERS,
IEEE Transactions on Consumer Electronici, Vol. 34, No. 3

[14] C. S. Choy, member IEEE, AN INFRA-RED REMOTE CONTROL SYSTEM


DESIGNED FOR UNIVERSAL CONTROL

69