M5Unit-METER 0.0.3 git rev:c518ea3
Loading...
Searching...
No Matches
m5::unit::UnitADS111x Class Referenceabstract

Base class for ADS111x series. More...

#include <unit_ADS111x.hpp>

Inheritance diagram for m5::unit::UnitADS111x:
m5::unit::UnitADS1113 m5::unit::UnitADS1114 m5::unit::UnitADS1115 m5::unit::UnitAVmeterBase m5::unit::UnitAmeter m5::unit::UnitVmeter

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitADS111x (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
bool generalReset ()
 General reset.
 
Settings for begin
config_t config ()
 Gets the configration.
 
void config (const config_t &cfg)
 Set the configration.
 
Properties
float coefficient () const
 Coefficient value.
 
Measurement data by periodic
int16_t adc () const
 Oldest measured ADC.
 
Periodic measurement
bool startPeriodicMeasurement ()
 Start periodic measurement in the current settings.
 
bool startPeriodicMeasurement (const ads111x::Sampling rate, const ads111x::Mux mux, const ads111x::Gain gain, const ads111x::ComparatorQueue comp_que)
 Start periodic measurement.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
Configration
Warning
ADS1113, ADS1114 and ADS1115 differ in the items that can be set
ads111x::Mux multiplexer () const
 Gets the input multiplexer.
 
ads111x::Gain gain () const
 Gets the programmable gain amplifier.
 
ads111x::Sampling samplingRate () const
 Gets the sampling rate.
 
bool comparatorMode () const
 Gets the comparator mode.
 
bool comparatorPolarity () const
 Gets the comparator polarity.
 
bool latchingComparator () const
 Gets the Latching comparator.
 
ads111x::ComparatorQueue comparatorQueue () const
 Gets the comparator queue.
 
virtual bool writeMultiplexer (const ads111x::Mux mux)=0
 Write the input multiplexer.
 
virtual bool writeGain (const ads111x::Gain gain)=0
 Write the programmable gain amplifier.
 
bool writeSamplingRate (const ads111x::Sampling rate)
 Write the data rate

 
virtual bool writeComparatorMode (const bool b)=0
 Write the comparator mode.
 
virtual bool writeComparatorPolarity (const bool b)=0
 Write the comparator polarity.
 
virtual bool writeLatchingComparator (const bool b)=0
 Write the latching comparator.
 
virtual bool writeComparatorQueue (const ads111x::ComparatorQueue c)=0
 Write the comparator queue.
 
Single shot measurement
bool measureSingleshot (ads111x::Data &d, const uint32_t timeoutMillis=1000U)
 Measurement single shot.
 
Threshold
bool readThreshold (int16_t &high, int16_t &low)
 Reads the threshold values.
 
bool writeThreshold (const int16_t high, const int16_t low)
 Write the threshold values.
 

Protected Member Functions

bool start_periodic_measurement ()
 
virtual bool start_periodic_measurement (const ads111x::Sampling rate, const ads111x::Mux mux, const ads111x::Gain gain, const ads111x::ComparatorQueue comp_que)=0
 
bool stop_periodic_measurement ()
 
bool read_adc_raw (ads111x::Data &d)
 
bool start_single_measurement ()
 
bool in_conversion ()
 
bool read_config (ads111x::Config &c)
 
bool write_config (const ads111x::Config &c)
 
void apply_interval (const ads111x::Sampling rate)
 
virtual void apply_coefficient (const ads111x::Gain gain)
 
bool write_multiplexer (const ads111x::Mux mux)
 
bool write_gain (const ads111x::Gain gain)
 
bool write_comparator_mode (const bool b)
 
bool write_comparator_polarity (const bool b)
 
bool write_latching_comparator (const bool b)
 
bool write_comparator_queue (const ads111x::ComparatorQueue c)
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitADS111x, ads111x::Data)
 

Protected Attributes

std::unique_ptr< m5::container::CircularBuffer< ads111x::Data > > _data {}
 
float _coefficient {}
 
ads111x::Config _ads_cfg {}
 
config_t _cfg {}
 

Detailed Description

Base class for ADS111x series.

Member Function Documentation

◆ coefficient()

float m5::unit::UnitADS111x::coefficient ( ) const
inline

Coefficient value.

Note
Changes as gain changes

◆ comparatorMode()

bool m5::unit::UnitADS111x::comparatorMode ( ) const
inline

Gets the comparator mode.

Return values
trueWindow comparator
falseTraditional comparator

◆ comparatorPolarity()

bool m5::unit::UnitADS111x::comparatorPolarity ( ) const
inline

Gets the comparator polarity.

Return values
trueActive high
falseActive low

◆ generalReset()

bool m5::unit::UnitADS111x::generalReset ( )

General reset.

Reset using I2C general call

Warning
This is a reset by General command, the command is also sent to all devices with I2C connections

◆ latchingComparator()

bool m5::unit::UnitADS111x::latchingComparator ( ) const
inline

Gets the Latching comparator.

Return values
trueLatching comparator
falseNonlatching comparator

◆ measureSingleshot()

bool m5::unit::UnitADS111x::measureSingleshot ( ads111x::Data & d,
const uint32_t timeoutMillis = 1000U )

Measurement single shot.

Measuring in the current settings

Parameters
[out]dataMeasuerd data
timeoutMillisTimeout for measure
Returns
True if successful
Warning
During periodic detection runs, an error is returned
Until it can be measured, it will be blocked until the timeout time

◆ readThreshold()

bool m5::unit::UnitADS111x::readThreshold ( int16_t & high,
int16_t & low )

Reads the threshold values.

Parameters
[out]highupper threshold value
[out]lowlower threshold value
Returns
True if successful

◆ startPeriodicMeasurement() [1/2]

bool m5::unit::UnitADS111x::startPeriodicMeasurement ( )
inline

Start periodic measurement in the current settings.

Returns
True if successful

◆ startPeriodicMeasurement() [2/2]

bool m5::unit::UnitADS111x::startPeriodicMeasurement ( const ads111x::Sampling rate,
const ads111x::Mux mux,
const ads111x::Gain gain,
const ads111x::ComparatorQueue comp_que )
inline

Start periodic measurement.

Parameters
rateSampling rate
muxInput multiplexer (Not supported in some classes)
gainProgrammable gain amplifier (Not supported in some classes)
comp_queComparator queue (Not supported in some classes)
Returns
True if successful

◆ stopPeriodicMeasurement()

bool m5::unit::UnitADS111x::stopPeriodicMeasurement ( )
inline

Stop periodic measurement.

Returns
True if successful

◆ writeComparatorMode()

virtual bool m5::unit::UnitADS111x::writeComparatorMode ( const bool b)
pure virtual

Write the comparator mode.

Implemented in m5::unit::UnitADS1113, m5::unit::UnitADS1114, and m5::unit::UnitADS1115.

◆ writeComparatorPolarity()

virtual bool m5::unit::UnitADS111x::writeComparatorPolarity ( const bool b)
pure virtual

Write the comparator polarity.

Implemented in m5::unit::UnitADS1113, m5::unit::UnitADS1114, and m5::unit::UnitADS1115.

◆ writeComparatorQueue()

virtual bool m5::unit::UnitADS111x::writeComparatorQueue ( const ads111x::ComparatorQueue c)
pure virtual

Write the comparator queue.

Implemented in m5::unit::UnitADS1113, m5::unit::UnitADS1114, and m5::unit::UnitADS1115.

◆ writeGain()

virtual bool m5::unit::UnitADS111x::writeGain ( const ads111x::Gain gain)
pure virtual

Write the programmable gain amplifier.

Warning
the threshould values must be updated whenever the PGA settings are changed
See also
writeThreshold

Implemented in m5::unit::UnitADS1113, m5::unit::UnitADS1114, m5::unit::UnitADS1115, and m5::unit::UnitAVmeterBase.

◆ writeLatchingComparator()

virtual bool m5::unit::UnitADS111x::writeLatchingComparator ( const bool b)
pure virtual

Write the latching comparator.

Implemented in m5::unit::UnitADS1113, m5::unit::UnitADS1114, and m5::unit::UnitADS1115.

◆ writeMultiplexer()

virtual bool m5::unit::UnitADS111x::writeMultiplexer ( const ads111x::Mux mux)
pure virtual

Write the input multiplexer.

Implemented in m5::unit::UnitADS1113, m5::unit::UnitADS1114, and m5::unit::UnitADS1115.

◆ writeThreshold()

bool m5::unit::UnitADS111x::writeThreshold ( const int16_t high,
const int16_t low )

Write the threshold values.

Parameters
highupper threshold value
lowlower threshold value
Returns
True if successful
Warning
The high value must always be greater than the low value