Post Top Ad

Wednesday, April 5, 2023

on video Control Position and Speed of Stepper motor with L298N module using Arduino


 Control Stepper Motor with L298N Motor Driver & Arduino

If you are planning on assembling your new robot, you will eventually want to learn how to control stepper motors. The easiest and inexpensive way to control stepper motors is to use the L298N motor driver. It can control both the speed and the spinning direction of any small to medium sized bipolar stepper motor such as the NEMA 17.


If you wish to control multiple stepper motors, it is recommended that you use a self-contained dedicated stepper motor driver such as the A4988. If you want to know more about it, check this tutorial out.


Controlling a Stepper Motor With an H-Bridge

The L298N module has two H-Bridges. Each H-bridge drives one of the electromagnetic coils of a stepper motor.


By energizing these electromagnetic coils in a specific sequence, the shaft of the stepper can be moved forward or backward precisely in small steps.


However, the speed of the motor is determined by how frequently these coils are energized.

L298N Motor Driver Chip

At the center of the module is a big, black chip with a chunky heat sink – the L298N, from ST Semiconductor.

Inside the L298N chip, you’ll find two standard H-bridges capable of driving a pair of DC motors or a single stepper motor.


The L298N motor driver has a supply range of 5V to 35V and is capable of supplying 2A continuous current per coil, so it works very well with most of our stepper motors.

Each channel of the module can deliver up to 2A to the stepper motor. However the amount of current supplied to the motor depends on the power supply of the system.


Control Pins

Using the four control pins IN1, IN2, IN3 and IN4, you can control both the speed and the spinning direction of the stepper motor. These pins actually control the switches of the H-Bridge circuit inside the L298N chip

When this jumper is in place, the 5V regulator is enabled, which derives the logic power supply (VSS) from the motor power supply (VS). In this case, the 5V input terminal (VSS) acts as the output pin and delivers 5V 0.5A. You can use it to power your Arduino or other circuitry that requires a 5V power supply.


When the jumper is removed, the 5V regulator is disabled and we have to separately supply 5V through the VSS pin.

How to Identify the Phases of a Bipolar Stepper Motor?

Before you start connecting the motor to the module, you need to identify the phases of the motor you plan to use. The best way to do this is to check the motor’s datasheet.


If you can’t find the datasheet, use the following trick.


Put your multimeter in ‘resistance’ mode and simply measure pairs of wires for their resistance.

If the resistance is only a few ohms (<100Ω), you’ve got a pair.

The other two wires should form the second pair.

Wiring a Bipolar Stepper Motor to the L298N Module and Arduino

Let’s start by connecting the power supply to the module. In our experiment we are using a NEMA 17 bipolar stepper rated at 12V. Therefore, we will connect the external 12V power supply to the VS terminal.


Next, we need to supply 5V to the logic circuitry of the L298N. We will be using the on-board 5V regulator to derive 5V from the motor power supply, so leave the 5V-EN jumper in place.


You also need to keep both the ENA and ENB jumpers in place so that the motor is always enabled.


Now, connect the input pins (IN1, IN2, IN3 and IN4) of the L298N module to the four Arduino digital output pins (8, 9, 10 and 11).


Finally connect one phase of the motor to terminal A (OUT1 and OUT2) and the other phase to terminal B (OUT3 and OUT4). Polarity doesn’t matter.



 Control Stepper Motor with L298N Motor Driver & Arduino

If you are planning on assembling your new robot, you will eventually want to learn how to control stepper motors. The easiest and inexpensive way to control stepper motors is to use the L298N motor driver. It can control both the speed and the spinning direction of any small to medium sized bipolar stepper motor such as the NEMA 17.


If you wish to control multiple stepper motors, it is recommended that you use a self-contained dedicated stepper motor driver such as the A4988. If you want to know more about it, check this tutorial out.


Controlling a Stepper Motor With an H-Bridge

The L298N module has two H-Bridges. Each H-bridge drives one of the electromagnetic coils of a stepper motor.


By energizing these electromagnetic coils in a specific sequence, the shaft of the stepper can be moved forward or backward precisely in small steps.


However, the speed of the motor is determined by how frequently these coils are energized.

L298N Motor Driver Chip

At the center of the module is a big, black chip with a chunky heat sink – the L298N, from ST Semiconductor.

Inside the L298N chip, you’ll find two standard H-bridges capable of driving a pair of DC motors or a single stepper motor.


The L298N motor driver has a supply range of 5V to 35V and is capable of supplying 2A continuous current per coil, so it works very well with most of our stepper motors.

Each channel of the module can deliver up to 2A to the stepper motor. However the amount of current supplied to the motor depends on the power supply of the system.


Control Pins

Using the four control pins IN1, IN2, IN3 and IN4, you can control both the speed and the spinning direction of the stepper motor. These pins actually control the switches of the H-Bridge circuit inside the L298N chip

When this jumper is in place, the 5V regulator is enabled, which derives the logic power supply (VSS) from the motor power supply (VS). In this case, the 5V input terminal (VSS) acts as the output pin and delivers 5V 0.5A. You can use it to power your Arduino or other circuitry that requires a 5V power supply.


When the jumper is removed, the 5V regulator is disabled and we have to separately supply 5V through the VSS pin.

How to Identify the Phases of a Bipolar Stepper Motor?

Before you start connecting the motor to the module, you need to identify the phases of the motor you plan to use. The best way to do this is to check the motor’s datasheet.


If you can’t find the datasheet, use the following trick.


Put your multimeter in ‘resistance’ mode and simply measure pairs of wires for their resistance.

If the resistance is only a few ohms (<100Ω), you’ve got a pair.

The other two wires should form the second pair.

Wiring a Bipolar Stepper Motor to the L298N Module and Arduino

Let’s start by connecting the power supply to the module. In our experiment we are using a NEMA 17 bipolar stepper rated at 12V. Therefore, we will connect the external 12V power supply to the VS terminal.


Next, we need to supply 5V to the logic circuitry of the L298N. We will be using the on-board 5V regulator to derive 5V from the motor power supply, so leave the 5V-EN jumper in place.


You also need to keep both the ENA and ENB jumpers in place so that the motor is always enabled.


Now, connect the input pins (IN1, IN2, IN3 and IN4) of the L298N module to the four Arduino digital output pins (8, 9, 10 and 11).


Finally connect one phase of the motor to terminal A (OUT1 and OUT2) and the other phase to terminal B (OUT3 and OUT4). Polarity doesn’t matter.


No comments:

Post a Comment

Post Top Ad

Pages