-
Notifications
You must be signed in to change notification settings - Fork 41
setMode()
The device specified in the optional parameter "deviceNumber" is set to the specified mode; if the parameter is not specifed then all INA2xx devices located are set to the specified mode. The Mode names shown below in uppercase can be used directly in programs as they are defined as constants.
The INA2xx devices have various operating modes. The two main modes are "continuous" (the default) and "triggered". In continuous mode the devices performs measurements in the background and then places the results in the appropriate registers, then goes off and repeats the process. This means that new values are continually written to the registers without user interaction. The triggered mode will only perform measurements when explicitly triggered by the user. Both of these modes have sub-modes which let conversions be limited to either the shunt measurements or the bus measurements or to both. The list of possible modes is as follows:
Mode Value (Binary) |
Mode Description | Program Constant |
---|---|---|
000 | Power Down mode with minimal energy consumption. No measurements are taken until the device is powered up with either a reset or explicitly writing a different mode to the configuration register | INA_MODE_POWER_DOWN |
001 | Triggered Shunt mode. When triggered, perform a single shunt voltage conversion only | INA_MODE_TRIGGERED_SHUNT |
010 | Triggered Bus mode. When triggered, perform a single bus voltage conversion only | INA_MODE_TRIGGERED_BUS |
011 | Trigger mode. When triggered, perform a single shunt and bus voltage conversion | INA_MODE_TRIGGERED_BOTH |
000 | Power Down mode with minimal energy consumption. No measurements are taken until the device is powered up with either a reset or explicitly writing a different mode to the configuration register | INA_MODE_POWER_DOWN |
100 | Power down mode with ADC turned off | INA_MODE_POWER_DOWN |
101 | Continuous shunt mode. Automatically perform shunt voltage measurements | INA_MODE_CONTINUOUS_SHUNT |
110 | Continuous bus mode. Automatically perform bus voltage measurements | INA_MODE_CONTINUOUS_BUS |
111 | Continuous mode (default startup value). Automatically perform bus and shunt measurements | INA_MODE_CONTINUOUS_BOTH |
INA_Class INA(); // Instantiate the class
void setup() {
INA.begin(10,100000); // 10A max with a 0.1 Ohm shunt resistor
INA.setMode(INA_MODE_CONTINUOUS_BUS); // only compute bus values for all devices
} // of setup
void loop() {
uint16_t BusMillivolts = INA.getBusMillivolts();
Serial.print("Bus voltage is ");
Serial.print((float)BusMillivolts/1000,3);
Serial.print(" Volts\n");
delay(5000); // wait 5 seconds before next measurement
} // of main loop
Overview
Installation
Class Instantiation
begin()
setI2CSpeed()
getBusMilliVolts()
getBusRaw()
getShuntMicroVolts()
getShuntRaw()
getBusMicroAmps()
getBusMicroWatts()
getDeviceAddress()
getDeviceName()
setMode()
setAveraging()
setBusConversion()
setShuntConversion()
reset()
waitForConversion()
conversionFinished()
alertOnConversion()
alertOnShuntOverVoltage()
alertOnShuntUnderVoltage()
alertOnBusOverVoltage()
alertOnBusUnderVoltage()
alertOnPowerOverLimit()