Due & A4988 stepper motor issue on one axis (RADDS v1.5)

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)

The fact that it works with Repetier is useful to know but I'm not going to study the Repetier software - it is much too complex.

I think this

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,

means that when you change the pins for the Z stepper from those for Z to those for Y the Y stepper does not move - even though the exact same code made the Z motor move when the Z pins were used.

I am not familiar with the "RADDS v1.5 board " but one possibility is that you need to pull the enable pin LOW to get the driver to work. (And if that works, don't ask me why it is not also needed for the other axes :slight_smile: )

Am I correct to assume that the pins for each motor are defined by the RADDS board?

Are you sure you have the Y pins correct? For example step and dir might be mixed up?

...R

Thanks very much for your reply.

Yes, that's what I meant. If I replace those Z pin numbers with the X pin numbers, the X stepper runs, but when I replace them with the Y pin numbers, the Y stepper doesn't run.

I wish I could say that pulling the enable pin LOW worked, but it unfortunately didn't make a difference :frowning:

Since the drivers are wired into the RADDS board, which stacks on the Due, yes, the RADDS board's circuitry determines which Due pins correspond to various driver pins. I'm rock-solid certain that these pins are correct and not swapped around; I contacted the manufacturer to make sure.

In all honesty, I am quite stumped. Perhaps the board is defective--maybe Repetier does something that shouldn't be necessary if the hardware is fully functional, but provides a fix if there's a break or problem somewhere (in my case, in the Y-axis).

I had suspected that Repetier would pull the enable pins low.

Try this Simple Stepper Code which does not use any library.

If that does not work you will just have to delve into the innards of Repetier to see what it may do differently.

If it does work it says something about AccelStepper - but I don't know what :slight_smile:
I don't know if AccelStepper claims to work on a DUE or if it uses some resource that may conflict with one of the pins used on your board.

I'm assuming that your board can have a max of 3 x A4988s

I don't have a DUE.

...R

Your Simple Stepper Code works just dandy. AccelStepper is definitely supposed to work with Due, so this is quite curious. It's particularly weird because AccelStepper code does work when the physical connections I mentioned in my first post are made with the voltmeter. I looked through the AccelStepper library code and couldn't see any specific references to the pins I'm using.

The board is actually built for six A4988s. I'm probably going to obtain a new board and see if the issue is still present. I think it's the logical next step.

Thanks again for your help; enjoy your weekend.

CellScale_:
The board is actually built for six A4988s.

Why not move the A4988 for the Y axis to a different slot so it can be controlled with pins other than 2 and 3 - just in case those pins have some strange effect on the AccelStepper library.

...R

That would be wonderful. Unfortunately, I neglected to mention that in the final application all six axes will be used--the restriction to three is just a temporary simplification as I figure out the code and setup. That was my bad. Thank you though.

Then it would be wise to explore whether AccelStepper can work on the other 3 axes :slight_smile:

Another point ... It is not very difficult to build your own acceleration code as an extension of my simple examples.

By the way, what will the 6 motors be doing? And how will their movements relate to each other?

...R

Fixed! Thanks Robin; you were right--it was all about the enable pins. I just had to set enable pins, invert them, and enable outputs for all steppers, like so:

  xStepper.setEnablePin(26);
  xStepper.setPinsInverted(false, false, true);
  xStepper.enableOutputs();

Glad that's fixed.