L293d Motor Driver Module

Get 90% discount on 'WIRELESS RC CAR ROBOTICS WITH ARDUINO ROBOT, PC & SMARTPHONE course' by clicking on the below https://www.udemy.com/wireless-rc-car-rob.

Description

The L293D V1 Motor Driver Shield has 4 full-bridge motor driver channels and can drive up to 4 DC motors or 2 stepper motors. It fits Arduino Uno or other Arduino with compatible I/O pins.

PACKAGE INCLUDES:

  • L293D V1 Motor Shield

KEY FEATURES OF L293D V1 MOTOR SHIELD:

  • Drive 4 DC motors with speed and direction control
  • Drive 2 stepper motors
  • 4.5 – 25V motor voltage range
  • 1.2A peak current per channel (600mA continuous)

The L293D V1 Motor Shield can drive up to 4 DC motors at voltages from 4.5 – 25V and at currents of up to 1.2A peak (600mA continuous) per motor with speed and direction control.

The module can also support up to 2 stepper motors. Each stepper motor takes the place of 2 of the DC motors, so you can run 2 stepper motors or 1 stepper motor and 2 DC motors or 4 DC motors.

The shield also technically supports 2 servo motors for which there are two 3-pin headers on the module. Unfortunately it powers the servo motors directly off the Arduino 5V which is never a good idea. Doing so can overheat the Arduino on-board 5V regulator as well as induce electrical noise into the Arduino 5V power causing intermittent problems that are difficult to troubleshoot, therefore it is not recommended to use this feature. If you are a hacker, the traces to the 5V center pins on the servo headers can be easily cut and rewired to a separate 5V power source.

Motor Power Connections

Motor voltage must be between 4.5 – 25V. This power can be shared with the Arduino or be separate. To select this, there is a jumper near the 2 terminal power connector labeled PWR.

When this jumper is installed, the power from the Arduino DC power jack is also connected to the motors. Vin (marked 9V on the board) is brought up form the Arduino to power the motors.

When the jumper is removed, that isolates the motor power from the Arduino and it must be supplied separately by connecting power to the 2 terminal power connector. Note: Do not apply power to the 2 terminal power connector with the jumper in place or it will short the two power supplies together!

1 x 2 Terminal EXT_PWR (Motor Power)

  • +M = Motor Vcc which must be between 4.5 and 25V.
  • GND = Motor Ground.

DC Motor Connections

The motor connections are via two screw terminals for each motor and labeled M1 thru M4. The center terminal on the 5-pos terminal blocks are connected to ground.

The wiring of which lead of the motor connects to which terminal is somewhat arbitrary and relative to what you consider forward vs reverse motor operation. If the motor goes in the opposite direction that you expect, simply reverse the wiring.

1 x 2 Terminal M1 – M4 (DC Motor 1-4)

  • Motor ‘-‘ positive lead
  • Motor ‘+’ negative lead

Stepper Motor Connections

Stepper motors are typically 4 wire. Coil 1 will connect across one motor port such as M1 (M3) and coil 2 will connect across the other motor port such as M2 (M4). If the stepper motor has 5 wires, the center tap wire will be connected to the center ground terminal.

1 x 2 Terminal M1(M3) – M2(M4) (Servo Motor 1-2)

  • Motor Coil 1
  • Motor Coil 2

Arduino to Shield Pin Connections

The shield has a remote reset button located on it for easy access.

The shield uses Pins D3,D4, D5, D6, D7, D8, D11 and D12 for DC and stepper motor control.

D9 and D10 come out to the Servo headers.

The other pins are available including the 6 analog pins that can also be used as digital I/O. These have solder pads so that a header can be added if desired for easy connections. Next to that is a row of 5V and Ground connections that can also be populated with headers if desired.

OUR EVALUATION RESULTS:

This is an older style motor driver which is very inexpensive and gets the job done for driving smaller DC motors or stepper motors.

The chips are socketed for easy replacement should that be required.

If you need a little more power handling and you are handy with soldering, it is possible to solder spare L293D chips piggy-back over the ones on the board. This effectively doubles the power handling capability to 2.4A peak and 1.2A continuouse current per motor.

Using the module requires use of the Adafruit Motor Shield V1 (AFMotor.h) library that come with the Arduino IDE.

For more information on using this module, refer to the Adafruit documentationwhich has be archived.

L293D V1 Motor Driver Shield Example Program

Before they are shipped, these modules are:

  • Inspected
  • Basic operation of driver verified
  • Repackaged in quality recloseable ESD bags for safe storage.

Notes:

  1. None
Motor

Technical Specifications

Operating Ratings
Voltage range (Vcc) 4.5 – 25 VDC
Max current per bridge (peak)1.2 A
Max current per bridge (sustained)600 mA
Dimensions
Driver Board (L x W)70 x 54 mm (2.75 x 2.1″)

If you are planning on assembling your new robot friend, you will eventually want to learn about controlling DC motors. One of the easiest and inexpensive way to control DC motors is to interface L298N Motor Driver with Arduino. It can control both speed and spinning direction of two DC motors.

And as a bonus, it can even control a bipolar stepper motor like NEMA 17.

Control Stepper Motor with L298N Motor Driver & Arduino
One of the easiest and inexpensive way to control stepper motors is to interface L298N Motor Driver with Arduino. It can control both speed and...

Controlling a DC Motor

In order to have a complete control over DC motor, we have to control its speed and rotation direction. This can be achieved by combining these two techniques.

  • PWM – For controlling speed
  • H-Bridge – For controlling rotation direction

PWM – For controlling speed

The speed of a DC motor can be controlled by varying its input voltage. A common technique for doing this is to use PWM (Pulse Width Modulation)

Raspberry

PWM is a technique where average value of the input voltage is adjusted by sending a series of ON-OFF pulses.

The average voltage is proportional to the width of the pulses known as Duty Cycle.

The higher the duty cycle, the greater the average voltage being applied to the dc motor(High Speed) and the lower the duty cycle, the less the average voltage being applied to the dc motor(Low Speed).

Below image illustrates PWM technique with various duty cycles andaverage voltages.

H-Bridge – For controlling rotation direction

The DC motor’s spinning direction can be controlled by changing polarity of its input voltage. A common technique for doing this is to use an H-Bridge.

An H-Bridge circuit contains four switches with the motor at the center forming an H-like arrangement.

Closing two particular switches at the same time reverses the polarity of the voltage applied to the motor. This causes change in spinning direction of the motor.

Below animation illustrates H-Bridge circuit working.

L298N Motor Driver IC

At the heart of the module is the big, black chip with chunky heat sink is an L298N.

The L298N is a dual-channel H-Bridge motor driver capable of driving a pair of DC motors. That means it can individually drive up to two motors making it ideal for building two-wheel robot platforms.

For more details please refer below datasheet.

Power Supply

The L298N motor driver module is powered through 3-pin 3.5mm-pitch screw terminals. It consists of pins for motor power supply(Vs), ground and 5V logic power supply(Vss).

NOTE

The L298N motor driver IC actually has two input power pins viz. ‘Vss’ and ‘Vs’.

From Vs pin the H-Bridge gets its power for driving the motors which can be 5 to 35V. Vss is used for driving the logic circuitry which can be 5 to 7V. And they both sink to a common ground named ‘GND’.

The module has an on-board 78M05 5V regulator from STMicroelectronics. It can be enabled or disabled through a jumper.

When this jumper is in place, the 5V regulator is enabled, supplying logic power supply(Vss) from the motor power supply(Vs). In this case, 5V input terminal acts as an output pin and delivers 5V 0.5A. You can use it to power up the Arduino or other circuitry that requires 5V power supply.

When the jumper is removed, the 5V regulator gets disabled and we have to supply 5 Volts separately through 5 Volt input terminal.

WARNING

You can put the jumper in place, if the motor power supply is below 12V. If it is greater than 12V, you should remove the jumper to avoid the onboard 5V regulator from getting damaged.

Also DO NOT supply power to both the motor power supply input and 5V power supply input when jumper is in place.

Voltage Drop of L298N

The voltage drop of the L298N motor driver is about 2V. This is due to the internal voltage drop in the switching transistors in the H-Bridge circuit.

So, if we connect 12V to the motor power supply terminal, the motors will receive voltage around 10V. This means that a 12V DC motor will never spin at its maximum speed.

To get maximum speed out of motor, the motor power supply should be bit higher voltage(2V) than motor’s actual voltage requirement.

Considering the voltage drop of 2V, if you are using 5V motors you’ll need to provide 7V at motor power supply terminal. If you have 12V motors then your motor supply voltage should be 14V.

Output Pins

The L298N motor driver’s output channels for the motor A and B are broken out to the edge of the module with two 3.5mm-pitch screw terminals.

You can connect two DC motors having voltages between 5 to 35V to these terminals.

Each channel on the module can deliver up to 2A to the DC motor. However, the amount of current supplied to the motor depends on system’s power supply.

Control Pins

For each of the L298N’s channels, there are two types of control pins which allow us to control speed and spinning direction of the DC motors at the same time viz. Direction control pins & Speed control pins.

Direction Control Pins

Using the direction control pins, we can control whether the motor spins forward or backward. These pins actually control the switches of the H-Bridge circuit inside L298N IC.

The module has two direction control pins for each channel. The IN1 and IN2 pins control the spinning direction of the motor A while IN3 and IN4 control motor B.

The spinning direction of a motor can be controlled by applying either a logic HIGH(5 Volts) or logic LOW(Ground) to these inputs. The below chart illustrates how this is done.

Controlling motor’s spinning direction with control inputs
Input1Input2Spinning Direction
Low(0)Low(0)Motor OFF
High(1)Low(0)Forward
Low(0)High(1)Backward
High(1)High(1)Motor OFF

Speed Control Pins

The speed control pins viz. ENA and ENB are used to turn the motors ON, OFF and control its speed.

Pulling these pins HIGH will make the motors spin, pulling it LOW will make them stop. But, with Pulse Width Modulation (PWM), we can actually control the speed of the motors.

The module usually comes with a jumper on these pins. When this jumper is in place, the motor is enabled and spins at maximum speed. If you want to control the speed of motors programmatically, you need to remove the jumpers and connect them to PWM-enabled pins on Arduino.

L298N Motor Driver Module Pinout

Before diving into hookup and example code, let’s first take a look at its Pinout.

VCC pin supplies power for the motor. It can be anywhere between 5 to 35V. Remember, if the 5V-EN jumper is in place, you need to supply 2 extra volts than motor’s actual voltage requirement, in order to get maximum speed out of your motor.

GND is a common ground pin.

5V pin supplies power for the switching logic circuitry inside L298N IC. If the 5V-EN jumper is in place, this pin acts as an output and can be used to power up your Arduino. If the 5V-EN jumper is removed, you need to connect it to the 5V pin on Arduino.

ENA pins are used to control speed of Motor A. Pulling this pin HIGH(Keeping the jumper in place) will make the Motor A spin, pulling it LOW will make the motor stop. Removing the jumper and connecting this pin to PWM input will let us control the speed of Motor A.

IN1 & IN2 pins are used to control spinning direction of Motor A. When one of them is HIGH and other is LOW, the Motor A will spin. If both the inputs are either HIGH or LOW the Motor A will stop.

IN3 & IN4 pins are used to control spinning direction of Motor B. When one of them is HIGH and other is LOW, the Motor B will spin. If both the inputs are either HIGH or LOW the Motor B will stop.

ENB pins are used to control speed of Motor B. Pulling this pin HIGH(Keeping the jumper in place) will make the Motor B spin, pulling it LOW will make the motor stop. Removing the jumper and connecting this pin to PWM input will let us control the speed of Motor B.

OUT1 & OUT2 pins are connected to Motor A.

OUT3 & OUT4 pins are connected to Motor B.

Motor Driver

Wiring L298N motor driver module with Arduino UNO

Now that we know everything about the module, we can begin hooking it up to our Arduino!

Start by connecting power supply to the motors. In our experiment we are using DC Gearbox Motors(also known as ‘TT’ motors) that are usually found in two-wheel-drive robots. They are rated for 3 to 12V. So, we will connect external 12V power supply to the VCC terminal. Considering internal voltage drop of L298N IC, the motors will receive 10V and will spin at slightly lower RPM. But, that’s OK.

L293d Motor Driver Module Datasheet

Next, we need to supply 5 Volts for the L298N’s logic circuitry. We will make use of the on-board 5V regulator and derive the 5 volts from the motor power supply so, keep the 5V-EN jumper in place.

Motor

Now, the input and enable pins(ENA, IN1, IN2, IN3, IN4 and ENB) of the L298N module are connected to six Arduino digital output pins(9, 8, 7, 5, 4 and 3). Note that the Arduino output pins 9 and 3 are both PWM-enabled.

Finally, connect one motor to terminal A(OUT1 & OUT2) and the other motor to terminal B(OUT3 & OUT4). You can interchange your motor’s connections, technically, there is no right or wrong way.

When you’re done you should have something that looks similar to the illustration shown below.

Arduino Code – Controlling a DC Motor

The following sketch will give you complete understanding on how to control speed and spinning direction of a DC motor with L298N motor driver and can serve as the basis for more practical experiments and projects.

L293d Motor Driver Module Price In Bd

Code Explanation:

The arduino code is pretty straightforward. It doesn’t require any libraries to get it working. The sketch starts with declaring Arduino pins to which L298N’s control pins are connected.

In setup section of code, all the motor control pins are declared as digital OUTPUT and pulled LOW to turn both the motors OFF.

L293d Motor Driver Module Working

In loop section of the code we call two user defined functions at an interval of a second. These functions are:

L293d Motor Driver Module Fritzing

  • directionControl() – This function spins both motors forward at maximum speed for two seconds. It then reverses the motor’s spinning direction and spins for another two seconds. Finally it turns the motors off.
  • speedControl() – This function accelerates both the motors from zero to maximum speed by producing PWM signals using analogWrite() function, then it decelerates them back to zero. Finally it turns the motors off.

Comments are closed.