Share this

ULN2003 Stepper Motor Drive Principle Analysis

2026-04-06 05:41:52 · · #1

A stepper motor is an electromechanical component that converts electrical pulse signals into angular or linear displacement. The input to a stepper motor is a pulse sequence, and the output is the corresponding incremental displacement or step motion. Under normal operating conditions, it takes a fixed number of steps per revolution; during continuous stepping motion, its rotational speed maintains a strict correspondence with the frequency of the input pulses, unaffected by voltage fluctuations or load changes. Because stepper motors can directly accept digital control, they are particularly suitable for microcomputer control.

This stepper motor is a four-phase stepper motor powered by a unipolar DC power supply. By energizing each phase winding of the stepper motor in the appropriate timing sequence, the stepper motor can rotate in steps. Figure 1 is a schematic diagram of the working principle of this four-phase reactive stepper motor.

Initially, when switch SB is connected to the power supply and switches SA, SC, and SD are disconnected, the B-phase magnetic pole aligns with rotor teeth 0 and 3. Simultaneously, rotor teeth 1 and 4 misalign with the C and D phase winding magnetic poles, and teeth 2 and 5 misalign with the D and A phase winding magnetic poles. When switch SC is connected to the power supply and switches SB, SA, and SD are disconnected, the rotor rotates due to the interaction between the magnetic lines of force of the C-phase winding and the magnetic lines of force between teeth 1 and 4, aligning teeth 1 and 4 with the C-phase winding magnetic poles.

Teeth 0 and 3 misalign with the A and B phase windings, while teeth 2 and 5 misalign with the A and D phase winding poles. This process continues, with the A, B, C, and D phase windings receiving power in turn, causing the rotor to rotate along the A, B, C, and D directions. Four-phase stepper motors can be classified into three operating modes based on the energizing sequence: single-four-step, double-four-step, and eight-step. The step angles of single-four-step and double-four-step are equal, but the torque of single-four-step is smaller. The step angle of the eight-step operating mode is half that of the single-four-step and double-four-step modes; therefore, the eight-step operating mode maintains higher torque while improving control accuracy.

The power-on timing and waveforms for single four-step, double four-step, and eight-step operating modes are shown in Figures 2.a, b, and c, respectively:

uln2003 stepper motor drive program

#include <reg52.h>

//unsignedcharIRCOM[]={0x00, 0x00, 0x00, 0x00, 0x10, 0x10};

unsignedcharzhuangtai=0;

unsignedcharcodeF_Rotaion[4]={0x03, 0x05, 0x0d, 0x09};

void delay(uchar delay) {

uchari;

for(delay;delay》0;delay--){

for (i=123;i>0;i--)

}

}

/*

void delay1(int ms)

{

uchary;

while (ms--)

{

for (y=0; y<250; y++)

{

_nop_();

_nop_();

_nop_();

_nop_();

}

}

}

/

voidmoto(){

unsignedchari;

for (i=0; i<4; i++){

P0 = F_Rotaion[i];

delay(500);

}

}

void nmoto(){

unsignedchari;

for (i=3; i>=0; i--){

P0 = F_Rotaion[i];

delay(500);

}

}

voidstopmoto(){

P0=0x00;

}

void yunxing(){

if (zhuangtai == 0) {

stopmoto();

}

elseif (zhuangtai==1){

moto();

}

elseif (zhuangtai==2){

nmoto();

}

}

voidjude(){

if (P3 == 0xef) {

zhuangtai=0;

}

elseif (P3==0xdf){

zhuangtai=1;

}

elseif (P3==0xbf){

zhuangtai=2;

}

}

main(){

/*

IE=0x81;

TCON=0x01;

/

P1=0x00;

P3=0xff;

jude();

yunxing();

}

/* void IR_IN() interrupt 0

{

ucharj, k, N=0;

EX0=0;

delay(15);

if (IRIN == 1)

{

EX0=1;

return;

}

while (!IRIN)

delay(1);

for (j=0;j<4;j++)

{

for (k=0; k<8; k++)

{

while (IRIN)

delay(1);

while (!IRIN)

delay(1);

while (IRIN)

{

delay(1);

N++;

if (N>=30)

{

EX0=1;

return;

}

}

IRCOM[j]=IRCOM[j]》》1;

if (N>=8)

IRCOM[j]=IRCOM[j]|0x80;}

N=0;

}

if (IRCOM[2]!=~IRCOM[3])

{

EX0=1;

return;

}

if (IRCOM[0] != 0x00)

{

EX0=1;

return;

}

IRCOM[4]=IRCOM[2]&0x0F;

IRCOM[5]=IRCOM[2]》》4;

play();

beep();

EX0=1;

}

Read next

CATDOLL 115CM Milana TPE

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22