Class Ina228
Represents a INA228 Precision Digital Current and Power Monitor
Assembly: Ina2xx.dll
View Source
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
public override void Configure()
Configure(bool, bool, ushort)
Sets Configuration
View Source
public void Configure(bool shuntGain4x = false, bool temperatureCompensation = false, ushort initialConversionDelayMs = 0)
Parameters
Type | Name |
---|---|
System.Boolean | shuntGain4x |
System.Boolean | temperatureCompensation |
System.UInt16 | initialConversionDelayMs |
ConfigureConversion(Mode, Averaging, ConversionTime, ConversionTime, ConversionTime)
Sets Configuration of ADC conversions
View Source
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
Type | Name | Description |
---|---|---|
Meadow.Foundation.Sensors.Power.Ina228.Mode | mode | selection of values and trigger mode |
Meadow.Foundation.Sensors.Power.Ina228.Averaging | averaging | On-chip value averaging |
Meadow.Foundation.Sensors.Power.Ina228.ConversionTime | voltageTime | Conversion time for Voltage measurements |
Meadow.Foundation.Sensors.Power.Ina228.ConversionTime | currentTime | Conversion time for Current measurements |
Meadow.Foundation.Sensors.Power.Ina228.ConversionTime | temperatureTime | Conversion 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
public void SetCalibration(Current maxExpectedCurrent, bool shuntGain4x = false)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Units.Current | maxExpectedCurrent | Maximum expected Current in the specific application. |
System.Boolean | shuntGain4x | true applies 4x gain to shunt measurements |
ReadCurrent()
Read the Current measurement from the power monitor IC.
View Source
public override Current ReadCurrent()
Returns
Meadow.Units.Current
ReadBusVoltage()
Read the Voltage measurement from the power monitor IC.
View Source
public override Voltage ReadBusVoltage()
Returns
Meadow.Units.Voltage
ReadShuntVoltage()
Read the Voltage across the Shunt (sense) resistor from the power monitor IC.
View Source
public override Voltage ReadShuntVoltage()
Returns
Meadow.Units.Voltage
ReadPower()
Read the Power measurement from the power monitor IC.
View Source
public override Power ReadPower()
Returns
Meadow.Units.Power
ReadEnergyAccumulator()
Read the Energy accumulator from the power monitor IC.
View Source
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
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
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