Collect deformation value via strain gauge with HX711

Hello. I am now working on my project on studying how each plastic injection parameter affercts the mold deflection. I decided to use a strain gauges to collect the deformation that occurs while injecting the workpiece. I applied my strain gauge to HX711 module and serial monitor via arduino UNO to see the value. But there is one thing I concerned is I'm not really sure about the calibration factors I'm using and how to know which value I should use and what is the raw data that came from the HX711 module.

So if anyone here has used or has some idea please help me.

Here is the code and my wiring circuit.

Thank you in advance.

From the code, I applied 2 Hx711 but in the schematic, I only draw 1 Hx711 :slight_smile:

#include "HX711.h"

#define DOUT  2
#define CLK  3

#define DOUT2  4
#define CLK2  5

HX711 scale1;
HX711 scale2;

float calibration_factor = -700000; // set up calibration factor here
float calibration_factor2 = -700000;

void setup() {
  Serial.begin(9600);
//  Serial.println("HX711 calibration sketch");
//  Serial.println("Remove all weight from scale");
//  Serial.println("After readings begin, place known weight on scale");
//  Serial.println("Press + or a to increase calibration factor");
//  Serial.println("Press - or z to decrease calibration factor");

  scale1.begin(DOUT, CLK);
  scale1.set_scale();
  scale1.tare(); //Reset the scale to 0

  scale2.begin(DOUT2, CLK2);
  scale2.set_scale();
  scale2.tare();

// long zero_factor = scale1.read_average(); //Get a baseline reading
// long zero_factor = scale2.read_average();
//  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
//  Serial.println(zero_factor);
}

void loop() {

  scale1.set_scale(calibration_factor); //Adjust to this calibration factor
scale2.set_scale(calibration_factor2);

//  Serial.print("Reading: ");
Serial.print("SG Left : ");
  Serial.print(scale1.get_units(), 5);
  Serial.print("  ||   SG Right (compensate) : ");
   Serial.println(scale2.get_units(), 5);
  //Serial.println(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
//  Serial.print(" calibration_factor: ");
//  Serial.print(calibration_factor);
//  Serial.println();

  if(Serial.available())
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
  }
  delay(100);
}

I'd use '1' and post-process the raw values until you figure out how to calibrate your system.

I'd also move the ...set_scale(calibration_factor); stuff inside of the Serial.read(); ... stuff because it's a confusing waste of time to re-set the calibration factor if you haven't actually changed it.

2 Likes

Using math alone, you should be able to estimate the strain as a function of the raw value.

To do that you need to understand the HX711 and your strain gauges by...studying the datasheets and Wheatstone bridge fundamentals.

Regarding the latter, this is a good place to start: https://www.hbm.com/en/7163/wheatstone-bridge-circuit/

If your primary interest is not the "exact" magnitude of strain for a certain injection parameter, but ratios or differences between strains caused by different injection parameters, then the above approach may be sufficient.

But if you really need more accurate values, the shunt calibration method may be the only practical way, if the "mold" is so complex that you can't apply a known "load" that causes a known strain.

Also, this sort of project is often combined with a finite element analysis, to compare modeled vs measured values.

2 Likes

Usually, I do 2-point calibration for the Load Cell/Strain Gauge to find the Gain and Offset of the system.

A(W1, C1)  //known weight-1 applied on Strain Gauge; C1 = Count (value of ADC)
B(W2, C2) //known weight-2 on Strain gauge
C(W, C)     //unknown weight to be measured.
   
W1-W2/C1-C2 = W1-W/C1-C
==> W = mC + k  //m = Gain;  k = offset

Sketch to find gain and Offset

/* This program takes 10 samples from LC + HX711B at
   1-sec interval and then computes the average.
*/

unsigned long x = 0, y=0;
unsigned long dataArray[10];
int j = 0;
void setup()
{
  Serial.begin(9600);
  pinMode(2, INPUT); //data line  //Yellow cable
  pinMode(3, OUTPUT);  //SCK line  //Orange cable
}

void loop()
{

  for (int j = 0; j < 10; j++)
  {
    digitalWrite(A0, LOW);//SCK is made LL
    while (digitalRead(2) != LOW) //wait until Data Line goes LOW
      ;
    {
      for (int i = 0; i < 24; i++)  //read 24-bit data from HX711
      {
        clk();      //generate CLK pulse to get MSB-it at A1-pin
        bitWrite(x, 0, digitalRead(A1));
        x = x << 1;
      }
      clk();  //25th pulse
      Serial.println(x, HEX);
      y = x;
      x = 0;
      delay(1000);
    }
    dataArray[j] = y;
  }

  Serial.println("===averaging process=========");
  unsigned long sum = 0;

  for (j = 0; j < 10; j++)
  {
    sum += dataArray[j];
  }
  Serial.print("Average Count = ");
  sum = sum / 10;
  Serial.println(sum, HEX);
 // float W = (float)0.90*(sum-901002)/946560 + 0.75;//0.005331 * sum - 1146.176;
  //W = (float)W / 1000.00; 
 // Serial.println(W, 2);
}

void clk()
{
  digitalWrite(3, HIGH);
  digitalWrite(3, LOW);
}
1 Like

Hey, I am currently doing a similar project to identify the strain expercienced by a buried pipeline due to external load.

The value that I received are in microstrain.
my question is did u convert the strain values to deformation?

"Strength of materials" (aka "mechanics of materials") principles are usually used to select gauges, decide where to apply them, and to interpret the resulting strains.

For simple problems, those principles take the form of simple formulas that are covered in first-year university classes for structural engineers and mechanical engineers. Similar principles are used for complex problems, though hidden within analysis software.

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