Difference between revisions of "Component: Load Cell (HX711) (Force)"
Line 16: | Line 16: | ||
==Component Source Code== | ==Component Source Code== | ||
+ | |||
+ | Please click here to download the component source project: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_Load_Cell_HX711.fcfx FC_Comp_Source_Load_Cell_HX711.fcfx] | ||
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Load_Cell_HX711.fcfx FC_Comp_Source_Load_Cell_HX711.fcfx] | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Load_Cell_HX711.fcfx FC_Comp_Source_Load_Cell_HX711.fcfx] | ||
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
Line 40: | Line 44: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
Line 91: | Line 97: | ||
==Macro reference== | ==Macro reference== | ||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetScaling''' | ||
+ | |- | ||
+ | | colspan="2" | Sets the scaler for the samples to provide a meanningful value. Default scaler is set to 1.0 | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" | Scaler | ||
+ | |- | ||
+ | | colspan="2" | Unity Scale = 1.0 | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScaledSample''' | ||
+ | |- | ||
+ | | colspan="2" | Takes a raw sample and then applies the scaling factor to return a real world value. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Zero''' | ||
+ | |- | ||
+ | | colspan="2" | Zeros the reading at the current sample | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RawSample''' | ||
+ | |- | ||
+ | | colspan="2" | Allows the HX711 to be directly read returning the raw unscaled 24-bit reading. Reading is relative to the last defined Zero point. If a timeout occurs and the HX711 is not ready then we return the last valid reading. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s32-icon.png]] - LONG | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetChannelAndGain''' | ||
+ | |- | ||
+ | | colspan="2" | Allows the preselected input channel and gain to be overridden. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | Channel | ||
+ | |- | ||
+ | | colspan="2" | Range: 0-1 / 0=A 1=B | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Gain | ||
+ | |- | ||
+ | | colspan="2" | Channel A can be 128 or 64, Channel B can be 32 | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSampleCount''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumSamples | ||
+ | |- | ||
+ | | colspan="2" | Default 1. Range 1-20 | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Delay | ||
+ | |- | ||
+ | | colspan="2" | Time to wait between samples in milliseconds. | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Property reference== | ||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties''' | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Input Channel | ||
+ | |- | ||
+ | | colspan="2" | 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 | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Input Gain | ||
+ | |- | ||
+ | | colspan="2" | Gain settings are channel specific. A Gain can be 128x or 64x B Gain is fixed at 32x | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]] | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data pin - connected to HX711 Data Out pin. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]] | ||
+ | | width="90%" | Clock | ||
+ | |- | ||
+ | | colspan="2" | Clock pin - connected to HX711 SCK pin. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-21-icon.png]] | ||
+ | | width="90%" | Clock Transition Delay | ||
+ | |- | ||
+ | | colspan="2" | Number of microseconds to wait after each clock edge. Max theoretical: 10Hz Mode = 1uS / 80 Hz Mode = 4uS | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Use Median Filter | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |}==Macro reference== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
Revision as of 15:23, 20 January 2023
Author | Matrix TSL |
Version | 2.0 |
Category | Force |
Contents
Load Cell (HX711) component
The HX711 load cell amplifier is used to get measurable data out from a load cell or strain gauge.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_Load_Cell_HX711.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_Load_Cell_HX711.fcfx
Detailed description
No detailed description exists yet for this component
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.
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.
Macro reference
![]() |
SetScaling |
Sets the scaler for the samples to provide a meanningful value. Default scaler is set to 1.0 | |
![]() |
Scaler |
Unity Scale = 1.0 | |
![]() |
Return |
![]() |
ScaledSample |
Takes a raw sample and then applies the scaling factor to return a real world value. | |
![]() |
Return |
![]() |
Zero |
Zeros the reading at the current sample | |
![]() |
Return |
![]() |
SetChannelAndGain |
Allows the preselected input channel and gain to be overridden. | |
![]() |
Channel |
Range: 0-1 / 0=A 1=B | |
![]() |
Gain |
Channel A can be 128 or 64, Channel B can be 32 | |
![]() |
Return |
Property reference
==Macro reference==
![]() |
SetScaling |
Sets the scaler for the samples to provide a meanningful value. Default scaler is set to 1.0 | |
![]() |
Scaler |
Unity Scale = 1.0 | |
![]() |
Return |
![]() |
ScaledSample |
Takes a raw sample and then applies the scaling factor to return a real world value. | |
![]() |
Return |
![]() |
Zero |
Zeros the reading at the current sample | |
![]() |
Return |
![]() |
SetChannelAndGain |
Allows the preselected input channel and gain to be overridden. | |
![]() |
Channel |
Range: 0-1 / 0=A 1=B | |
![]() |
Gain |
Channel A can be 128 or 64, Channel B can be 32 | |
![]() |
Return |
Property reference
==Macro reference==
![]() |
SetScaling |
Sets the scaler for the samples to provide a meanningful value. Default scaler is set to 1.0 | |
![]() |
Scaler |
Unity Scale = 1.0 | |
![]() |
Return |
![]() |
ScaledSample |
Takes a raw sample and then applies the scaling factor to return a real world value. | |
![]() |
Return |
![]() |
Zero |
Zeros the reading at the current sample | |
![]() |
Return |
![]() |
SetChannelAndGain |
Allows the preselected input channel and gain to be overridden. | |
![]() |
Channel |
Range: 0-1 / 0=A 1=B | |
![]() |
Gain |
Channel A can be 128 or 64, Channel B can be 32 | |
![]() |
Return |