DVR8825 assistance please

I’m trying to control a stepper with the DVR8825(Pololu) driver and the stepper motor is bipolar 200 st/rev, 2.8V, 1.7A/phase(Pololu item #2267). Using the Arduino Uno. Motor power supply is a 12V 10ah lipo battery. I have followed the directions to set the current limit.

The motor runs very well with the following code but it’s too slow for my application. I’ve tried tweaking it in many ways but with little success…

int dirPin = 8;
int stepperPin = 7;
void setup() {
  TWBR = ((F_CPU /400000l) - 16) / 2; // Change the i2c clock to 400KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
 pinMode(dirPin, OUTPUT);
 pinMode(stepperPin, OUTPUT);
}
 void step(boolean dir,int steps){
 digitalWrite(dirPin,dir);
 delay(50);
 for(int i=0;i<steps;i++){
   digitalWrite(stepperPin, HIGH);
   delayMicroseconds(400);
   digitalWrite(stepperPin, LOW);
   delayMicroseconds(400);
 }
}
void loop(){
 step(true,2000);
 delay(500);
 step(false,2000);
 delay(500);
}

So then I decided to try AccelStepper(code below). When the motor runs(that is if it runs successfully) it is sufficient for my application. But it won’t run correctly consistently. It will stall, whine and chatter. I’ve tried several adjustments but with no success. I look forward to your advice/comments.
Regards-
Paul

//This is an example of how you would control 1 stepper

#include <AccelStepper.h>

int motorSpeed = 9600; //maximum steps per second (about 3rps / at 16 microsteps)
int motorAccel = 80000; //steps/second/second to accelerate

int motorDirPin = 8; //digital pin 8
int motorStepPin = 7; //digital pin 7

//set up the accelStepper intance
//the "1" tells it we are using a driver
AccelStepper stepper(1, motorStepPin, motorDirPin); 



void setup(){
 stepper.setMaxSpeed(motorSpeed);
 stepper.setSpeed(motorSpeed);
   TWBR = ((F_CPU /400000l) - 16) / 2; // Change the i2c clock to 400KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
 stepper.setAcceleration(motorAccel);
 
 stepper.moveTo(4000); //move 32000 steps (should be 10 rev)
}

void loop(){
 
 //if stepper is at desired location
 if (stepper.distanceToGo() == 0){
  //go the other way the same amount of steps
  //so if current position is 400 steps out, go position -400
  stepper.moveTo(-stepper.currentPosition()); 
  delay(1500);
 }
 

 
 //these must be called as often as possible to ensure smooth operation
 //any delay will cause jerky motion
 stepper.run();
 }

You might like to try this Simple Stepper Code. Someone else said they were able to modify to get a high step rate. I think they were using the 2nd example.

A higher voltage may be necessary for higher speed.

...R Stepper Motor Basics

For high performance you need ramped speed - such as AccelStepper gives you.

For high performance you need higher supply voltages - try 24V?

For high performance you usuaully need microstepping to reduce resonance and/or a mechanical damping system, or you get miss-stepping due to mid-band resonance. Unfortunately AccelStepper library is very slow and wont drive high step rates needed for microsteps at high speed. Its slow because it does square-root calculations for every step. There are faster ways to generate ramped step profiles.

Resonance varies with the load, so actually test the system with the actual load attached, it may perform nuch better than an unloaded motor (which is very resonant).