Hi all,
I have a weird issue with my Arduino mega2560
I'm trying to control A4988 modules with the analogWrite function. (Because I just want to rotate the motor, I don't care about steps or whatsoever and the frequency of the analogWrite is good enough for me, so instead of sending High and then Low to the step pins I just use analogWrite)
When I send a signal to a single pin, there are no issues, and the motors rotate nicely.
When I send it up to 3, there is also no issue, the moment I try to send it to more than 3, something weird happens, the motors won't rotate as smoothly, they will become so noisy, and in fact, few of them won't even rotate.
When I measure the voltage at the Step pin, I notice that I don't get as much voltage on each pin as compared to when controlling less than 3 motors only, it is usually less (like a drop from around 3.4v to 1.8v
Have a look at this simple code:
const byte stepPin[7] = {8, 7, 6, 5, 9, 3, 2};
const byte dirPin[7] = {22, 24, 26, 28, 30, 32, 34};
void setup() {
for (int i = 0; i < 7; i++) {
pinMode(dirPin[i], OUTPUT);
digitalWrite(dirPin[i], HIGH);
pinMode(stepPin[i], OUTPUT);
analogWrite(stepPin[i], 125);
delay(3000);
}
}
void loop() {
// put your main code here, to run repeatedly:
}
when I change the for loop to for (int i = 0; i < 3; i++) or say for (int i =3; i < 6; i++), there are no problems there.
I only get the issues when i'm running more than 3.
Any ideas on what's wrong?
I'm powering the full system with a 20A 12V power supply that goes through a step down to 5.5v that i feed to the arduino through the Vin pin.