- Stepper Motor Definition: A stepper motor is a DC motor that moves in steps, with rotation speed dependent on the electrical signal rate.
- Components: The motor has a rotor (permanent magnet) and a stator (winding), with the rotor rotating and the stator stationary.
- Working Principle: The motor’s stepping motion is achieved by changing the stator’s magnetic properties to attract and repel the rotor.
- Stepping Sequence: A specific sequence of electrical signals ensures correct motor motion, typically involving four steps.
- Stepper Motor Interfacing: Interfacing involves using a driver like ULN2003 to connect the motor to a microcontroller, as microcontrollers alone cannot provide enough current.
Interfacing a stepper motor means driving its windings from a microcontroller through a current buffer. The machine is a pulsed DC motor that moves in fixed angular steps. Speed follows the pulse rate, and direction follows the pulse pattern.
A stepper motor has a rotor (usually a permanent magnet) and a stator made of windings. In the diagram below the rotor sits in the centre and the stator windings surround it. That layout is a four-phase unipolar winding.

Working of Stepper Motor
Each stator winding has a centre tap. Energising one half or the other reverses the current in that phase. The stator field then attracts and repels the rotor one step at a time.
Stepping Sequence
The shaft only tracks the command if the phases are energised in order. The table below is the voltage pattern for each stator phase. A common full-step drive uses four steps.
Steps 1 to 4 give clockwise rotation. Steps 4 to 1 give counterclockwise rotation.
| Step No | A | A | B | B |
| 1 | 1 | 0 | 0 | 1 |
| 2 | 1 | 1 | 0 | 0 |
| 3 | 0 | 1 | 1 | 0 |
| 4 | 0 | 0 | 1 | 1 |
Interfacing Diagram

The diagram below shows the interfacing of stepper motor to a micro-controller. The same buffer idea applies to PIC, AVR or 8051 families.
A microcontroller pin cannot supply winding current, so a driver such as ULN2003 is used. Discrete transistors or other driver ICs can do the same job. Fit external pull-up resistors if the driver input needs them. Never connect the motor directly to the controller pins. The motor voltage depends on the winding rating.
A typical 4-phase unipolar stepper has 5 leads: four phase ends and one common from the centre taps. With a ULN2003 low-side driver that common goes to the motor positive supply, not to ground. The ULN2003 COM pin also goes to that supply so the clamp diodes can catch inductive kick.
The programming algorithm for continuous clockwise rotation is:
- Initialize the port pins used for the motor as outputs
- Write a shared delay of about 500 ms, then shorten it once the motor can follow
- Output first sequence 0x09 on the pins
- Call delay function
- Output second sequence 0x0C on the pins
- Call delay function
- Output third sequence 0x06 on the pins
- Call delay function
- Output fourth sequence 0x03 on the pins
- Call delay function
- Go to step 3
Step Angle
The number of steps in one revolution is 360 degrees divided by the step angle. Common step angles run from 0.72 degrees (500 steps) to 15 degrees (24 steps). A 1.8 degree hybrid motor needs 200 full steps. Choose the motor whose step angle is no coarser than the smallest move the machine must make.
Half Stepping
Half stepping alternates one-phase and two-phase excitation so the shaft moves half the rated full-step angle. A motor rated 15 degrees per full step then moves 7.5 degrees per half step.
| Step No | A | A | B | B |
| 1 | 1 | 0 | 0 | 1 |
| 2 | 1 | 0 | 0 | 0 |
| 3 | 1 | 1 | 0 | 0 |
| 4 | 0 | 1 | 0 | 0 |
| 5 | 0 | 1 | 1 | 0 |
| 6 | 0 | 0 | 1 | 0 |
| 7 | 0 | 0 | 1 | 1 |
| 8 | 0 | 0 | 0 | 1 |
C Code for 8051 Micro-controller
#include
#define out P1 // motor on Port 1 lower nibble
#define step 200 // one revolution for a 1.8 degree motor
unsigned char i;
void delay (unsigned char k);
void main()
{
for( i = 0; i<step; i++)
{
for(j = 0; j<40000; j++);
}
Stepper Motor v/s Servo Motor
Both the stepper motor and the servo motor are used for position control, but they close the loop in different ways. A stepper has many rotor teeth that act as north and south poles. Those teeth line up with the energised stator coil, so each command pulse advances one step without a shaft sensor.
A servo motor uses a drive circuit and a feedback sensor. The error between the command and the measured shaft angle then drives the motor.





