Controlling Stepper Motors with the 12way Interface
The right hand numbers in fig. 1 represent the output
lines at the interface board. Wires from the stepper motors are connected
to these points. The combination of "AND" and "Exclusive
OR" gates determines which line is turned on.
fig 1.
Digital Logic - A Brief Refresher:
If both inputs of an "AND" gate are HIGH,
the output will be HIGH. If either input is LOW, the output will be LOW.
Ie both input 'a' AND input 'b' must be HIGH for the output to be HIGH.
The output of the "Exclusive OR" will be LOW unless
'a' OR 'b' is HIGH all other conditions will produce a LOW output.
Eg if Pin 9 at the printer port is HIGH (ie 128 sent), output
12 will be ON.
If Pin 9 and Pin 8 are HIGH (ie
128 + 64 = 192 sent), output 11 will be ON.
The second example is the key to understanding the logic of this design (Compliments of Ian Threlfo): If Pins 9 and 8 at the printer port are HIGH, then pin 3 of the AND gate will be HIGH. This means that pins 1, 2, 5 and 6 of the two Exclusive OR gates will be HIGH. The outputs of the Exclusive ORs will therefore be LOW (off). There are two methods used to drive the stepper motor:
Uni phase - where each line is turned on in sequence.
Assuming you have identified the correct order of wires coming out of the
stepper motor and connected them to points 12, 11, 10 and 9 consecutively
(White, Blue, Red, Yellow) , the motor will rotate if you send the sequence:
out 128
out 192
out 64
out 32
Bi phase - this method of driving turns on two coils at
once and produces increased torque. If we label the coils as "A",
"B", "C" and "D", the sequence of turning
on coils is:
A + D
A + B
B + C
C + D
In the above example, with Coil A connected to output
12, Coil B connected to output 11, Coil C connected to output 10 and Coil
D connected to output 9 we have problems. If you understood the Digital
Logic explanation in the box on the previous page you would realise that
it is not possible to turn on coils 'A' and 'B" together, or coils
'B' and 'C' together.
To drive the steppers in Bi phase mode, you must connect
the wires to each 'bank' of outputs so that the clash described above does
not occur (A "bank" consisting of three output lines controlled
by two lines from the printer port.). The simplest approach is to connect
the wires from each motor to the first, second and third outputs respectively
of each bank.
To connect the first motor …
Motor1 Line 1 White output 12 out 128
Motor1 Line 2 Blue output 9 out 32
Motor1 Line 3 Red output 6 out 8
Motor1 Line 4 Yellow output 3 out 2
In the example above, A = 128, B = 32, C = 8 and D = 2.
To drive the motors in Bi phase, the output codes will
be:
A + D = 128 + 2 = 130
A + B = 128 + 32 = 160
B + C = 32 + 8 = 40
C + D = 8 + 2 = 10
In Pascal, the source code is:
port[888] := 130;
delay(5);
port[888] := 160;
delay(5);
port[888] := 40;
delay(5);
port[888] := 10;
delay(5);