Xilinx Inc.
IC CPLD 144MC 7.5NS 144TQFP
Ⅱ. Functional features of L298N
Ⅴ. Pin diagram and functions of L298N
Ⅶ. How to use PWM to regulate the speed of the motor?
Stepper motors play an important role in many embedded systems. As a commonly used motor drive module, the L298N module can effectively control the movement of stepper motors. L298N has the characteristics of low heat generation, strong driving capability, large output current, high working voltage, and strong anti-interference ability. It is usually used to drive solenoids, solenoid valves, relays, DC motors and stepper motors. Below we will introduce the characteristics, pin functions and usage of L298N in detail.
L298N is a vertical package version of L298. It is a dual-channel full-bridge motor driver chip that can accept high voltage and high current. Its working voltage can reach 46V, and its maximum output current is 4A. In addition, L298N also has two enable control terminals. These control terminals allow the working mode of the circuit to be dynamically adjusted by plugging and unplugging the onboard jumper without being interfered by the input signal. The L298N is equipped with a logic power input, which allows the internal logic circuit portion to operate at low voltage. At the same time, it can also output a logic voltage of 5V externally. In order to avoid damage to the voltage stabilizing chip, when using a driving voltage higher than 12V, it is strongly recommended to use an external 5V interface for independent power supply.
L298N controls the I/O input terminal on the main control chip and adjusts the output voltage directly through the power supply to realize the forward, reverse and stop of the motor. Normally, L298N can directly drive relays (four-way), solenoids, solenoid valves, two DC motors and one stepper motor (two-phase or four-phase).
Alternatives and equivalents:
• E-L298N
• L298HN
• LM18298T
1. Logic input compatibility: The logic input of L298N is compatible with TTL, CMOS and other logic levels.
2. Overheating protection: L298N has overheating protection function. When the chip temperature is too high, it will automatically disconnect the output.
3. Built-in free polarity diode: L298N has a built-in free polarity diode, which can be used for braking of DC motors.
4. Large current output: L298N can provide large output current and is suitable for some applications that require large driving current.
5. Double H-bridge structure: L298N integrates a double H-bridge structure, which can control the steering and speed of two DC motors or stepper motors.
The circuit diagram of L298N is as follows:
OUT1, OUT2 and OUT3, OUT4 are connected to Motor1, Motor2; IN1, IN2, IN3, IN4 pins from the microcontroller to access the control level, to control the motor forward and reverse; ENA, ENB connected to the control of the enable terminal, to control the speed of the motor. The L298N control logic relationship diagram is as follows:
Regarding the motor speed regulation, we have adopted the PWM speed regulation method. The principle lies in realizing the speed regulation by controlling the conduction time T of the switching tube in one cycle. The average voltage U across the motor during a complete cycle T can be expressed as U = Vcc × (t/T) = a × Vcc. Where, a = t/T, is known as the duty cycle and Vcc represents the supply voltage. The speed of the motor is proportional to the voltage across the motor, while the voltage across the motor is proportional to the duty cycle of the control waveform. Therefore, there is a proportional relationship between the speed of the motor and the duty cycle: the higher the duty cycle, the faster the speed of the motor.
When using L298N, we need to input control signals to IN1, IN2, IN3 and IN4 to control the forward and reverse rotation and speed of the motor. Here are several control methods:
1. PWM control mode
PWM mode can effectively control the speed of the motor. When using PWM mode, we need to use the two pins EN1 and EN2 to adjust the speed of the motor. Specifically, when the EN1 and EN2 pins are at high level, the motor will operate normally; when they are at low level, the motor will stop rotating.
2. One-way control mode
When IN1, IN2, IN3 and IN4 are high level at the same time, the motor rotates forward; when any two input ports are high level and the other two input ports are low level, the motor rotates reversely.
3. Bidirectional control mode
When using the bidirectional control mode, IN1 and IN2 are responsible for controlling motor 1, while IN3 and IN4 are responsible for controlling motor 2. Specifically, when IN1 is high level and IN2 is low level, motor 1 will rotate forward; conversely, when IN1 is low level and IN2 is high level, motor 1 will rotate reversely. In the same way, the control logic of IN3 and IN4 is also applicable to the forward and reverse rotation control of motor 2.
1. Power pin
VS: supply voltage input (up to 46V)
GND: ground pin
2. Logic control pin
IN1, IN2: used to control the rotation direction of motor 1
IN3, IN4: used to control the rotation direction of motor 2
3. Motor control pin:
OUT1, OUT2: used to control the direction of motor 1
OUT3, OUT4: used to control the direction of motor 2
ENA: enable pin, used to control the speed of motor 1
ENB: enable pin, used to control the speed of motor 2
1. Connect the power supply: The power supply of the L298N driver module should be kept in the range of 12V to 35V. In practical applications, in order to ensure the stability of the power supply, we may also need to filter the power supply.
2. Connect the motors: We connect the two motors to the output pins of the L298N through the driver, and the control level is directly input to the motor through the L298N.
3. Control L298N: We use the control port (enable, control pin) to control the L298N. We need to set the status of the enable port and control pin when assigning values. These statuses will determine the level status of the L298N output. By changing these states, we can effectively control the forward and reverse rotation and speed of the motor.
If we want to use PWM to regulate the speed of the motor, we have two wiring methods:
1. Wiring method one (recommended):
We remove the jumper cap between channel enable and 5V, connect the enable pin to the PWM pin of Arduino, and connect pins 1 and 2 to the two normal pins of Arduino. In this way, we can control the switch of the channel through the PWM pin to adjust the speed of the motor; by controlling the level status of pins 1 and 2, we can control the rotation direction of the motor. This way of wiring does only require the use of one PWM pin per channel, but takes up two normal pins. Therefore, in practical applications, we need to weigh and choose among multiple wiring methods based on the number of pins available on the Arduino.
2. Wiring method two (not recommended):
We do not remove the jumper between channel enable and 5V, so the channel will remain continuously open. Then, we connected pins 1 and 2 to the two PWM interfaces of Arduino respectively. By controlling the outputs corresponding to these two pins respectively, we can control the motor rotation direction and speed. Obviously, this wiring method will occupy more PWM pins, because each channel requires two PWM pins to control. However, this method does not occupy any common pins. Therefore, we do not recommend using this wiring scheme when PWM pin resources are tight.
1. Electric vehicles: L298N can be used to control the drive motors in electric vehicles, such as electric bicycles, scooters, etc. For example, in bicycles, by precisely controlling the rotation speed and direction of the motor, L298N can achieve acceleration, deceleration and stable driving of electric bicycles. The rider can transmit instructions to the L298N by operating the handle or buttons, thereby controlling the output of the motor to make the bicycle drive according to the rider's wishes.
2. Automated industrial equipment: In the field of industrial automation, L298N can be used to control the motors of various industrial equipment, such as conveyor belts, robotic arms, industrial robots, etc. For example, in the robotic arm, the L298N accurately controls the rotation angle and speed of the motor, allowing the robotic arm to move according to a predetermined trajectory and achieve high-precision operation. This not only improves production efficiency, but also reduces production losses caused by operational errors.
3. Robot technology: L298N is often used in robot projects to control the drive motor to realize the movement and action of the robot. Industrial robots often need to undertake heavy-load, high-precision work, and have extremely high requirements on drive motors. L298N provides powerful power support for industrial robots with its excellent driving capability and stability. Whether it is handling, assembly or inspection, L298N can ensure that industrial robots complete tasks accurately and efficiently.
4. Smart home: In smart home systems, L298N can be used to control the motors of blinds, curtains, doors and other equipment to achieve automated control. By combining with sensors, home equipment can be automatically adjusted according to lighting, temperature and other conditions.
5. Solar tracking system: In solar systems, L298N can be used to control the tilt angle of solar panels to implement a solar tracking system. Through the control of L298N, the solar tracking system can sense the position changes of the sun in real time and adjust the tilt angle of the solar panels accordingly. This dynamic adjustment process ensures that the solar panels always maintain the optimal angle to the sun, thereby improving the energy collection efficiency of the solar panels.
Frequently Asked Questions
1. Can L298N control speed?
The L298N is a dual H-Bridge motor driver which allows speed and direction control of two DC motors at the same time.
2. Why is my L298N not working?
It must be above 4.5V for correct operation of the L298. 2. You will lose perhaps 2.5V across the L298. Maybe there isn't enough voltage left to run the motor.
3. What is the L298N?
The L298N Motor Driver is a controller that uses an H-Bridge to easily control motors direction and PWM to control the speed. This module allows you to independently manage two motors of up to 2A each in both directions. Supply range may vary between 5V and 35V, enough for most DC motor projects.
4. Can we connect 4 motors to L298N?
The answer is Yes and No. It depends on how you use the L298N motor driver. The L298N originally designed for controlling two DC motors or one Stepper motor. But, if you do not want each motor rotate backward, then you can use each side of L298N driver to control two DC motors, and a total of 4 motors.