0% found this document useful (0 votes)
21 views4 pages

Reviewer Robotics

The document provides a tutorial on interfacing the L298N DC Motor Driver Module with Arduino for controlling DC motors. It explains the use of PWM for speed control and H-Bridge for direction control, detailing the connections and pin functions necessary for operation. Additionally, it includes wiring instructions and cautions regarding power supply configurations for optimal performance.

Uploaded by

jamodiongjulia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Reviewer Robotics

The document provides a tutorial on interfacing the L298N DC Motor Driver Module with Arduino for controlling DC motors. It explains the use of PWM for speed control and H-Bridge for direction control, detailing the connections and pin functions necessary for operation. Additionally, it includes wiring instructions and cautions regarding power supply configurations for optimal performance.

Uploaded by

jamodiongjulia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ROBOTICS

Interface L298N DC Motor Driver Module with Arduino


https://lastminuteengineers.com/l298n-dc-stepper-driver-arduino-tutorial/

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.

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)
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).
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 switches at the same time reverses the polarity of
the voltage applied to the motor. This causes change in
spinning direction of the motor.
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.

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.

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.

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.

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.
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.
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.
Wiring DC motors to L298N motor driver & Arduino

You might also like