-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Thanks for your library. Just starting trying to use it today and was wondering why several of my readings were not correct. Turns out that you're not handling negative numbers properly.
From the datasheet, section 7.6.3.2 states: This register stores the current shunt voltage reading, VSHUNT. Negative numbers are represented in two's complement format.
float INA233::getShuntVoltage_mV() {
uint16_t value=getShuntVoltage_raw();
float vshunt;
vshunt=(value*pow(10,-R_vs)-b_vs)/m_vs;
return vshunt * 1000;
}
should be:
float INA233::getShuntVoltage_mV() {
int16_t value=getShuntVoltage_raw();
float vshunt;
vshunt=(value*pow(10,-R_vs)-b_vs)/m_vs;
return vshunt * 1000;
}
There's the same problem in getCurrent_mA()...needs to use int16_t for value.
Metadata
Metadata
Assignees
Labels
No labels