L298N Motor Drive Controller Board Module. L298N Motor Drive Controller Board Module for Arduino. Free Shipping Worldwide. The L298N is a motor driver IC by ST Microelectronics. Mounted on an easy-to-use module, the L298N follows an H-bridge configuration for easily changing the direction of a DC motor. It also allows easy motor speed control. The L298N motor drive is also capable of controlling stepper motors.
![]()
Let us continue exploring Raspberry Pi and its features by Interfacing L298N Motor Driver with Raspberry Pi and control a DC Motor with the help of a Python Script. In this project, we will learn about L298N Motor Driver and how the Raspberry Pi L298N Motor Driver Module Interface works.
Overview
Interfacing L298N Motor Driver Module with Raspberry Pi will allow us to control a DC Motor (in fact, you can control two DC Motors).
When I say control a DC Motor, I mean you can start a motor, stop it, make it rotate in forward direction, backward directions, increase the speed of rotation and also decrease the speed.
For this, I’ll be using the L298N Motor Driver Module. If you remember, I have already made a project on CONTROLLING A DC MOTOR WITH RASPBERRY PI using L293D Motor Driver.
How different will it be for controlling a DC Motor using Raspberry Pi with L293D and L298N? Well, there won’t be much of a difference as essentially both these modules serve the same purpose.
But it is always nice to learn about something new and implement it into a project. So, first, let me take you through a simple introduction to L298N Motor Driver Module.
L298N Motor Driver Module
In recent times, L298N Motor Driver Module has become the favorite choice of hobbyists and makers when it comes to DC Motor Control. It became so popular that the module is now available at a very low cost.
The L298N Motor Driver Module is based on the powerful L298N Motor Driver IC. The pin diagram of the L298N Motor Driver IC is shown in the image below. This IC, along with few other extra components make up the L298N Motor Driver Module.
The above image shows the L298N Motor Driver Module with names of all the components on it. To name a few, it contains screw terminals for connecting motors and power supply, male headers for connecting different pins like enable, IN1, IN2 etc.
NOTE:
![]()
Circuit Diagram of Raspberry Pi L298N Interface
The following image shows the circuit diagram of the Raspberry Pi L298N Motor Driver Module Interface. The circuit diagram is made with the help of Fritzing App.
Components Required
Circuit Design
The design of the Raspberry Pi L298N Motor Driver Interface Circuit is very simple. First connect 12V Power Supply to L298N Motor Driver Module. Then, make the GND terminals of Raspberry Pi and L298N Motor Driver Module common (connect them together).
Now, since we are controlling a single DC Motor, we need to use a single channel of the L298N. In order to do that, connect the ENA pin of L298N to Physical Pin 22 (GPIO25) of Raspberry Pi.
Coming to the Inputs of the Motor, connect the IN1 and IN2 of L298N Module to Physical Pins 16 and 18 (GPIO23 and GPIO24). That’s it. The rest of the job is done by the Python Script.
Code
The Python Script for Interfacing L298N Motor Driver Module with Raspberry Pi is given below. We will see the explanation of the code in the Working Section.
Working of the Project
If you take a look at the code carefully, you can easily understand the working of the project. After creating the Python Script with the above code, run the script.
You will get a message regarding the default speed and direction of the Motor. This is followed by a list of commands you must use to control the motor. These commands are given below.
I think the commands are self-explanatory.
Applications
Related Posts:Specifications
The onboard 78M05 linear regulator provided a stable 5V (up to 0.5A) that can be used to power the L298N H-bridge and other parts.
L298N block diagramL298N pin connectionsLogic table
L=Low, H=High, X=Don’t care, Z=High impedance, Vin=Input voltage, Vdrop=Voltage drop
Note: There is a voltage drop between the input voltage and the L298’s motor outputs, you can expect a 1V to 3V drop depend on the input voltage and current draw.
SchematicHow to Control DC Motors
The first DC motor is connected to Out1 and Out2 of the Motor Driver Controller Board which is controlled by In1 & In2. Set In1=HIGH and In2=LOW cause the motor to go forward, reverse the input signal (In1=LOW, In2=HIGH) cause the motor to go backward. Set both In1 & In2 to LOW make the motor stop immediately.
ENA is HIGH by default that make the motor running at a constant speed. In order to control the speed of the motor, the jummper must removed from EnA, then connect it to PWM capable digital output of a micro-controller.
In certain circumstances, ENA is connected to a non-PWM digital output of the micro-controller in order to stop the motor slowly.
The above connections and methods can be applied to controlling the second DC motor.
Controlling DC Motors with an Arduino
By connecting the L298N Motor Driver Controller Board to an Arduino, you can control two DC motors. Code below is the Arduino sketch that control two motors at a constant speed.
Controlling Motors speed with an Arduino
Sketch below control the speed of two DC motors.
Please remove the jumper from ENA & ENB, ENA & ENB is then connected to Digital 9 and Digital 10 respectively.
Stepper Motor Basics
There are two types of stepper motors: unipolar and bipolar stepper motors. A unipolar stepper motor only operates with positive voltage (requiring only one power source, e.g. 5V and 0). A bipolar stepper motor has two polarities (requiring two power sources, e.g. 2.5V and -2.5V).
Stepper Modes
Stepper motors can be driven in different patterns or sqeunces.
Note: The L298N only work with bipolar stepper motor, It would not work with unipolar stepper motor.
Controlling Bipolar Stepper Motors with an Arduino
There is a stepper library allows you to control unipolar or bipolar stepper motors, please click here for more information.
Related article
I also wrote an article on how to use a wireless router to control the L298N Module, please click here for details.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |