Control of Lights and Fans using TV Remote - IITB-EE

Control of Lights and Fans using TV Remote - IITB-EE
EE 318 Electronic Design Lab -I, Project Report, EE Dept., IIT Bombay, April 2006
Control of Electrical Lights and Fans using TV Remote
Group No. D07
Anshu Jain (03d07005) <anshuj@ee.iitb.ac.in>
Sandeep Gupta (03d07014) <sandeepg@ee.iitb.ac.in>
Durga Prasad (03d07033) <dprasad@ee.iitb.ac.in>
Supervisor: Prof. P.C.Pandey
Course Instructors: Prof. P.C.Pandey & Prof. V.K.Tandon
Abstract
The objective of this design project is to build a system for controlling light intensity of
an electrical bulb or speed of fan using a TV remote or using serial port interface. The
system provides regulation against input power supply. Intensity/speed of the load is
controlled by changing the RMS voltage across the load using triac circuitry that is by
changing the corresponding firing angle at the gate of the triac. An ADC circuit monitors
the unregulated input voltage, followed by software to check for voltage variation and
provide regulation.
1. Introduction
The main aim of this project is to design an electronic circuit which can control intensity
of an electric bulb and speed of a fan using infrared TV remote or using serial port
interface.
RMS voltage across a triac is related to the RMS voltage of the mains according to the
following relation
Vrms(load) = Vrms(mains)(1- θ/π)0.5
Here, θ is the firing angle of the triac measured from the zero crossing point.
Thus by changing the firing angle we can regulate the voltage across the load. Hence we
can vary the intensity/speed of the light/fan. If θ is zero i.e. if triac is fired at the zero
crossing, then maximum power is transferred to the load similarly if triac is fired at the
peak of the cycle (i.e. θ= π/2) then only half of the power is transferred to the load. Thus
our main job was to generate these pulses according to the signal from the TV remote or
serial port. We are also monitoring the attenuated unregulated DC input voltage using an
ADC, so as to provide voltage regulation against the mains voltage. For regulation
against the mains frequency we are changing the instance of firing of the triac.
1
2. Design approach: 2.1 Block Diagram:
The block diagram (fig. 1) consists of:
• Power supply consisting of 230V/9V step down transformer followed by a bridge
rectifier, a low pass filter and a 5V voltage regulator (7805).
• IR receiver for receiving the signals from TV remote.
• RS 232 level shifter for serial port interfacing.
• Two microcontrollers one for decoding the signals (40 pin) and other (20 pin) for
generating the trigger pulse for triac.
• A zero crossing detector.
• ADC for voltage regulation.
• LCD for displaying the current status of the loads.
• Triac circuitry.
230V/9V
Step down
transformer
Low pass
filter
Bridge
Rectifier
Zero crossing
detector
Serial
port
data
TV
remote
RS232
Driver
5V Voltage
regulator
(7805)
ADC
0804
40 pin
microcontroller
20 pin
microcontroller
Triac
IR
receiver
Load
LCD
Fig. 1 Block diagram
2.2 Description of the various blocks:
a) 5V Power supply
Fig. 2 shows the circuit to generate 5V DC supply from mains supply. For this purpose
we used 230V/9V step down transformer followed by a bridge rectifier consisting of
IN4001 diodes, low pass filter and 5V voltage regulator LM7805 (IC1). Output from
transformer is also used to detect zero crossing. Capacitor C1 is used to filter the output
2
from bridge rectifier to generate unregulated DC supply (Vx) which serves as input for
ADC and voltage regulator. C2 and C3 are used for frequency stabilization. This 5V DC
supply is used for power supply for various chips in the whole circuit.
Fig. 2: DC power Supply Circuit
b) IR Receiver
We are using RC5 encoded remote. Every time a button is pressed at the remote control,
it sends a train of 14 bits, 1.728ms per bit, the whole train is repeated every 130 ms if the
button is kept pressed.
TSOP 1738 (IC2) is used as an infrared receiver. It’s a 3 pin module with active low
output. When no key is pressed on remote, it shows high output. Fig. 3 shows the pin
diagram of TSOP. Output pin of TSOP is connected to pin 3.2 of 40 pin microcontroller
AT89c42 (IC5).
Fig. 3: IR receiver TSOP 1738 (IC2)
Fig. 4 shows the output signal from TSOP. This type of coding is called Manchester
coding technically known as return to zero ( RZ ) format. In this coding each bit is
divided into 2 half bits one as left bit and second one right bit. Bit value is determined by
the transition at the center of the bit. If there is downward transition i.e. bit is changing
from high to low at the center then bit value is one ( Logic 1 ) and if there is upward
transition at the center then value of that bit is zero ( Logic 0 ).
3
Fig. 4: Output from TSOP
The first two bits in the bit train, #1 and #2, are called Auto Gain Control (AGC)
calibration. They are ON on the left side or takes transition from 1 to 0 at the center
(Logic 1), and serve to calibrate the IR receiver’s AGC. The bit #3 is the CHECK bit,
every time a key is pressed at the remote (even repeatedly the same key) this bit flips
state. The next 5 bits, #4 to #8, are used for SYSTEM ADDRESS, or to identify which
kind of device should execute the COMMAND bits. The next 6 bits, #9 to #14, are used
for COMMAND information to the device selected by the ADDRESS bits. Bit #14 is the
LSB.
c) RS232 Driver
As we have to receive data so we are using only receiver part of RS232 driver. The level
shifting of RS232 input for interfacing to the microcontroller has been carried out using
IC3 (MAX232) as shown in Fig. 5. Pin 3 (TXD) of Male D9 connector is connected to
pin 13 of MAX232 and pin 12 in connected to pin 3.0 of microcontroller 89c52.
d) IR Decoder
40-pin microcontroller AT89C52 is used to decode the IR signal from the TV remote and
RS232. Here we are using a crystal of 11.0562 MHz so as to get a baud rate of 9600. The
output of the TSOP is connected to pin P3.2 (external interrupt 0) and the serial data from
Max232 is connected to pin P3.0 (serial interrupt).Whenever an interrupt comes at pin
P3.2 the microcontroller first give a delay of 0.433ms so that we can read the mid point
of any particular bit. Now as we don’t need first 6 bits we skip the first 6 bits and read the
next 8 bits by sampling the command bits (14 bit train) receive from the TV remote. Flow
chart for decoding signal from TV remote is shown in Fig. 12.
This microcontroller is also being interrupted whenever computer sends a
command over the serial port. The command consists of a train of 11 bits including the
start bit and the stop bit with baud rate 9600.Microcontroller decodes this data by using
the serial receiver (Rx) of the microcontroller.
After decoding the signal from the TV remote or from serial port this
microcontroller also sends the instruction to the next microcontroller. This is done by
setting the port 2 pins accordingly. First 3 bits P2.0, P2.1 and P2.2 denotes which load
4
Fig. 5: RS232 Driver
to be executed. In our case we are using only 2 loads thus we need only 1 bit (P2.2). P2.2
is set if load is fan and is reset if load is light. But we can control 8 loads using this
scheme. Next two bits are for the instruction to be executed which is coded as follows:
P2.3 P2.4
OFF
0
0
ON
0
1
Decrease
1
0
Increase
1
1
Pin P2.5 is used to send a signal to the next microcontroller to show that a new
key is pressed. P2.5 is complemented whenever a key is pressed on a TV remote or
whenever a new data comes at the serial port. Remaining two bit i.e. P2.6 and P2.7 are
not used thus can be used for some other purpose.
e) Zero Crossing Detector
Fig. 7 is circuit for zero crossing. Zero crossing is used as a reference for measuring
firing angle of the triac. Output from transformer serves as input for low power quad
OPAMP LM324 (IC4) (Fig. 6).
5
Fig. 6: Low power quad Opamp LM324 (IC4)
Fig. 7: Zero crossing detector circuit
LM 324 has four opamps. One of them was used as comparator with input as output from
transformer followed by potential divider while 2nd opamp was used as a buffer which
avoids comparator output getting loaded by microcontroller. Because the output of
LM741 is bipolar and thus it can damage microcontroller so we used LM324.
Output from the buffer Vz is connected to pin 1.0 of 20 pin microcontroller
AT89c2051(IC6).
R1 = R2 = R3 = R4 = 1K ohm.
f) Voltage Regulation against mains power supply
For regulation against voltage supply we used ADC0804 which is one channel input
ADC. It’s a 20 pin chip with differential input voltage range 0V-5V. Unregulated DC
voltage (Vx) followed by a potential divider is used as input for ADC (pin 6). A register
R of 10K and capacitor C of 150uf are used to generate a clock frequency of 640
6
Fig 8 (a): Ouptput waveform across transformer
Fig. 8 (b): Output waveforms of zero crossing detector
Fig. 9: ADC0804
KHz. Because Vx has magnitude about 10V so we used potential divider to make the
input for ADC with in chip’s input voltage range.
Voltage span of ADC is made 2.2V to 7.2 volts by providing constant 2.2V to the
negative input pin of ADC. Here we are assuming voltage variation from 200V to 250V
with 230V normal voltage. So our input voltage to ADC changes from 2.2V to 2.9V. We
used a limiter circuit followed by a zener diode of 2.2V breakdown voltage for this
purpose. Chip select low pin of ADC is connected to pin 3.1 of 89c52, write low to pin
3.4 and INTR low to pin 3.5. Output from ADC pin 11 to 18 are multiplexed with LCD
and connected to pin p1.0 to p1.7 of the microcontroller 89c52. When ADC subroutine is
7
called in the program p3.1 is made active low. Thus ADC chip is selected. p3.4 is made
active low for some time interval ( about 10 us ) and then made active high. ADC starts
conversion after 1 to 8 clock periods and when conversion is completed it interrupts
microcontroller. Interrupt pin is connected to p3.5 of 89c52. We are comparing output of
ADC (pin 11 to pin 18) with output corresponding to 230V and changing the firing angle
of triac accordingly.
g) Firing pulse generation
20 pin microcontroller AT89C2051 processes the instruction form the first
microcontroller and generates the triac firing pulses accordingly. Output from the zero
crossing detector is connected to pin p1.0 and is used to get the count for the half cycle.
This count is then used to get the counts for the various levels. Zero crossing detector
output is also used to synchronize the triac pulse with the input supply frequency. Fig. 13
shows the flowchart for its working.
h) Triac:
A triac is a three terminal semiconductor device that is triggered by a low-energy signal
applied to its gate. The supply to the triac is an AC signal and it will always turn off when
the applied voltage reaches zero at the end of the current half cycle. If a turn on pulse is
applied, the triac goes from a high-impedance state to a conductive state, and it starts
conducting current through the load. So the position at which this turn on pulse is fired
(firing angle) directly control the percentage power of that half-cycle transmitted to the
load.
Pload = Pmain (1-θ/π)
Fig. 10: Triac circuit
The pulses from the microcontroller are connected to the pin 1(the anode of the
photodiode) of the opto-coupler MOC3020 and the cathode (pin 2) is connected to the
ground. On the pulses, the photodiode radiates and drives the triac inside MOC3020. In
this part the pulses are in optical form hence providing the optical isolation between the
triac load circuit and the electronic circuit. The diac of the opto-coupler further drives the
triac with the load connected between a power supply terminal and A2 terminal of the
triac and the other power supply terminal and A1 are shorted.
R1 = 560 Ω; R2 = 250 Ω; R3 = 1k Ω; C1 = 0.22µF.
8
i) LCD Display:
The LCD display contains two internal byte wide registers, one for commands (RS=0)
and the second for characters to be displayed (RS=1). Pins 1 and 3 are connected to the
ground, and pins 7 to 14 are connected to Port 1 of the microcontroller AT89C52 to
furnish the command or data byte, and pins 4,5 and 6 (register select, read/write and
enable high signals respectively) are connected to 3.5,3.6 and 3.7. Pin 14 of LCD is
monitored for logic high (busy) to ensure the display is not overwritten.
Fig. 11: LCD display
Each time a remote key is pressed it displays the respective levels of each load and holds
till a new signal is received by an IR receiver.
9
START
Wait for falling
edge at IR output
No
If IR
receiver
output=0
Yes
Give a delay of
0.433ms, count = 8
Skip first six bits
i.e. give a delay of 6 x
1.732 ms
Move IR output into C
bit and RLC through
accumulator.
Give a delay of 1.732
ms, decrement count
No
If
Count=0
Yes
STOP
Fig. 12: Flowchart for IR decoding
10
START
Get the count for one half cycle
from zero crossing detector
Get the count corresponding to
various levels
Wait for the instruction from
the first microcontroller
Synchronize with the mains
frequency
Load the count according to
instruction from first
Microcontroller and run timer
Set the firing
angle pulse at
port pin
Yes
Interrupt
from
timers
No
Yes
New key is
pressed
No
Fig. 13: Flowchart for the generation of triac pulses
11
Fig. 14: Complete Circuit Diagram
12
Fig. 15: a) Voltage waveform of mains supply
b) Pulse pattern at the gate of triac at level 1
c) Voltage across triac at level 1
13
Fig. 16: a) Voltage waveform of mains supply
b) Pulse pattern at the gate of triac at level 4
c) Voltage across triac at level 4
d) Pulse pattern at the gate of triac at level 7
e) Voltage across triac at level 7
14
3. Implementation
Fig. 14 shows the complete circuit diagram. Figs. 15 and 16 show voltage waveforms for
mains supply, pulse at triac and voltage across triac for level 1 (ON), 4 and 7 (maximum
speed/intensity).
4. Conclusion
Intensity of a bulb and speed of the fan can be controlled in 8 different levels including
ON and OFF using a TV Remote or a Serial port interface. The level at which different
loads are operating is displayed on a LCD.
5. Further Scope
As one of the ports of AT89c52 is still unused, a keypad can be provided to control this
system or this port can also be used to provide internet connectivity to the system. A little
beyond this can also be thought of, where the device is instructed through the
instructions, sent in an SMS, from a cellular phone.
References
[1] A. S. Sedra, K. C. Smith, “Microelectronic Circuits”, Fourth edition, 1982,
Oxford University Press (2003).
[2] K. J. Ayala, “8051 Microcontroller, Architecture, Programming and
Applications”, Penram International Publishing (India) (2001).
[3] National Semiconductors, “National Analog and Interface Products
Databook”, National Semiconductors (2001).
[4] http://symlink.dk/electro/hd44780/
[5] 8052 Resources, Vault Information Services. [Online]. Available:
http://www.8052.com
[6] Infrared Remote Control Tutorial, Universal Solution Technology Research
Inc. - Orlando, FL USA 32837-5314. [Online]. Available:
http://www.ustr.net/infrared/infrared1.shtml
[7] AT89C51 Datasheet, Atmel Corporation, [Online]. Available:
http://www.atmel.com/dyn/resources/prod_documents/doc0265.pdf
[8] TRIAC tutorial, American Microsemiconductor Inc., [Online]. Available:
http://www.americanmicrosemi.com/tutorials/triac.htm
[9] LM324 Datasheet, National Semiconductor Corporation, [Online]. Available:
http://www.national.com/pf/LM/LM324.html
[10] Building a 5 Volt power supply, Iguana Labs, [Online]. Available:
http://www.iguanalabs.com/7805kit.htm
[11] IN4001 Datasheet, ChipDocs, [Online]. Available:
http://www.chipdocs.com/pndecoder/datasheets/ZOWIE/1N4001.html
[12] TSOP1738 IR Receiver Datasheet, Vishay, [Online]. Available:
http://www.vishay.com/docs/tsop17.pdf
15
6. APPENDIX:
User Manual
a) For Remote
1
2
3
4
Ch up
Ch down
Vol up
Vol down
Light ON
Light OFF
Fan ON
Fan OFF
Increase Light Intensity
Decrease Light Intensity
Increase Fan speed
Decrease Fan speed
b) For Computer
1
2
3
4
5
6
7
8
Light ON
Light OFF
Fan ON
Fan OFF
Increase Light Intensity
Decrease Light Intensity
Increase Fan Speed
Decrease Fan Speed
16
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising