DC Motor Control Exp
DC Motor Control Exp
MUMBAI
DEPARTMENT OF INSTRUMENTATION ENGINEERING
TE Instrumentation
SEM-V
Application of Microcontroller-I
Experiment NumberON-OFF control of DC motor using switches and motor driver IC
Roll NumberNameDiv.-
Experiment No.:-
Date:-
Aim:- To Perform on-off control of a DC motor using switches and L293D motor driver IC.
Objective:- To make the students understand the use of switches and L293D to change
the direction of rotation of the motor.
L293D is a 16-pin IC which can control a set of two DC motors simultaneously in any direction.
It means that you can control two DC motor with a single L293D IC.
The l293d can drive small and quiet big motors as well.
There are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive the motor, the pin 1
and 9 need to be high. For driving the motor with left H-bridge you need to enable pin 1 to high.
And for right H-Bridge you need to make the pin 9 to high. If anyone of the either pin1 or pin9
goes low then the motor in the corresponding section will suspend working. Its like a switch.
There are 4 input pins for this l293d, pin 2, 7 on the left and pin 15 ,10 on the right. Left input
pins will regulate the rotation of motor connected across left side and right input for motor on the
right hand side. The motors are rotated on the basis of the inputs provided across the input pins
as LOGIC 0 or LOGIC 1.
In simple you need to provide Logic 0 or 1 across the input pins for rotating the motor.
Lets consider a Motor connected on left side output pins (pin 3,6). For rotating the motor in
clockwise direction the input pins has to be provided with Logic 1 and Logic 0.
Pin 2 = Logic 1 and Pin 7 = Logic 0 | Clockwise Direction
Pin 2 = Logic 0 and Pin 7 = Logic 1 | Anticlockwise Direction
Pin 2 = Logic 0 and Pin 7 = Logic 0 | Idle [No rotation] [Hi-Impedance state]
Pin 2 = Logic 1 and Pin 7 = Logic 1 | Idle [No rotation]
In a very similar way the motor can also operated across input pin 15,10 for motor on the right
hand side.
VCC is the voltage that it needs for its own internal operation 5v; l293D will not use this voltage
for driving the motor. For driving the motor it has a separate provision to provide
motor supply VSS. L293d will use this to drive the motor. It means if you want to operate a
motor at 9V then you need to provide a Supply of 9V across VSS Motor supply.
The maximum voltage for VSS motor supply is 36V. It can supply a max current of 600mA per
channel. Since it can drive motors Up to 36v hence you can drive pretty big motors with this
l293d.
Below, we interface 2 DC motors using L293D IC with 8051 and turn them ON or OFF using
switches.
Procedure:1.
2.
3.
4.
5.
6.
Program:#include<reg51.h>
#define sw P1 //switches be connected to port P1
//P1.1 m1 and m2 forward
//P1.2 m1 and m2 reverse
//p1.3 m1 forward m2 stop
//p1.4 m2 forward m1 stop
sbit EN1=P2^0; //enable pin for motor 1
sbit EN2=P3^0; //enable pin for motor 2
sbit m1_0=P2^1;
sbit m1_1=P2^2;
sbit m2_0=P3^1;
sbit m2_1=P3^2;
void main( )
{
EN1=0;
m1_0=0;
m1_1=0;
4
EN2=0;
m2_0=0;
m2_1=0;
while(1)
{
//both the motors are enabled
EN1=1;
EN2=1;
//sw1 is pressed
if(sw==0xFE) // 1111 1110
{
m1_0=0;
m1_1=1;
m2_0=0;
m2_1=1;
}
//sw2 is pressed
else if(sw==0xFD) // 1111 1101
{
m1_0=1;
m1_1=0;
m2_0=1;
m2_1=0;
}
//sw 3 is pressed
else if(sw==0xFB) // 1111 1011
{
m1_0=0;
m1_1=1;
m2_0=0;
m2_1=0;
}
//sw4 is pressed
else if(sw==0xF7) // 1111 0111
{
m1_0=0;
m1_1=0;
m2_0=0;
m2_1=1;
}
//none is pressed
else
{
m1_0=0;
m1_1=0;
m2_0=0;
m2_1=0;
}
}
}
Output:-
Conclusion:
We successfully implemented ON-OFF control of two DC motors using L293D IC and switches.