Class Ina219
A TI INA219 current, voltage, and power monitor.
public static class Ina219
- Inheritance
-
Ina219
- Inherited Members
Methods
BusMillivolts(ushort)
Converts a raw bus-voltage register to millivolts.
public static uint BusMillivolts(ushort raw)
Parameters
rawushortThe register value.
Returns
- uint
The bus voltage.
BusRegister(uint)
Builds the bus-voltage register a monitor reports for a bus voltage.
public static ushort BusRegister(uint millivolts)
Parameters
millivoltsuintThe bus voltage in millivolts.
Returns
- ushort
The register value, with the conversion-ready flag set.
Calibration(uint, uint)
Computes the calibration register for a shunt and resolution.
public static ushort Calibration(uint currentLsbMicroamps, uint shuntMilliohms)
Parameters
currentLsbMicroampsuintThe microamps per count wanted.
shuntMilliohmsuintThe shunt resistor value.
Returns
- ushort
The register value to write.
ConversionReady(ushort)
Reports whether a bus-voltage register says a conversion is ready.
public static bool ConversionReady(ushort raw)
Parameters
rawushortThe register value.
Returns
- bool
Whether the conversion-ready flag is set.
CurrentMicroamps(short, uint)
Converts a raw current register to microamps.
public static int CurrentMicroamps(short raw, uint currentLsbMicroamps)
Parameters
rawshortThe signed register value.
currentLsbMicroampsuintThe resolution the calibration selected.
Returns
- int
The current.
CurrentRegister(int, uint)
Builds the current register a monitor reports for a current.
public static short CurrentRegister(int microamps, uint currentLsbMicroamps)
Parameters
microampsintThe current in microamps.
currentLsbMicroampsuintThe current LSB the calibration was set for.
Returns
- short
The signed register value.
MathOverflow(ushort)
Reports whether a bus-voltage register flags a math overflow.
public static bool MathOverflow(ushort raw)
Parameters
rawushortThe register value.
Returns
- bool
Whether the current and power readings are meaningless, which means the calibration needs revisiting.
MinimumCurrentLsbMicroamps(uint)
Returns the smallest resolution that still covers a maximum.
public static uint MinimumCurrentLsbMicroamps(uint maxExpectedMicroamps)
Parameters
maxExpectedMicroampsuintThe largest current measured.
Returns
- uint
The minimum current LSB in microamps.
PowerMicrowatts(ushort, uint)
Converts a raw power register to microwatts.
public static uint PowerMicrowatts(ushort raw, uint currentLsbMicroamps)
Parameters
Returns
- uint
The power. The power LSB is fixed at twenty times the current LSB.
PowerRegister(uint, uint)
Builds the power register a monitor reports for a power.
public static ushort PowerRegister(uint microwatts, uint currentLsbMicroamps)
Parameters
microwattsuintThe power in microwatts.
currentLsbMicroampsuintThe current LSB the calibration was set for.
Returns
- ushort
The register value.
ShuntMicrovolts(short)
Converts a raw shunt-voltage register to microvolts.
public static int ShuntMicrovolts(short raw)
Parameters
rawshortThe signed register value.
Returns
- int
The shunt voltage.
ShuntRegister(int)
Builds the shunt-voltage register a monitor reports for a shunt voltage.
public static short ShuntRegister(int microvolts)
Parameters
microvoltsintThe shunt voltage in microvolts.
Returns
- short
The signed register value, at 10 uV per count.
Remarks
The inverse of ShuntMicrovolts(short), so a node can be written and tested against what a monitor sends without one attached.