I'm running a NEMA 34 (6A, 800-40,000 steps/rev) with a 2HSS86H motor driver using Accelstepper.
I'm super new to Arduino and steppers, but I got it working by using a sketch from a Jeremy Fielding video. However, the speed of the motor topped out around 6 rpms. I thought this was weird, so I tried using a sketch from a Dronebot Workshop video and the motor ran much faster (around 300 rpm). I had the driver set to 800 steps/rev while running both sketches.
No matter how I change the setSpeed and setMaxSpeed values, I can't get the motor to run faster than 6 rpms using Accelstepper.
Any idea why?
Here's the sketch from the Jeremy Fielding video, using Accelstepper:
#include <AccelStepper.h>
int Stepper1Pulse = 5;
int Stepper1Direction = 6;
int speedpot = A0;
int Motor1speed = 0;
int speedmin = 0;
int speedmax = 4000;
AccelStepper step1(1, Stepper1Pulse, Stepper1Direction);
void setup() {
step1.setMaxSpeed (speedmax);
step1.setSpeed(0);
step1.setAcceleration(50);
pinMode(Stepper1Pulse, OUTPUT);
pinMode(Stepper1Direction, OUTPUT);
digitalWrite(Stepper1Pulse, LOW);
digitalWrite(Stepper1Direction, LOW);
Serial.begin(9600);
Serial.println("Running: StepperDriverTest");
}
void loop() {
Motor1speed = map((analogRead(speedpot)), 0, 1023, speedmin, speedmax);
step1.setSpeed(Motor1speed);
Serial.println(Motor1speed);
step1.runSpeed();
}
And here's the sketch from the Dronebot Workshop video, without Accelstepper:
int reverseSwitch = 4;
int driverPUL = 5;
int driverDIR = 6;
int spd = A0;
int pd = 500;
boolean setdir = LOW;
void revmotor(){
setdir = !setdir;
}
void setup() {
Serial.begin(9600);
Serial.println("Running: StepperSpeedPot");
pinMode (driverPUL, OUTPUT);
pinMode (driverDIR, OUTPUT);
attachInterrupt(digitalPinToInterrupt(reverseSwitch), revmotor, FALLING);
}
void loop() {
pd = map((analogRead(spd)), 0, 1023, 2000, 50);
digitalWrite(driverDIR, setdir);
digitalWrite(driverPUL, HIGH);
delayMicroseconds(pd);
digitalWrite(driverPUL, LOW);
delayMicroseconds(pd);
}