I have a new problem now.
When I use the library to control multiple motors, in particular, more than three, weird things happen like not all of them will rotate or one or two of them will just make noises and be so loud.
But before I try to run all of them together, I tested each motor individually using the exact same set up and the all of the motors can rotate with no issues.
However, it's only when i'm rotating more than three motors do I get the problems.
so here is the code:
/* ====== minimumStepper =======================================
Bare minimum to get a stepper with step/dir driver turning
*/
#include <MobaTools.h>
// Stepper connections - Please adapt to your own needs.
const byte stepPin[7] = {8, 7, 6, 5, 13, 3, 2}; //motors from right to left when me facing the load cells {8, 7, 6, 5, 4, 3, 2}
const byte dirPin[7] = {22, 24, 26, 28, 30, 32, 34};
const int stepsPerRev = 400; // Steps per revolution - may need to be adjusted
MoToStepper mysteppers[] {{stepsPerRev, STEPDIR}, {stepsPerRev, STEPDIR}, {stepsPerRev, STEPDIR}, {stepsPerRev, STEPDIR}, {stepsPerRev, STEPDIR}, {stepsPerRev, STEPDIR}, {stepsPerRev, STEPDIR}};
void setup() {
for (int i = 0; i < 7; i++)
{
mysteppers[i].attach(stepPin[i], dirPin[i]);
mysteppers[i].setSpeed (1200);
mysteppers[i].setRampLen(50);
}
for (byte i = 0; i < 7; i++) { // 0 to 5 is SIX elements
mysteppers[i].rotate(1);
delay(500);
// mysteppers[i].stop();
// delay(2000);
}
}
void loop() {
}
I tried reducing the speed or increasing it; the issue remains there, I just cannot control more than three smoothly.
Like if for example if i use the for loop with up to 3 motors only, i have everything running smoothly regardless of which three motors i'm using. However, the moment i go to 4 motors and beyond, one of them won't function or it will just act weirdly.
Now i did one thing, i tested the voltage at the step pin on each A4988 driver and found that when i increase the number of motors to more than 3, i get a low voltage of around 1.6v or so. whereas when i'm dealing with 3 or less i would get a voltage of nearly 3v.
For you reference: I'm powering the arduino through the same 20A 12V power supply by using a step down module to get the voltage to 5 volts and then feeding that to the Vin pin in the arduino
Any idea how to solve this??