# Practical Electronics/Stepper Motors

Stepper Motors are devices that turn a shaft by a small set angle (usually between 1 and 5 degrees) at a time. This is done very precisely, and so they are very useful for application requiring motion that does not have any feedback to govern the motor speed. However, they cannot be simply driven by a DC or AC voltage like simpler motors; they need more complex circuitry to drive them.
For more information on stepper motors, please visit the "Stepper" page in the Wikibook of Electric Motors and Generators. For this book, we will just look at the basics. There are two kinds of stepper motor - unipolar and bipolar. Bipolar motors are the simplest, so we will look at those first.

## Bipolar Motors

Bipolar motors have two coils, each with a connection at each end, giving a total of four wires. It is possible to identify which wires are which, as the resistance between wires of different coils will be infinite. Generally, the connections are named in schematics, 1a and 1b being the two connections for one coil and 2a and 2b being for the other coil.
To drive a bipolar stepper motor by one step, the coils have to be energized in a particular sequence. Consider just one coil; if 1a is held high and 1b is held low, the coil is said to conduct forwards. If 1a is at ground and 1b is high, then it conducts backwards. To drive the stepper motor, the coils have to be switched from conducting forwards to conducting backwards alternately.
The input voltages to the four wires in order to drive the motor forward on step are shown in the table below. The coil polarities generated by this sequence are shown on the far right of the table.
| Seq. | 1a | 1b | 2a | 2b | Coil 1 Polarity | Coil 2 Polarity |
| 1 | + | - | + | - | Forwards | Forwards |
| 2 | - | + | + | - | Backwards | Forwards |
| 3 | - | + | - | + | Backwards | Backwards |
| 4 | + | - | - | + | Forwards | Backwards |
There are many ways to produce this sequence, from using basic logic to incorporating the control into a micro-controller. Below is the circuit diagram for a motor controller made of simple logic components. Every time there is a low-to-high transition on the STEP input, the circuit advances the output on stage. The DIR input controls the direction of the step; if it is high, it steps one way, if it is low it steps the other way.
However, this circuit cannot drive a stepper motor by itself, as the logic outputs cannot supply nearly enough current. Some sort of amplification is needed. A dual H-Bridge arrangement can provide the necessary current and voltage reversal:
Recommended transistors for driving stepper motors are MOSFETs IRF510 or IRF530 (N-channel) and IRF9520 or IRF9530 (P-channel). These have built in clamping diodes, so the D1-D8 in the above circuit are unnecessary. If you are operating at high currents, it is wise to keep them for added protection. However any kind of power transistor (FET or BJT) should be suitable for this, as long as the current required to drive the motor does not exceed the rating of the transistor.

## Unipolar Motors

Unipolar motors have a more complex system of coil windings, but a simpler method of driving. Instead of having two connections, a unipolar motor coil has three - there is a centre tap on each coil. Unipolar motors have six leads therefore, in two groups of three. Sometimes there are just five, as the centre taps may be joined internally.
To identify unmarked leads, first find the two triplets of wires - there will be no connection at all between the triplets. Then, find the centre tap - this is the wire with equal resistance between it and the other two wires in the triplet. If the centre taps are joined together internally, this will be more difficult, but by trial and error, it should be possible. Usually, however, the connection can be worked out by looking carefully as the wires as they come out of the motor - they will often be physically grouped into triplets or connected to a small PCB with the connections laid out logically.
By holding this centre tap at a common voltage (probably ground) and switching the voltage used to power to motor from one end of the coil to the other, the direction of voltage flow can be reversed.
The windings in unipolar motors are bifilar, meaning there are two coils wound on top of each other - one connecting the "a" connector to the centre tap and one connecting the "b" connector to the centre tap. Because each half of the bifilar winding is as big as one coil in a bipolar motor, unipolar motors tend to be wider than bipolar motors.
The advantage of unipolar motors is that there is no need for H-bridge drivers because all that needs to be done is to apply a high voltage to one of the connectors when the coil is to be energised - the other end does not need an opposite treatment, it can just be disconnected rather than having to be connected to the opposite power rail.
The sequence of voltages applied to connectors 1a, 1b, 2a and 2b is the same as before, so the system of XOR gates and JK flip-flops (or PIC, etc) can be used for unipolar motors. The transistor driver circuit is simpler, however:
Any kind of power transistor (FET or BJT) should be suitable for this, as long as the current required to drive the motor does not exceed the rating of the transistor. Suggested transistors are IRF520, TIP31, TIP120, etc. Again, if the transistors have built in clamping diodes, the separate diodes are not needed, but will not do any damage if left in (suitable is any diode with voltage and forward current values similar to the transistor).
If need be, unipolar motors can have the centre taps ignored and be used as bipolar motors. This will result in less torque as the coils are twice as long and so have twice the resistance and half the current. Alternatives, ignore one of the end connections and use one half of the winding. This should provide exactly the same characteristics as the motor when used normally. However, care should be taken to insulate the dangling wire as it will act like an auto-transformer and double the voltage applied to the lower half-coil.