Hello I am having issues with accelStepper giving me enough speed. I have used the standard stepper motor library and got much better performance. I am using a 16Mhz Nano. with a step and direction style driver. This nano should be fast enough to run this single stepper at 100 steps per second. with the code below, why am I only getting about 25 pulse per second. Later on I will need the accelerate function of this library.
#include <AccelStepper.h>
AccelStepper target(1, 6, 8); // pin 6 = pulse, pin 8 = direction
const int buttonRT = 11;
const int buttonBK = 10;
const int buttonLT = 9;
int Desired_position = 0;
void setup() {
target.setMaxSpeed(10000);
target.setSpeed(10000);
target.setMinPulseWidth(20);
pinMode(buttonRT, INPUT_PULLUP);
pinMode(buttonBK, INPUT_PULLUP);
pinMode(buttonLT, INPUT_PULLUP);
Serial.begin(9600);
}
void loop(){
// position control
{while (digitalRead(buttonRT) == LOW) {Desired_position = 50;}
//wired N.O.
while (digitalRead(buttonBK) == HIGH) {Desired_position = 0;}
//wired N.C.
while (digitalRead(buttonLT) == LOW) {Desired_position = -50;}}
//wired N.O.
//Stepper control
//{ int Desired_position = 0;
//target.run();
// target.moveTo(Desired_position);}
//{
// Read new position
target.moveTo(Desired_position);
//target.setSpeed(10000);
target.runSpeedToPosition();
// read the input pin:
int buttonState1 = digitalRead(buttonRT);
int buttonState2 = digitalRead(buttonBK);
int buttonState3 = digitalRead(buttonLT);
// print out the state of the button:
Serial.print(buttonState1);
Serial.print(buttonState2);
Serial.print(buttonState3);
Serial.print("Desired_position");
Serial.print(Desired_position);
delayMicroseconds(10); // delay in between reads for stability
}