window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-R1K3RMK9DY'); Stepper motors and Arduino motors 28BYJ-48 with ULN2003 driver

Stepper motors and Arduino motors 28BYJ-48 with ULN2003 driver

In this article, we will talk about stepper motors in Arduino projects using the very popular 28BYJ-48 model as an example. Just like servo drives, stepper motors are a critical element in automated systems and robotics. They can be found in many devices nearby, from a CD drive to a 3D printer or a robotic arm. In this article, you will find a description of the operation of stepper motors, an example of connecting to an Arduino using drivers based on ULN2003 and examples of sketches using the standard Stepper library.

Contents hide ]

  • 1 Stepper motor - how it works
  • 2 Where to buy a stepper motor
  • 3 Driver for stepping motor control
    • 3.1 Stepper motor driver based on L298N
    • 3.2 Stepper motor driver ULN2003
    • 3.3 Other drivers
  • 4 Connecting a stepper motor to Arduino
  • 5 Overview of the main models of stepper motors for arduino
  • 6 Description of the library for working with a stepper motor
  • 7 Example sketch for control
  • 8 Conclusion

Stepper motor - how it works


Stepper motor circuit

A stepper motor is a motor that moves its shaft depending on the steps and direction specified in the microcontroller program. Such devices are most often used in robotics, printers, manipulators, various machine tools and other electronic devices. The big advantage of stepper motors over constant rotation motors is that they provide accurate angular positioning of the rotor. Also, stepper motors have the ability to quickly start, stop, reverse.

The stepper motor rotates the rotor at a predetermined angle with an appropriate control signal. Thanks to this, it is possible to control the position of the units of the mechanisms and go to the specified position. The motor works as follows - in the central shaft there is a row of magnets and several coils. When power is applied, a magnetic field is created which acts on the magnets and causes the shaft to rotate. Parameters such as the angle of rotation (steps), the direction of movement are set in the program for the microcontroller.











Simplified animated diagrams of stepper motor operation

The main types of stepper motors:

  • Variable magnet motors (rarely used);
  • Permanent magnet motors;
  • Hybrid motors (more difficult to manufacture, more expensive, but the most common type of stepper motor).

Where to buy a stepper motor

The simplest engines Options on the AliExpress website:

Stepper motor Nema17 42BYGH 1.7A (17HS4401-S) for 3D printerSet of 5 ULN2003 28BYJ-48 Stepper Motors with Arduino Driver BoardsStepper Motor with 5V Stepper Motor Driver Module 28BYJ-48 + ULN2003
Another Stepper Motor Option for Arduino 28BYJ-48 5V 4 Phase DC Motor + ULN2003 Drive Test BoardSet of three stepper motors Nema17 Stepper Motor 42BYGH 1.7A (17HS4401) for 3D prienterAliExpress.com Product – 3D Printer Parts StepStick A4988 DRV8825 Stepper Motor Driver With Heat sink Carrier Reprap RAMPS 1.4 1.5 1.6 MKS GEN V1.4 board

 

Stepper motor driver

A driver is a device that links the controller and the stepper motor. The L298N and ULN2003 drivers are most commonly used to control a bipolar stepper motor.

Operating the motor in bipolar mode has several advantages:

  • Increase in torque by 40% compared to unipolar motors;
  • Possibility of using motors with any configuration of the phase winding.

But a significant disadvantage in bipolar mode is the complexity of the driver itself. The unipolar drive driver requires only 4 transistor switches; more complex circuitry is required for the bipolar drive driver to work. With each winding, various actions must be carried out separately - connecting to a power source, disconnecting. For such switching, a four-key bridge circuit is used.


Stepper motor driver based on L298N

This bridge driver controls a motor with a current of up to 2A and a supply of up to 46V. The module based on the L298N driver consists of an L298N microcircuit, a cooling system, terminal blocks, connectors for connecting signals, a voltage stabilizer and protective diodes.


L298N motor driver

Stepper motor driver ULN2003


Description of UNL2003 stepper motor driver

Stepper motors with ULN2003 based driver modules are frequent guests in Arduino workshops due to their cheapness and availability. As a rule, you have to pay for this with not very high reliability and accuracy.

 

Other drivers

There is another kind of driver - STEP / DIR drivers. These are hardware modules that use the STEP / DIR protocol to communicate with the microcontroller. STEP / DIR drivers expand the capabilities:

  • They allow you to stabilize phase currents;
  • Possibility of setting microstepping mode;
  • Providing protection of the key from closing;
  • Overheat protection;
  • Opto-isolation of the control signal, high immunity from interference.

STEP / DIR drivers use 3 signals:

  • STEP is an impulse that initiates a turn by a step / part of a step, depending on the mode. The engine speed will be determined from the pulse repetition rate.
  • DIR is a signal that sets the direction of rotation. Typically clockwise rotation is performed when a high signal is applied. This type of signal is generated before the STEP pulse.
  • ENABLE - enable / disable the driver. This signal can be used to stop the motor running without holding current.

One of the most inexpensive STEP / DIR drivers is the TB6560-V2 module. This driver provides all the necessary functions and modes.

Connecting a stepper motor to Arduino

The connection will be considered using the example of the 28BYj-48 unipolar motor and the L298 and ULN2003 drivers. Arduino Uno will be used as a board.


Connecting a stepper motor to Arduino

Another variant of the circuit using the L298:


Connecting a stepper motor to Arduino based on L298

The connection diagram based on ULN2003 is shown in the figure below. The control outputs from the IN1-IN4 driver are connected to any digital contacts on the Arduino. In this case, digital pins 8-11 are used. Power is connected to 5V. It is also advisable to use a separate power source for the motor so that the Arduino board does not overheat.


Connecting a stepper motor to Arduino

Schematic connection diagram.


Schematic diagram of connecting a stepper motor

Another connection diagram for the Nema17 bipolar stepper motor through the L298 driver is as follows.



Overview of the main models of stepper motors for arduino

Nema 17 is a bipolar stepper motor that is most commonly used in 3D printers and CNC machines. The 170хHSхххА series of the motor is universal.

Main characteristics of the engine:

  • The angular step is 1.8 °, that is, there are 200 steps per 1 revolution;
  • The engine is two-phase;
  • Working temperatures from -20C to 85C;
  • Rated current 1.7A;
  • Holding moment 2.8 kg x cm;
  • Equipped with 42 mm flange for easy and quality installation;
  • High torque - 5.5 kg x cm.

28BYJ-48 is a unipolar stepper motor. Used in small projects of robots, servo drives, radio-controlled devices.


Engine characteristics:

  • Rated power supply - 5V;
  • 4-phase motor, 5 wires;
  • Number of steps: 64;
  • Step angle 5.625 °;
  • Rotation speed: 15 revolutions per second
  • Torque 450 g / cm;
  • DC resistance 50Ω ± 7% (25 ℃).

Description of the library for working with a stepper motor

In the Arduino IDE, there is a standard Strepper.h library for writing stepper motor programs. The main functions in this library are:

  • Stepper (number of steps, contact numbers). This function creates a Stepper object that corresponds to the motor connected to the Arduino board. The argument is the contacts on the board to which the motor is connected, and the number of steps that are taken to complete a revolution around its axis. Information on the number of steps can be found in the documentation for the motor. Instead of the number of steps, an angle can be specified, which is one step. To determine the number of steps, you need to divide 360 ​​degrees by this number.
  • Set Speed ​​(long rpms) - a function that specifies the rotation speed. The argument is a positive integer that specifies the number of revolutions per minute. Set after the Step () function.
  • Step (Steps) –Rotate the specified number of steps. The argument can be either a positive number - clockwise rotation of the engine, or negative - counterclockwise.

Example sketch for control

The set of examples of the Stepper.h library contains the stepper_oneRevolution program, in which all parameters for a stepper motor are set - the number of steps, speed, rotation.

#include <Stepper.h>

const int stepsPerRevolution = 200;

Stepper myStepper (stepsPerRevolution, 8,9,10,11); // connect to pins 8 ... 11 on Arduino

void setup() {

myStepper.setSpeed ​​(60); // setting the rotor speed

Serial.begin(9600);

}

void loop() {

// The function waits for a command to come in, transforms the text and sends a signal to the motor to rotate it the specified number of steps.

Serial.println ("Move right"); //clockwise

myStepper.step(stepsPerRevolution);

delay(1000);

Serial.println ("Move left"); //counterclock-wise

myStepper.step(-stepsPerRevolution);

delay(1000);

}

Conclusion

In this article, we learned what a stepper motor is, how you can connect it to an arduino, what a stepper motor driver is. We also looked at an example of writing a sketch using the built-in Stepper library. As you can see, there is nothing particularly difficult in working with stepper motors, and we recommend that you definitely experiment on your own and try to include it in your Arduino projects .

(adsbygoogle = window.adsbygoogle || []).push({});
Previous Post Next Post

Contact Form