28BYJ-48 stepper motor: everything you need to know

28byj-48 stepper motor

El 28BYJ-48 is a unipolar stepper motor low cost and high precision, ideal for electronics projects, for 3D printers, CNC machines, and robotics. Its compact size, low power consumption and ease of use make it a popular choice for electronics hobbyists and professionals.

Furthermore, along with this engine, a module with ULN2003, for your control. In this way, we have everything necessary to be able to use this system completely, using a microcontroller or a board Arduino or similar.

What is 28BYJ-48 stepper motor?

indoor electric motor: stator-rotor

Un stepper motor is a type of electric motor which moves in small discrete angular steps, rather than a continuous rotation. It works using a set of electromagnets that are activated in a specific sequence. By activating different electromagnets, a magnetic field is created that attracts the rotor of the motor, causing it to rotate one step at a time. The number of steps per revolution and the precision of movement depend on the specific motor design and the control sequence used.

Within stepper motors we have two types:

  • Unipolar- They have a single set of coils and require a special controller to reverse the current and make the motor rotate in both directions.
  • Bipolar- They have two sets of independent coils, allowing them to rotate in both directions without the need for a special controller.

In the case of the 28BYJ-28 it is unipolar type, as I mentioned previously. And, within this group, it is characterized by having the following specs:

  • Unipolar stepper: simple control with only 4 cables.
  • Integrated reducer: offers high precision (0.088° per step) and torque (3 N·cm).
  • Low power consumption: 83 mA (5V model) or 32 mA (12V model).
  • Food: 5V or 12V (depending on model).
  • Economical price: from €1.2 per unit, or a little more if they include a ULN2003 module.

As for the possible applications, I already mentioned some of them before, but here I give you again some ideas for your projects:

  • Control of hydraulic and pneumatic valves.
  • Articulated robots and robotic arms.
  • Sensor positioning.
  • Rotating tables for scanners.
  • 3d printers.
  • CNC machines.

The stepper motor does not work alone, it requires another element. In this case, The 28BYJ-48 is controlled by a board with an integrated ULN2003, which allows the current of the Arduino outputs to be amplified to power the motor coils. By activating the coils in the correct sequence, the motor rotates step by step with great precision.

Types of control sequences and phases

There are various control sequences for the 28BYJ-48, the most commons are:

  • Full wave sequence: activates all coils at the same time.
  • Half step sequence: Activates two adjacent coils at the same time.
  • Microscopic step sequence: Activates one coil at a time.

Let's see the phases in detail:

  • Sequence 1-phase: In a 1-phase sequence we turn on a single coil at a time. Taking this ignition sequence to a table, the following would have to be generated in the engine pinout:
Step A B TO' B '
1 ON OFF OFF OFF
2 OFF ON OFF OFF
3 OFF OFF ON OFF
4 OFF OFF OFF ON
  • 2-phase sequence: we turn on two correlative coils in each phase, so the magnetic field generated is greater (41% more) so the motor has more torque, that is, we obtain more strength. As a negative point, we doubled energy consumption. As for the table, it would be:
Step A B TO' B '
1 ON ON OFF OFF
2 OFF ON ON OFF
3 OFF OFF ON ON
4 ON OFF OFF ON
  • Half-step sequence: This is another of the stages that we are going to see, you can experience what interests you most. Here we alternately turn on one and two coils, achieving an accuracy of half a step. It is used in applications where the highest precision is needed, although there could be problems when the application is at the torque limit. Expressing the sequence in table form results in:
Half-step A B TO' B '
1 ON OFF OFF OFF
2 ON ON OFF OFF
3 OFF ON OFF OFF
4 OFF ON ON OFF
5 OFF OFF ON OFF
6 OFF OFF ON ON
7 OFF OFF OFF ON
8 ON OFF OFF ON

28BYJ-28 with Arduino

28byj-48 with Arduino

The first thing is to properly connect the module and motor 28byj-48 to our Arduino board, to do this, you simply have to make the following connections:

  • Pin – from ULN2003 to GND of Arduino.
  • Pin + of the ULN2003 to Vcc (5v or in other cases, if it is a 12v motor, a power supply with that voltage would have to be used) from Arduino.
  • IN1, IN2, IN3 and IN4 of the ULN2003 to the digital inputs D8, D9, D10 and D11 of the Arduino.
  • The 28byj-48 motor, simply connect it to the port on the ULN2003 module.

Now that you are connected, the next thing is to use an example in Arduino IDE, which you can use as is to experiment or modify it to your liking. In this example, all the phase tables are commented out, like // in front of the line, you know... If you want to use one of them, just delete // in front of the instructions.

//Definir los pines
const int motorPin1 = 8;    // 28BYJ48 In1
const int motorPin2 = 9;    // 28BYJ48 In2
const int motorPin3 = 10;   // 28BYJ48 In3
const int motorPin4 = 11;   // 28BYJ48 In4
                   
//Definición de variables
int motorSpeed = 1200;   //Velocidad del motor
int stepCounter = 0;     //Contador de pasos
int stepsPerRev = 4076;  //Pasos para un giro completo

//Tablas de secuencia (descomentar la que necesites)
//Secuencia 1-fase
//const int numSteps = 4;
//const int stepsLookup[4] = { B1000, B0100, B0010, B0001 };

//Secuencia 2-fases
//const int numSteps = 4;
//const int stepsLookup[4] = { B1100, B0110, B0011, B1001 };

//Secuencia media fase
//const int numSteps = 8;
//const int stepsLookup[8] = { B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001 };

void setup()
{
  //Declarar los pines usados como salida
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
}

void loop()
{
  for (int i = 0; i < stepsPerRev * 2; i++)
  {
    clockwise();
    delayMicroseconds(motorSpeed);
  }
  for (int i = 0; i < stepsPerRev * 2; i++)
  {
    anticlockwise();
    delayMicroseconds(motorSpeed);
  }
  delay(1000);
}

void clockwise()
{
  stepCounter++;
  if (stepCounter >= numSteps) stepCounter = 0;
  setOutput(stepCounter);
}

void anticlockwise()
{
  stepCounter--;
  if (stepCounter < 0) stepCounter = numSteps - 1;
  setOutput(stepCounter);
}

void setOutput(int step)
{
  digitalWrite(motorPin1, bitRead(stepsLookup[step], 0));
  digitalWrite(motorPin2, bitRead(stepsLookup[step], 1));
  digitalWrite(motorPin3, bitRead(stepsLookup[step], 2));
  digitalWrite(motorPin4, bitRead(stepsLookup[step], 3));
}


Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.