Component: Load Cell (HX711) (Sensors)

From Flowcode Help
Jump to navigationJump to search
Author Matrix TSL
Version 1.0 (Release)
Category Sensors


Image Load Cell (HX711) component

The HX711 load cell amplifier is used to get measurable data out from a load cell or strain gauge.

Examples

A simple example showing how to get a meaningful reading out of the HX711 IC connected to a load cell sensor. Zeros/Tares the reading when the switch is pressed.


FC6 Icon.png HX711 Example


The scale factor was determined by performing calibration with a unity scale of 1.0 and fixed weight weights. A table of weight vs reading was constructed to provide the correct scale factor.


Here is a guide to calibrate your sensor


When 0g was present on the load cell we zero the output.


When 10g was present on the load cell we get a reading of approx 2170.

2170 / 10g = 217 per g.


When 20g was present on the load cell we get a reading of approx 4340.

4340 / 20g = 217 per g.


1 / 217 = Scale Factor of 0.004608


The readings may not be 100% linear so it's best to take several samples based on different weights across the range you want to be able to measure and from this you can work out a close fitting average.

Downloadable macro reference

SetScaling

Sets the scaler for the samples to provide a meanningful value.

Default scaler is set to 1.0

Parameters

FLOAT Scaler
Unity Scale = 1.0


Return value

This call does not return a value


Zero

Zeros the reading at the current sample

Parameters

This macro has no parameters


Return value

This call does not return a value


Sample

Allows the HX711 to be directly read using the specified scaling amount.

Parameters

This macro has no parameters


Return value

LONG


SetSampleCount

Specifies the number of samples to perform when taking a reading.

The more samples the more filtered the signal will become from high frequency noise.

Parameters

BYTE NumSamples
Default 1. Range 1-20
UINT Delay
Time to wait between samples in milliseconds.


Return value

This call does not return a value


Initialise

Sets up the I/O ready for communications with the HX711 IC and performs an initial sample to set the channel and gain.

Must be called before calling other HX711 component macros.

Parameters

This macro has no parameters


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

Input Channel

This property is of type Fixed list of ints and can be referenced with the variable name InputChannel.

Selects which channel to sample A or B.

Gain settings are channel specific.

A Gain can be 128x or 64x

B Gain is fixed at 32x

Input Gain

This property is of type Fixed list of ints and can be referenced with the variable name InputGain.

Gain settings are channel specific.

A Gain can be 128x or 64x

B Gain is fixed at 32x

Data

This property is of type Single digital pin and can be referenced with the variable name Data.

Data pin - connected to HX711 Data Out pin.

Clock

This property is of type Single digital pin and can be referenced with the variable name Clock.

Clock pin - connected to HX711 SCK pin.