(Well, not so much a tutorial as an explanation of how I went about this, and I hope it's useful to someone who is starting out with steppers... (I was going to say "stepping out with steppers" but I won't.))1: Read up on steppers
. There are zillions of hits if you Google. At least understand that it's the stepping of the field that drags the motor round, and that there are unipolar and bipolar... basically expect 6 wires for unipolar and 4 for bipolar.2: Identify your motor and get a data sheet if possible
... well mine was reasonably easy, since it has a label on it telling me that it's a Mitsumi M42SP- 13NK. Problem is that the data sheet tells me there are 12V and 24V versions of this guy (with the same part number and no further identification on the motor?- how dumb is that....) 3: Suss out the wiring
. Hidden in a table in the datasheet were the phrases "2 phase" and "bipolar driving", which matches the visible fact that there are 4 wires. The datasheet is silent on which wire's which.... The sheet says the phases should show 4.2 ohms, the sticky label on the motor said 7.5. The wires btw, in order of appearance on the little pcb sticking out the side are red, black, blue and yellow. Measuring the resistance, I got 7.5 ohms between red and black, and 7.5 between blue and yellow... all other combinations (eg red - blue) showed open. So we can deduce red/black is one phase and blue/yellow the other. (Datasheet obviously talking cr@p about the 4.2 ohms then....)4: Get this guy turning with some VDC.
I was hoping that either this is a 12V motor, or that if it's a 24V one it'll at least work with 12V for my experimentation purposes. Ok, we know which wires belong together phase-wise, but not the order... 50-50 chance of getting this right... well I got it right first time. Took two wires from my 12VDC and guided by the sequence of wires as they stick out the side of the motor (red black blue yellow) I applied power thusly:
red +, black -
blue +, yellow - (and yay it moved)
black +, red - (reverse of 1st line) (and it moved again in the same direction)
yellow +, blue - (reverse of 2nd line) (and yet another step)
So now it's a matter of hooking this up to a 293D and Arduino.... In the coding that follows I cunningly named these 4 steps Red, Blue, Black and Yellow, named after the +ve wire5: Get to grips with the 293D...
Get hold of a datasheet and have a look at the pin-out pic: the key thing to see is that there are 4 pairs of pins named 1A/1Y, 2A/2Y, 3A/3Y and 4A/4Y. Take note that the pin pairs called 1, 2, 3 and 4 have got nothing to do with the actual pin numbers!
Each of these pairs has an input (the "A" one) and an output (the "Y" one). The logic is positive, so A high means Y high. The point of the chip is to be able to control a motor with a voltage and current other than that which the signals provide. Pin 8 of the 293 is where you provide the right voltage for the motor (say 12V) ...so, if you make an A-pin a high 5V in, you get a high 12V out on the matching Y-pin to drive the motor. So it seems possible to force the 4 wires on the motor to the necessary highs and lows we know we need from (4) above. 6: Let's wire the 293 to drive our 4 wire stepper...
In the case of a 4-wire bipolar stepper, we signal in and output to each pair of wires in a motor phase. I've got the red and black on the left side of the 293 (pairs 1 and 2) and the blue and yellow on the other side (pairs 3 and 4)... Take a look at the pic attached, and see that:
Pin 3 (1Y) goes to the motor red
Pin2 (1A) comes from Arduino D8
Pin 6 (2Y) goes to the motor black
Pin7 (2A) comes from Arduino D9
Pin 14 (4Y) goes to motor blue
Pin 15 (4A) comes from Arduino D10
Pin 11 (3Y) goes to motor yellow
Pin10 (3A) comes from Arduino D11
So to sequence the motor phases Red, Blue, Black, Yellow we simply cycle the Arduino D-pins 8, 10, 9, 11 with matching lows.
The other pins on the 293 are:
1, 9 and 16 to 5V (from Arduino for convenience for now...)
4, 5, 12 and 13 to ground (power supply 0V and tied to Arduino ground)
8 to motor power, 12V+ here.
(Arduino powered from USB here)7: And some code....
// to run a stepper from a 2938: Heat
// no libraries involved ;)
// Jim Brown March 2013
// E&OE, YMMV
int ledpin = 13;
//arduino pin names match motor wires
int red = 8;
int black = 9;
int blue= 10;
int yellow = 11;
//speed control.... pause between steps
int stepPause = 100;
// switch led on 13 off
... the 293 got hot to the touch quite quickly, and I don't have a heatsink to stick on top, so I didn't let it run too long. On a pcb the 4 ground pins should be soldered to some copper. Also the motor got quite warm: I wonder if mine isn't a 24 volt version, and drawing twice as much current as it should. I didn't even try to measure that, assuming that a meter wouldn't register the short pulse...