LoadCell + HX711 give very delayed result

I m trying to make a brake pedal for simracing using a 20kg loadcell and the HX711 and a promicro , i only have 1 loadcell . i managed to get the promicro recognized as a HID controller device in windows with axis that move when i put weight on the loadcell however , the axis ( and the numbers on serial monitor ) are showing very delayed results .

this is a video i made showing the problem : https://youtu.be/gcctvu708Dc

this is my HX711 :

and this is my code ( half of which i copy pasted from the read1 value example of the HX711_ADC library ) :

#include <HX711_ADC.h>
#include <EEPROM.h>
#include <Joystick.h>

HX711_ADC LoadCell(4, 8); // HX711 DOUT , SCK PINS
int loadvalue =0;  // RAW value of loadcell after calibration ( in grams ) 
const int calVal_eepromAdress = 0; // calibration value memory address in the eeprom ( i think )
int brake; // braking value mapped and sent to the controller axis
int throttle; // throttle value mapped and sent to the controller axis
int clutch; // clutch value mapped and sent to the controller axis
int maxbrakepressure = 6000;  // maximum value read after calibration OR maximum braking load ( test which is higher )


//create the controller

Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD,
  0, 0,                 // Button Count, Hat Switch Count
  false, false, true,   // No X and Y, but Z Axis
  false, false, false,  // No Rx, Ry, or Rz
  false, true,          // No rudder, but throttle
  false, true, false);  // No accelerator , brake on , no steering
  

void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
  LoadCell.begin(); //sets pins connected to load cell amplifier ( HX711 ) and starts the load cell
  
 float calibrationValue; // calibration value
 EEPROM.get(calVal_eepromAdress, calibrationValue); // getting calibration value from EEPROM
 unsigned long stabilizingtime = 3000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
 boolean _tare = true; //set this to false if you don't want tare to be performed at startup
 LoadCell.start(stabilizingtime, _tare);
 LoadCell.setCalFactor(calibrationValue);
 Joystick.begin(true);
}





void loop(){
if (LoadCell.update()){
loadvalue = LoadCell.getData();
brake=map(loadvalue, 0 , maxbrakepressure , 0 , 1023);
Joystick.setThrottle(brake);
}

  Serial.println(brake);

// receive command from serial terminal, send 't' to initiate tare operation:
  if (Serial.available() > 0) {
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay();
  }

}




Try reducing the number of samples from the default 16 in the moving average. See

and

Thanks for the suggestion. I will try that first thing tomorrow . Hopefully it wont be difficult to edit the library files cause i ve never done it before and i only know some basic c++ programming and thats about it . Thanks again .

You don't need to edit the library file, just call that routine with a smaller-than-the-default-16:

LoadCell.setSamplesInUse(1);

I pointed at the library routine because I'm not sure if there's better documentation somewhere.

1 Like

Ah i see , so i just add that line at the very end of setup() if i understood correctly ?

Update : your suggestion solved the issue . Thanks . Now it s as responsive as i can expect from 10 SPS . Now onto making it 80 SPS . Thanks

( i dont know how to mark the thread as solved )

1 Like

Great! Good luck.

You hover and click the Solution checkbox after the post that solves it.

Here's an image:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.