Use of 24BYJ48 stepper motors with drivers (ULN2003)
Table of Contents
1.Size and Wiring
The scheme of the color of the connecting wire has many kinds, produced by different companies, different models, the scheme of the connecting wire may be different.
Maintex commonly uses the scheme of red, black, yellow, brown and blue. The motor objects are as follows:


The red color is the common wire, and then the 4 wires next to each other are A, B, C, and D.
2. The Motor Structure and Parameters
The internal structure of this 5-wire 4-phase motor is shown below:

Positively energize the common pole, and then pull A, B, C, and D down in sequence, a rotating magnetic field can be formed, dragging the rotor to turn.
The motor comes with a speed reducer with a reduction ratio of 1:64 and a stepping angle of 5.625/64 degrees, so if you need to rotate 1 turn, then you need 360/5.625*64=4096 pulse signals.

The motor also contains the following main parameters.

3. The Drive Circuit
Generally use a Darlington tube driver, such as ULN2003A.

4. Drivers
Stepping motor driving method.
1-phase excitation method: Only one coil conducts at each instant, and the other coils rest. It is characterized by simple excitation method, low power consumption and good accuracy. However, the torque is small, the vibration is large, and the angle traveled by each excitation signal is the nominal angle.
2-phase excitation method: Two coils conduct at the same time at each instant, characterized by large torque, low vibration, each excitation rotation angle is the nominal angle.
1-2-phase excitation method: 1-phase and 2-phase alternating conduction, high precision, and smooth operation. Every time an excitation signal is sent, the rotation angle is one half of the nominal angle. There is called half-step drive.
4-phase motors, the first and second methods are called 4-phase 4-tap, and the third is called 4-phase 8-tap.
The 1-phase excitation, 2-phase excitation and 1-2-phase excitation methods are shown in the following table.

51 microcontroller routine for 1-phase excitation (using ULN2003)
sbit D1=P1^4; //Define stepper motor connection port
sbit C1=P1^5; //Define stepper motor connection port
sbit B1=P1^6; //Define stepper motor connection port
sbit A1=P1^7; //Define stepper motor connection port
#define Coil_A {A1=1;B1=0;C1=0;D1=0;}//Phase A energized, other phases de-energized
#define Coil_B {A1=0;B1=1;C1=0;D1=0;}//Phase B energized, other phases de-energized
#define Coil_C {A1=0;B1=0;C1=1;D1=0;}//Phase C energized, other phases de-energized
#define Coil_D {A1=0;B1=0;C1=0;D1=1;}//Phase D energized, other phases de-energized
#define Coil_OFF {A1=0;B1=0;C1=0;D1=0;}//Total blackout.
main()
{
Speed=50; //Adjust the rotation speed, the speed should not be adjusted too fast, otherwise there will be no torque rotation.
while(1)
{
Coil_A //Coil_A is replaced by {A1=1;B1=0;C1=0;D1=0;}.
DelayMs(Speed); //Changing this parameter adjusts the speed of the motor. The smaller the number, the higher the speed and the lower the torque.
Coil_B //Coil_B is replaced by {A1=0;B1=1;C1=0;D1=0;}.
DelayMs(Speed);
Coil_C //Coil_C is replaced by {A1=0;B1=0;C1=1;D1=0;}.
DelayMs(Speed);
Coil_D //Coil_D is replaced by {A1=0;B1=0;C1=0;D1=1;}.
DelayMs(Speed);
}
}
51 microcontroller routine for 2-phase excitation (using ULN2003)
sbit D1=P1^4; //Define stepper motor connection port
sbit C1=P1^5; //Define stepper motor connection port
sbit B1=P1^6; //Define stepper motor connection port
sbit A1=P1^7; //Define stepper motor connection port
#define Coil_AB {A1=1;B1=1;C1=0;D1=0;}//Phase AB energized, other phases de-energized
#define Coil_BC {A1=0;B1=1;C1=1;D1=0;}//Phase BC energized, other phases de-energized
#define Coil_CD {A1=0;B1=0;C1=1;D1=1;}//Phase CD energized, other phases de-energized
#define Coil_DA {A1=1;B1=0;C1=0;D1=1;}//Phase DA energized, other phases de-energized
#define Coil_OFF {A1=0;B1=0;C1=0;D1=0;}//Total blackout
main()
{
Speed=50; //Adjust the rotation speed, the speed should not be adjusted too fast, otherwise there will be no torque rotation.
while(1)
{
Coil_AB //Coil_AB is replaced by {A1=1; B1=1; C1=0; D1=0;}.
DelayMs(Speed); //Changing this parameter adjusts the speed of the motor. The smaller the number, the higher the speed and the lower the torque.
Coil_BC //Coil_BC is replaced by {A1=0; B1=1; C1=1; D1=0;}.
DelayMs(Speed);
Coil_CD //Coil_CD is replaced by {A1=0; B1=0; C1=1; D1=1;}.
DelayMs(Speed);
Coil_DA //Coil_DA is replaced by {A1=1; B1=0; C1=0; D1=1;}.
DelayMs(Speed);
}
}
51 microcontroller routine for 1-2-phase excitation (using ULN2003)
sbit D1=P1^4; //Define stepper motor connection port
sbit C1=P1^5; //Define stepper motor connection port
sbit B1=P1^6; //Define stepper motor connection port
sbit A1=P1^7; //Define stepper motor connection port
#define Coil_AB {A1=1;B1=1;C1=0;D1=0;}//Phase AB energized, other phases de-energized
#define Coil_BC {A1=0;B1=1;C1=1;D1=0;}//Phase BC energized, other phases de-energized
#define Coil_CD {A1=0;B1=0;C1=1;D1=1;}//Phase CD energized, other phases de-energized
#define Coil_DA {A1=1;B1=0;C1=0;D1=1;}//Phase DA energized, other phases de-energized
#define Coil_A {A1=1;B1=0;C1=0;D1=0;}//Phase A energized, other phases de-energized
#define Coil_B {A1=0;B1=1;C1=0;D1=0;}//Phase B energized, other phases de-energized
#define Coil_C {A1=0;B1=0;C1=1;D1=0;}//Phase C energized, other phases de-energized
#define Coil_D {A1=0;B1=0;C1=0;D1=1;}//Phase D energized, other phases de-energized
#define Coil_OFF {A1=0;B1=0;C1=0;D1=0;}//Total blackout
#define Coil_OFF {A1=0;B1=0;C1=0;D1=0;}//Total blackout
main()
{
Speed=100; //Adjust the rotation speed, the speed should not be adjusted too fast, otherwise there will be no torque rotation.
while(1)
{
Coil_A
DelayMs(Speed);
Coil_AB //Coil_AB is replaced by {A1=1;B1=1;C1=0;D1=0;}.
DelayMs(Speed); //Changing this parameter adjusts the speed of the motor. The smaller the number, the higher the speed and the lower the torque.
Coil_B
DelayMs(Speed);
Coil_BC
DelayMs(Speed);
Coil_C
DelayMs(Speed);
Coil_CD
DelayMs(Speed);
Coil_D
DelayMs(Speed);
Coil_DA
DelayMs(Speed);
}
}
No comment