Difference between revisions of "Component: Load Cell (HX711) (Sensors)"
(XML import) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
{| width="50%" | {| width="50%" | ||
Line 19: | Line 18: | ||
==Examples== | ==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. | ||
+ | |||
+ | |||
+ | {{Fcfile|HX711_Example.fcfx|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== | ==Downloadable macro reference== | ||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>SetScaling</tt></u></span>=== | ||
+ | Sets the scaler for the samples to provide a meanningful value. | ||
+ | |||
+ | Default scaler is set to 1.0 | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|FLOAT]] ''Scaler'' | ||
+ | ::Unity Scale = 1.0 | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :''This call does not return a value'' | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Zero</tt></u></span>=== | ||
+ | Zeros the reading at the current sample | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :''This macro has no parameters'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :''This call does not return a value'' | ||
+ | |||
===<span style="font-weight: normal;"><u><tt>Sample</tt></u></span>=== | ===<span style="font-weight: normal;"><u><tt>Sample</tt></u></span>=== | ||
− | + | Allows the HX711 to be directly read using the specified scaling amount. | |
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :''This macro has no parameters'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|LONG]] | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>SetSampleCount</tt></u></span>=== | ||
+ | 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''' | '''Parameters''' | ||
− | :[[Variable Types| | + | :[[Variable Types|BYTE]] ''NumSamples'' |
− | :: | + | ::Default 1. Range 1-20 |
+ | |||
+ | :[[Variable Types|UINT]] ''Delay'' | ||
+ | ::Time to wait between samples in milliseconds. | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :''This call does not return a value'' | ||
+ | |||
− | : | + | ===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>=== |
− | + | 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''' | '''Return value''' | ||
− | : | + | :''This call does not return a value'' |
Line 57: | Line 135: | ||
==Property reference== | ==Property reference== | ||
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Input Channel</u></span> |
+ | |||
+ | 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 | ||
+ | |||
+ | <span style="font-weight: normal;"><u>Input Gain</u></span> | ||
+ | |||
+ | 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 | |
− | + | <span style="font-weight: normal;"><u>Data</u></span> | |
+ | 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. | ||
− | <span style="font-weight: normal;"><u> | + | <span style="font-weight: normal;"><u>Clock</u></span> |
− | This property is of type ''Single digital pin'' and can be referenced with the variable name '' | + | This property is of type ''Single digital pin'' and can be referenced with the variable name ''Clock''. |
− | + | Clock pin - connected to HX711 SCK pin. |
Latest revision as of 13:21, 7 September 2018
Author | Matrix TSL |
Version | 1.0 (Release) |
Category | Sensors |
Contents
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.
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
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.