In most of the industries for motion control AC motor or DC motor are used. To control the motion there is a need of either AC drive or DC drive. The basic functions of this drive are to give smooth start to motor change the direction, change the speed etc. Here I am demonstrating one such application of DC drive that will control speed and direction of a DC motor using standard TV remote control. All the standard TV remote controls works on RC5 protocol developed by Philips. So here I am using one RC5 decoder chip ST3049 that will decode the codes of RC5 remote control and directly gives 6bit digital data. Controlling of DC motor is handled by micro controller 89C51 with help of dual H-Bridge chip L293D.
Note:- RC5 decoder chip ST3049 is available at www.sunrom.com. The details of this chip given here are taken from datasheet of ST3049.
Before starting directly the explanation of application let us first understand what is RC5 code?
RC5 code: –
RC5 is most popular protocol used for IR remote control. It was developed by Philips. Now it has become universal protocol and used in almost each and every remote control. Also care is taken that IR code is unique for electronics equipments and manufacturers.
IR transmitter transmits 14bit code. This IR code is repeated after certain interval. This 14 bit code can be divided into 4 parts.
1. Two start bits.
2. One Toggle bit.
3. Five address bits.
4. Six Command bits.
Start bits:- Initial two start bits are always ‘1′.
Toggle bit:- Toggle bit changes every time when new button is pressed. Now this is useful for volume control. For example if you long press mute or any number key button then this 14 bit code is transmitted multiple time but command is executed first time only. But this is not the case with volume/channel change button. For volume change long press is important feature. So receiver controller uses this toggle bit and decodes command.
Address and command bits:- Five Address bits are used for system address. There is unique address for each equipment. Similarly there are 64 commands.
Here is the figure given for the RC5 code frame.
Now let us see how ST3049 will decode this code. So now let us understand working and operation of RC5 decoder chip ST3049.
RC5 decoder ST3049
RC5 decoder ST3049: –
The above figure shows pin diagram of chip ST3049. Pin functions are as described in below table
Pin no |
Pin name |
Function |
4 |
input |
receives input form IR sensor |
Vcc |
positive bias |
connected to +V |
Gnd |
Ground |
connected to Ground |
T0 |
toggle |
This bit toggles each time a new key is pressed. That allows identifying between holding down a key and pressing a key twice or more. |
CA |
command ack |
this pin goes low for 50ms as valid RC5 code is received and data is updated on D0-D5 |
X1-X2 |
external crystal input |
connect 4 MHz crystal along with two 22pf capacitors with these pins |
A0-A4 |
address inputs |
5 bit address input. |
D0-D4 |
data outputs |
6 bit data output. when any key is pressed from remote control it will generate 6 bit data |
|
|
|
so with very few extra components we can decode RC5 code with the help of this chip. Here is the circuit that will receive RC5 code and generate 6bit output.
RC5 decoder circuit
RC5 decoder circuit:-
As shown in above figure we need IR sensor TSOP1738, 4 MHz crystal, 1 LED, 2 capacitors and a current limiting register.
Connection: – the output of IR sensor is directly connected with input pin of ST3049. A 4 MHz crystal along with two 22pf capacitors connected with X1 & X2. One LED is connected to CA pin as shown. All the address inputs are connected to ground to set an address for TV set 1. 6 bit data outputs A-F can be connected with microcontroller directly. CA pin is also taken out to generate an interrupt when ever data is available on D0-D5.
Operation: – IR sensor will detect 40KHz IR signal generated from any standard remote (either TV, VCR, CD player etc.) It demodulates it and gives the RC5 code to ST3049 chip. St3049 Verifies valid RC5 code and depending upon the key pressed from remote control it will latch 6bit data on D0-D5 and also gives low pulse on CA pin. Some of the data outputs for very popular keys on remote control are as given.
Key on Remote control |
6 bit data output |
0 – 9 |
000000 (0) – 001001(9) |
stand by |
010010(12) |
mute |
010011(13) |
volume up |
010110(16) |
volume down |
010111(17) |
|
|
System Block-Diagram
System Block-Diagram: –
As shown in above figure major components are St3049, micro controller 89C51 and dual H-Bridge driver L293D. Let us see function of each one by one
IR sensor: – demodulates 38KHz wave and gives RC5 code to ST3049
ST3049: – decodes RC5 code and gives 6 bit data to 89C51
89C51: – this is the heart of entire system. It performs following tasks.
- Starts or stops DC motor
- Changes its directions also varies its speed
- Indicates speed increase / decrease on bar graph
- Indicates start / stop and CW / CCW direction of motor on indicators
L293D: – it provides sufficient current (up to 1A) to drive DC motor
Circuit diagram
Circuit diagram: –
Connection: – as shown in Circuit Diagram Tab 1, figure P1 is connected with data outputs of St3049. 8-LED bar graph are connected with P2. Four LEDs are connected with P3.0, P3.1, P3.4 and P3.5. Pins P3.6 and P3.7 drives DC motor through L293D chip. Pin P3.2 is connected with CA pin of ST3049. 12 MHz crystal along with 2 33pf capacitor provides basic clock signal. C3, D5 and R1 forms power on reset circuit. One push button is given to reset micro controller.
- Operation: – As ST3049 receives valid RC5 code it will generate external interrupt for micro controller
- As external interrupt arrives micro controller will get 6 bit code form P1
- It will compare the code with the code that are already stored in memory. Here I have selected four codes as given in below table
Key on remote |
6 bit code |
Function |
stand by (on/off) |
12 |
to start or stop motor |
mute |
13 |
to change direction |
volume up |
16 |
increase speed |
volume down |
17 |
decrease speed |
- When a match found controller will perform that particular task. Like starting motor, changing direction, increase / decrease speed etc.
- Al song with that it will also give indication on LEDs
Green LED |
Motor running |
Red LED |
Motor stop |
Yellow LED |
CW direction |
Orange LED |
CCW direction |
- 8 LED bar graph shows increase or decrease in speed in 8 steps
This entire operation depends upon the program embedded in micro controller. So now let us understand software program
Software Program
Software program for remote control DC drive
Entire program can be well explained by explaining all the functions used in this program.
Start function is a continuous function that will rotate motor in either direction with set speed. Actually it generates PWM to vary the speed of motor. It will set the direction of motor and then generate PWM on either P3.6 or P3.7
Intra function is an interrupt enabled function that will receive data byte available on P1. Whenever interrupt arrives it will be automatically called and after some delay it will get the byte available on P1
chngdir will change the direction of motor every time. It increments a count every time and checks even or odd. If it’s even sets CW direction and vice versa
incspeed increase speed by one step. Actually it increases pulse width time by 1 ms. Total time is 10 ms and we are varying the width of pulse from 1ms to 9ms. So speed of motor varies in 8 step. That is indicated on 8 LED bar graph. Dec speed is similar to this but it will decreases pulse width by 1 ms
Shift up function is similar to rotate the content of port P2 left, once. It sends one more zero every time on P2 pins from P2.7 to P2.0 so bar graph is raised once. shiftdown function does the reverse thing. It will send one more 1 on P2 pins from P2.0 to P2.7. So bargraph is reduced by once.
Delay function is a variable delay that varies the delay from 1 ms to the count you load into the function. T0 generates basic delay of 1ms and then this basic delay in a loop is repeated for number of times (like 2,3,4….) to generate delay of 2ms, 3ms, 4 ms and likewise
Kodaly is fix delay and it is just used to settle down the data byte available on P1 from ST3049.
Project Source Code
Project Source Code
###
#include<reg51.h>
unsigned char a;
bdata unsigned char byte=0x0F, databyt=0x00;
unsigned int d1=5,d2=5,c=0,f=0;
sbit b0 = byte^0;
sbit b1 = byte^1;
sbit b2 = byte^2;
sbit b3 = byte^3;
sbit b4 = byte^4;
sbit b5 = byte^5;
sbit b6 = byte^6;
sbit b7 = byte^7;
sbit led1=P3^0;
sbit led2=P3^1;
sbit led3=P3^4;
sbit led4=P3^5;
sbit op1=P3^6;
sbit op2=P3^7;
void keydely()
{
int x,y;
for(x=0;x<25;x++)
for(y=0;y<1000;y++);
}
void delay(int d)
{
int k;
TL0 = 0x17;
TH0 = 0xFC;
TR0 = 1;
for(k=0;k<d;k++)
{
while(TF0==0);
TF0 = 0;
TL0 = 0x17;
TH0 = 0xFC;
}
TR0 = 0;
}
void shiftup()
{
b0=b1;
b1=b2;
b2=b3;
b3=b4;
b4=b5;
b5=b6;
b6=b7;
b7=0;
}
void shiftdown()
{
b7=b6;
b6=b5;
b5=b4;
b4=b3;
b3=b2;
b2=b1;
b1=b0;
b0=1;
}
void incspeed()
{
if(d1<9)
{
d1++;
d2--;
shiftup();
P2=byte;
}
}
void decspeed()
{
if(d2<9)
{
d2++;
d1--;
shiftdown();
P2=byte;
}
}
void chngdir()
{
c++;
if((c%2)==1)
{
led3=0;
led4=1;
}
else
{
led3=1;
led4=0;
}
}
void start()
{
led2=0;
led1=1;
if((c%2)==0)
{
op2=0;
while(databyt==0x00)
{
op1=1;
delay(d1);
op2=0;
delay(d2);
}
}
else
{
op1=0;
while(databyt==0x00)
{
op2=1;
delay(d1);
op2=0;
delay(d2);
}
}
}
void intr() interrupt 0
{
keydely();
databyt=P1;
}
void main()
{
int tmp=0;
TMOD = 0x01;
P3=0x04;
P2=byte;
led2=1;
led3=1;
IE=0x81;
back: while(databyt==0x00);
check: switch(databyt)
{
case 0xD2:
tmp++;
if((tmp%2)==1)
{
f=1;
databyt=0x00;
start();
}
else
{
f=0;
led2=1;
led1=0;
databyt=0x00;
op1=0;
op2=0;
}
break;
case 0xD6:
incspeed();
databyt=0x00;
start();
break;
case 0xD7:
decspeed();
databyt=0x00;
start();
break;
case 0xD3:
chngdir();
databyt=0x00;
start();
break;
}
if(f==0)goto back;
else goto check;
}
###
Circuit Diagrams
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.