I am trying to run three stepper motors from a RADDS v1.5 board mounted on an Arduino Due and controlled with A4988 drivers (NOT for a 3D printing purpose), controlled through the sketch below:
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper xStepper(AccelStepper::DRIVER, 24, 23);
AccelStepper yStepper(AccelStepper::DRIVER, 17, 16);
AccelStepper zStepper(AccelStepper::DRIVER, 2, 3);
int posX = 3600;
int posY = 3600;
int posZ = 3600;
void setup()
{
xStepper.setMaxSpeed(5000);
xStepper.setAcceleration(1000);
yStepper.setMaxSpeed(5000);
yStepper.setAcceleration(1000);
zStepper.setMaxSpeed(5000);
zStepper.setAcceleration(1000);
}
void loop()
{
if (xStepper.distanceToGo() == 0)
{
posX = -posX;
xStepper.moveTo(posX);
}
if (yStepper.distanceToGo() == 0)
{
posY = -posY;
yStepper.moveTo(posY);
}
if (zStepper.distanceToGo() == 0)
{
posZ = -posZ;
zStepper.moveTo(posZ);
}
xStepper.run();
yStepper.run();
zStepper.run();
}
This works like a dream for the X and Z axes, but the Y axis stays completely still apart from a tiny initial jitter when power is first supplied to the RADDS (even when I swap steppers and drivers around; current limiting is the same on all drivers).
I thought it was a hardware issue. Then I decided to configure Repetier and tried to manually move each axis from there. To my surprise, the Y axis functioned just fine, spinning when told.
Here is a video I took to illustrate the entire issue. In this video, I run the Z-axis stepper motor, then change nothing but the pin numbers (which should cause the Y-axis stepper motor to run), then record the Y-axis stepper's stillness, then run Repetier.ino and record the Y-axis stepper being successfully controlled through Repetier Host. I apologise for the footage of loading bars; I wanted to get it all in one take.
I know I have the right pin numbers; 17 and 16 are the step and direction pins (respectively) even in the Repetier pins.h file that configuration generated. This is visible when I'm uploading the Repetier.ino sketch (which is also attached inside Repetier-Firmware.zip, along with the configuration files).
When I tool around with a voltmeter, pins on X and Y drivers have the same values, except for the fact that the step and dir pins on the Y axis have a higher voltage (0-60 mV on X and 0-260 mV on Y) and when I measure the voltage between the ground pin (directly across from the step pin) and the step pin, the Y-axis stepper turns. It only turns in one direction even though it should switch after stopping, and I think this is because the dir pin isn't connected.
But if the problem is due to step and dir pins being disconnected, why does the axis work in Repetier and how can I make it work when controlling it purely through Arduino (which is necessary to my project)?
Thanks a lot and let me know if you need any more information.
Repetier-Firmware.zip (468 KB)