Professional Documents
Culture Documents
INTRODUCTION
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.
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 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).
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)
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.
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
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
$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
$0D-13 Mute
$10-16 Volume+
$11-17 Volume-
$12-18 Brightness+
$13-19 Brightness-
$32-50 Fastrewind
$34-52 Fastforward
$35-53 Play
$36-54 Stop
$37-55 Recording
Chapter-2
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.
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.
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:
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)
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.
Accumulator
I/O
Registers Ports
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.
Features
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:
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.
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.
Table 2.2
Other Pin Configurations:
PQFP/TQFP:
PQFP: Plastic Gull Wing Quad Flatpack.
TQFP: Thin Plastic Gull Wing Quad Flatpack.
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
Control module
Figure 3.1: Block Diagram of IR receiver
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.
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.
1 check bit
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
25
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
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
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
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
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.
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:
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.
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.
Features
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.
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.
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.
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.
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.
Switching regulator
Special 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.
Characteristics:
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.
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.
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.
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:
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.
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.
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.
Features
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.
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.
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
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
69