L293D Motor Controller

From VEEROBOT » Wiki
Jump to navigation Jump to search

Introduction

One of the first tasks in the world of robotics is to make something move. Later realizing that it is not an easy task is something that happens. There is a brain for your robot in the form of a microcontroller and there are motors and wheels ready to take commands. But you cannot connect the tiny signal from the microcontroller and connect it directly to the motor. If you do so, all you see is the motor laughing at you

This is where you require a motor driver. The tiny chip on the board takes those tiny signals (or commands) from your microcontroller and boosts it until it is large enough to drive a motor. The board around makes sure connections between your controller and motor is hassle free

The chip on the board is an L293D H-Bridge driver which is capable of driving two DC motors and delivers output current upto 1A on each channel. Another pair of pins control speed of motors by conventional PWM method. Motor driver can either be powered by the microcontroller power pins or through an external power supply. Onboard regulator makes sure 5V is supplied to chip for logical operation and higher voltage (external supply) to motors

MotorDriver l293d.jpg

Features

  • Onboard 5V regulator so that you do not require two different power sources to power the board
  • Extended Pins for M1a, M1b, M2a, M2b, E1 and E2
  • Jumpers to connect E1 and E2 to VCC in case you do not use enable pins
  • Power LED to indicate power to the board
  • Terminal blocks to provide a strong hold while making plugging in and pulling out motor wires easy
  • Capacitors to store energy and help in voltage spike suppression
  • Additional 5V, VS and Ground pins for connecting other modules or controllers
  • M3 Mounting holes for mounting this board on robots and other projects
  • Chip mounted on a 16 Pin Socket in case you need to replace the chip

Specifications

Module L293D Motor Controller Board
Number of Pins 8 (IN2, IN1, EN1, VCC, VCC, EN2, IN3, IN4)
Input Type PWM on EN1 and EN2
Input Type Digital Input on IN1, IN2, IN3 and IN4
Lead Pitch 0.1th inch (2.54 mm) Breadboard compatible
LED Indicator Yes, to indicate Power
Weight 20.00 grams
Dimension 1.3" x 1.3" x 1.5" inch (33.02mm x 33.02mm x 38.1mm)
Operating Temperature 0C to 60C (± 10%)
Chip Operating Voltage 4.5V to 6V
External Power Supply 6V to 12V
Output Current Max. 1A per channel
Output Channels 2 - can control up to two motors

Interface

VEEROBOT Motor Controller

Power Supply

There are multiple ways motor control board can be powered

  1. Connect External Power Supply directly to terminal block named (PWR-T) to VS and GND
  2. Connect External Power Supply to VS and GND Pins. This is useful if your power source has jumper female connectors
  3. Connect 5V power supply from your controller board directly to 5V and GND pins. However, note that this would also mean that motors will be running at 5V and advisable only if you are using tiny motors

Controlling Motors

There are eight pins on the bottom of the board. First three are used to control first motor while Last three are used to control second motor.

  • IN1 & IN2

These two pins accept digital input and control the direction of the first motor. Sending a ONE (HIGH) to IN1 and ZERO (LOW) to IN2 turns motor clockwise while vice-verse turns it anti-clock wise. However, this is also dependent on the way motors are connected. If you would like motor to turn in reverse direction of existing state, swap these wires (or swap the motor wires connected to terminal blocks)

  • IN3 & IN4

These two pins accept digital input and control the direction of the second motor. Sending a ONE (HIGH) to IN1 and ZERO (LOW) to IN2 turns motor clockwise while vice-verse turns it anti-clock wise. However, this is also dependent on the way motors are connected. If you would like motor to turn in reverse direction of existing state, swap these wires (or swap the motor wires connected to terminal blocks)

  • EN1 & EN2

These pins are used to enable or disable control of motor1 and motor2 respectively. The pins can also be used for controlling the speed of motor by sending PWM signals from your micro-controller. If you are not using these pins, use provided jumpers to connect this to 5V (adjacent pins) which pulls it high and will always be enabled. Pulling it low turns off control.

Usage

Code to control 2 motors with an Arduino Board and Motor Controller Board

/*
 * Product: Motor Driver - L293D
 * SKU    : VEE00054
 * Description: The example demonstrates controlling 2 DC Motors with VEEROBOT Motor Controller
 * from an Arduino board. Connect 6 pins as mentioned below and upload the below code.
 * Two DC motors should be connected to terminal blocks on opposite sides of the board
 * Copyright: www.veerobot.com
*/
 
#define E1 10    // Enable Pin for motor 1
#define E2 11    // Enable Pin for motor 2
 
#define I1 8     // Control pin a for motor 1
#define I2 9     // Control pin b for motor 1
#define I3 12    // Control pin a for motor 2
#define I4 13    // Control pin b for motor 2
 
void setup() {
	pinMode(E1, OUTPUT);
	pinMode(E2, OUTPUT);
	pinMode(I1, OUTPUT);
	pinMode(I2, OUTPUT);
	pinMode(I3, OUTPUT);
	pinMode(I4, OUTPUT);
}
 
void loop() {
	analogWrite(E1, 128);   // Run Motor1 at half speed
	analogWrite(E2, 255);   // Run Motor2 at full speed

	digitalWrite(I1, HIGH);
	digitalWrite(I2, LOW);
	digitalWrite(I3, HIGH);
	digitalWrite(I4, LOW);
	delay(5000);		// run for 5 seconds and then reverse direction

	digitalWrite(E1, LOW);
	digitalWrite(E2, LOW);
	delay(5000);		// run for 5 seconds more

	analogWrite(E1, 255);   // Run Motor1 at full speed
	analogWrite(E2, 128);   // Run Motor2 at half speed

	digitalWrite(I1, LOW);
	digitalWrite(I2, HIGH);
	digitalWrite(I3, LOW);
	digitalWrite(I4, HIGH);
	delay(5000);		// run for 5 seconds and go back to the loop
}

Application Ideas

Making a robot or controlling a motor without using a motor controller is like driving a car with steering.

  • Controlling 2 DC motors direction and speed - Requires 6 pins from the microcontroller
  • Controlling a single Bi-polar stepper motor
  • Controlling 2 DC motors direction - Requires only 4 pins from microcontroller

Note: You can always tweak and hack the code so that only 4 pins can be used for both direction and speed control. A little logic (Hing: turning input pins on and off while using delays in between) can always make it possible.

Demonstration

  • coming soon...

Resources

Support

If you have any questions or queries, Contact Us

Get this

L293D Motor Controller