Luís Moreira

Hi,
I'm programming the arduino for the project I've shared and I have a problem with the delay of the load cell, because I used a while fuction to stop the motor only when the value that I want be reach. Because of this, the value is reading in steps and the motor also runs in steps.

This is the code:

#include <AccelStepper.h>
#include <MultiStepper.h>

// Load cell Setup

#include "HX711.h"

#define calibration_factor 80000.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define zero_factor 38154 //This large value is obtained using the SparkFun_HX711_Calibration sketch

#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

long loadvalue; // Used to store the clamping load value


// Stepper Setup


AccelStepper stepper(4, 8, 9, 10, 11);
//

void setup() {
  Serial.begin(9600);

  // Set the parameters for the Load Cell
  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.set_offset(zero_factor); //Zero out the scale using a previously known zero_factor

  // Set Max Speed
  stepper.setMaxSpeed(1000.0);
  stepper.setSpeed(500);
 

}

void loop() {
     
   while (scale.get_value() < 1){
    stepper.runSpeed();
   }
}  
 
If you could help me, i'll be very happy!

Luís Moreira
Portugal 

Quote 0 0

Add a Website Forum to your website.