Arduino(6): L293D drive motor

In the past, I have done several motor-related implementations, such as: Arduino(8): Control the stepper motor   is to use the ULN2003 IC to drive the stepper motor, Arduino(15): control servo motor Servo  without driver IC, Arduino(25): The Mini DVD plotter  drives the disc drive motor with the Arduino L293D Motor Shield. 
The picture below shows my current motor driver board or driver IC. L298N has appeared on the Raspberry Pi car. Others are not used in practice. The next few implementations are for the hand. Driver boards or ICs to understand their functions and how to use them. This article begins with L293D.


Generally, when controlling the DC motor drive, if it is only rotated in a single direction, the steering can be controlled by controlling the pins of the positive and negative voltages. If you want to have the ability to reverse polarity, you must reverse the motor voltage in the circuit operation. The L293D IC is commonly used, and other L298N, TA7257P, SN754410 and so on. Generally, the motor current is much larger than the Arduino control board. If it is used directly, the control board may be burned out because the current output of the control board is too small to push the motor or the current of the motor is too large. Therefore, it is recommended to use a separate power supply motor with the motor driver L293D.

[L293D]

According to the specification of L293D, the main specifications are as follows:
  • Motor Type -  Brushed DC
  • Current - output  600mA
  • Voltage - Power Supply  4.5V ~ 36V
  • 16 pins


Source:components101


The L293D pin description is as follows: 
Pin
name
Description
1
Enable 1-2
Used as the left half of the IC control. When the Pin is at a high voltage, the left half of the IC can function. Conversely, at low voltages, the left half of the IC has no effect. Used to open, close and control the speed of motor A and motor B , respectively. high potential on the pins will cause the motor to rotate, and turning it low will stop them.
2
Input 1
When this pin is at a high voltage, current will flow out to Output 1 . Using the direction control pin, we can control whether the motor rotates forward or backward. These pins actually control the switching of the H- bridge circuit inside the L293D IC .
3
Output 1
This pin is to be connected to a pin of the terminal motor.
4,5
GND
Ground.
6
Output 2
This pin is to be connected to a pin of the terminal motor.
7
Input 2
When this Pin is high voltage, current will flow out to Output 2 . Using the direction control pin, we can control whether the motor rotates forward or backward. These pins actually control the switching of the H- bridge circuit inside the L293D IC .
8
Vcc2 (Vs)
The voltage supplied to the motor, if the motor to be driven is 12V , then the Pin 12VDC should be supplied Up to 36V .
9
Enable 3-4
Used as the right half of the IC control. When the Pin is at a high voltage, the right half of the IC can function. Conversely, at low voltages, the right half of the IC has no effect. Using the direction control pin, we can control whether the motor rotates forward or backward. These pins actually control the switching of the H- bridge circuit inside the L293D IC .
10
Input 3
When this pin is high voltage, current will flow out to Output 3 .
11
Output 3
This pin is to be connected to a pin of the terminal motor.
12,13
GND
Ground.
14
Output 4
This pin is to be connected to a pin of the terminal motor.
15
Input 4
When this pin is at a high voltage, current will flow out to Output 4 .
16
Vcc1 (Vss)
Power supply to the IC , this Pin should supply 5V .
Pin 8 is the power input for the motor, and pin 16 is for the IC, as long as +5V. Pins 1, 9 are Enable switches used to determine the two sets of H Bridge. The current direction of the pins 2 and 7 (HIGH → LOW) will affect the output of the pins 3 and 6, and the pins 4, 5, 13, and 12 will be grounded. The current direction of the pins 15 and 10 (HIGH → LOW) will affect the pins. On the output of 11, 14, pins 1, 9 are Enable to determine the two sets of H Bridge switches (HIGH and LOW).


[material]

• Breadboard x 1 
• Arduino UNO R3 x 1 
• DC 5V motor x 1 
• L293D IC x 1 
• Linear variable resistor x 1 
• Connection line x N

[Wiring and circuit diagram]

Arduino
L293D
motor
Variable resistance
5V
8
-
Vcc
Pin 11
9
-
-
Pin 10
10
-
-
-
11
One end
-
GND
12
-
GND
-
14
another side
-
Pin 9
15
-
-
5V
16
-
-
A0
-
-
Data




[code]

#define MotorPin1 10
#define MotorPin2 9
#define EnablePin 11
#define rPin A0

void setup() {
pinMode(MotorPin1,OUTPUT);
pinMode(MotorPin2,OUTPUT);
pinMode(EnablePin,OUTPUT);
pinMode(rPin,INPUT);
}

void loop() {
int rValue=0,pwmValue=0;
while(1)  {
  rValue=analogRead(rPin);      
  pwmValue=map(rValue,0,1023,0,254);  
  digitalWrite(MotorPin1,LOW);    
  digitalWrite(MotorPin2,HIGH);
  analogWrite(EnablePin,pwmValue); 
  delay(100);
 }
}

[Results]


[Reference]

● WikiPedia:H Bridge
● Lastminuteengineers:Control DC Motors with L293D Motor Driver IC & Arduino

Post a Comment

Previous Post Next Post