Using the DVM, find the pairs of wires that have similar
resistance and label them P1 and P2. These are the four
control wires. Also find the pair of wires that do not
measure any resistance and label them the positive power
source Vcc (+ 12 volts). Do not connect them to the battery
or bench power supply at this time. The ground (Vss) wire
leading from the stepper motor controller circuit should
already be connected to the (-) terminal of the 12 volt
battery as shown in the schematic. Make sure that the
ground wire is connected between the stepper motor
controller circuit and the microcontroller. Use the DVM to
insure that there is continuity between all these power and
ground connections.
Start the wire decoding process by downloading and
running the Easy C Professional Stepper Motor application
stepper1.hex that is provided on the SERVO website at
www.servomagazine.com. The LEDs should be flashing in
a specific pattern indicating that the stepper motor coils are
driven using the full step or wave step pattern. Take the
remaining two pairs of wires leading from the stepper
motor and connect them to the stepper motor driving
circuit as shown in the schematic. Now connect the (+)
terminal of the 12 volt battery or bench power supply to
the pair of wires labeled + 12 volts and watch carefully for
any shorts or hot wires. See if the stepper motor starts
turning or vibrating. If it turns CW or CCW,
congratulations! You are done. Otherwise, repeat the above
procedure, but swap the positions of two pairs of control
wires, P1 and P2 and even swap the wires between each
pair until the stepper motor starts turning. Make sure that
you remove the + 12 volt power cable while performing the
swaps. If the stepper motor starts to move in both
directions, it means you are getting closer to the correct
connection. If this process does not seem to work for you,
it could be that you are trying to connect to a bipolar
stepper motor or that the stepper motor requires higher
voltage and current (some stepper motors use 35 volts).
Using a driver such as the ULN2803A for driving
stepper motors is a good way to learn how they work. It
also protects the microcontroller from possible harm from
voltage spikes induced by the stepper motor coils from
currents induced by collapsing magnetic fields “snubbing
out the spikes” with its internal protection diodes. Using it
for driving large stepper motors is not recommended since
they can draw much more than the 500 mA from each coil.
#include “Main.h”
void main ( void )
{
int i = 0; // Loop Index for VEX Output Bit
int j = 0; // Loop Index for Stepper Motor
Command
{
// Loop for Stepper Motor Commands
for ( j=0 ; j<4 ; j++ )
{
// Single Phase Stepper Motor Commands
int Single_Phase[4] = {0b0001, 0b0010, 0b0100,
0b1000};
// Dual Phase Stepper Motor Commands
int Dual_Phase[4] = {0b0011, 0b0110, 0b1100,
0b1001};
SetDigitalOutput ( 1 , 0 ) ; // Turn Coil 1 Off
SetDigitalOutput ( 2 , 0 ) ; // Turn Coil 2 Off
SetDigitalOutput ( 3 , 0 ) ; // Turn Coil 3 Off
SetDigitalOutput ( 4 , 0 ) ; // Turn Coil 4 Off
// Loop for activating each coil
// from the Stepper Motor
// using the Single Phase bit patterns
for ( i=1 ; i<5 ; i++ )
{
// Turn Coil On or Off
// depending on stepper
// motor command
SetDigitalOutput ( i , (Single_
Phase[j]>> (i-1)) ) ;
}
// Wait 7 milliseconds - works
// with larger six wire
// stepper motor and a ULN2804 IC
Wait ( 7 ) ;
}
while ( 1 ) // Stepper Motor Control loop
}
LISTING 1. This is an example written in Easy C Professional that shows you how to move the stepper
motor using the full step mode with a microcontroller and a ULN2803A driver.
72 SERVO 10.2010