A stepper motor is a brushless, synchronous electric motor that converts electrical  pulses into mechanical movement. Every revolution of the stepper motor is divided into a discrete number of steps, and the motor must be sent a separate pulse for each step. The stepper motor can only take one step at a time and each step is the same size. Since each pulse causes the motor to rotate a precise angle, the motor’s position can be controlled without any feedback mechanism. As the electrical pulses increase in frequency, the step movement changes into continuous rotation, with the speed of rotation directly proportional to the frequency of the pulses. Step motors are used every day in both industrial and commercial applications because of their low cost, high reliability, high torque at low speeds and a simple, rugged construction that operates in almost any environment.

►Unipolar stepper motor
The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power connection. They are called unipolar steppers because power always comes in on this one pole.

Unipolar Stepper Motor Windings

►Bipolar stepper motor
The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you’ve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).

Bipolar Stepper Motor windings

Stepper Motor interfacing with Microcontrollers

Stepper motors can be used in various areas of microcontroller projects such as making robots, robotic arm, automatic door lock system etc.Here,I will discuss different controlling types (Half step and Full step), Interfacing Techniques (using L293D or ULN2003) to control stepper motor.

Step Sequence

Stepper motors can be driven in two different patterns or sqeunces. namely,

  • Full Step Sequence
  • Half Step Sequence

►Full Step Sequence

In the full step sequence, two coils are energized at the same time and motor shaft rotates. The order in which coils has to be energized is given in the table below.

Full Step Sequence

►Half Step Sequence
In Half mode step sequence, motor step angle reduces to half the angle in full mode. So the angualar resolution is also increased i.e. it becomes double the angular resolution in full mode. Also in half mode sequence the number of steps gets doubled as that of full mode. Half mode is usually preffered over full mode. Table below shows the pattern of energizing the coils.

Half Step Sequence

►Step Angle

Step angle of the stepper motor is defined as the angle traversed by the motor in one step. To calculate step angle,simply divide 360 by number of steps a motor takes to complete one revolution. As we have seen that in half mode, the number of steps taken by the motor to complete one revolution gets doubled, so step angle reduces to half.

As in above examples, Stepper Motor rotating in full mode takes 4 steps to complete a revolution, So step angle can be calculated as…

Step Angle ø = 360° / 4 = 90°

and in case of half mode step angle gets half so 45°.

So this way we can calculate step angle for any stepper motor. Usually step angle is given in the spec sheet of the stepper motor you are using. Knowing stepper motor’s step angle helps you calibrate the rotation of motor also to helps you move the motor to correct angular position.

►Connecting Unipolar Stepper Motor with Microcontroller(PIC16F887) using ULN2003

Stepper Motor Interfacing with microcontroller Using ULN2003

►Connecting Unipolar Stepper Motor with Microcontroller(PIC16F887) using L293D

Stepper Motor Interfacing With microcontroller Using L293D

Source Code

Here,I  have used PIC16F887  Microcntroller  and Code is written in C using mikroC PRO for PIC.Adjusting the delay will increase or decrease the speed of the motor. Here just for demonstration i have taken some delay, you can change it as you want.

►Programming Full step Sequence

void main() {ANSEL  = 0;                // Configure AN pins as digital I/O
PORTD = 0;
TRISD = 0;                 // Configure PORTD as output


►Programming Half step Sequence

void main() {

ANSEL  = 0;                // Configure AN pins as digital I/O
PORTD = 0;
TRISD = 0;                 // Configure PORTD as output




Comments on: "Stepper Motor Interfacing With Microcontroller" (19)

  1. salam can u plz tell me how powerfully rotations can be achieved by uln2003 or some other ic for heavy loads

  2. Anonymous said:

    Can you please tell me how to interface stepper motor with PIC 18F4550

  3. Can u pls tel me the cost of the entire circuit model including pic 16F887 and ULN 2003/L293D.

  4. Nice and brief tutorial. I learnt a lot more than from tone of pages. Thanks.

  5. i want to pdf file of control of stepper motort speed using microcontroller plz if u have then send to my mail

  6. […] Stepper Motor Interfacing With Microcontroller […]

  7. how to 6 wire stepper motor terminal find

  8. mildsufi said:

    thanks a lot…i really appreciate…..

  9. yashshailesh said:

    hello nice and quite understandable tutorial .
    sir i want to know about stepper motor specification.
    i have stepper motor with 5.3V 1Amp .
    what is its meaning ?, how much voltage ,current required , how we know? .
    and which circuit needed to drive means ULN2003,L293D,L293 or MOSFET how we know ?.

  10. i need a pdf file of this….plz do reply

  11. Venance Assey said:

    thankx, it is informative to me.

  12. Venance Assey said:

    plz, if you can. i need program to control speed of dc motor.

  13. plz..if u can,i need the rating of dc motor used for elevator car with speed control program.

  14. thank you

  15. pic18forstudents
    you can interface easily using pic18f4520 and uln2003 driver for stepper motor…
    see pic18forstudentscouk

  16. pandiarajan said:

    how to unipolar stepper motor interfacing with LPC1788

  17. #include
    void delay(void);
    void main()
    void main(void)
    unsigned int i,j;
    for(i=0;i<0xff;i )
    for(j=0;j<0xff;j );

  18. thank u

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 50 other followers

%d bloggers like this: