|PSMD Triple Axis Stepper Controller|
The gift stimulated me to learn about stepper motors and drivers, as well as ultimately to put together a functional device which makes use of both. While at the beginning I was shying away from 3D printing, in the end I've migrated in that direction given the wealth of information available on the subject. This post is not about a 3D printer, but rather about the motion systems used in a 3D printer, or in any CNC machine for that matter (milling machine, laser engraver, etc).
All stepper motor drivers operate in current limiting mode. This means that they turn off voltage when a maximum current has been reached. The stepper motors that I am using for the x-axis and y-axis positioning are rated for 4V. Yet they are being driven by a computer power supply outputting 12V. If the 12V remains applied for the duration of a step, the motor would get too hot or could have windings burn out. The A4988 and other similar drivers sense the current through a resistor and limit the duty cycle (amount of time) that the voltage is applied to the motor through an H-bridge, effectively limiting the average current seen by the motor. The details are a little more complicated:
"Each full-bridge is controlled by a fixed off-time PWM current control circuit that limits the load current to a desired value, ITRIP . Initially, a diagonal pair of source and sink FET outputs are enabled and current flows through the motor winding and the current sense resistor, Rsense. When the voltage across Rsense equals the DAC output voltage, the current sense comparator resets the PWM latch. The latch then turns off the appropriate source driver and initiates a fixed off time decay mode." See the A4988 datasheet here for more details.
You can adjust the reference voltage, Vref (which is, I think, the DAC output voltage referenced above) using a potentiometer wired to the REF pin on the A4988 chip. In my case, I purchased stepper motors rated at 1.2A per coil of current. (Other important facts about the motors: 44 oz-in holding torque, and 4V rated voltage, see here for motor specs ). According to the data sheet, Itrip = Vref/(8Rsense). Looking at the Polulu website for the A4988, Rsense = 0.05 Ohm, so we can solve for the desired Vref = Itrip x 8 x 0.05. With Itrip =1.2A, we get Vref = 1.2 x 8 x 0.05 = 0.48V. I set the potentiometers for this reference. There are excellent directions online for setting up the A4988 at this URL: http://aeons.phrenzy.org/~berserk/reprap/PololuPres_V3.pdf .
All the stepper drivers which I have are controlled by three digital TTL level pins. One controls whether the stepper is enabled or disabled. The second controls the direction of spin of the stepper. The third is a step pin, which initiates a step when it is pulsed high (or maybe when it drops low again... I'm not sure). A simple function to "step" a stepper has the following form:
void takeSingleStep(int stepPin)
When called, this function pulses the step pin low, then high, then low again. I found that the second delay (currently set at 1000 us = 1ms) is important; if that delay is too small then the stepper doesn't have time to execute multiple steps sequentially and it makes weird noises and moves erratically.
A simple function which turns on or off the stepper motors is shown below.
void enableStepperXYZ(int isEnabled, int enablePin)
digitalWrite(enablePin, LOW); // enable HIGH = stepper driver OFF
digitalWrite(enablePin, HIGH); // enable HIGH = stepper driver OFF
Two simple set of functions which change the direction of rotation are shown below. I found that one way did not work for the v3.3 driver; they are labelled appropriately.
The following function worked for only the PSMD and is an absolute function: it sets the direction either clockwise or counterclockwise.
void setCurrentDirection(boolean dir, int dirPin)
if(dir == false)
The following two functions worked for both boards and are relative functions: they set the direction to be opposite the previous direction.
boolean currentDirectionZ = true;
void setCurrentDirectionZ(boolean dir, int dirPin)
if(dir == false)
currentDirectionZ = dir;
Besides the step, enable, and direction pins, there are other pins on the A4988 which are important, but the PDMS board takes care of most of them for you. For example, the reset and the sleep pins are both pulled high, effectively making them unusable but so you do not need to worry about them. The board has three mini-switches attached to MS1, MS2, and MS3, which allow you to easily set the stepping mode (full, 1/2, 1/4, 1/8 or 1/16).
|MakerBot v3.3 Stepper Driver|
I used the v3.3 board with 42BYGHW-811 Wantan stepper motors, which are rated to a higher current of 2.5A. The Rsense resistors are 0.25 Ohm for this board, so with a rated current of Itrip = 2.5A, we can calculate the value of Vref to set for the v3.3 board as 5V. The maximum permissible for the logic of the A3977 circuits is 4V according to the datasheet, so I set Vref = 4.0V.
The PSMD board also has integrated pinouts for limit switches, which are sometimes used to detect the end position in the X, Y, and Z axes (both low and high limits). The pins provide +5V, and a signal pin. You can digitally read the signal pin to see when it is shorted to ground with a pullup resistor enabled on the Arduino.
|v3.3 Cable Ribbon Pinout|
|PSMD Cable Ribbon Pinout|