I built 28 byj-40 stepper control circuit using ULN2003 from scratch. The stepper is powered using 4 AA batteries (5V~) and the Arduino is powered from my PC.
The stepper runs correctly and only gets warm, never gets hot even after 30 min. The ULN2003 stays cool despite being a relatively inefficient driver. I guess this is because my total power is low? I measured the battery current and it's only 200mA at max.
However, I measured the voltage at the output pins of the Arduino and it's only around 1.8V. I wonder if this is because the voltage fluctuates too fast and my multimeter takes only the "average value." ???
I used the Accelstepper library:
#include <AccelStepper.h>
#define HALFSTEP 8
// Motor pin definitions
#define motorPin1 3 // IN1 on the ULN2003 driver 1
#define motorPin2 4 // IN2 on the ULN2003 driver 1
#define motorPin3 5 // IN3 on the ULN2003 driver 1
#define motorPin4 6 // IN4 on the ULN2003 driver 1
// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
stepper1.setMaxSpeed(3000.0);
stepper1.setAcceleration(50.0);
stepper1.setSpeed(5);
stepper1.moveTo(5550);
}//--(end setup )---
void loop() {
//Change direction when the stepper reaches the target position
if (stepper1.distanceToGo() == 0) {
stepper1.moveTo(-stepper1.currentPosition());
}
stepper1.run();
}
I tested the pins using the blinker sketch and it outputs 5V, so we know the Arduino is fine. I then tested it using a different code for the stepper, one that does not use the Accelstepper library, and the output pin voltage fluctuates but I can see 4.5V from time to time:
#include <Stepper.h>
/-----( Declare Constants, Pin Numbers )-----/
//---( Number of steps per revolution of INTERNAL motor in 4-step mode )---
#define STEPS_PER_MOTOR_REVOLUTION 32
//---( Steps per OUTPUT SHAFT of gear reduction )---
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048
/-----( Declare objects )-----/
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
//The pin connections need to be pins 8,9,10,11 connected
// to Motor Driver In1, In2, In3, In4
// Then the pins are entered here in the sequence 1-3-2-4 for proper sequencing
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 3, 5, 4, 6);
/-----( Declare Variables )-----/
int Steps2Take;
void setup() /----( SETUP: RUNS ONCE )----/
{
// Nothing (Stepper Library sets pins as outputs)
}/--(end setup )---/
void loop() /----( LOOP: RUNS CONSTANTLY )----/
{
Steps2Take = STEPS_PER_OUTPUT_REVOLUTION *.5; // Rotate CW 1/2 turn
small_stepper.setSpeed(500);
small_stepper.step(Steps2Take);
delay(10);
Steps2Take = - STEPS_PER_OUTPUT_REVOLUTION * .5; // Rotate CCW 1/2 turn
small_stepper.setSpeed(500); // 700 a good max speed??
small_stepper.step(Steps2Take);
delay(10);
}/* --(end main loop )-- */
So does anyone know the output voltage stays a constant 1.8ish on the multimeter when I used the Accelstepper library?
Thanks