basic stepper control

21
Internship Project (July 2005 ) Stepper Motor Driver Circuits Group Members: 1> Zubair Shahid s2354 2>Syed Faisal-ur- Rahman s2306 INTRODUCTION: This report is based on the experiments we performed on steppers during our internship at FAST-NUCES Karachi. The purpose of our experiments was to study stepper motors, to design stepper driver circuit and to control stepper motors using computers. This report includes: 1> Information about stepper motors and their types. 2> Identifying the type and decoding the leads of a stepper motor. 3> Stepper control using digital circuit. 4> Stepper control using parallel port. 5> Dual-axis stepper control. We hope this report will help anybody who is interested in studying about stepper motors. Zubair Shahid (s2354) Syed Faisal (s2306)

Upload: suneela-khandavalli

Post on 26-Mar-2015

96 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Basic Stepper Control

Internship Project (July 2005 )  

Stepper Motor Driver Circuits        

                   Group Members: 

                   1> Zubair Shahid                                          s2354

                   2>Syed Faisal-ur-Rahman                            s2306INTRODUCTION:

 This report is based on the experiments we performed on steppers during our internship at FAST-NUCES Karachi. The purpose of our experiments was to study stepper motors, to design stepper driver circuit and to control stepper motors using computers. This report includes:

1>    Information about stepper motors and their types.2>    Identifying the type and decoding the leads of a stepper motor.3>    Stepper control using digital circuit.4>    Stepper control using parallel port.5>    Dual-axis stepper control.

We hope this report will help anybody who is interested in studying about stepper motors.                                                                     Zubair Shahid (s2354)                                                                    Syed Faisal     (s2306)               

Page 2: Basic Stepper Control

              

STEPPER MOTORS

Stepper motors are digitally controlled brushless motors that rotate a step every time a clock pulse is applied to a driver circuit used to control the stepper.

Number of step angles may vary normally from 1 to 30 degrees per step. Stepper motors are different from dc motors in such a way that they can produce high torque at low speed, which makes them suitable for the design of applications needing high precision and low speed control.

KINDS OF STEPPER MOTORS

1> Variable-reluctance stepper motors.2> Permanent-magnet stepper motors.

3> Hybrid stepper motors.

1>VARIABLE-RELUCTANCE MOTORS

The variable reluctance motor does not use a permanent magnet. As a result, the motor rotor can move without constraint or "detent" torque. This type of construction is good in non-industrial applications that do not require a high degree of motor torque, such as the positioning of a micro slide.

Page 3: Basic Stepper Control

The variable reluctance motor in the above illustration has four "stator pole sets" (A, B, C,), set 15 degrees apart. Current applied to pole A through the motor winding causes a magnetic attraction that aligns the rotor (tooth) to pole A. Energizing stator pole B causes the rotor to rotate 15 degrees in alignment with pole B. This process will continue with pole C and back to A in a clockwise direction. Reversing the procedure (C to A) would result in a counterclockwise rotation.

2>PERMANENT-MAGNET STEPPER MOTORS

The permanent magnet motor, also referred to as a "canstack" motor, has, as the name implies, a permanent magnet rotor. It has a same stator as a variable reluctance motor. It’s simple construction and low cost make it an ideal choice for non industrial applications, such as a line printer print wheel positioner.

Permanent-magnet motors have following three types:

a>UNIPOLAR STEPPER MOTORS

It is normally available with 5 or 6 wired combinations. It consists of a four-pole or two coil pair stator with center taps between coil pairs and a six-toothed permanent magnet rotor. The center taps may be wired internally and brought out as one wire (making 5 wired unipolar stepper) or may be brought out separately as two wires (making 6 wired unipolar stepper).The center taps are typically wired to the positive supply voltage,

Page 4: Basic Stepper Control

whereas the two free ends of a coil pair are alternatively grounded to reverse the direction of the field provided by that winding. When current is applied on the center tap, it causes on stator pole to go north and the other to go south. By removing current from the first tap and giving it to the other causes the rotor to move one step.

b>BIPOLAR STEPPER MOTORS

These steppers resemble unipolar steppers but there coil pairs do not have center taps. This means that instead of simply supplying a fixed supply voltage to a lead, as was the case with unipolar steppers, the supply voltage must be alternately applied to different coil ends.

At the same time, the opposite end of a coil pair must be set to the opposite polarity (ground).The circuit used to derive bipolar motors need H-bridge network for every coil pair.

c>UNIVERSAL STEPPER MOTORS

These steppers represent a unipolar-bipolar hybrid .A universal stepper motor comes with four independent windings and eight leads. By connecting the coil windings in parallel the universal motor can be converted into a unipolar motor. If the windings are connected in series, the stepper can be converted into a bipolar.

3>HYBRID

Hybrid motors combine the best characteristics of the variable reluctance and permanent magnet motors. They are constructed with multi-toothed stator poles and a permanent magnet rotor. Standard hybrid motors have 200 rotor teeth and rotate at 1.80 step angles. Other hybrid motors are available in 0.9ºand 3.6º step angle configurations. Because they exhibit high static and dynamic torque and run at very high step rates, hybrid motors are used in a wide variety of industrial applications.

Page 5: Basic Stepper Control

OPERATIONS 

            The stepper motor can be operated in three basic modes discussed below:The tables in the following section are for uni-polar stepper motors, for bi-polar stepper motors,  convert 1’s to “+V” and 0’s to “-V”

 (a)             Full Sepping:

In full stepping, the motor rotates one step angle. Full stepping can be done in two major modes:

(I)                High torque:            In high torque mode, the motor rotates with high torque but with a drawback of consuming more current because two coils are energized at one instant.A      A-        B         B-1       1          0          00       1          1          00       0          1          11       0          0          1 (II)             Low Torque:

In low torque mode,     the rotor rotates with relatively low torque with the added advantage that it consumes less current since only one coil is energized at any one instant.A         A+       B         B+1          0          0          00          1          0          00          0          1          00          0          0          1

 (b)             Half  Stepping:

In the half stepping mode, the rotor is rotated half the step angle of the motor used. Although the torque obtained is not high, the rotor can be positioned more priciesly.

            A         A-        B         B-            1          0          0          0            1          1          0          0            0          1          0          0                      0          1          1          0            0          0          1          0            0          0          1          1            0          0          0          1            1          0          0          1

Page 6: Basic Stepper Control

 (c)              Micro Stepping:

   It is also known as mini-stepping. It utilizes two phases simultaneously with the two currents deliberately made unequal. The current in first phase is held constant while that in second phase is increased in very small increments until maximum current is reached. The current in first phase is then reduced to zero using same small increments. In this way, resultant step is very small and then is called as micro step.  

Page 7: Basic Stepper Control

 

CONTROLLING USING DIGITAL DRIVERThe driver for stepper motor must be able to produce fixed pattern of output

pulses for the stepper motor depending on the mode of driving. The goal can be achieved by using a combinational circuit of logic gates and flip flops.

If using the TTL, additional circuitry must also be added so as to power the motor windings and to control the spikes produced by the coil. Powering circuits may be a simple transistor, Darlington pair, PMOSFET etc.

For simplification purposes, current amplifying IC’s can be used for powering the motor windings. A few of them are described below:

ULN2003:       Array of 7 Darlington pairs with protection diodes for up to 50V spikes and can supply current up to 500mA.ULN2023:       Array of 7 Darlington pairs with protection diodes for up to 95V spikes and can supply current up to 350mA.ULN2803:       Array of 8 Darlington pairs with protection diodes for up to 50V spikes and can supply current up to 500mA.ULN2823:       Array of 8 Darlington pairs with protection diodes for up to 95V spikes and can supply current up to 350mA.

                                                                        If using a bi-polar stepper motor, an additional circuit, known as an H-Bridge is used to convert the logics 0 & 1 into +V and –V.

                                                       H-bridge schematic diagram 

Page 8: Basic Stepper Control

CONTROLLING USING COMPUTERThe logics used for driving a stepper motor can be produced using any output port of a computer. Warning:Additional care must be taken while connecting any circuitry to the computer. Generally, most computer ports can handle currents below 1.5mA. In case of providing or sinking excess current from the port, the port or the mother board can be permanently damaged. To limit the current drawn from the port, it is recommended to use a buffer IC such as 74LS244 etc.

Page 9: Basic Stepper Control

Experiments 

Experiment #1 

IDENTIFYING THE TYPE OF A STEPPER MOTOR Before designing a driver circuit you must know which type of stepper motor you are using.Normally unipolar, bipolar and universal are available in the market. Based on this, you can guess that if your stepper has four leads it is more likely to be a bipolar .If it has 6 leads it is more likely a unipolar with separate center taps. If it has 5 leads it is more likely a unipolar with common center taps. A motor with 8 leads would most likely be a universal stepper motor or variable-reluctance motor. In this case try spinning the shaft if it spins freely then it is variable reluctance. If it gives some resistance then it is a permanent-magnet universal stepper.  DECODING THE LEADS OF A STEPPER MOTORS For this purpose you need to use an ohmmeter. 1>In case of bipolar just determine which pair yields the low resistance. Low resistance indicates that the wires are two ends of same winding. If two wires are not part of the same windings then the will have infinite resistance between them. 2>Similar approach will lead to the decoding of universal stepper motors. 3>Decoding a six-wire unipolar stepper motors requires isolating two three-wire pairs. From there, you figure out which is the common by noticing which measured pair among the isolated three wires gives a unit R worth of resistance and which gives a unit 2R worth of resistance.           

   

Page 10: Basic Stepper Control

For our experiments we used a unipolar 6-leads stepper.To decode the stepper we made a table using the color of the wires. 2R indicates 2 wires connected but none of them is a ground.R indicates connected and one of them is a ground.(I) Infinite resistance indicates the wires are not connected.   Red           Blue Gray Brown White Yellow Resistance

o O         I

o   o       R

o     o     I

o       o   2R

o         o I

    o   o   R

  O       o 2R

  O   o     R

  O o       I

  O     o   I

      o   o R

  By using the above table we figured out that Red, Gray and White are connected and Gray is the ground. Similarly Blue, Brown and Yellow are connected and Brown is the ground.   

  

Experiment #2 

Objective:       Driving a uni-polar stepper motor using digital logic circuitry using 555 timer. 

For driving a uni-polar stepper motor in wave drive mode, we need to give current to the four active wires of the stepper motor in the following pattern. 

A         A+       B         B+1          0          0          0

Page 11: Basic Stepper Control

0          1          0          00          0          1          00          0          0          1

  For this purpose we used a bi-directional shift register 74LS194 in such a manner that it shifted a single high value in both forward and reverse direction thus rotating the shaft in CW and CCW direction.The stepper motor which we used drew about 350mA but most TTL IC’s can source about 25mA. Thus we used a ULN2003 IC which can source up to 500mA.The speed and the amount of turns that the motor takes is dependent on the frequency and the number of pulses applied to the clock pulse input whereas the direction of the motor is dependent on the combinational values at the s0 and s1 of the shift register.  

Experiment #3 

Objective:       Driving a uni-polar stepper motor using digital logic circuitry using parallel port for pulse generation. 

For this purpose, we connected the pin 2 of parallel port to the CP input of the shift register and pin 18 to the ground of our circuit.For simplicity, we used non-XP platform for this experiment.The function we used is the following: void ClockPulse(int pulses, int tHigh, int tLow){            for(int x=0;x<pulses;x++)            {                        outportb(0x0378,0x01);                        delay(tHigh);                        outportb(0x0378,0x00);                        delay(tLow);

                                    }                        } 

The above function produces a pulse “pulses” times with output HIGH for “tHigh” milliseconds and LOW for “tLow milliseconds.

             

Page 12: Basic Stepper Control

Experiment #4 

Objective:       Driving a uni-polar stepper motor using parallel port for driving sequence (Half-step/Full-Step/Wave-drive). 

It is much simpler to control a stepper motor by using the parallel port rather than using driving circuitry because of the complexity involved in the latter. Again severe attention should be given to the protection of the parallel port. As described earlier, generally parallel ports can handle currents of about 1.5 mA and an average stepper motor require currents >100mA. For this purpose, we used 74LS244 for buffer and ULN2003 for the current amplifier. The circuit diagram was as the following:     

Pin 2, 3, 4 and 5 of the parallel port are connected to inputs of the buffer IC. The outputs of the buffer are connected to the inputs of the ULN2003 and finally the outputs of the ULN2003 are connected to the active wires of the stepper motor making sure that order of the signal reaching the motor should not change. Since we used a “Centronics” 36 pin cable, we connected a few pins from 19-30 to the ground of our circuit. For the programming part, we used a separate function for every drive sequence. The following tables show the outputs to the port required to run the motor in desired format.

Wave DriveStep Output(HEX) Output(BIN)

1 1 00012 2 00103 4 01004 8 1000

  

                

Full Step(High Torque)Step Output(HEX) Output(BIN)

1 9 10012 C 11003 6 01104 3 0011

Half StepStep Output(HEX) Output(BIN)

1 8 10002 C 11003 4 01004 6 01105 2 00106 3 00117 1 00018 9 1001

Page 13: Basic Stepper Control

           

 The functions for simply driving the stepper motor in one direction in non-XP platform were as the following: void Wave(int steps, int interval){                for (int x=0;x<steps;x++)                {                                outportb(0x0378,0x01)                                delay(interval);                                outportb(0x0378,0x02)                                delay(interval);                                outportb(0x0378,0x04)                                delay(interval);                                outportb(0x0378,0x08)                                delay(interval);                }} void FullStep(int steps, int interval){                for (int x=0;x<steps;x++)                {                                outportb(0x0378,0x09)                                delay(interval);                                outportb(0x0378,0x0c)                                delay(interval);                                outportb(0x0378,0x06)                                delay(interval);                                outportb(0x0378,0x03)                                delay(interval);                }}  void HalfStep(int steps, int interval){                for (int x=0;x<steps;x++)                {                                outportb(0x0378,0x08)                                delay(interval);                                outportb(0x0378,0x0c)

Page 14: Basic Stepper Control

                                delay(interval);                                outportb(0x0378,0x04)                                delay(interval);                                outportb(0x0378,0x06)                                delay(interval);                                outportb(0x0378,0x02)                                delay(interval);                                outportb(0x0378,0x03)                                delay(interval);                                outportb(0x0378,0x01)                                delay(interval);                                outportb(0x0378,0x09)                                delay(interval);                }}  We then altered the above code with the help of some if-then-else statements so as to include direction control. For controlling the degrees of rotation, following algorithm can be followed:Complete revolutions = (targetº / ºper step of motor) / x              

                                Remaining steps= (targetº / ºper step of motor) % xwhere x is # of steps for complete revolution

                                                                 

                                 Experiment #5 :  

Objective:    Achieving dual axis stepper control. 

DUAL-AXIS STEPPER CONTROL In previous experiment we controlled one stepper motor using computer. Now if we require dual axis control (like in printers) then we have to know how to control two motors with the same program.For that we need to make a 2 dimensional matrix and each element of the matrix will consist of numbers which will use more than 4 bits (means we have to use D4 to D 7 addresses). This can be understood by the following example: If we have to represent 17 in binary then it will look like 10001 and in 8-bit format   0001 0001 If we break the above then we will get two ones on the first address of the 2 4-bit pairs.We know in full step mode we need to shift “1” by one address so to give current to the next coil, in dual-axis control we need to do the shifting process with both the motors.For this purpose we use 2 dimensional matrix (in our program 2d array) : x/y motor coils Coil 1x Coil 2x Coil 3x Coil 4x

Page 15: Basic Stepper Control

Coil 1y 17 18 20 24Coil 2y 33 34 36 40Coil 3y 65 66 68 72Coil 4y 129 130 132 136  We implemented the above technique using the following code:#include <iostream.h>

#include <conio.h>

#include <dos.h>

 

int posX=-1;

int posY=-1;

int turnsX=1;

int turnsY=1;

int

Arr[4][4]={{17,18,20,24},{33,34,36,40},{65,66,68,72},{129,130,132,136}};

 

void Move(int x,int y)

{

//if (x!=0&&y!=0)

{

        if (posX==0&&x==-1)

        {

               posX=3;

               turnsX-=1;

 

        }

        else

        if (posX==3&&x==1)

        {

               posX=0;

               turnsX+=1;

        }else

        if (posX!=3&&x==1)

        {

               posX+=1;

        }else

        if (posX!=0&&x==-1)

        {

               posX-=1;

        }

 

 

Page 16: Basic Stepper Control

 

        if (posY==0&&y==-1)

        {

               posY=3;

               turnsY-=1;

        }else

        if (posY==3&&y==1)

        {

               posY=0;

               turnsY+=1;

        }

        else

        if (posY!=3&&y==1)

        {

               posY+=1;

        }else

        if (posY!=0&&y==-1)

        {

               posY-=1;

        }

 

 

}

        outportb(0x0378,Arr[posX][posY]);

 

}

 

void main(void)

{

        clrscr();

        for (int n=0;n<=12;n++)

              

Move(1,1);

        cout<<"\n\n"<<turnsX<<"  "<<turnsY;

        getch();

 

        clrscr();

        for (int

a=0;a<=4;a++)

        {

               for (int b=0;b<=4;b++)

               {

                      

cout<<Arr[a][b]<<"\t";

 

Page 17: Basic Stepper Control

               }

               cout<<endl;

        }