Electronics

Motor Driver Board Module L298n Dual H-Bridge DC Stepper Control Advanced Version

AED 35.70

1

Description

L298 N Dual H-Bridge Stepper motor module driver for Arduino. It uses L298 N chip, can directly drive two 3V-30V DC motor, and provide a 5V support power source with the 5-volt regulator in it, you can drive the motor with  5V, 3.3V boards. the L289 single-chip driver made especially for MCU motor control. You can easily control the direction and speed of any DC motor, also the control of any 2 Phases stepper motor.




Characteristics


- Chip control: L298 N.
- Power supply voltage: VMS 5 - 35 V).
- Peak current for Output: 2 A per bridge.
- logic voltage: 4.5 V-5.5 V.
- The logiccurrent Range: 0 mA-36mA.
- Control signal Voltage input range: 4.5 V-5.5 V (high) / 0 V (low).
- Max Power Consumption: 20 W.
- Operating temperature: -25 ° C -130 ° C.
- Size: 55 x 60 x 30 cm.


Stepper Motor without shield



File:L298n-detals.jpg



Package Includes
1 * L298 N Dual H Bridge DC Module Stepper Motor Driver Board Board for Arduino


This is how to drive a stepper motor with L289n Motor Driver and how to wire and connect the motor with the motor driver and drive it with Arduino Code
:

Bipolar Stepper with L298N H-Bridge

we used a NEMA 17 sized bipolar stepper rated at 12 volts but any bipolar stepper motor can be used as long as you observe the voltage ratings and use a suitable power supply. Once again please don’t attempt to power the motor from the Arduino power supply.

As you recall a bipolar stepper motor requires a driver that can reverse polarity to the motor coils in order to reverse the motor direction.  A good component to accomplish this with is an “H-Bridge”.


Essentially this is a device that contains four internal power transistors that allow control of the direction of current through a motor coil.

We will be using the L298n H-Bridge controller, the L298N module. These modules are very inexpensive and are very reliable and they can be used to control either two DC motors or one stepper motor. Obviously we will be using it to control a stepper motor today, the L298N is a dual H-Bridge so each H-Bridge will drive one of the coils in our bipolar stepper motor.

Here is how we have hooked up ourL298N H-Bridge, bipolar stepper, and Arduino Uno:

Bipolar Stepper Motor with Arduino and L298N H-Bridge module

Note that you may not need to make all of these connections, this depends upon how you configure your L298N module.  And also note that the motor power supply you use should match your motor requirements.

The L298N module has a jumper to set its internal 5-volt logic circuits to use either an external power supply (jumper off) or to use a built-in voltage regulator and derive the 5-volts from the motor power supply (jumper on). If you choose to use your motor supply make sure it is at least 7.5 volts and eliminate the power connection from the Arduino 5 volt output.

L298N module has a set of jumpers that allow you to tie the two Enable lines high so that the motors are always enabled, which is what we want here.  you can also eliminate the connection from the Arduino 5-volt output to ENA and ENB and just set the jumpers instead.

We will also use a potentiometer to act as speed control. Any value from 10k up will work, lower values will put a lot of load onto the Arduino 5-volt output.

Once you get everything hooked up it’s time to load the code up to the Arduino. Here is the sketch:

/*
  Stepper Motor Demonstration 3
  Stepper-Demo3.ino
  Demonstrates NEMA 17 Bipolar Stepper with L298N Driver
  Uses Potentiometer on Analog Input A0
  Uses Arduino Stepper Library
 
 
*/
 
// Include the Arduino Stepper Library
#include 
 
// Define Constants
 
// Number of steps per output rotation
const int STEPS_PER_REV = 200;
const int SPEED_CONTROL = A0;
 
// Create Instance of Stepper Class
// Specify Pins used for motor coils
// The pins used are 8,9,10,11 
// Connected to L298N Motor Driver In1, In2, In3, In4 
// Pins entered in sequence 1-2-3-4 for proper step sequencing
 
Stepper stepper_NEMA17(STEPS_PER_REV, 8, 9, 10, 11);
 
void setup() {
  // nothing to do inside the setup
}
 
void loop() {
  // read the sensor value:
  int sensorReading = analogRead(SPEED_CONTROL);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) {
    stepper_NEMA17.setSpeed(motorSpeed);
    // step 1/100 of a revolution:
    stepper_NEMA17.step(STEPS_PER_REV / 100);
  }
}

 

The sketch uses the Arduino Stepper library.

After including the library we define a couple of constants:

  • STEPS_PER_REV is the number of steps per revolution that our motor is rated at. Mine was rated at 200, which is the same as 1.8 degrees per step. Change this to match your motor.
  • SPEED_CONTROL is the analog port we connect the potentiometer. It is set to A0.

The sequence for our bipolar stepper is 1-2-3-4 so we create our instance of the stepper class with this in mind. Our L298N is connected to pins 8, 9, 10, and 11.

Again the stepper library sets up the pins as outputs so there is no need to do that in the setup routine.

In the loop, we read the potentiometer position by measuring the input voltage on the analog pin using the Arduino analogRead function. We then map it to a range of 0 to 100 using the useful Arduino map function.

The value derived from the map function is then used to set the motor speed. As long as it is over zero we set the motor speed and then step it one-hundredth of a revolution, which in the case of our motor will move it two steps or 3 degrees.

After that, we do it all again. The result is that the motor speed will be controlled by the potentiometer.

Note that no attempt has been made to control the motor direction in this design. If you wish you can do this by setting the motor speed to a negative number to spin the motor counterclockwise.  The H-Bridge will do the job of reversing the motor voltage polarity to reverse the motor.

As you can see an L298N makes a great stepper motor controller as well as a DC motor controller.