Hello everyone ,
I have some difficulty to calibrate my 4 load cells which are connected to 4 HX711 and an arduino uno.
I am using the compugician/Hx711-multi program forked from bodge/HX711 on GitHub.
I am a beginner, so I am begging for help .
My program is working well , I just miss the possibility to add calibration values for my load cells.
Any help would be warmly welcome !
Here the code :
#include "HX711-multi.h"
// Pins to the load cell amp
#define CLK A0 // clock pin to the load cell amp
#define DOUT1 A1 // data pin to the first lca
#define DOUT2 A2 // data pin to the second lca
#define DOUT3 A3 // data pin to the third lca
#define DOUT4 A4 // data pin to the fourth lca
#define BOOT_MESSAGE "MIT_ML_SCALE V0.8"
#define TARE_TIMEOUT_SECONDS 4
byte DOUTS[4] = {DOUT1, DOUT2, DOUT3, DOUT4};
#define CHANNEL_COUNT sizeof(DOUTS)/sizeof(byte)
double go = 9.80662;
double MaxeX;
double MaxeY;
double F1;
double F2;
double F3;
double F4;
double y01 = -0.072; // distance between the leading edge and the first load cell [m]
double y02 = 0.066;
double xcp;
double x04 = -0.105;
double x03 = 0.105;
long int results[CHANNEL_COUNT];
HX711MULTI scales(CHANNEL_COUNT, DOUTS, CLK);
void setup() {
Serial.begin(115200);
Serial.println(BOOT_MESSAGE);
Serial.flush();
pinMode(11,OUTPUT);
tare();
}
void tare() {
bool tareSuccessful = false;
unsigned long tareStartTime = millis();
while (!tareSuccessful && millis()<(tareStartTime+TARE_TIMEOUT_SECONDS*1000)) {
tareSuccessful = scales.tare(20,10000); //reject 'tare' if still ringing
}
}
void sendRawData() {
scales.read(results);
for (int i=0; i<scales.get_count(); ++i) {;
Serial.print( -results[i]);
Serial.print( (i!=scales.get_count()-1)?"\t":"\n");
}
delay(10);
}
void loop() {
sendRawData(); //this is for sending raw data, for where everything else is done in processing
F1 = results[1]*go/1000; //[N]
F2 = results[2]*go/1000; //[N]
F3 = results[3]*go/1000; //[N]
F4 = results[4]*go/1000; //[N]drag = (weights[2])*go/1000; //[N]
MaxeX = y01 * F1 + y02 * F2; // [Nm]
MaxeY = x03 * F3 + x04 * F4;
//ycp = (y03 * F3 + y04
xcp = (y02 * F2 + y01 * F2) / (F1 + F2)*1000;
Serial.print("momentum at the leading edge for x = ");
Serial.print(MaxeX);
Serial.print("momentum at the leading edge for y = ");
Serial.print(MaxeY);
Serial.println(" [Nm]");
Serial.print("position of the centre of pressure: ");
Serial.print(xcp);
Serial.println(" [mm]");
Serial.println();
//on serial data (any data) re-tare
if (Serial.available()>0) {
while (Serial.available()) {
Serial.read();
}
tare();
}
}