Thursday, April 30, 2015

89C51 Stepper motor interfacing

Objective :
  1. To control direction
  2.  Number of steps
  3.  Rotation Angle
  4.  Speed

A stepper motor is a brushless and synchronous motor which divides the complete rotation into number of steps. Each stepper motor will have some fixed step angle and motor rotates at this angle. Interfacing of stepper to 8051 and ULN 2003 is shown in diagram.
            The main principle of this circuit is to rotate the stepper motor step wise at a particular step angle. The ULN2003 IC is used to drive the  stepper motor  as the controller cannot provide current required by the motor.
            The circuit consists of AT89C51 microcontroller, ULN2003A, Motor. AT89c51 is low power, high-performance, CMOS 8bit, 8051 family microcontroller. It has 32 programmable I/O lines. It has 4K bytes of Flash programmable and erasable memory. An external crystal oscillator is connected at the 18 and 19 pins of the microcontroller. Motor is connected to the port2 of the microcontroller through a driver IC.
            The  ULN2003A is a current driver IC. It is used to drive the current of the stepper motor as it requires more than 60mA of current. It is an array of Darlington pairs. It consists of seven pairs of Darlington arrays with common emitter. The IC consists of 16 pins in which 7 are input pins, 7 are output pins and remaining are VCC and Ground. The first four input pins are connected to the microcontroller. In the same way, four output pins are connected to the stepper motor.
            Stepper motor has 6 pins. In these six pins, 2 pins are connected to the supply of 12V and the remaining are connected to the output of the stepper motor. Stepper rotates at a given step angle. Each step in rotation is a fraction of full cycle. This depends on the mechanical parts and the driving method.

            Similar to all the motors, stepper motors will have stator and rotor. Rotor has permanent magnet and stator has coil. The basic stepper motor has 4 coils with 90 degrees rotation step. These four coils are activated in the cyclic order. There are different methods to drive a stepper motor.

Circuit Diagram :

Stepper motor interfacing with 8051


/* Stepper Motor Control                         */
/* 2nd Dec 2005                                  */
/* Copyright 2005 Circuits4You                   */ 
/* WWW -             */
/* Email -                 */
//================================================================= #include <reg51.h> #define Forward 0x01 #define Reverse 0x00 void delay(int k); void Stepper(int step,int speed,char direction); //================================================================= // Main Function //================================================================= void main() { Stepper(24*5,5,1); while(1); } //================================================================= // Variable delay //================================================================= void delay(int k) { int i,j; for(i=0;i<k;i++) { for(j=0;j<1000;j++); } } //================================================================= // Stepper motor control //================================================================= void Stepper(int step,int speed,char direction) { int k,a; a=0x01; //Initial value for full step mode for(k=0;k<step;k++) {
  P1 &= 0xF0;       //Clear Lower Bits
  P1 |= a;          //Motor is connected to P1
  delay(speed);    //Set delay for Speed

  if(direction==0)   //Direction decision
   a=a<<1;    //Shift left by 1-bit
   a=a>>1;    //Shif right by 1-bit

No comments:

Post a Comment