Skyward boardcore
|
Load cell transducer. More...
#include <HX711.h>
Public Member Functions | |
HX711 (SPIBusInterface &bus, miosix::GpioPin sckPin, SPIBusConfig config=getDefaultSPIConfig(), unsigned char sckAlternateFunction=5) | |
bool | init () override |
Initialize the sensor. | |
bool | selfTest () override |
Check if the sensor is working. | |
void | computeScale (float value, float sample) |
Calculates the scale value such that the load cell's output matches the given value. | |
void | computeScale (float value) |
Same as computeScale but uses the last sample. | |
void | setScale (float scale) |
Simply changes the scale. | |
float | getScale () |
Returns the current scale. | |
void | setOffset (float offset) |
Sets the offset to the given value. | |
void | updateOffset (float offset) |
Updates the offset by adding it to the current offset. | |
float | getOffset () |
Return the current offset. | |
![]() | |
Sensor () | |
Sensor (Sensor &&other) | |
virtual | ~Sensor () |
void | sample () override |
Sample the sensor. | |
virtual HX711Data | getLastSample () |
![]() | |
virtual | ~AbstractSensor () |
SensorErrors | getLastError () |
Get last error for debugging purposes. Avoid silent fails. | |
Static Public Member Functions | |
static SPIBusConfig | getDefaultSPIConfig () |
Protected Member Functions | |
HX711Data | sampleImpl () override |
Read a data sample from the sensor. In case of errors, the method should return the last available correct sample. | |
Additional Inherited Members | |
![]() | |
using | DataType |
![]() | |
DataType | lastSample |
miosix::FastMutex | mutex |
![]() | |
SensorErrors | lastError = SensorErrors::NO_ERRORS |
Load cell transducer.
HX711 is a precision 24-bit analog-to-digital converter (ADC) designed for weigh scales and industrial control applications to interface directly with a bridge sensor.
The input multiplexer selects either Channel A or B differential input to the low-noise programmable gain amplifier (PGA). Channel A can be programmed with a gain of 128 or 64, corresponding to a full-scale differential input voltage of ±20mV or ±40mV respectively, when a 5V supply is connected to AVDD analog power supply pin. Channel B has a fixed gain of 32. On-chip power supply regulator eliminates the need for an external supply regulator to provide analog power for the ADC and the sensor. Clock input is flexible. It can be from an external clock source, a crystal, or the on-chip oscillator that does not require any external component. On-chip power-on-reset circuitry simplifies digital interface initialization. There is no programming needed for the internal registers. All controls to the HX711 are through the pins.
Reference: https://github.com/bogde/HX711
Boardcore::HX711::HX711 | ( | SPIBusInterface & | bus, |
miosix::GpioPin | sckPin, | ||
SPIBusConfig | config = getDefaultSPIConfig(), | ||
unsigned char | sckAlternateFunction = 5 ) |
void Boardcore::HX711::computeScale | ( | float | value | ) |
void Boardcore::HX711::computeScale | ( | float | value, |
float | sample ) |
Calculates the scale value such that the load cell's output matches the given value.
The value is used to compute the scale coefficient in this way: scale = value / (sample - offset)
value | Value that the load cell should read now. |
sample | Sensor sample used to compute the scale. |
|
static |
float Boardcore::HX711::getOffset | ( | ) |
float Boardcore::HX711::getScale | ( | ) |
|
overridevirtual |
Initialize the sensor.
Implements Boardcore::AbstractSensor.
|
overrideprotectedvirtual |
Read a data sample from the sensor. In case of errors, the method should return the last available correct sample.
Implements Boardcore::Sensor< HX711Data >.
|
overridevirtual |
Check if the sensor is working.
Implements Boardcore::AbstractSensor.
void Boardcore::HX711::setOffset | ( | float | offset | ) |
void Boardcore::HX711::setScale | ( | float | scale | ) |
void Boardcore::HX711::updateOffset | ( | float | offset | ) |