How to connect and configure a load cell using HX711 transmitter with Arduino based PLC

How to connect and configure a load cell using HX711 transmitter with Arduino based PLC

In this post is showed how to use a load cell transductor with our equipment’s for example an Ardbox analog. Load cell is a transductor that generate an electrical signal directly proportional to the measured force.

On market there are different transmitters that can convert this analog signal to digital. In this example is used the HX711 that is very used in industrial applications. HX711 get and convert the analog signal from the load cell to digital with his intern converter A/D of 24 bits.

How to connect the different devices?

The connections between load cell and HX711 are showed below:

Load Cell

HX711

Red wire

E+

Black wire

E-

White wire

A+

Green wire

A-

 

 

And the connections between HX711 and one of our PLC’s are showed below:

HX711

Industrial Shields PLC

GND

GND

DT

PIN 2

SCK

PIN 3

VCC

5V

 

IMPORTAN: The frequency of the clock is quite high, so we must use PIN3 for Ardbox and PIN3 and PIN2 for M-Duino !!!

Once there are all the wires connected we can proceed with the software to get the rights values from the HX711.

Actually HX711 has an Arduino IDE library. You can get this library from GitHub: https://github.com/bogde/HX711

Once it is installed HX711 library we can proceed to calibrate the weighing scales. Basically to find the value of the scale, that is to find the conversion factor to convert the read value to weight unit.

After that, we need to find an object with known weight. It is better if the known weight is closer with the maximum value of the working range of our load cell. On this example has been used a weight of 4 kg because maximum value of the working range of our load cell is 5 kg.

The next step is to upload the next sketch to our PLC:

#include "HX711.h"

#define DOUT  2

#define CLK  3

HX711 weighingScales(DOUT, CLK);

void setup() {

  Serial.begin(9600);

  while(!Serial); // This is not necessary if you have an M-Duino

  Serial.print("Read ADC value:  ");

  Serial.println(weighingScales.read());

  Serial.println("Don't put any weight to the weighing scale");

  weighingScales.set_scale(); //The default scale is 1

  weighingScales.tare(20);  //The actual weight is Tare.

  Serial.println("Put the known weight:");

}

void loop() {

  Serial.print("Read Value:  ");

  Serial.println(weighingScales.get_value(10),0);

  delay(500);

}

 

The program has to run without the know weight, because when the program begin calculate de tare. After open the serial monitor and wait for restart the tare, we can put the known weight.

After put the known weight, on the seral monitor we will see the weight readings values, this value are without scale. This means that the values must be big numbers.

With an average of these values we can calculate the value of the scale, following that formula:

Once the scale value has been calculated we have all the requirements to configure the load cell.  We just have to write the scale value on the HX711 function set_scale(). Next is showed an example of how can look a final program for a load cell:

#include "HX711.h"

#define DOUT  2

#define CLK  3

HX711 weighingScales(DOUT, CLK);

void setup() {

  Serial.begin(9600);

  while(!Serial); // This is not necessary if you have an M-Duino


  Serial.println("Calculating tare...");

  Serial.println("...");

  weighingScales.set_scale(433456.25); // Set up our scale

  weighingScales.tare(20);  //The actual weight is Tare.

  Serial.println("Ready to weigh"); 

}

void loop() {

  Serial.print("Weight: ");

  Serial.print(weighingScales.get_units(20),3);

  Serial.println(" kg");

  delay(500);

}

 

See also:

HOW TO GENERATE A DIFFERENT PWM’S SIGNALS WITH OURS EQUIPMENT’SHOW TO USE THE WATCHDOGHOW TO CREATE A WEB SERVER TO READ A SD CARD IN OUR PLCHOW TO CONNECT A SD CARD TO A PLCHOW TO UPLOAD A BOOTLOADER ON A ARDBOX/M-DUINO PLC

Comments are closed.