Wednesday, March 18, 2009

STEPPER MOTOR CONTROLLING

Introduction to Stepper Motors

A stepper motor is a permanent magnet or variable reluctance dc motor that has the following performance characteristics:

1. Rotation in both directions,

2. Precision angular incremental changes,

3. Repetition of accurate motion or velocity profiles,

4. A holding torque at zero speed, and

5. Capability for digital control.

A stepper motor can move in accurate angular increments knows as steps in response to the application of digital pulses to an electric drive circuit from a digital controller. The number and rate of the pulses control the position and speed of the motor shaft. Generally, stepper motors are manufactured with steps per revolution of 12, 24, 72, 144, 180, and 200, resulting in shaft increments of 30, 15, 5, 2.5, 2, and 1.8 degrees per step.

Stepper motors are either bipolar, requiring two power sources or a switchable polarity power source, or unipolar, requiring only one power source. They are powered by dc current sources and require digital circuitry to produce the coil energizing sequences for rotation of the motor. Feedback is not always required for control, but the use of an encoder or other position sensor can ensure accuracy when it is essential. The advantage of operating without feedback is that a closed loop control system is not required. Generally, stepper motors produce less than 1 horsepower(746W) and are therefore frequently used in low-power position control applications.

Theory

Unipolar stepper motor

Fig.1 A unipolar stepper motor

Unipolar stepping motors with 5 or 6 wires are usually wired as shown in the schematic in Figure 1, with a center tap on each of two windings. In use, the center taps of the windings are typically wired to the positive supply, and the two ends of each winding are alternately grounded to reverse the direction of the field provided by that winding. An animated GIF of figure 1.2 is available. The motor cross section shown in Figure 1 is of a 30 degree per step motor -- the difference between these two motor types is not relevant at this level of abstraction. Motor winding number 1 is distributed between the top and bottom stator pole, while motor winding number 2 is distributed between the left and right motor poles. The rotor is a permanent magnet with 6 poles, 3 south and 3 north, arranged around its circumference. For higher angular resolutions, the rotor must have proportionally more poles. The 30 degree per step motor in the figure is one of the most common permanent magnet motor designs, although 15 and 7.5 degree per step motors are widely available. As shown in the figure, the current flowing from the center tap of winding 1 to terminal a causes the top stator pole to be a north pole while the bottom stator pole is a south pole. This attracts the rotor into the position shown. If the power to winding 1 is removed and winding 2 is energized, the rotor will turn 30 degrees, or one step. To rotate the motor continuously, we just apply power to the two windings in sequence. Assuming positive logic, where a 1 means turning on the current through a motor winding, the following two control sequences will spin the motor illustrated in Figure 1 clockwise 24 steps or 4 revolutions:

Winding 1a 1000100010001000100010001
Winding 1b 0010001000100010001000100
Winding 2a 0100010001000100010001000
Winding 2b 0001000100010001000100010
time --->
Winding 1a 1100110011001100110011001
Winding 1b 0011001100110011001100110
Winding 2a 0110011001100110011001100
Winding 2b 1001100110011001100110011
time --->

Note that the two halves of each winding are never energized at the same time. Both sequences shown above will rotate a permanent magnet one step at a time. The top sequence only powers one winding at a time, as illustrated in the figure above; thus, it uses less power. The bottom sequence involves powering two windings at a time and generally produces a torque about 1.4 times greater than the top sequence while using twice as much power.

Bipolar stepper motor

Fig 2. A bipolar stepper motor

Bipolar permanent magnet and hybrid motors are constructed with exactly the same mechanism as is used on unipolar motors, but the two windings are wired more simply, with no center taps. Thus, the motor itself is simpler but the drive circuitry needed to reverse the polarity of each pair of motor poles is more complex. The schematic in Figure 2 shows how such a motor is wired, while the motor cross section shown here is exactly the same as the cross section shown in Figure 1. The drive circuitry for such a motor requires an H-bridge control circuit for each winding. Briefly, an H-bridge allows the polarity of the power applied to each end of each winding to be controlled independently. The control sequences for single stepping such a motor are shown below, using + and - symbols to indicate the polarity of the power applied to each motor terminal:

Terminal 1a +---+---+---+---
Terminal 1b --+---+---+---+-
Terminal 2a -+---+---+---+--
Terminal 2b ---+---+---+---+
time --->

Note that these sequences are identical to those for a unipolar permanent magnet motor, at an abstract level, and that avove the level of the H-bridge power switching electronics, the control systems for the two types of motor can be identical. Note that many full H-bridge driver chips have one control input to enable the output and another to control the direction. Given such bridge chips, one for eachwinding, the following control sequences will spin the motor identically to the control sequences given above:

Enable 1    1111111111111111
Direction 1 1100110011001100
Enable 2 1111111111111111
Direction 2 0110011001100110
time --->

To distinguish a bipolar permanent magnet motor from other 4 wire motors, measure the resistances between the different terminals. It is worth noting that some permanent magnet stepping motors have 4 independent windings, organized as two sets of two. Within each set, if the two windings are wired in series, the result can be used as a high voltage bipolar motor. If they are wired in parallel, the result can be used as a low voltage bipolar motor. If they are wired in series with a center tap, the result can be used as a low voltage unipolar motor.

How Stepper Motors Work

Stepper motors consist of a permanent magnet rotating shaft, called the rotor, and electromagnets on the stationary portion that surrounds the motor, called the stator. Figure 1 illustrates one complete rotation of a stepper motor. At position 1, we can see that the rotor is beginning at the upper electromagnet, which is currently active (has voltage applied to it). To move the rotor clockwise (CW), the upper electromagnet is deactivated and the right electromagnet is activated, causing the rotor to move 90 degrees CW, aligning itself with the active magnet. This process is repeated in the same manner at the south and west electromagnets until we once again reach the starting position.

Figure 1

Figure 1

In the above example, we used a motor with a resolution of 90 degrees or demonstration purposes. In reality, this would not be a very practical motor for most applications. The average stepper motor's resolution -- the amount of degrees rotated per pulse -- is much higher than this. For example, a motor with a resolution of 5 degrees would move its rotor 5 degrees per step, thereby requiring 72 pulses (steps) to complete a full 360 degree rotation.

You may double the resolution of some motors by a process known as "half-stepping". Instead of switching the next electromagnet in the rotation on one at a time, with half stepping you turn on both electromagnets, causing an equal attraction between, thereby doubling the resolution. As you can see in Figure 2, in the first position only the upper electromagnet is active, and the rotor is drawn completely to it. In position 2, both the top and right electromagnets are active, causing the rotor to position itself between the two active poles. Finally, in position 3, the top magnet is deactivated and the rotor is drawn all the way right. This process can then be repeated for the entire rotation.

Figure 2

Figure 2

There are several types of stepper motors. 4-wire stepper motors contain only two electromagnets, however the operation is more complicated than those with three or four magnets, because the driving circuit must be able to reverse the current after each step. For our purposes, we will be using a 6-wire motor.

Unlike our example motors which rotated 90 degrees per step, real-world motors employ a series of mini-poles on the stator and rotor to increase resolution. Although this may seem to add more complexity to the process of driving the motors, the operation is identical to the simple 90 degree motor we used in our example. An example of a multipole motor can be seen in Figure 3. In position 1, the north pole of the rotor's perminant magnet is aligned with the south pole of the stator's electromagnet. Note that multiple positions are alligned at once. In position 2, the upper electromagnet is deactivated and the next one to its immediate left is activated, causing the rotor to rotate a precise amount of degrees. In this example, after eight steps the sequence repeats.

Figure 3

Figure 3

The specific stepper motor we are using for our experiments (ST-02: 5VDC, 5 degrees per step) has 6 wires coming out of the casing. If we follow Figure 5, the electrical equivalent of the stepper motor, we can see that 3 wires go to each half of the coils, and that the coil windings are connected in pairs. This is true for all four-phase stepper motors.

Figure 5

Figure 5

However, if you do not have an equivalent diagram for the motor you want to use, you can make a resistance chart to decipher the mystery connections. There is a 13 ohm reistance between the center-tap wire and each end lead, and 26 ohms between the two end leads. Wires originating from seperate coils are not connected, and therefore would not read on the ohm meter.

Stepping Modes


There are several stepping modes that you can use to drive the stepper motor.

1. Single Stepping - the simplest mode turns one coil ON at a time. 48 pulses are needed to complete one revolution. Each pulse moves rotor by 7.5 degrees. The following sequence has to be repeated 12 times for motor to complete one revolution.

Pulse
Coil a1
Coil b1
Coil a2
Coil b2
1
ON



2

ON


3


ON

4



ON


2. High Torque Stepping - high power / precision mode turns ON two coils on at a time. 48 pulses are needed to complete one revolution. Each pulse moves rotor by 7.5 degrees.
The following sequence has to be repeated 12 times for motor to complete one revolution.

Pulse
Coil a1
Coil b1
Coil a2
Coil b2
1
ON
ON


2

ON
ON

3


ON
ON
4
ON


ON

3. Half Stepping - stepping is doubled and motor needs 96 pulses to complete one revolution. Each pulse moves rotor by approximately 3.75 degrees. Notice the mix of single stepping mode (lighter green) and high torque mode (darker green).

Pulse
Coil a1
Coil b1
Coil a2
Coil b2
1
ON



2
ON
ON


3

ON


4

ON
ON

5


ON

6


ON
ON
7



ON
8
ON


ON


- single stepping mode, normal strength, quiet

- high torque mode, high strength, slightly louder

Driving Stepper Motors with the L293D

The L293D contains two H-bridges (for more information on H-bridges, click here.) for driving small DC motors. It can also be used to drive stepper motors because stepper motors are, in fact, two(or more) coils being driven in a sequence, backwards and forwards. One L293D can, in theory, drive one bi-polar 2 phase stepper motor, if you supply the correct sequence.

STEPPER CONTROLLER SCHEMATIC

schem1.gif (5116 bytes)


Bipolar Stepper Motor

The L293D chip has 16 pins. Here is how each of the pins should be connected:

Pin 1, 9 Enable pins. Hook them together and you can either keep them high and run the motor all the time, or you can control them with you own controller(e.g. 68HC11).

Pin 3, 6, 11, 14 Here is where you plug in the two coils. To tell which wires correspond to each coil, you can use a mulitmeter to measure the resistance between the wires. The wires correspond to the same coil has a much lower resistance than wires correspond to different coils. (This method only applies to bipolar stepper motors. For unipolar stepper motors, you have to refer to the spec. sheet to tell which wires correspond to each coil.) You can then get one coil hooked up to pin 3,6 and another one hooked up to pin 11, 14.

Pin 4, 5, 12, 13 Gets hooked to ground.

Pin 8 Motor voltage, for the motors we are using, it is 12V.

Pin 16 +5V. It is the power supply of the chip and it's a good idea to keep this power supply separate from your motor power.

Pin 2, 7, 10, 15 Control signals. Here is where you supply the pulse sequence. The following is how you pulse them for a single-cycle (to move the motor in the opposite direction, just reverse the steps. i.e. from step 4 to step1):


Coil 1a

Coil 2a

Coil 1b

Coil 2b

Step 1

High

High

Low

Low

Step 2

Low

High

High

Low

Step 3

Low

Low

High

High

Step 4

High

Low

Low

High

20 comments:

Madhur Behl said...

Hi,
I wanted to congratulate you as this blog is so commendable, its absolutely great.
I am a robotics enthusiast myself and in charge of the robotics club in our College.
Integrating everything from basic to higher level robotics was certainly required and you have done that.
well done !

heloitsadi said...

Please specify your collage and be in attachment with this blog as lots of matter about autonomous robots and robo programming will be uploaded soon.

alok said...

hello boss..
can u pls tel me abt the different motors available which can be used in a robowar system of abt 15-20 kg weight for a good fast n controlled motion..if u can specify the power,cost n current ratings too..coz there is a current boundation

thnx..!!

heloitsadi said...

You will definitely need high RPM motors(>500 RPM in 12V to 24V ratings) for robowar machines, Geared DC motors will be the best and easy to get options. You can look for them at-
robokits.in
nex-robotics.com
thinklabs.in

Also you can refer to "Calculation of Torque and RPM motors" tutorial to get an idea about the exact specification of motors you will require.

Please mention the city you are from, so that i can provide you the exact shop locations to get these motors.

alok said...

i'm frm jpr only..

thnx a lot..!!u're doin a gr8 gr8 work out here..

heloitsadi said...

Thanks for the appreciation Alok !

Nice to see someone from Jaipur interested in this field, Which college are you from and what all work have you done in robotics...

alok said...

i'm from mnit..
me n my batchmates want to make a bot for robowars..so we're looking for some help

heloitsadi said...

You can contact Contrivence, Temple computers or Tishitu electronics if they can provide the hydraulics and pneumatics assemblies, hopefully you may get it..

Faris said...

i am going to do the Magnetic Lunar Dust Removal Brush as my senior design project and my part will be the electric stuff, so i need help if you can. please contact me at:
gamel-usa@hotmail.com

thanks.

heloitsadi said...

Hi Faris,

Your project seems to be very interesting. I will definitely help as much as i can. You can just mail the detailed description about the project at "robozeal@gmail.com" and contact on this very ID for further queries.

Anonymous said...

Please stop stealing other people's work. Have you asked for a permission to use the contents from the author:(?

http://www.cs.uiowa.edu/~jones/step/types.html#multiphase

heloitsadi said...

The content is neither posted under my name nor it is being copied with the intention of stealing someone's work.. All those posts posted solely by me are under my name and those which are taken over from somewhere includes the reference of that person. "The aim of the blog is to provide the data related to robotics collectively at one place". I have maintained all the links as it is, If you are the author of the content and want it to be removed, it will be done.. just leave your reply regarding this.

shobhan03 said...

good job...nice info.. this page certainly goes into my "save page as"... i wanted to know how to operate a stepper motor and was hoping to hit few good pages on it, and i found this..
thanks once again..

waseem.rajpoot said...

hi;
can you tell me that how much weight this "ST-02: 5VDC" stepper motor can afford'
actually i want to make a hand for robot to pick the block.
so this motor is good for this work...???

sindhu said...

hi,
awsome blog. was informative. i have a doubt. i need to move a 7kg solar panel.should i consider weight of solar panel while choosing stepper motr?

leo said...

very nice each and every word are informative great well done......

kiran said...

Can anyone post the code for driving stepper motor with ATMEGA16 through L293D........

Naeem said...

hi i am going to design wireless stepper motor cotrol using rf communication...can u tell me that interfacing code is same or different for different stepper motor..??

Naeem said...

if u can help in writing the interfacing code then plz..silent_life74@yahoo.com.

gaurav rai said...

hey frds i want to make something with a one single stepper motor which works on 12v can help me wat can i make plz