Introduction: L293D Motor Driver
A motor driver is an integrated circuit chip which is usually used to control motors in autonomous robots. Motor driver act as an interface between Arduino and the motors . The most commonly used motor driver IC’s are from the L293 series such as L293D, L293NE, etc. These ICs are designed to control 2 DC motors simultaneously. L293D consist of two H-bridge. H-bridge is the simplest circuit for controlling a low current rated motor. We will be referring the motor driver IC as L293D only. L293D has 16 pins.
Step 1: Part List
1) L293D IC
2) 4 1microfarad capacitor
3) 6 Header Male pins
4) 12 Volt battery or source
5) Wires or female sockets
6) 2 Motors
7) Arduino (Any) to test the Driver
8) Computer with arduino IDE
9) Misc itmes like soldering iron , soldering Wire etc
Step 2: Schematic and Working
The L293D is a 16 pin IC, with eight pins, on each side, dedicated to the controlling of a motor. There are 2 INPUT pins, 2 OUTPUT pins and 1 ENABLE pin for each motor. L293D consist of two H-bridge. H-bridge is the simplest circuit for controlling a low current rated motor.
Pin No. - Pin Characteristics
- 1 - Enable 1-2, when this is HIGH the left part of the IC will work and when it is low the left part won’t work.
- 2 - INPUT 1, when this pin is HIGH the current will flow though output 1
- 3 - OUTPUT 1, this pin should be connected to one of the terminal of motor
- 4,5 - GND, ground pins
- 6 - OUTPUT 2, this pin should be connected to one of the terminal of motor
- 7 - INPUT 2, when this pin is HIGH the current will flow though output 2
- 8 - VCC2, this is the voltage which will be supplied to the motor.
- 16 - VCC1, this is the power source to the IC. So, this pin should be supplied with 5 V
- 15 - INPUT 4, when this pin is HIGH the current will flow though output 4
- 14 - OUTPUT 4, this pin should be connected to one of the terminal of motor
- 13,12 - GND, ground pins
- 11 - OUTPUT 3, this pin should be connected to one of the terminal of motor
- 10 - INPUT 3, when this pin is HIGH the current will flow though output 3
- 9 - Enable 3-4, when this is HIGH the right part of the IC will work and when it is low the right part won’t work.
Why 4 grounds in the IC?
The motor driver IC deals with heavy currents. Due to so much current flow the IC gets heated. So, we need a heat sink to reduce the heating. Therefore, there are 4 ground pins. When we solder the pins on PCB, we get a huge metalllic area between the grounds where the heat can be released.
Why Capacitors?
The DC motor is an inductive load. So, it develops a back EMF when supplied by a voltage. There can be fluctuations of voltage while using the motor say when suddenly we take a reverse while the motor was moving in some direction. At this point the fluctuation in voltage is quite high and this can damage the IC. Thus, we use four capacitors that help to dampen the extreme variation in current.
Step 3: Working Mechanism and Arduino Code
Now depending upon the values of the Input and Enable the motors will rotate in either clockwise or anticlockwise direction with full speed (when Enable is HIGH) or with less speed (when Enable is provided with PWM).Let us assume for Left Motor when Enable is HIGH and Input 1 and Input 2 are HIGH and LOW respectively then the motor will move in clockwise direction.
Arduino Code I used to test :-
//Testing the DC Motors with
// L293D //Define Pins //Motor A int enableA = 2; int MotorA1 = 4; int MotorA2 = 5; //Motor B int enableB = 3; int MotorB1 =6; int MotorB2 =7; void setup() { Serial.begin (9600); //configure pin modes pinMode (enableA, OUTPUT); pinMode (MotorA1, OUTPUT); pinMode (MotorA2, OUTPUT); pinMode (enableB, OUTPUT); pinMode (MotorB1, OUTPUT); pinMode (MotorB2, OUTPUT); } void loop() { //enabling motor A Serial.println ("Enabling Motors"); digitalWrite (enableA, HIGH); digitalWrite (enableB, HIGH); delay (1000); //do something Serial.println ("Motion Forward"); digitalWrite (MotorA1, LOW); digitalWrite (MotorA2, HIGH); digitalWrite (MotorB1, LOW); digitalWrite (MotorB2, HIGH); delay (3000); Serial.println ("Motion Backwards"); digitalWrite (MotorA1,HIGH); digitalWrite (MotorA2,LOW); digitalWrite (MotorB1,HIGH); digitalWrite (MotorB2,LOW); delay (3000); Serial.println ("Stoping motors"); //stop digitalWrite (enableA, LOW); digitalWrite (enableB, LOW); delay (3000); }