Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Commit

Permalink
Corrected shunt voltage overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SV-Zanshin committed Aug 10, 2017
1 parent dad12e7 commit 6673a46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions INA226.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ uint16_t INA226_Class::getBusMilliVolts(const bool waitSwitch) { //
*******************************************************************************************************************/
int16_t INA226_Class::getShuntMicroVolts(const bool waitSwitch) { // //
if (waitSwitch) waitForConversion(); // wait for conversion to complete //
int16_t shuntVoltage = readWord(INA_SHUNT_VOLTAGE_REGISTER); // Get the raw value //
int32_t shuntVoltage = readWord(INA_SHUNT_VOLTAGE_REGISTER); // Get the raw value //
shuntVoltage = shuntVoltage*INA_SHUNT_VOLTAGE_LSB/10; // Convert to microvolts //
if (!bitRead(_OperatingMode,2) && bitRead(_OperatingMode,0)) { // If triggered and shunt active //
int16_t configRegister = readWord(INA_CONFIGURATION_REGISTER); // Get the current register //
writeWord(INA_CONFIGURATION_REGISTER,configRegister); // Write back to trigger next //
} // of if-then triggered mode enabled // //
return(shuntVoltage); // return computed microvolts //
return((int16_t)shuntVoltage); // return computed microvolts //
} // of method getShuntMicroVolts() // //
/*******************************************************************************************************************
** Method getBusMicroAmps retrieves the computed current in microamps. **
Expand Down

0 comments on commit 6673a46

Please sign in to comment.