M5Unit-METER 0.2.1 git rev:6a6ea23
|
Base class for INA226 unit. More...
#include <unit_INA226.hpp>
Classes | |
struct | config_t |
Settings for begin. More... | |
Public Member Functions | |
virtual bool | begin () override |
virtual void | update (const bool force=false) override |
bool | readAlertOccurred (bool &alert) |
Read the alert occurred? | |
bool | powerDown () |
Power down. | |
bool | softReset (const bool all=false) |
Software reset. | |
Settings for begin | |
config_t | config () |
Gets the configration. | |
void | config (const config_t &cfg) |
Set the configration. | |
Properties | |
float | shuntResistor () const |
Gets the maximum current (A) | |
float | maximumCurrent () const |
Gets the maximum current (A) | |
float | currentLSB () const |
Gets the current LSB. | |
Measurement data by periodic | |
float | shuntVoltage () const |
Oldest shunt voltage (mV) | |
float | voltage () const |
Oldest Bus voltage (mV) | |
float | power () const |
Oldest power (mW) | |
float | current () const |
Oldest current (mA) | |
Periodic measurement | |
bool | startPeriodicMeasurement (const bool current=true, const bool voltage=true, const bool power=true) |
Start periodic measurement in the current settings. | |
bool | startPeriodicMeasurement (const ina226::Sampling rate, const ina226::ConversionTime sct, const ina226::ConversionTime bct, const bool current=true, const bool voltage=true, const bool power=true) |
Start periodic measurement. | |
bool | stopPeriodicMeasurement () |
Stop periodic measurement. | |
Single shot measurement | |
bool | measureSingleshot (ina226::Data &data, const bool current=true, const bool voltage=true, const bool power=true) |
Measurement single shot. | |
bool | measureSingleshot (ina226::Data &data, const ina226::Sampling rate, const ina226::ConversionTime sct, const ina226::ConversionTime bct, const bool current=true, const bool voltage=true, const bool power=true) |
Measurement single shot. | |
Settings | |
bool | readMode (ina226::Mode &mode) |
Read the operation mode. | |
bool | readSamplingRate (ina226::Sampling &rate) |
Read the sampling rate. | |
bool | writeSamplingRate (const ina226::Sampling rate) |
Write the sampling rate. | |
bool | readBusVoltageConversionTime (ina226::ConversionTime &ct) |
Read the convsrsion time of Bus voltage. | |
bool | writeBusVoltageConversionTime (const ina226::ConversionTime ct) |
Write the convsrsion time of Bus voltage @paramct Conversion time. | |
bool | readShuntVoltageConversionTime (ina226::ConversionTime &ct) |
Read the convsrsion time of Shunt voltage. | |
bool | writeShuntVoltageConversionTime (const ina226::ConversionTime ct) |
Write the convsrsion time of Shunt voltage @paramct Conversion time. | |
bool | readCalibration (uint16_t &cal) |
Read the calibration value. | |
bool | writeCalibration (const uint16_t cal) |
Write the calibration value. | |
bool | readAlert (ina226::Alert &type) |
Read the alert type. | |
bool | writeAlert (const ina226::Alert type, const uint16_t limit, const bool latch=true) |
Write the alert type and limit value. | |
bool | readAlertLimit (uint16_t &limit) |
Read the alerm limit value. | |
bool | writeAlertLimit (const uint16_t limit) |
Write the alerm limit value. | |
Protected Member Functions | |
UnitINA226 (const float shuntRes, const float maxCurA, const float curLSB, const uint8_t addr=DEFAULT_ADDRESS) | |
Constructor. | |
bool | start_periodic_measurement (const bool current, const bool voltage, const bool power) |
bool | start_periodic_measurement (const ina226::Sampling rate, const ina226::ConversionTime sct, const ina226::ConversionTime bct, const bool current, const bool voltage, const bool power) |
bool | stop_periodic_measurement () |
bool | write_mode (const ina226::Mode mode) |
bool | read_configuration (uint16_t &v) |
bool | write_configuration (const uint16_t v) |
bool | read_mask (uint16_t &m) |
bool | write_mask (const uint16_t m) |
bool | is_data_ready () |
bool | read_measurement (ina226::Data &d) |
M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitINA226, ina226::Data) | |
Base class for INA226 unit.
|
protected |
Constructor.
shuntRes | Shunt resistor (O) |
maxCurA | Maximum measure current (A) @paream curLSB currentLSB |
bool m5::unit::UnitINA226::measureSingleshot | ( | ina226::Data & | data, |
const bool | current = true, | ||
const bool | voltage = true, | ||
const bool | power = true ) |
Measurement single shot.
Measuring in the current settings
[out] | data | Measuerd data |
current | Measure current if true | |
voltage | Measure bus voltage if true | |
power | Measure power if true |
bool m5::unit::UnitINA226::measureSingleshot | ( | ina226::Data & | data, |
const ina226::Sampling | rate, | ||
const ina226::ConversionTime | sct, | ||
const ina226::ConversionTime | bct, | ||
const bool | current = true, | ||
const bool | voltage = true, | ||
const bool | power = true ) |
Measurement single shot.
Measuring in the current settings
[out] | data | Measuerd data |
rate | Sampling Sampling rate @paran sct Shunt conversion time @paran bct Bus conversion time | |
current | Measure current if true | |
voltage | Measure bus voltage if true | |
power | Measure power if true |
bool m5::unit::UnitINA226::powerDown | ( | ) |
Power down.
bool m5::unit::UnitINA226::readAlert | ( | ina226::Alert & | type | ) |
Read the alert type.
[out] | type | Alert type |
bool m5::unit::UnitINA226::readAlertLimit | ( | uint16_t & | limit | ) |
Read the alerm limit value.
[out] | limit | Limit value |
bool m5::unit::UnitINA226::readAlertOccurred | ( | bool & | alert | ) |
Read the alert occurred?
[out] | alert | An alert occurred if true |
bool m5::unit::UnitINA226::readBusVoltageConversionTime | ( | ina226::ConversionTime & | ct | ) |
Read the convsrsion time of Bus voltage.
[out] | ct | Conversion time |
bool m5::unit::UnitINA226::readCalibration | ( | uint16_t & | cal | ) |
Read the calibration value.
[out] | cal | Calibration value |
bool m5::unit::UnitINA226::readMode | ( | ina226::Mode & | mode | ) |
Read the operation mode.
[out] | mode | Mode |
bool m5::unit::UnitINA226::readSamplingRate | ( | ina226::Sampling & | rate | ) |
Read the sampling rate.
[out] | rate | Samling rate |
bool m5::unit::UnitINA226::readShuntVoltageConversionTime | ( | ina226::ConversionTime & | ct | ) |
Read the convsrsion time of Shunt voltage.
[out] | ct | Conversion time |
bool m5::unit::UnitINA226::softReset | ( | const bool | all = false | ) |
Software reset.
all | Rewrite calibration value if false |
|
inline |
Start periodic measurement in the current settings.
current | Measure current if true |
voltage | Measure bus voltage if true |
power | Measure power if true |
|
inline |
Start periodic measurement.
rate | Sampling Sampling rate @paran sct Shunt conversion time @paran bct Bus conversion time |
current | Measure current if true |
voltage | Measure bus voltage if true |
power | Measure power if true |
|
inline |
Stop periodic measurement.
bool m5::unit::UnitINA226::writeAlert | ( | const ina226::Alert | type, |
const uint16_t | limit, | ||
const bool | latch = true ) |
Write the alert type and limit value.
type | Alert type |
limit | Limit value (Ignore if type is Alert::ConversionReady) |
latch | Alert latch enabled if true |
Type | Alert | Description | Unit | Value |
---|---|---|---|---|
Type::ShuntOver Type::ShuntUnder | SOL/SUL | Shunt over/under limit | V | V / 0.00125 |
Type::BusOver Type::BusUnder | BOL/BUL | Bus over/under limit | V | V / 0..00125 |
Type::PowerOver | POL | Power over limit | W | W / (25 × currentLSB) |
Type::ConversionReady | CNVR | Conversion ready | - | - |
bool m5::unit::UnitINA226::writeAlertLimit | ( | const uint16_t | limit | ) |
Write the alerm limit value.
limit | Limit value |
bool m5::unit::UnitINA226::writeBusVoltageConversionTime | ( | const ina226::ConversionTime | ct | ) |
Write the convsrsion time of Bus voltage @paramct Conversion time.
bool m5::unit::UnitINA226::writeCalibration | ( | const uint16_t | cal | ) |
Write the calibration value.
cal | Calibration value |
bool m5::unit::UnitINA226::writeSamplingRate | ( | const ina226::Sampling | rate | ) |
Write the sampling rate.
rate | Samling rate |
bool m5::unit::UnitINA226::writeShuntVoltageConversionTime | ( | const ina226::ConversionTime | ct | ) |
Write the convsrsion time of Shunt voltage @paramct Conversion time.