Table of Contents

Class Ina226

Namespace
Pamoja.Sensors
Assembly
Pamoja.Sensors.dll

A Texas Instruments INA226 current, voltage, and power monitor. Every call goes straight to the pamoja C ABI, which decodes exactly what the manufacturer's datasheet specifies.

public static class Ina226
Inheritance
Ina226
Inherited Members

Methods

ActiveAlertFunction(PamojaIna226MaskEnable)

Returns the alert function an INA226 pin actually responds to.

public static PamojaIna226AlertFunction? ActiveAlertFunction(PamojaIna226MaskEnable mask)

Parameters

mask PamojaIna226MaskEnable

The mask.

Returns

PamojaIna226AlertFunction?

The value, or null where the part defines none.

Address(byte, byte)

Returns the I2C address an INA226's A1 and A0 pin codes select.

public static byte Address(byte a1, byte a0)

Parameters

a1 byte

The a1.

a0 byte

The a0.

Returns

byte

The decoded value.

Exceptions

PamojaException

The device data is not valid.

AveragingSamples(byte)

Returns how many samples an INA226 averaging code folds into one result.

public static ushort AveragingSamples(byte code)

Parameters

code byte

The code.

Returns

ushort

The value the C ABI computes.

BusMicrovolts(ushort)

Converts a raw INA226 bus-voltage register to microvolts.

public static uint BusMicrovolts(ushort raw)

Parameters

raw ushort

The raw.

Returns

uint

The value the C ABI computes.

BusRegister(uint)

Builds the INA226 bus-voltage register a monitor reports for a bus voltage.

public static ushort BusRegister(uint microvolts)

Parameters

microvolts uint

The microvolts.

Returns

ushort

The value the C ABI computes.

BusVolts(ushort)

Converts a raw INA226 bus-voltage register to volts.

public static float BusVolts(ushort raw)

Parameters

raw ushort

The raw.

Returns

float

The value the C ABI computes.

Calibration(uint, uint)

Computes the INA226 calibration register for a shunt and current resolution.

public static ushort Calibration(uint currentLsbMicroamps, uint shuntMilliohms)

Parameters

currentLsbMicroamps uint

The current lsb microamps.

shuntMilliohms uint

The shunt milliohms.

Returns

ushort

The value the C ABI computes.

ConfigFromRegister(ushort)

Parses an INA226 configuration register value.

public static PamojaIna226Config ConfigFromRegister(ushort raw)

Parameters

raw ushort

The raw.

Returns

PamojaIna226Config

The decoded value.

Exceptions

PamojaException

The device data is not valid.

ConfigToRegister(PamojaIna226Config)

Assembles an INA226 configuration register value.

public static ushort ConfigToRegister(PamojaIna226Config config)

Parameters

config PamojaIna226Config

The config.

Returns

ushort

The value the C ABI computes.

ConversionMicros(byte)

Returns the conversion time an INA226 code selects.

public static uint ConversionMicros(byte code)

Parameters

code byte

The code.

Returns

uint

The value the C ABI computes.

CurrentAmps(short, uint)

Converts a raw INA226 current register to amps.

public static float CurrentAmps(short raw, uint currentLsbMicroamps)

Parameters

raw short

The raw.

currentLsbMicroamps uint

The current lsb microamps.

Returns

float

The value the C ABI computes.

CurrentMicroamps(short, uint)

Converts a raw INA226 current register to microamps.

public static int CurrentMicroamps(short raw, uint currentLsbMicroamps)

Parameters

raw short

The raw.

currentLsbMicroamps uint

The current lsb microamps.

Returns

int

The value the C ABI computes.

CurrentRegister(int, uint)

Builds the INA226 current register a monitor reports for a current.

public static short CurrentRegister(int microamps, uint currentLsbMicroamps)

Parameters

microamps int

The microamps.

currentLsbMicroamps uint

The current lsb microamps.

Returns

short

The value the C ABI computes.

CurrentRegisterFromShunt(short, ushort)

Computes the INA226 current register the chip derives from a shunt reading.

public static short CurrentRegisterFromShunt(short shunt, ushort calibration)

Parameters

shunt short

The shunt.

calibration ushort

The calibration.

Returns

short

The value the C ABI computes.

DieId(ushort)

Splits an INA226 die-ID register into its device and revision fields.

public static PamojaIna226DieId DieId(ushort raw)

Parameters

raw ushort

The raw.

Returns

PamojaIna226DieId

The decoded value.

Exceptions

PamojaException

The device data is not valid.

Identify(ushort, ushort)

Checks that a pair of identification registers belongs to an INA226.

public static PamojaIna226DieId Identify(ushort manufacturerId, ushort dieId)

Parameters

manufacturerId ushort

The manufacturer id.

dieId ushort

The die id.

Returns

PamojaIna226DieId

The decoded value.

Exceptions

PamojaException

The device data is not valid.

IsContinuous(byte)

Reports whether an INA226 mode code keeps converting after the first result.

public static bool IsContinuous(byte code)

Parameters

code byte

The code.

Returns

bool

The value the C ABI computes.

MaskEnableFromRegister(ushort)

Parses an INA226 Mask/Enable register value.

public static PamojaIna226MaskEnable MaskEnableFromRegister(ushort raw)

Parameters

raw ushort

The raw.

Returns

PamojaIna226MaskEnable

The decoded value.

Exceptions

PamojaException

The device data is not valid.

MaskEnableToRegister(PamojaIna226MaskEnable)

Assembles an INA226 Mask/Enable register value.

public static ushort MaskEnableToRegister(PamojaIna226MaskEnable mask)

Parameters

mask PamojaIna226MaskEnable

The mask.

Returns

ushort

The value the C ABI computes.

MeasuresBus(byte)

Reports whether an INA226 mode code converts the bus voltage.

public static bool MeasuresBus(byte code)

Parameters

code byte

The code.

Returns

bool

The value the C ABI computes.

MeasuresShunt(byte)

Reports whether an INA226 mode code converts the shunt voltage.

public static bool MeasuresShunt(byte code)

Parameters

code byte

The code.

Returns

bool

The value the C ABI computes.

MinimumCurrentLsbMicroamps(uint)

Returns the smallest current resolution that still covers an expected maximum.

public static uint MinimumCurrentLsbMicroamps(uint maxExpectedMicroamps)

Parameters

maxExpectedMicroamps uint

The max expected microamps.

Returns

uint

The value the C ABI computes.

PowerMicrowatts(ushort, uint)

Converts a raw INA226 power register to microwatts.

public static uint PowerMicrowatts(ushort raw, uint currentLsbMicroamps)

Parameters

raw ushort

The raw.

currentLsbMicroamps uint

The current lsb microamps.

Returns

uint

The value the C ABI computes.

PowerRegister(uint, uint)

Builds the INA226 power register a monitor reports for a power.

public static ushort PowerRegister(uint microwatts, uint currentLsbMicroamps)

Parameters

microwatts uint

The microwatts.

currentLsbMicroamps uint

The current lsb microamps.

Returns

ushort

The value the C ABI computes.

PowerRegisterFromCurrent(short, ushort)

Computes the INA226 power register the chip derives from a current reading.

public static ushort PowerRegisterFromCurrent(short current, ushort bus)

Parameters

current short

The current.

bus ushort

The bus.

Returns

ushort

The value the C ABI computes.

PowerWatts(ushort, uint)

Converts a raw INA226 power register to watts.

public static float PowerWatts(ushort raw, uint currentLsbMicroamps)

Parameters

raw ushort

The raw.

currentLsbMicroamps uint

The current lsb microamps.

Returns

float

The value the C ABI computes.

ShuntMillivolts(short)

Converts a raw INA226 shunt-voltage register to millivolts.

public static float ShuntMillivolts(short raw)

Parameters

raw short

The raw.

Returns

float

The value the C ABI computes.

ShuntNanovolts(short)

Converts a raw INA226 shunt-voltage register to nanovolts.

public static int ShuntNanovolts(short raw)

Parameters

raw short

The raw.

Returns

int

The value the C ABI computes.

ShuntRegister(int)

Builds the INA226 shunt-voltage register a monitor reports for a shunt voltage.

public static short ShuntRegister(int nanovolts)

Parameters

nanovolts int

The nanovolts.

Returns

short

The value the C ABI computes.

UpdateMicros(PamojaIna226Config)

Returns how often an INA226 in a configuration updates its results.

public static uint UpdateMicros(PamojaIna226Config config)

Parameters

config PamojaIna226Config

The config.

Returns

uint

The value the C ABI computes.