Using multiple a4988 fails

Hi everyone,

for a small project, I need to drive five Nema 17 stepper motors and chose the cheap a4988 drivers to do so. I bought a cheaper version of this driver Pololu - A4988 Stepper Motor Driver Carrier

I also went ahead and created a PCB with KiCad and had it manufactured in china. I assume a error in my (ugly) schematic and hope that it is obvious enough for someone to find as I am not an expert :slight_smile:

The Idea was to have the drivers nice and organized on a single PCB. I added solder jumpers to be able to set the direction for all drivers at once and/or do steps at once. In my case I only soldered the direction jumpers. All MS1 pins are connected to each other, same for MS2 and 3. Reset and Sleep are bridged on every controller. The enable-pin is not connected to anything. I basically tried to follow the instructions of this post: https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/

At first I thought everything would work fine, because as long as I only have one controller connected, the corresponding motor spins just fine! As soon as I add a second controller, either the first or the second motor will not spin correctly. It just vibrates around and makes noise while the other motor spins fine. I can switch motors and controller as I want, the behavior stays the same, to it is not a bad driver (or motor) and the PCB is at least somewhat functional because it can drive a single motor in any slot.

const int stepPin1 = 8;
const int stepPin2 = 9;
const int stepPin3 = 10;
const int stepPin4 = 11;
const int stepPin5 = 12;
const int dirPin = 4;

const int m1Pin = 1;
const int m2Pin = 2;
const int m3Pin = 3;

void setup() {
  // put your setup code here, to run once:
  pinMode(stepPin1, OUTPUT);
  pinMode(stepPin2, OUTPUT);
  pinMode(stepPin3, OUTPUT);
  pinMode(stepPin4, OUTPUT);
  pinMode(stepPin5, OUTPUT);
  pinMode(dirPin, OUTPUT);
  digitalWrite(m1Pin, HIGH);
  digitalWrite(m2Pin, HIGH);
  digitalWrite(m3Pin, HIGH);
  digitalWrite(dirPin, LOW); // Changes the rotation direction

}

void toggle(int pin) {
  digitalWrite(pin, HIGH);
  delayMicroseconds(50);
  digitalWrite(pin, LOW);
  delayMicroseconds(50);
}

void toggleMulti(int pin) {
  for (int i = 0; i < 5000; i++) {
    toggle(pin);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

  toggleMulti(stepPin1);
  toggleMulti(stepPin2);
}

But my goal was obviously controlling all five of them.

One thing I found out is that the voltage at the MS-Pins is very low. I set them to HIGH in the setup section and with one driver I measure about 3.5 volts at the MS2 pin and with the second one 2.7 volts. Strange because the Arduino should have a logic voltage of 5v, shouldn’t it? I power everything with a 12V 4A power supply into the VIN pin of the arduino and the screw terminal on the PCB (Common ground if that matters).

Otherwise I have no idea why adding a second controller freaks the first or the second one out so much…

Can you find a explanation and possible solution for my problem?

Thank you very much,
~Janik

Okay, wow I just saw the WAY to obvious error with the lane crossing the contact of the screw terminal. Luckily I never connected the fifth driver...

But this error should not affect the other slots.

Hi,
Good to hear, a fault found, did it fix it?

Tom... :slight_smile:

3 words, "design rule check"

Hi thanks for the replies.

I actually looked at the design validation and it gives me a few errors around the solder jumpers which I ignored because I cannot see any actual problem there (see image attached). I then sadly overlooked the one very important error. I will be more careful in the future.

Anyways this one error is isolated to one of the five mounting locations for the controllers and I have not yet used this specific location (luckily).
This design fault does not affect the other problem when I have two controllers on the presumably correctly routed locations.