stepper too slow

I have a stepper motor attached to a gearbox so getting the stepper up to full speed is important. The system is working almost like a clamp. I am in need of a way to move the stepper motor fast. The problem I’m having is I need the stepper to stop at a certain pre-load (5 lbs). In order to do this I have also included the hx711 library that reads the load cell. Currently the stepper is going very slow and just clicking maybe one step a second. At the moment I’m using accelstepper and hx711 libraries.

Current code:

#include "AccelStepper.h" 
#include "HX711.h"

AccelStepper stepperY(1, 2, 3);   // 1 = Dedicated Driver Board, 2 = pinStep, 3 = pinDirection
#define slot_sensor 9 
long TravelY;  // Used to store the Y value entered in the Serial Monitor
int move_finished=1;  // Used to check if move is completed
long initial_homing=-1;  // Used to Home Stepper at startup
long val = 0;
float count = 0;

void setup() {
   Serial.begin(9600);  // Serial monitor with speed of 9600 Bauds
   
   pinMode(slot_sensor, INPUT_PULLUP);
   
   delay(10);  // 10ms Delay

}

void loop() {
HX711 cell(5,4);
  Serial.println("Preloading");

delay(1000);

//  stepperY.setCurrentPosition(0);  // Set the current position as zero for now
  stepperY.setMaxSpeed(3000.0);      // 
  stepperY.setAcceleration(1000.0);  // 

  while (cell.read()<-25000) {  // load cell reads -25000 at 5 lbs
    stepperY.moveTo(initial_homing);  
    initial_homing--;
    stepperY.run();  
}
    Serial.println(cell.read());  
}

Now if I don’t read the cell reading it works at the perfect speed, but then I have no way to stop the stepper at the desired preload.
example:

#include "AccelStepper.h" 
#include "HX711.h"

AccelStepper stepperY(1, 2, 3);   // 1 = Dedicated Driver Board, 2 = pinStep, 3 = pinDirection
#define slot_sensor 9 
long TravelY;  // Used to store the Y value entered in the Serial Monitor
int move_finished=1;  // Used to check if move is completed
long initial_homing=-1;  // Used to Home Stepper at startup
long val = 0;
float count = 0;

void setup() {
   Serial.begin(9600);  // Serial monitor with speed of 9600 Bauds
   
   pinMode(slot_sensor, INPUT_PULLUP);
   
   delay(10);  // 10ms Delay

}

void loop() {
HX711 cell(5,4);
  Serial.println("Preloading");

delay(1000);

//  stepperY.setCurrentPosition(0);  // Set the current position as zero for now
  stepperY.setMaxSpeed(3000.0);      // 
  stepperY.setAcceleration(1000.0);  // 

  while (-26000<-25000) {  // load cell reads -25000 at 5 lbs
    stepperY.moveTo(initial_homing);  
    initial_homing--;
    stepperY.run();  
}
    Serial.println(cell.read());  
}

Open to any and all suggestion on how I can accomplish my goal of getting the stepper to spin faster and stop when the load cell reads the correct preload. Any help is appreciated.

Have you timed how long it takes for a load cell reading?

I have the impression (without personal experience) that some of the libraries are written so that they wait for ages for a reading rather than starting a reading and returning later for the answer. If the reading takes a long time it will obviously affect the wbility to produce step pulses.

...R

Robin2:
Have you timed how long it takes for a load cell reading?

I have the impression (without personal experience) that some of the libraries are written so that they wait for ages for a reading rather than starting a reading and returning later for the answer. If the reading takes a long time it will obviously affect the wbility to produce step pulses.

...R

Yes, you are correct. That is exactly the problem I am having. The problem is I have no idea how I can fix it. That's why I showed the second code. When I am not reading the load cell values the stepper reaches the expected speeds.

I don’t have one of those load cells so I can’t offer specific advice. I suggest you get the manufacturer’s datasheet for the load cell. It may well include some example code. Even if it does not it will explain exactly how the device works.

…R