Robin,
I changed the code to see how a real stepper would react instead of pulsing led 13 in the void stepperMotor()
So for the test I want to move the stepper in 180 degrees = 100 steps just to see if it works and if there is any motion.
But the stepper only steps one step per second with this code.
Paco
[/// this is just to test the understanding of using the HX711 and steppermotor
#include <HX711.h>
#include <AccelStepper.h>
// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0
HX711 scale(A1, A0); // 24 bit load cell amplifier
AccelStepper stepper(1,9,8); // set up the stepper as 4 wire bipolair on pin 8,9 for EASY DRIVER or other driver board
unsigned long startMillis;
unsigned long endMillis;
unsigned long currMillis;
unsigned long prevMillis;
unsigned long intervalMillis = 10; // do not change
byte maxTests = 100;
byte curTest = 1;
byte maxSteps = 100;
byte curStep = 1;
long scaleData = 0;
void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(3000);
stepper.setSpeed(3000);
stepper.setAcceleration(800); // do not remove!
prevMillis = millis();
}
void loop()
{
if (curTest > maxTests)
{
return;
}
startMillis = millis();
curStep = 0;
testTiming();
endMillis = millis();
curTest ++;
stepper.run(); // does it block the 100 steps?
}
void testTiming()
{
while (curStep < maxSteps) // will loop through the steps at the speed set by intervalMillis
{
currMillis = millis();
if (currMillis - prevMillis >= intervalMillis)
{
stepMotor();
prevMillis += intervalMillis;
curStep ++;
}
}
// now the Scale should be ready for reading
scaleData = (scale.read()/100);
Serial.print("B,");
Serial.println(scaleData);
Serial.print("A,");
Serial.println(stepper.currentPosition());
}
void stepMotor()
{
stepper.moveTo(100);
}
code]