Load cell linear or non-linear plot

Hello,

I am working on a project that requires me to use a load cell. I need the load cell data to be highly accurate. I am using a load cell connected to a HX711 board set at 80hz.

One concern I have is if my load cell has a linear plot or a non-linear plot. I have mapped out the data from the load cell against the real weights.

This is the graph I ended up with:

Can anyone tell me if these results are enough to say with confidence that the load cell data is linear? (it seems pretty linear to me :man_shrugging: )

R^2 = 0.997 is the indicator of the confidence and is a very high number to get.

However there is definitely a visible bump, so

  • is this test repeatable (have you run it e.g. 20 times and see the same bump)
  • are these all single measurements?
  • or averages from e.g. 5 or 10 measurements?
  • was the temperature constant during measurement?

If you want to handle the bump you might look at

which provides multiple point calibration to handle non-linearities.

Hi,

Thanks for your reply,

  • Each test is the average of 1000 readings (since the data is recorded at 80hz). This is done 3 times.
  • The 3 results are then averaged again.
  • Temperature was room temperature throughout.

I did try to use your MultiMap library in order to create a non-linear plot but i found that it was too slow. Maybe I am doing something wrong. I need the 80hz of data as I am recording a very small moment in time.

Here is the code I used ( I got about 1hz of data):

#include "HX711.h"
#include <MultiMap.h>
int G;
HX711 scale;
  float sharp(float G);

void setup() {
  Serial.begin(9600);
  scale.begin(9,10); 
  scale.tare();
}

void loop() {
 float G = scale.get_units(1);

float sharp(int weight);
{
  float out[] = {0, 500, 1000};

  float in[]  = {10, 5000, 10000 };

  float weight = multiMap<float>(G, in, out, 3);
  return weight;
}
}

Is the HX711_MP a better library to use for my application?

I am fairly new to the hole coding thing so my code isnt very good and I could be doing things wrong.

Thanks again for your help.

What were these "real weights" and how accurately are they known?

It uses multimap internally , so it should take similar amount of time.

Can you run this code?
It measures the time in micros of the measurement and of the multimapping.
It should show that the multimapping is not time consuming.

Please note that the serial baud rate is set to 115200.

#include "HX711.h"
#include <MultiMap.h>

HX711 scale;
float sharp(float G);

float out[] = {0, 500, 1000};
float in[]  = {10, 5000, 10000 };


void setup()
{
  Serial.begin(115200);  //  <<<<<<<<<<<<<<<<<
  Serial.println(__FILE__);

  scale.begin(9, 10);
  scale.tare();
}

void loop()
{
  uint32_t start = micros();
  float G = scale.get_units(1);
  uint32_t stop = micros();
  Serial.print("G:\t");
  Serial.println(stop - start);

  start = micros();
  float M = multiMap<float>(G, in, out, 3);
  stop = micros();
  Serial.print("M:\t");
  Serial.println(stop - start);
}

What were these "real weights" and how accurately are they known?

They are precision weights (from amazon) and they are accurate to at least what my weighing scales can read.

I have run the code and it does seem to be running feaster which is good.

However I just seem to be getting the same output even if I put weights on the load cell. It cycles through these.

M: 20
G: 10732
M: 16
G: 10756
M: 20
G: 10732
M: 16
G: 10756
M: 20

I have added the rest of the measurement data to the code below:

#include "HX711.h"
#include <MultiMap.h>

HX711 scale;
float sharp(float G);

float out[] = {0,10,20,30,40,50,60,70,80,90,100,150,200,250,300,400,500,600,700,800,900,1000,1200,1400,1600,1800,2000,2500,3000,3500,4000};
float in[]  = {58458.33333,62220.33333,66053,69057.66667,71834,75096.33333,78006.66667,81054.33333,83915.66667,87138.33333,89430.33333,104678.6667,120613,134464.3333,149991.6667,181428.3333,211653.3333,243324.3333,273871.3333,303086,336010.6667,366756.3333,429986,490740,558840.6667,617843.6667,673671.3333,828331,986758.3333,1140857.667,1293730.333 };


void setup()
{
  Serial.begin(115200);  //  <<<<<<<<<<<<<<<<<
  Serial.println(__FILE__);

  scale.begin(9, 10);
  scale.tare();
}

void loop()
{
  uint32_t start = micros();
  float G = scale.get_units(1);
  uint32_t stop = micros();
  Serial.print("G:\t");
  Serial.println(stop - start);

  start = micros();
  float M = multiMap<float>(G, in, out, 3);
  stop = micros();
  Serial.print("M:\t");
  Serial.println(stop - start);
}

I will have another look at the MultiMap and the HX711_MP libraries as I don't think I have understood them properly.

Thanks again for your help. :pray:

As the Arduino float has only 6-7 significant digits, and the load cell itself also in that range,
I would only use the whole numbers: 58458, 62220, 66053`

Furthermore the arrays now have 31 entries, which is probably a lot given you had quite a straight line. Think you can do with less.

You need to calibrate the units in the code.

  • **scale.set_scale(420.0983); ** // TODO you need to calibrate this yourself.

Finally I would add a delay(2000) in the loop to get started.

  • first get it working
  • then get it working faster

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