When working with Arduino, many hams use stepper motors. But what is it? How to connect it? How to work with him? And anyway, where are they used? Answers to all these questions will be presented in this article.
About stepper motors
It can be said that stepper motors are the foundation of precision robotics. They are used everywhere due to their accuracy. The fact is that stepper motors use small steps when turning the shaft, this allows them to be ultra-precise when working. It was thanks to the “steps” that they began to be called stepper motors. Take, for example, a printer. A stepper motor is also used there. Or some kind of manipulator, where accuracy is very important, because even if the robot makes a half degree error, everything will go wrong. Servo drives can be considered an analogue of stepper motors, since when they are programmed, the degree of rotation is also indicated, however, servo is inferior to stepper motors in accuracy. But there are many situations where the use of servos is more expedient than the use of “shagovikov”.
28BYJ-48 stepper motor
Among the many choices of stepper motors, attention should be paid specifically to the 28BYJ-48 model stepper motor. It costs quite cheaply, only 100-150 rubles apiece. What a stepper motor looks like for Arduino can be seen in the photo below.
Many hams prefer this particular model because of the low price and good accuracy. The motor type is unipolar, the number of phases is 4. It consumes a stepper motor for Arduino from 5 to 12V. However, it is recommended to use 6-7V. Engines can operate in two modes: full-step and half-step. Recommended for use in half-step mode. This is 5.625 degrees per step. With a full step, a step of 11.25 degrees is given. Engine weight - 30 grams.
Driver ULN2003
A special driver is used to connect the stepper motor to the Arduino. One of these is ULN2003. This is due to the fact that when the stepper motor is running, there is a fairly powerful current strength that Arduino contacts simply can not withstand. This is what the driver is used for. The engine itself is connected to the driver, it is almost impossible to mix everything up, as there is a key that shows how to connect it. Well, then the driver itself is connected to the Arduino for further work. Often in stores, the driver is already bundled with a stepper motor. However, there are cases when engines are sold without a driver, you need to pay attention to this. If you buy on Aliexpress, it is better to work only with trusted sellers who have a lot of reviews.
Connection
As mentioned above, a driver is used to operate the stepper motor with Arduino. Use a different source to power the engine so as not to overload the Arduino board. And the remaining conclusions, starting from IN1 to IN4, are connected to any digital contacts on the Arduino. As you can see, connecting a stepper motor to the Arduino is quite simple. In the photo you can see an example of connection.
Control
To control stepper motors with Arduino, the development environment already has a ready-made library that allows you to control the motor using a small program code. If it weren’t, it would be necessary to draw up and calculate the movement of the engine using a special table, which would take a lot of time. However, there is a minus to this library. The fact is that it makes it possible to use the engine only in full-step mode. Although initially recommended to use the "step" in a half-step. But for simple projects using a single stepper motor, this library is suitable. It is called Stepper. You can write code to control the stepper motor with Arduino. A sketch looks like the example below.
#include <Stepper.h> const int stepsPerRevolution = 200; Stepper myStepper(stepsPerRevolution, 8,9,10,11);
This is an example from the library itself for controlling stepper motors. You can specify how many steps you need to complete, as well as how fast. Consider the code in more detail. At the very beginning, the Stepper library is connected, which was already mentioned above. After that, a constant is created with the number of steps that the stepper motor must perform. Next, a Stepper type variable is created with the data, using which contacts the stepper motor is connected to the Arduino. The speed and the very process of moving the stepper motor are set. But if you want to use more than one engine in your project and work in half-step mode, then you can use third-party libraries. One such is Accel Stepper. This library has proved to be very good at work, it has many features. When working with it, the steps are accurate, the engines do not heat up. In general, recommended for use. To install the library, you need to download and transfer the contents of the archive to the Libraries folder in the Arduino root folder.
This article examined an example of connecting a stepper motor to the Arduino, as well as its control using program code. Every amateur radio should try to work with him at least once in his projects!