Hello,
I have connected 8 5v 28BYJ-48 stepper motors to an Arduino Mega 2560. I am using a separate 5v power supply for the motors and the Arduino is connected to the computer via a USB cable . The motors turn smoothly to begin with but then they begin to stall/stutter and the LED's on the driver boards flicker.
I tried again but with only 4 motors and these ran smoothly. I have attached a rough schematic of how everything is connected and code I am using below.
Would you say I need a bigger power supply?
Many thanks.
#include <AccelStepper.h>
// Define step constants
//#define FULLSTEP 4
#define HALFSTEP 8
// Define Motor Pins (2 Motors used)
#define motorPin1 22 // Blue - 28BYJ48 pin 1
#define motorPin2 23 // Pink - 28BYJ48 pin 2
#define motorPin3 24 // Yellow - 28BYJ48 pin 3
#define motorPin4 25 // Orange - 28BYJ48 pin 4
#define motorPin5 26 // Blue - 28BYJ48 pin 1
#define motorPin6 27 // Pink - 28BYJ48 pin 2
#define motorPin7 28 // Yellow - 28BYJ48 pin 3
#define motorPin8 29 // Orange - 28BYJ48 pin 4
#define motorPin9 30 // Blue - 28BYJ48 pin 1
#define motorPin10 31 // Pink - 28BYJ48 pin 2
#define motorPin11 32 // Yellow - 28BYJ48 pin 3
#define motorPin12 33 // Orange - 28BYJ48 pin 4
#define motorPin13 34 // Blue - 28BYJ48 pin 1
#define motorPin14 35 // Pink - 28BYJ48 pin 2
#define motorPin15 36 // Yellow - 28BYJ48 pin 3
#define motorPin16 37 // Orange - 28BYJ48 pin 4
#define motorPin17 38 // Blue - 28BYJ48 pin 1
#define motorPin18 39 // Pink - 28BYJ48 pin 2
#define motorPin19 40 // Yellow - 28BYJ48 pin 3
#define motorPin20 41 // Orange - 28BYJ48 pin 4
#define motorPin21 42 // Blue - 28BYJ48 pin 1
#define motorPin22 43 // Pink - 28BYJ48 pin 2
#define motorPin23 44 // Yellow - 28BYJ48 pin 3
#define motorPin24 45 // Orange - 28BYJ48 pin 4
#define motorPin25 46 // Blue - 28BYJ48 pin 1
#define motorPin26 47 // Pink - 28BYJ48 pin 2
#define motorPin27 48 // Yellow - 28BYJ48 pin 3
#define motorPin28 49 // Orange - 28BYJ48 pin 4
#define motorPin29 50 // Blue - 28BYJ48 pin 1
#define motorPin30 51 // Pink - 28BYJ48 pin 2
#define motorPin31 52 // Yellow - 28BYJ48 pin 3
#define motorPin32 53 // Orange - 28BYJ48 pin 4
// Define two motor objects
// The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8);
AccelStepper stepper3(HALFSTEP, motorPin9, motorPin11, motorPin10, motorPin12);
AccelStepper stepper4(HALFSTEP, motorPin13, motorPin15, motorPin14, motorPin16);
AccelStepper stepper5(HALFSTEP, motorPin17, motorPin19, motorPin18, motorPin20);
AccelStepper stepper6(HALFSTEP, motorPin21, motorPin23, motorPin22, motorPin24);
AccelStepper stepper7(HALFSTEP, motorPin25, motorPin27, motorPin26, motorPin28);
AccelStepper stepper8(HALFSTEP, motorPin29, motorPin31, motorPin30, motorPin32);
void setup() {
// put your setup code here, to run once:
stepper1.setMaxSpeed(1000.0);
stepper1.setAcceleration(100.0);
stepper1.setSpeed(50);
stepper1.moveTo(4072);
// 1 revolution Motor 2 CCW
stepper2.setMaxSpeed(1000.0);
stepper2.setAcceleration(100.0);
stepper2.setSpeed(50);
stepper2.moveTo(4072);
stepper3.setMaxSpeed(1000);
stepper3.setAcceleration(100.0);
stepper3.setSpeed(50);
stepper3.moveTo(4072);
stepper4.setMaxSpeed(1000.0);
stepper4.setAcceleration(100.0);
stepper4.setSpeed(50);
stepper4.moveTo(4072);
stepper5.setMaxSpeed(1000.0);
stepper5.setAcceleration(100.0);
stepper5.setSpeed(50);
stepper5.moveTo(4072);
stepper6.setMaxSpeed(1000.0);
stepper6.setAcceleration(100.0);
stepper6.setSpeed(50);
stepper6.moveTo(4072);
stepper7.setMaxSpeed(1000.0);
stepper7.setAcceleration(100.0);
stepper7.setSpeed(50);
stepper7.moveTo(4072);
stepper8.setMaxSpeed(1000.0);
stepper8.setAcceleration(100.0);
stepper8.setSpeed(50);
stepper8.moveTo(4072);
}
void loop() {
stepper1.run();
stepper2.run();
stepper3.run();
stepper4.run();
stepper5.run();
stepper6.run();
stepper7.run();
stepper8.run();
// put your main code here, to run repeatedly:
}