STEPPER MOTOR INTERFACING WITH 8051 MICROCONTROLLER



STEPPER MOTOR INTERFACING WITH 8051 MICROCONTROLLERStepper motors are type of DC motors. Stepper motor has multiple electromagnetic coils that are arranged in group called phases. Motor rotates when particular phase is energized. One step rotation occurs at a time by energizing a particular coil. We can also control the speed of motor. It can be interfaced with 8051 microcontroller but the same case is here about DC motors that we can’t connect them directly with controller. Here in this article we will learn how to interface stepper motor with 8051 microcontroller. Before starting this article you should know how to use keil for 8051 programming and how to use input output ports of 8051 microcontroller



Stepper motor COMPARISON WITH DC MOTOR

Unlike DC motors, the current consumption of stepper motors does not depend upon the load. Upon no load they still draw much current. In this way, they get hot and this lowers their efficiency. In stepper motors there is smaller torque at high speeds than at low speeds. But mostly these stepper motors are used in high speed routine. For obtaining that high speed performance they need to be paired with a proper driver.

ADVANTAGES of stepper motor

Stepper motors are used because of their:



  • Low cost
  • High reliability (because of no contact brushes)
  • Good performance in starting, stopping and reversing the direction
  • High torque at low speed
  • Gravel construction (can be used in variable environment)

BASICS OF STEPPER MOTOR

Stepper motor is brushless which take digital signals. It converts digital pulses into mechanical shaft rotation. Rotation is divided into steps and a separate pulse is sent for each step. For each pulse motor rotates a few degrees which is mostly 1.8 degree angle. As we interface it with controller, so when digital pulses increase in frequency, the stepping movement of motor converts to continuous rotation of motor. So we can say that speed of rotation is directly proportional to the frequency of pulses given by controller.

WINDING ARRANGEMENT:

For a two phase stepper motor, there are two winding arrangements of electromagnetic coils.

  • Unipolar
  • Bipolar

UNIPOLAR MOTOR:

  • Only one winding with center tap per phase
  • Each winding section is switched on for each direction of magnetic field
  • Center tap of each winding is made common

BIPOLAR MOTOR:

  • A single winding per phase
  • Current in winding must be reversed to reverse a magnetic pole
  • Two leads per phase, none are commonstepper motor with 8051 microcontroller

STEP MODES:

In this article we will use unipolar stepper motor. Unipolar stepper motors can be used in three modes:

  • Wave Drive mode
  • Full Drive mode
  • Half Drive mode

Wave Drive:

  • Only one electromagnet is energized at single time.
  • Torque which is generated will be less than full drive.
  • Power consumption is reduced in it.
  • This type of drive is chosen when the power consumption fact is more important than torque.

Full Drive:

  • Two electromagnets are energized at single time.
  • Torque which is generated will be greater than wave drive.
  • Power consumption is higher in it.
  • This type of drive is chosen when the torque is more important than power consumption.

Half Drive:

  • One and two electromagnets are alternatively energized in this mode.
  • It is a combination of both, wave drive and full drive.
  • It has low torque but the angular resolution is doubled.
  • This type of drive is chosen when we want to increase the angular resolution of the motor.

Since each drive has its own advantages and disadvantages, thus we choose the drive according to the application we want and power consumption.

Stepper motor INTERFACING  WITH 8051 MICROCONTROLLER

Due to high voltage and current limitations of microcontroller, a motor Driver IC is used. We can use L293D or ULN2003. Working of both is already described in previous articles.

CIRCUIT COMPONENTS:

  • AT89C51 microcontroller
  • 12 MHz Oscillator.
  • 12V DC battery.
  • 5V DC battery.
  • L293D motor driver
  • Unipolar Stepper motor – 1.
  • 2 Ceramic capacitors – 33pF
  • 300Ω resistors – 3
  • Push buttons – 3

CONNECTIONS:

  • P2 (Lower four pins) of 8051 microcontroller is used as output port and it gives inputs to the L293D (motor driver IC) to drive one stepper motor.
  • P0 (Lower three pins) of 8051 microcontroller is used as input port. 3 Buttons are connected to them so that we can manually start and stop the motor.
  • Stepper motor is given input through OUT1, OUT2, OUT3 and OUT4 of L293D.
  • 12V battery is used to give input to the VS for motor.
  • 5V battery is used to give input to VSS for motor driver IC.

PROTEUS SIMULATION of stepper motor interfacing with 8051 microcontrollerstepper motor interfacing with 8051 microcontroller

Working stepper motor interfacing with 8051 microcontroller

I tried to use all three modes. When I press button 1, it works as wave drive. Only one electromagnet is energized at single time and in coding one pin is high at a time. When I open the switch/button, motor tends to stops and gets stop within few seconds.

Wave drive Stepping Sequence
Step #Pin 1Pin 2Pin 3Pin4
11000
20100
30010
40001

When I press button 2, it works as full drive. Two electromagnets are energized at single time and in coding one pin is high at a time. When I open the switch/button 2, motor tends to stops and gets stop within few seconds.

Full drive Stepping Sequence
Step #Pin 1Pin 2Pin 3Pin4
11100
20110
30011
41001

When I press button 3, it works as half drive. One and two electromagnets are alternatively energized at a single time and in coding:

  • First pin is high
  • Then first and second both get high
  • Second alone goes high
  • Second along with third goes high
  • In same way, alternatively one and two pins go high
Half drive Stepping Sequence
Step #Pin 1Pin 2Pin 3Pin4
11000
21100
30100
40110
50010
60011
70001
81001

When I open the switch/button, motor tends to stops and gets stop within few seconds.

CODE of stepper motor interfacing with 8051 microcontroller

#include<reg52.h>

void delay(int);

sbit B1 = P0^0;

sbit B2 = P0^1;

sbit B3 = P0^2;




void main()

{

P1=0x07;

P2=0x00;




if(B1==1)                                                             //for wave drive

{

    P2=0x01; //0001

    delay(1000);

    P2=0x02; //0010

    delay(1000);

    P2=0x04; //0100

    delay(1000);

    P2=0x08; //1000

    delay(1000);

}

if(B1==0)

{

                P2=00000000;

}




if(B2==1)                                               //for full drive

{

    P2 = 0x03; //0011

    delay(1000);

    P2 = 0x06; //0110

    delay(1000);

    P2 = 0x0C; //1100

    delay(1000);

    P2 = 0x09; //1001

    delay(1000);

}

if(B2==0)

{

                P2=00000000;

}




if(B3==1)                                             //for half drive

{

                P2=0x01; //0001

    delay(1000);

    P2=0x03; //0011

    delay(1000);

    P2=0x02; //0010

    delay(1000);

    P2=0x06; //0110

    delay(1000);

    P2=0x04; //0100

    delay(1000);

    P2=0x0C; //1100

    delay(1000);

    P2=0x08; //1000

    delay(1000);

    P2=0x09; //1001

    delay(1000);

}

if(B3==0)

{

                P2=00000000;

}




}



void delay(int k)

{

  int i,j;

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

  {

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

    {}

  }

}



One Response

  1. jeevan March 18, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,395 other subscribers