Skip to main content

Class Ina228

Represents a INA228 Precision Digital Current and Power Monitor

Assembly: Ina2xx.dll
View Source
Declaration
public class Ina228 : Ina2xx, IObservable<IChangeResult<(Current? Current, Voltage? Voltage, Power? Power)>>, ISamplingSensor<(Current? Current, Voltage? Voltage, Power? Power)>, ISensor<(Current? Current, Voltage? Voltage, Power? Power)>, IDisposable, ICurrentSensor, ISamplingSensor<Current>, ISensor<Current>, IVoltageSensor, ISamplingSensor<Voltage>, ISensor<Voltage>, IPowerSensor, ISamplingSensor<Power>, ISensor<Power>, ISensor, ISamplingSensor, II2cPeripheral

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

Implements:

Expand

System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Current>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Power>>>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Current>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Power>>>, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Current>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Power>>>, System.IDisposable, Meadow.Peripherals.Sensors.ICurrentSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>, Meadow.Peripherals.Sensors.IVoltageSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Voltage>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Voltage>, Meadow.Peripherals.Sensors.IPowerSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Power>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Power>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, Meadow.Hardware.II2cPeripheral

Methods

Configure()

Sets the sensor Configuration to default values. Each implementation should provide overloads for specific available options.

View Source
Declaration
public override void Configure()

Configure(bool, bool, ushort)

Sets Configuration

View Source
Declaration
public void Configure(bool shuntGain4x = false, bool temperatureCompensation = false, ushort initialConversionDelayMs = 0)
Parameters
TypeName
System.BooleanshuntGain4x
System.BooleantemperatureCompensation
System.UInt16initialConversionDelayMs

ConfigureConversion(Mode, Averaging, ConversionTime, ConversionTime, ConversionTime)

Sets Configuration of ADC conversions

View Source
Declaration
public void ConfigureConversion(Ina228.Mode mode = Mode.ContinuousAll, Ina228.Averaging averaging = Averaging.Average_1, Ina228.ConversionTime voltageTime = ConversionTime.ConversionTime_1052us, Ina228.ConversionTime currentTime = ConversionTime.ConversionTime_1052us, Ina228.ConversionTime temperatureTime = ConversionTime.ConversionTime_1052us)
Parameters
TypeNameDescription
Meadow.Foundation.Sensors.Power.Ina228.Modemodeselection of values and trigger mode
Meadow.Foundation.Sensors.Power.Ina228.AveragingaveragingOn-chip value averaging
Meadow.Foundation.Sensors.Power.Ina228.ConversionTimevoltageTimeConversion time for Voltage measurements
Meadow.Foundation.Sensors.Power.Ina228.ConversionTimecurrentTimeConversion time for Current measurements
Meadow.Foundation.Sensors.Power.Ina228.ConversionTimetemperatureTimeConversion time for Die Temperature measurements

SetCalibration(Current, bool)

_currentScale and _powerScale are set along with _calibration using logic outlined in the datasheet for the INA228

View Source
Declaration
public void SetCalibration(Current maxExpectedCurrent, bool shuntGain4x = false)
Parameters
TypeNameDescription
Meadow.Units.CurrentmaxExpectedCurrentMaximum expected Current in the specific application.
System.BooleanshuntGain4xtrue applies 4x gain to shunt measurements

ReadCurrent()

Read the Current measurement from the power monitor IC.

View Source
Declaration
public override Current ReadCurrent()
Returns

Meadow.Units.Current

ReadBusVoltage()

Read the Voltage measurement from the power monitor IC.

View Source
Declaration
public override Voltage ReadBusVoltage()
Returns

Meadow.Units.Voltage

ReadShuntVoltage()

Read the Voltage across the Shunt (sense) resistor from the power monitor IC.

View Source
Declaration
public override Voltage ReadShuntVoltage()
Returns

Meadow.Units.Voltage

ReadPower()

Read the Power measurement from the power monitor IC.

View Source
Declaration
public override Power ReadPower()
Returns

Meadow.Units.Power

ReadEnergyAccumulator()

Read the Energy accumulator from the power monitor IC.

View Source
Declaration
public Energy ReadEnergyAccumulator()
Returns

Meadow.Units.Energy: Meadow.Units.Energy representing the energy accumulator value.### ReadChargeAccumulator() Read the Charge accumulator from the power monitor IC.

View Source
Declaration
public double ReadChargeAccumulator()
Returns

System.Double: Meadow.Units.Charge representing the charge accumulator value.### ResetAccumulators() Resets the Energy and Charge accumulators on the power monitor IC.

View Source
Declaration
public void ResetAccumulators()

Implements

  • System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Current>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Power>>>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Current>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Power>>>
  • Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Current>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Power>>>
  • System.IDisposable
  • Meadow.Peripherals.Sensors.ICurrentSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.IVoltageSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Voltage>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Voltage>
  • Meadow.Peripherals.Sensors.IPowerSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Power>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Power>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • Meadow.Hardware.II2cPeripheral