rc5 Basics
rc5 Basics
BACHELOR OF ENGINEERING
in
MG UNIVERSITY: KOTTAYAM
MAY 2011
MG UNIVERSITY: KOTTAYAM
BONAFIDE CERTIFICATE
Certified that this project report REMOTE CONTROLLING OF HOME APPLIANCES is the bonafide work of LIBIN THOMAS, LINU POULOSE and LISHA ANNA DANIEL who carried out the project work under my supervision.
SIGNATURE
SIGNATURE
Mr. DEEPAK.P
STAFF IN CHARGE ASST. PROFESSOR DEPARTMENT OF ECE
ACKNOWLEDGEMENT
Dedicating this project to the God Almighty whose abundant grace and mercies enabled its successful completion, we would like to express our profound gratitude to all the people who had inspired and motivated us to make this project a success. We here by express our sincere thanks to our Principal Dr. C. E Krishnan for providing us ample facilities in our college to work on this project. We are also extremely thankful to Prof. Arumuga Samy, Head of ECE Department who gave us all help and directions which were very helpful in the successful completion of our mini project. We are very thankful to him for providing the necessary laboratory facilities. We also wish to express our gratitude to Mr. Deepak P, Mr. Vishnu and Mr. Noble C Kurian for their valuable guidance and suggestions in the whole
course of our project activities. Last but not the least we thank all our staffs of ECE Department and our friends for their sincere co-operation with us for the completion of our project.
ABSTRACT
The main aim of conducting this project is to control a maximum of eight electrical appliances by just using a TV remote. Normal IR circuits can switch only one device. But using this circuit, different devices can be controlled using same remote with different switches. In this circuit, we interfaced 8 devices. These devices are switched using remote keypad -1 to 8. AT89C2051 microcontroller is used to control the inputs and outputs. TSOP 1736 (infrared receiver) is used to receive the infrared signals from TV Remote. ULN2803 (High voltage, high current) buffer is used to drive relays. A working system will ultimately be demonstrated to validate the design.
TABLE OF CONTENTS
CHAPTER NO. TITLE PAGENO.
ABSTRACT LIST OF FIGURES 1 2 3 INTRODUCTION BLOCK DIAGRAM BLOCK DIAGRAM EXPLANATION 3.1 IR TRANSMITTER 3.2 IR RECEIVER 3.3 IR DECODER 3.4 RELAY DRIVER IC 3.5 RELAYS 4 5 CIRCUIT DIAGRAM WORKING 5.1 RC5 PROTOCOL 5.2 IR RECEIVER(TSOP1736) 5.3 MICROCONTROLLER(AT89C2051) 5.3.1 FEATURES 5.3.2 DECODING WITH AT89C2051 5.4 RELAY DRIVER IC(ULN2803) 5.4.1 WORKING 5.5 RELAYS 6 7 POWER SUPPLY CIRCUIT ALGORITHM OF THE PROGRAM TO DECODE RC5 PROTOCOL 8 9 10 11 PROGRAM PCB FABRICATION TECHNIQUE PCB LAYOUT APPLICATIONS 5
4 7 8 9 10 10 10 10 11 11 12 14 15 17 19 20 21 23 24 26 28
29 30 36 37 38
12 13 14 15 16
38 38 39 40 41
LIST OF FIGURES
1. BLOCK DIAGRAM 2. CIRCUIT DIAGRAM 3. POWER SUPPLY DIAGRAM 4. RELAY CONNECTION FOR EACH APPLIANCE 5. RC5 PROTOCOL 6. TSOP1736 7. PIN DIAGRAM OF AT89C2051 8. DECODING WITH MICROCONTROLLER 9. PIN DIAGRAM OF ULN2803 10. DARLINGTON PAIR 11. INTERFACING BETWEEN ULN2803 AND RELAY 12. RELAY 13. 7812 IC 14. 7805 IC 15. PCB LAYOUT
1. INTRODUCTION
Infrared (IR) light is an electromagnetic radiation with a wavelength longer than that of visible light, measured from the nominal edge of visible red light at 0.7 micrometers, and extending conventionally to 300 micrometers. These radiations with a frequency below our eyes sensitivity cannot be seen, but can only be felt by our skin temperature sensors. Infra-Red is interesting, because it is easily generated and doesn't suffer electromagnetic interference and so it is widely used in communication and control circuits. The adventure of using lots of infra-red in TV/VCR remote controls helped engineers to work on innovative projects like controlling home appliances using TV remotes etc. A TV remote that follows RC5 Protocol is used here. Receiver in the circuit receives pulsed IR rays from the remote and sends them to a microcontroller that plays the role of a decoder. Decoded signal is thus received by relay driver ICs whose output activates the corresponding home appliance. Thus this circuit can control the ON/OFF process of eight appliances. One of the major advantages of this circuit is to control any appliances by just being in our living room. A major disadvantage is that obstacles on the path of IR rays can block its remote sensing capabilities.
2. BLOCK DIAGRAM
3.2 IR RECEIVER The IR receiver in the circuit is TSOP 1736. These are capable of receiving pulsed IR rays of 36 kHz only and can receive no other frequencies. It receives the signals from the transmitter and retrieves the original modulating signal from the 36 kHz carrier. The front end of this module has a PIN photodiode and the input signal from the remote is passed into an Automatic Gain Control (AGC) stage from which the signal passes into a Band pass filter and finally into a demodulator. The demodulated output drives an NPN transistor. The collector of this transistor forms the output of the module.
3.3 IR DECODER The microcontroller AT89C2051 is used as the IR decoder in the circuit. It is flashed with a program that decodes the RC5 Protocol. It is designed to control the inputs and outputs. The demodulated output from the receiver
10
will be sensed and decoded using this microcontroller. Thus it helps to determine which device is being operated by the user.
3.4 RELAY DRIVER IC As we all know ULN2803 is used as the relay driver IC. It consists of octal high voltage, high current Darlington transistor arrays. The eight NPN Darlington connected transistors in this family of arrays are ideally suited for interfacing between low logic level digital circuitry (such as TTL, CMOS or PMOS/NMOS) and the higher current/voltage requirements of lamps, relays, printer hammers or other similar loads for a broad range of computer, industrial, and consumer applications. 3.5 RELAYS A relay is an electrically operated switch. It allows one circuit to switch a second circuit which is completely separated from the first. The output from the driver IC is send to the corresponding relays which thus results in its excitation and gets activated. As a result it controls the corresponding home appliance.
11
4. CIRCUIT DIAGRAM
12
13
5. WORKING
Our project as mentioned earlier is aimed at controlling 8 home appliances using a Philips TV remote or any remote supporting RC5 Protocol. It controls the on/off process of the appliances interfaced to this circuit. The devices are operated using the keypads 1-8. It performs the function of an IR transmitter which sends pulsed IR rays after modulating the original signal with a carrier of 36 kHz frequency. These signals are received by TSOP 1736 which is our IR receiver. These are designed to receive signals of only 36 kHz. It senses the received output and demodulates them. Therefore original signals are retrieved after demodulation. The output from the receiver is then sent to the microcontroller AT89C2051. It is programmed so as to decode the RC5 Protocol. It decodes the signals from TSOP1736 and thereby it recognizes the device to be functioned. The inputs and outputs are thus controlled. The decoded output from the microcontroller is obtained by the relay driver IC ULN2803. It consists of eight NPN Darlington connected transistors (often called a Darlington pair). Here the signals from AT89C2051 are given to the base of the corresponding transistor in the Darlington array. Thus, when a 5V input is applied to any of the input pins (1 to 8), output voltage at corresponding output pin (11 to 18) drops down to zero providing GND for the external circuit. Thus, the external circuit gets grounded at one end while it is provided +Vcc at its other end. So, the circuit gets completed and starts operating. A total of eight relays are connected to the output pins of ULN2803. When the relay gets excited from the outputs appearing at the driver IC pins, it gets activated. Thus the coil gets energized and the COM gets connected to the N/O contact and the AC mains circuit gets completed and the appliance starts working.
14
Fig 5: RC5 PROTOCOL The basics of the protocol are well known. The handset contains a keypad and a transmitter integrated circuit (IC) driving an IR LED. The command data is a Manchester coded bit stream modulating a 36 kHz carrier. (Often the carrier used is 38 kHz or 40 kHz, apparently due to misinformation about the actual protocol.) The IR signal from the transmitter is detected by a specialized IC with an integral photo-diode, and is amplified, filtered, and demodulated so that the receiving device can act upon the received command. RC-5 only provides a one-way link, with information traveling from the handset to the receiving unit. The 36 kHz
15
carrier frequency was chosen to render the system immune to interference from TV scan lines. The command comprises 14 bits: 2 start bits for the automatic gain control in the infrared receiver. 1 toggle bit (change every time when a new button is pressed on the IR transmitter) 5 address bits for the system address 6 instruction bits for the pressed key As mentioned before the RC5 code uses the biphase modulation technique which means that every bit consists of 2 parts which are never the same. So a bit is always a high/low or a low/high transition. By the RC5 code a 1 is a low high transition and a 0 is high low transition. For all the bits the most significant bit is transmitted first. Remember also that the output signal of the integrated receivers is inverted. Detecting an IR signal the output of the integrated receiver will be 0V. The duration time of each bit is equal to 1.778 ms, and the total time of a full RC5 code is 24.778 ms. The code word is repeated every 113.778 ms as long as a key remains pressed. To improve noise rejection the pulses are modulated at a carrier frequency. The carrier frequency of the RC5 code is 36 kHz so take always a receiver with a response frequency of 36 kHz.
16
Photo detector and preamplifier in one package Internal filter for PCM frequency Improved shielding against electrical field disturbance TTL and CMOS compatibility Output active low Low power consumption High immunity against ambient light Continuous data transmission possible(up to 2400 bps)
The circuit of the TSOP1736 is designed in that way that unexpected output pulses due to noise or disturbance signals are avoided. A band pass filter, an
17
integrator stage and an automatic gain control are used to suppress such disturbances. The distinguishing mark between data signal and disturbance signal are carrier frequency, burst length and duty cycle. The data signal should fulfill the following condition: Carrier frequency should be close to center frequency of the band pass (eg 36kHz). Burst length should be 10 cycles/burst or longer. After each burst which is between 10 cycles and 70cycles a gap time of at least 14 cycles is necessary. For each burst which is longer than 1.8ms a corresponding gap time is necessary at some time in the data stream. This gap time should have at least same length as the burst. Up to 1400 short bursts per second can be received continuously. Some examples for suitable data format are: NEC Code, Toshiba Micom Format, Sharp Code, RC5Code, RC6 Code, R2000 Code and Sony Format (SIRCS). When a disturbance signal is applied to the TSOP1736 it can still receive the data signal. However the sensitivity is reduced to that level that no unexpected pulses will occur. Some examples for such disturbance signals which are suppressed by the TSOP1736 are: DC light (e.g. from tungsten bulb or sunlight) Continuous signal at 36 kHz or at any other frequency. Signals from fluorescent lamps with electronic ballast.
18
19
5.3.1 FEATURES
Compatible with MCS-51Products 2K Bytes of Reprogrammable Flash Memory Endurance: 10,000 Write/Erase Cycles 2.7V to 6V Operating Range Fully Static Operation: 0 Hz to 24 MHz Two-level Program Memory Lock 128 x 8-bit Internal RAM 15 Programmable I/O Lines Two 16-bit Timer/Counters Six Interrupt Sources Programmable Serial UART Channel Direct LED Drive Outputs On-chip Analog Comparator Low-power Idle and Power-down Modes Green (Pb/Halide-free) Packaging Option
20
Now it starts to read the next 11 bits spaced 1.728ms each. The first 5 bits are Address and the next 6 bits are Command. Thus these bits are properly decoded and the output is produced. The general working of the RC5 Protocol decoding program (working based on program) under which our microcontroller is working is as follows: First the ports to be used in the microcontroller are initialized through the program. The output of the IR receiver is connected to the port 3.3 or the interrupt pin of AT89C2051. Thus this pin is the input. Ports 1.1 to 1.7 serve as the output pins. Initially at the start of the program all the relays are switched off. Now the controller waits for the first bit to be received. As the first two bits are not of concern a time delay of 3.024ms is provided and then the flip bit or the toggle bit is recognized. Then the five address bits followed by the six command bits are decoded. Then the microcontroller checks which key is pressed. This is done in such a way that the controller checks if the bit is in a high state or low state. If the bit is in high state it is changed to low state and vice versa. That is if a device is ON it is turned OFF or vice versa. If the power key of the remote is pressed then all the bits are made low. This means, if that key is pressed all the devices are turned off at one shot.
22
5.4.1 WORKING
The ULN 2803 IC consists of eight NPN Darlington connected transistors (often called a Darlington pair). Darlington pair consists of two bipolar transistors such that the current amplified by the first is amplified further by the second to get a high curre nt gain or hfe. The figure shown below is one of the eight Darlington pairs of ULN 2803 IC.
Q1 and Q2 both will not conduct as there is no base current provided to them. Thus, nothing will appear at the output (OUT).
Input current will increase and both transistors Q1 and Q2 will begin to conduct. Now, input current of Q2 is combination of input current and
24
emitter current of Q1, so Q2 will conduct more than Q1 resulting in higher current gain which is very much required to meet the higher current requirements of devices like motors, relays etc. Output current flows through Q2 providing a path (sink) to ground for the external circuit that the output is applied to. Thus, when a 5V input is applied to any of the input pins (1 to 8), output voltage at corresponding output pin (11 to 18) drops down to zero providing GND for the external circuit. Thus, the external circuit gets grounded at one end while it is provided +Vcc at its other end. So, the circuit gets completed and starts operating.
The interfacing between relay driver IC and relay is shown in figure 11 below:
25
5.5 RELAYS
A relay is an electrically operated switch. It allows one circuit to switch a second circuit which is completely separated 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.
In the above figure, when controlling switch is closed, current flows through the coil and thus, magnetic field is produced. The resulting magnetic field attracts an armature that is mechanically linked to a set of contacts. The movement makes a connection with a fixed contact and circuit gets completed. 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 and the connection is broken. The relay's switch connections are usually labeled COM, N/C and N/O as shown in figure 11 above: COM = Common, always connect to this; it is the moving part of the switch.
26
N/C = Normally Closed, COM is connected to this when the relay coil is off. N/O = Normally Open, COM is connected to this when the relay coil is on. Connect to COM and N/O if you want the switched circuit to be on when the relay coil is on. Connect to COM and N/C if you want the switched circuit to be on when the relay coil is off.
27
Fig 13:7812 IC 7805 IC 7805 is a famous IC which is being widely used in 5V voltage regulator circuits.
Fig 14:7805 IC
28
29
8. PROGRAM
VAR1 TEMP equ r7 equ 10H ;Temporary Variable ;Temp variable ;Count ;Device address ;Command ;Flip bit ;Temp bit for flip ;IR Receiver connected to this pin ;Switch 1 connected here ;Switch 2 connected here ;Switch 3 connected here ;Switch 4 connected here ;Switch 5 connected here ;Switch 6 connected here ;Switch 7 connected here ;Switch 8 connected here ;Port at which switches are connected
COUNT equ 11H ADDR CMD FLIP TOG IR SW1 SW2 SW3 SW4 SW5 SW6 SW7 SW8 SWport equ 12H equ 13H bit 00H bit 01H equ P3.3 equ P1.0 equ P1.1 equ P1.2 equ P1.3 equ P1.4 equ P1.5 equ P1.6 equ P1.7 equ P1
org 00H mov SWport,#00H mov sp,#50H clr TOG main: jb IR,$ mov VAR1,#255
;Start of prog ;switch all relays off! ;Stack pointer initialization ;Clear temp bit
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 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,#4 djnz VAR1,$ mov c,IR rlc a djnz COUNT,fadd
31
mov ADDR,A clr a mov COUNT,#6 fcmd: mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ mov VAR1,#255 djnz VAR1,$ mov VAR1,#4 djnz VAR1,$ mov c,IR rlc a djnz COUNT,fcmd mov TEMP,CMD mov CMD,a mov a,ADDR cjne a,#00,nvalid mov a,TEMP cjne a,CMD,valid nvalid: ljmp main valid: clr a mov c,FLIP rlc a
;Save the old command ;Save the new command ;Check for valid address
32
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 isset1: clr SW1 ljmp main skip1: cjne a,#2,skip2 jb SW2,isset2 setb SW2 ljmp main isset2: clr SW2 ljmp main skip2:
33
cjne a,#3,skip3 jb SW3,isset3 setb SW3 ljmp main isset3: clr SW3 ljmp main skip3: 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
34
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 ; End of program
35
36
37
11. APPLICATIONS
The main application of this circuit is that we can control any appliance by just being in our living room. This is very much helpful for elderly people as well as for those who are unable to walk either due to physical disabilities or due to accidents. This circuit enables us to control appliances in the top floor also. Another major use of our project is that we can turn off the operating devices all together at one shot by just pressing the power button.
12. ADVANTAGES
Time saving as it is operated by a remote. Controlling all devices from one place. More secure as there is no direct contact with the appliance.
38
14.CONCLUSION
Hereby we come to an end of or project remote controlling of home appliances. This project gives us an idea of RC5 Protocol and the microcontroller AT89C2051. This project can be used anywhere either at home or offices. This is also cost efficient. Thus by this attempt of ours the ON/OFF processes of many devices was successfully carried out by just using a TV remote.
39
15. REFERENCE
1]http://arif-ece.blogspot.com/2010/05/circuit-for-controlling-8-appliances.html
2]http://www.8051projects.net/out.php?link=http://www.ustr.net/infrared/infrar ed1.shtml
40
16. APPENDICES
41