blog

A Brief Discussion on the Principle and Usage of the L298N Module

Top of L298N module

What is L298N Module?

L298N Module is specially designed for motor controlling.

The current required for machine startup normally is more than 1A, even the running current, it also need 100mA and most controllers can only output 20mA current.

If the motor is driven directly, it may burn out the controller directly. And when the motor shuts down suddenly, it would generates a large voltage. If without additional control circuit, it can break down the integrated circuit.

However, the L298N Module could make the motor obtain a larger voltage and current, generate more kinetic energy, while separating the microcontroller from the motor, preventing the microcontroller from being broken down.

L298N Working Principle

There are Two H-bridge circuit, which integrated internally of L298N, each of them controls a motor.

The H-bridge consists of four switching tubes, which shaped like the letter “H”, normally two switching tubes are for one group. Two switching tubes in a group are connected in series.

By connecting the power supply in parallel, the outputs are drawn at the middle connection of the two switching tubes, and the input signals of the two switching tubes are inverse.

Which means when one is turned on and the other is turned off, it could realize the control of output voltage (supply voltage or GND connection). By changing the input signal can make the motor in forward rotation, reverse rotation or stop without changing the circuit.

H-bridge schematic diagram
The internal structure of L298N 2

Taking the motor in right as an example, when the jumper cap is not pulled up,  EN A is connected to the 5V power supply, and assuming that IN1 inputs a high level and IN2 inputs a low level, the motor is in forward rotation.

If IN1 inputs a low level and IN2 inputs a high level, then the motor will in reverse rotation.

If IN1 and IN2 inputs are the same, there is no potential difference between the two ports, then the motor will stop rotating. (Normally it is low level input. It may cause instability while high level input).

L298N Interface&Parameter

Pin of L298N module

Function Introduction

  • 12V Input is the power input interface, which is used for an external power supply to the L298N.
  • 5V Output is the power output interface, which can be used to supply power to the Arduino microcontroller.
  • The GND interface is a ground level interface, which can be used to connect to the negative terminal (GND) of the power supply or the GND of the Arduino.
  • IN(1,2,3,4) is the input port of signal, which can be used to connect to the signal output port of Arduino, raspberry pi and other microcontrollers to control the high and low levels of the output, thereby controlling the forward and reverse rotation of the motor.
  • OUT A and OUT B are output ports, which can be used to connect to the motor. Enable is the enable port, high level is valid. Only when 5V voltage is connected, the output port work.

Interface Parameter

Parameter name

VALUE

VD Logic Input Voltage VD

DC: 4.5V~7V

Driver Input Voltage VS

DC: 5~46V

Driver Working Current Io

0A~2A

Max. Power Dissipation

25W(T=75°C)

High Level Range

2.3V~5V

Low Level Range

-0.3V~1.5V

Working Temperature

-25°C~+130°C

Size

43mm X 43mm

Weight

29g

Usage Instruction

Arduino Drive DC Motor

Wiring

L298N Drive Wiring Diagram for DC Motor

Arduino Sample Code

				
					void setup() {
  pinMode(2, OUTPUT);   //sign out
  pinMode(3, OUTPUT);   //PWM out,Arduino has built-in PWM function
  pinMode(13, OUTPUT);  //led
  digitalWrite(2,0);            //initialize
  digitalWrite(3,0);	       //It is recommended to use a low level when the motor stops
}
void loop() {
  digitalWrite(2,0);//stop
  delay(3000);
  for(int i=0;i<255;i++)   //Accelerate through PWM
  {
    analogWrite(3,i);
    delay(10);
  }
  analogWrite(3,255);    //max speed
  delay(5000);
  analogWrite(3,30);	  //PWM speed regulation
  delay(5000);
  analogWrite(3,0);//stop
  delay(3000);	  //Wait at least 100ms before reversing the motor
  digitalWrite(2,1);	  //Output inversion
  delay(5000);
}
				
			

Stepper Driver Motor

Wiring

L298N Circuit Diagram for Driving Stepper Motor

How to determine the common line: Use a multimeter to measure the resistance between the wires. The resistance between the common line and other wires is approximately half of the resistance between the other wires. For example, if the resistance between wire A and wire B is 25Ω, then the resistance between the common line and wire A or wire B is approximately 12.5Ω.

Sample Code

				
					void setup() {
  pinMode(2,OUTPUT);//Stepper motor signal pin
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  delay(20);
  digitalWrite(2,0);//Turn off output
  digitalWrite(3,0);
  digitalWrite(4,0);
  digitalWrite(5,0);
}
int t=2;//Set selection speed
void loop() {
  digitalWrite(2,1);//Drive stepper motor
  digitalWrite(3,0);
  digitalWrite(4,0);
  digitalWrite(5,0);
  delay(t);
  digitalWrite(2,0);
  digitalWrite(3,1);
  digitalWrite(4,0);
  digitalWrite(5,0);
  delay(t);
  digitalWrite(2,0);
  digitalWrite(3,0);
  digitalWrite(4,1);
  digitalWrite(5,0);
  delay(t);
  digitalWrite(2,0);
  digitalWrite(3,0);
  digitalWrite(4,0);
  digitalWrite(5,1);
  delay(t);
}
				
			

L298N VS L293D

Model

L298N

L293D

Cost

High cost due to many peripheral parts

Low cost

Power

Max. Current can reach 2A

Current is only 0.6A at same voltage

Design

More complex peripheral circuit and and heat dissipation design

Only simple circuit design and the addition of a reewheeling diode

Supported Voltage Range

5V-46V

5V-35V

Heat Dissipation

Higher power, heat sinks must be used and if necessary cooling fans need to be installed

Lower power, according to the actual situation, can consider to install heat sinks

Efficiency

30% ~ 70%

50% ~ 90%

Temperature

-25 ~ 130 °C

0 ~ 70°C

Related Downloads

Download Link:

        L298N Datasheet 

        L293D Datasheet

FAQ

  • Can L298N control speed?

The L298N cannot control the speed when the input signal and input voltage are constant.

If want to control the speed, need to change the input signal from a fixed digital signal (5V or connected to GND) to a PWM signal, and adjust the rotation speed by adjusting the duty cycle of the PWM.

The principle is to turn on the motor one moment and them turn off one moment. During the period of power off, the motor will not stop immediately because of inertia, but it will slowly decelerate. During the period of power on, it will slowly accelerate, when the frequency is fast enough, the motor as a whole can maintain a relatively stable and controllable speed.

  • Can L298N control 4 motors or stepper motor?

Yes, due to the unique internal H-bridge structure and the design of the control circuit, L298N can individually control each output pin.

Each motor can be controlled by connecting one of the pins to the OUT pin of the module, and connecting the other end to the power supply or GND (the voltage cannot exceed the specified voltage of the module, such as 35V),  but the forward and reverse rotation cannot be controlled.

If want to control the stepper motor (five four-wire system), need to control the pin output in turn through Arduino or other microcontroller.

  • How many volts can L298N handle?

Due to the different design of module manufacturers, the max. voltage is usually around 35V-46V. Under normal circumstances of usage, 5V or 12V power supply is used. It need partial adjustment when power supply voltage more than 12V.

  • What is a H-bridge of L298N?

The H-bridge is a special type of circuit, it consists of four switching tubes and is named because shaped like the letter “H”.

Normally two switching tubes are for one group, two switching tubes in a group are connected in series.

By connecting the power supply in parallel, the outputs are drawn at the middle connection of the two switching tubes, and the input signals of the two switching tubes are inverse.

Which means, when one is turned on and the other is turned off, it can realize the control of output voltage (supply voltage or GND connection). By changing the input signal can make the motor in forward rotation, reverse rotation or stop without changing the circuit.

  • Is L298N a relay?

No, although the L298N also has the function of switching, but through its internal circuit design, it has a certain output control capability. While the relay just can only be on and off, and the switching frequency is very low, which can not use PWM for speed regulation.

  • How to control motor without motor driver?

Can connecting the switching tube in series with the motor, and installing a freewheeling diode. The overall design difficulty is high, If need to forward, reverse and also build the H-bridge circuit for control. It is recommended to use the L298N Module directly for control, which is convenient and fast.

  • L298N motor driver not working

Following are the possible reasons why the L298N does not work:

  1. Insufficient Power Supply: the lowest operating voltage of L298N is 5V and during operation, the current is relatively high. But some power supplies, such as AM1117, can only output 3.3V and the current is small (<1A). When failure of normal operation is caused by insufficient driving ability, it is recommended to replace the power supply with higher voltage and current.
  2.  Insufficient Signal Strength: output signal voltage of some microcontroller is 3.3V. And due to the wire is too long, the voltage of the signal is further reduced, much lower than 4.5V, the min. voltage of the control signal of the L298N. Or the signal of GND is not connected. Or there is no common zero-potential reference point, the module can not identify the signal voltage.  These can cause that the L298N can not identify the control signal and therefore cannot output normally.

  3. The integrated circuit or module is damaged.

  • What is the difference between a motor driver and a motor controller?

The motor driver can only drive the motor, while the motor controller can not only drive the motor, but also can control the speed of the motor and the forward and reverse rotation of the motor. The motor controller is much more powerful.

  • If there are more questions, please visit the forum.

Purchase Link

Leave a Reply

Your email address will not be published. Required fields are marked *