apogeeweb title
Home  Technical Articles   L298

Oct 16 2020

L298: DC Motor Control| PWM Speed Regulation

I Description

This blog introduces the working principle of the L298-based direct PWM speed control system. At the same time, the software and hardware components of the system are also given. The running test in the latter part of the blog shows that this L298-based direct PWM speed control system works stably and reliably. Moreover, the speed regulation requirements of DC motors can be met.

L298 Motor Control Arduino Tutorial


I Description

II Introduction

III Working Principle of DC Household WM Speed Control System

IV Introduction to L298

V Software Implementation of PWM Speed Regulation

VI Conclusion


II Introduction

For a long time, because DC motors have the following characteristics:

  • Good linear speed regulation characteristics;
  • Simple control function;
  • Higher efficiency
  • Excellent dynamic characteristics.

Therefore, the DC motor is widely used in speed control.

Especially with the development of computers in the field of human control and the development of high switching frequency, fully controlled second-generation power semiconductor devices (GTR, GTO, MOS inkstone T, IGBT, etc.), the pulse width modulation (PWM) DC speed control system is in It is more and more commonly used in speed control.

III Working Principle of DC Household WM Speed Control System

The PWM speed control device uses the switching characteristics of high-power transistors to modulate a fixed-voltage DC power supply, and switches on and off at a fixed frequency. Then, change the length of the "on" and "off" time in a cycle as needed. By changing the "duty cycle" of the voltage on the armature of the DC servo motor, the average voltage can be changed to control the motor speed.

Therefore, this device is also called a "switch drive device."

PWM control diagram

Figure 1. PWM control diagram

The schematic diagram of PWM control is shown in Figure 1. The controllable switch S is repeatedly turned on and off at certain time intervals. When S is connected, the power supply Us is applied to both ends of the motor through the switch S, the power supply provides energy to the motor, and the motor stores energy. When the switch S is off, the power supply Us is interrupted to provide electrical energy to the motor. But the energy stored in the armature inductance during the switch S is on. At this time, the motor current continues to flow through the freewheeling diode VD.

The voltage waveform obtained at both ends of the motor is shown in Figure 2, and the average voltage Uav can be expressed by the following formula:


  • ton: The time when the switch is turned on each time;
  • T: Short time period when the switch is on;
  • α: Duty cycle.

It can be seen from the above formula that changing the ratio of the switch-on time ton to the switching period T, that is, changing the duty cycle of the pulse. The average voltage across the motor also changes accordingly. Thus, the motor speed is controlled.

PWM control waveform

Figure 2. PWM control waveform

There are two modulation methods for changing the duty cycle:

  • One is that the switching period is constant, and the duty cycle is changed by changing the on-pulse width. That is pulse width modulation.
  • Another way is to have a constant turn-on pulse width and change the duty cycle by changing the switching frequency (f=1/T). That is pulse frequency modulation.

Since PFM control relies on the pulse frequency to change the duty cycle, when it encounters a mechanical resonance at a particular frequency, it often results in system vibration and audio whistling. This serious shortcoming makes PFM control unsuitable in servo systems. At present, the control of DC motors is mainly based on the application of PWM control.

IV Introduction to L298

L298 is a dual H-bridge high-voltage high-current power integrated circuit, which directly uses ITL logic level control. It can be used to drive inductive loads such as relays, coils, DC motors, and stepping motors. Its driving voltage can reach 46V, and the total DC current can reach 4A. There are two identical PWM power amplifier circuits inside.

The internal structure of L298 is shown in Figure 3.

Hardware composition diagram of PWM speed controller

Figure 3. Hardware composition diagram of PWM speed controller

According to the input and output relationship of L298, the enable control terminal EnA is connected to the P1.0 port of the AT89C52. For the PWM signal, the input terminal In2 is low level, the motor rotates forward; the input terminal In2 is the PWM signal, input terminal In1 is recorded as low level, the motor reverses).

When it is low level, the 4 transistors on the drive bridge are all cut off, so that the armature current of the running motor is reversed and the motor stops freely. The speed of the motor is realized by adjusting the duty ratio of the PWM signal by the single-chip microcomputer.

V Software Implementation of PWM Speed Regulation

In terms of program design, the generation of the PWM pulse signal of the MCU can use the following two methods: software delay and timer delay.

Although software delay is easier to implement, in theory, it occupies too much system resources and is inconvenient to use.

The PWM speed controller uses the timer 0 interrupt mode to generate PWM pulse, and the PWM control subroutine is the interrupt service routine of timer 0. At the same time, it also generates a sampling period, that is, the Anzhao sampling period starts A/D conversion. Its program flow chart is shown as in Fig. 4.

Program flow chart

Figure 4. Program flow chart

VI Conclusion

Based on the L298 DC motor PWM speed regulator, the 1/0 port of the A8T9C52 microcontroller outputs the PWM signal, and directly uses the TTL level to control the drive chip L298 to adjust the motor speed. It is simple and convenient to control.

And the experiment shows that the system works stably and reliably, satisfies the functional requirements of speed regulation, and has great theoretical and practical value.


  • What is l298n?

This L298N Motor Driver Module is a high power motor driver module for driving DC and Stepper Motors. This module consists of an L298 motor driver IC and a 78M05 5V regulator. L298N Module can control up to 4 DC motors, or 2 DC motors with directional and speed control.

  • What is the use of l298n?

The L298N is a dual H-Bridge motor driver which allows speed and direction control of two DC motors at the same time. The module can drive DC motors that have voltages between 5 and 35V, with a peak current up to 2A.

  • How does l298n control DC motor speed?

1.If you send a HIGH signal to the enable 1 pin, motor A is ready to be controlled and at the maximum speed;

2.If you send a LOW signal to the enable 1 pin, motor A turns off;

3.If you send a PWM signal, you can control the speed of the motor. The motor speed is proportional to the duty cycle.

  • What is l298n motor driver module?

This L298N Motor Driver Module is a high power motor driver module for driving DC and Stepper Motors. This module consists of an L298 motor driver IC and a 78M05 5V regulator. L298N Module can control up to 4 DC motors, or 2 DC motors with directional and speed control.

  • How does l298n motor driver work?

The L298N is a dual H-Bridge motor driver which allows speed and direction control of two DC motors at the same time. The module can drive DC motors that have voltages between 5 and 35V, with a peak current up to 2A.

  • How do i use a l298 motor driver with 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.

  • What is the function of H bridge?

An H-bridge is an electronic circuit that switches the polarity of a voltage applied to a load. These circuits are often used in robotics and other applications to allow DC motors to run forwards or backwards.

  • What is the difference between l293d and l298n?

L293 is quadruple half-H driver while L298 is dual full-H driver, i.e, in L293 all four input- output lines are independent while in L298, a half H driver cannot be used independently, only full H driver has to be used. ... Hence, heat sink is provided in L298.


Related Articles

0 comment

Leave a Reply

Your email address will not be published.