significant bit handling fixes

This commit is contained in:
Wolfgang Hottgenroth
2014-11-16 19:19:49 +01:00
parent cb329623af
commit 5422180fd5
2 changed files with 6 additions and 4 deletions

View File

@ -74,10 +74,12 @@ void ADS1210::exec() {
//Serial << "DOR4x8: " << _HEX(res.in[3]) << " " << _HEX(res.in[2]) << " " << _HEX(res.in[1]) << " " << _HEX(res.in[0]) << endl;
//Serial << "DOR1x32: " << _HEX(res.out) << endl;
value = (res.out & V_MASK);
value = res.out >> SKIPPED_BITS;
u = (((float)value) / ((float)V_MAX)) * U_REF;
rRaw = ((((float)V_MAX) / ((float)value)) - 1.0) * R_REF;
uint32_t vMax = V_MAX >> SKIPPED_BITS;
u = (((float)value) / ((float)vMax)) * U_REF;
rRaw = ((((float)vMax) / ((float)value)) - 1.0) * R_REF;
r = (rRaw + m_calOffset) * m_calFactor;
}
}