Introduction to Stepper Motor

Stepper motor is a DC motor (brushless) that divides the full rotation of 360 degrees into equal and discrete steps. It can be categorized between Servo motor and DC motor as we can control the rotation of the shaft and the motor can be controlled for precise positioning.                                                            

It consists of multiple coils that are divided into phases and each phase is energized in sequence, the rotor of the stepper motor rotates in steps. The motor rotates by applying some sequence of control signals and the speed can be varied by changing the control signal applied to it.

Stepper Motor

Stepper motor is made of mainly two parts:

  1. Stator (coil winding).
  2. Rotor (made up of mostly permanent magnet or ferromagnetic material).
Types of Stepper Motor

There are 3 types of stepper motor:

  1. Variable Reluctance (VR) Stepper Motor- It is based on the flux lines property which captures the low reluctance path. The stator and rotor are fixed in such a manner that the magnetic reluctance is minimum.
  2. Permanent Magnet (PM) Stepper Motor- In this, the rotor is made of permanent magnet poles of high retentively steel and is of cylindrical in shape. The rotor poles line up with the stator teeth depending on the excitation of the winding.
  3. Hybrid Stepper Motor- It has the combined features of both VR and PM Stepper motor. These are used in applications where there is a requirement of very small stepping angle like 1.5, 1.8 and 2.5 degrees.

 On the basis of the winding of the stator, Stepper motor can also be classified as:

Unipolar Stepper Motor- the driver circuit of a unipolar stepper motor can be applied with a Darlington Transistor IC like ULN2003A or a transistor-based circuit. Unipolar stepper motor have four coils and each pair of coils have a common terminal, so this motor has 6 or 5 wires.

Unipolar Stepper Motor

  1. Bipolar Stepper Motor- in case of a bipolar stepper motor, we need to implement an H – bridge type driver like L293DD Motor Driver IC. Bipolar stepper motor has two coils, so a bipolar motor has 4 wires.

Bipolar Stepper Motor

The wiring of stepper motor is not easy as that of a simple DC motor. We need to find the correct pair of wires. In this article, we’ll discuss 4, 5, and 6 wire stepper motor.


Stepper Motor Connections

The power required to run a stepper is quite high which the micro controller can’t draw. The maximum current that the pins can draw is 1500mA but is not enough and the motor requires 10 times of this current. The problem can be solved by adding an external IC which can handle all the power issues. 

Another issue is that when the stator coil changes current a spike occurs which can cause damage to your micro controller pins. Therefore we need an IC driver with an internal H bridge to resolve such issues. Also for changing the polarity of the stator poles in the process of reversing the current depends on the H bridge only. The commonly used H bridge IC used for motor interfacing is L293D. We are using a motor shield here with two L293DD( 20 pins) IC for the motor interfacing.


For driving a stepper motor we need a Darlington pair or H-bridge. There are motor driver ICs available for which have required motor driving circuit integrated. We can use ULN2003 or L293D ICs. In this article, we’ll use Motor Shield which has two L293DD ICs, easy to access pvt connectors, managed power supply, etc.


    Motor Shield

    To control the DC motors through Raspberry Pi we require motor drivers or motor shields. The driver/shield provides the motor with the necessary power to the motors for smooth operations and actions.

    The current requirement for motors is high, even the 5V motor draws 300-400mA current initially. After the motor gains speed the current reduces to 150-200mA. This is a huge current to bear for our micro-controllers so never directly connect your motor to any micro-controller it will cause damage to it. 

    The solution to this is a motor driver/ motor driver. These are the circuits which provide the Raspberry Pi with the necessary drive current to run the motors.

    We are going to use a Motor-shield which is based on the L293DD IC and is capable of driving 4 independent DC motors or 2 Stepper Motors. L293DD is a dual full-bridge driver that can output up to 1Amp per bridge with a voltage up to 24V.


    • Dual H-Bridge IC L293DD.
    • Motor Input Supply Range: 6V – 24V.
    • Single Motor Output Current: 600mA or 1A peak per channel.
    • Onboard Arrow Indicator for motor direction Indication.
    • 2 IR sensor connectors with 3.3V level output protection. 
    • 1 Ultrasonic sensor connector with 3.3V level output protection.

    Stacking Motor Shield

    Stacking Motor Shield

    To attach the Motor-shield to the Raspberry Pi, simply stack the motor-shield onto the Raspberry Pi. Make sure that all of the pins are correctly seated and the Motor Shield over-lays the Raspberry Pi.

    Powering your Motor Shield 

    The motor-shield can draw power from the Raspberry Pi but that power is not enough to power motors when loaded with the chassis of your robot. For testing your robot program however the Pi can provide enough to power the LEDs. To provide power for 4 motors you will need a supply of 7V to 12V with at least 1500mAH. For 2 motors power requirements are obviously less and you can use 4 x AA batteries, although these will drain quickly. 

    Connecting motors to the shield 

    Connect each motor to a single pair of labeled motor terminals on the Motor Shield (one terminal of the motor to one terminal of the connector of the Motor-shield).

    Connecting motors to the shield

    Motor Shield Connections 

    Stepper Motor

    1. Add the shield on the Raspberry Pi and make sure the shield placement is correct. Wrong connections can damage your Pi and Shield both.
    2. Set up the power connection, power your motor shield with a supply power of range 6V-24V. There are two ways to give the power to shield through the power channel or through the power pins. Don’t turn on the power immediately, after connecting all the device switch on the power supply.
    3. Now connect your Stepper motors to the motor terminal of the shield. At a time you can use 2 stepper motors.
    4. After the circuit setup comes time to code your motor shield. You can also use our test programs for motors. To get the codes to continue with the following steps:
    • Open your Raspberry Pi Terminal and clone the code by writing: git clone 
    • Your code will be downloaded to '/home/pi' directory.
    • Go to directory 'Motor Shield' and open ''.
    • Run the file on Python3 IDLE.

    connection between the motor and Raspberry Pi using the Motor shield

    We’ll find out in this section how to make the connection between the motor and Raspberry Pi using the Motor shield. First, we have to find the common wire which can be done by using a multi-meter. Let’s see how to find it out. 

    6 Wire Motor

    The 6 wire stepper motor can be used as a unipolar motor or as a bipolar motor and has four coil end wires with two centre trap wires. The motor has two coils with three wires each and out of the three wires; one is a common centre trap wire. The centre trap wires have less or half resistance than other coil end wires.  The way that we can determine which wire is this, is by measuring the resistance and the resistance from one of the centre wires to one of the other wires on the same coil will be much less as compared to the other pairs. If two wires are not on the same coil, you will measure an open circuit.

    Wire Motor

    This following table is the resistance measurement of 6 wire motor:


    From the above tables, you can easily figure out that the black and white wires are of less resistance or half the resistance as compared with the other wires. It concludes that the black and white wires are the central trap wires. For unipolar driver, we have to use all 6 wires and for bipolar driver, use one coil end wire and one centre tap of each winding.

    5 Wire Motor

    5 Wire Motor

    The 5 wire stepper motor is a unipolar motor has four coil end wires and one centre trap wire. It is same as 6 wire stepper motor but the centre trap wires are connected together internally. This makes it impossible to work as a bipolar motor. To find the centre trap wire we need to measure the resistance of the wires like we did for 6 wire the procedure will be the same. The resistance of the coil end wires will be equal in resistance while the centre trap wire is half of the resistance of coil end wires. In the end, arrange the wires in the correct sequence because the wrong sequence can cause step back and forth.

    4 Wire Motor

    4 Wire Motor

    The 4 wire stepper motor can be driven in bipolar mode and each phase has only one winding. Each winding has two wires. To check the wires sequence we need to measure the resistance of all the wires. There are two coils with two wires each. Measure the resistance and if there’s a reading on the Multi-meter then the wires are part of the same coil and if there is no reading this means the wires are of different coil. Arrange the wires in the correct sequence now because the wrong sequence can cause step back and forth. 

    4 Wire Motor



    Leave a comment

    All comments are moderated before being published