calibration started

This commit is contained in:
Wolfgang Hottgenroth
2014-11-19 22:25:33 +01:00
parent 9ab050c430
commit f201ce5c4a
5 changed files with 71 additions and 39 deletions

View File

@ -58,6 +58,16 @@ uint8_t ADS1210::readRegister(const uint8_t regAddr) const {
return res;
}
void ADS1210:setCalFactor(float calFactor) {
m_calFactor = calFactor;
Config::setFloat(m_eepromAddr + CONFIG_CAL_FACTOR, m_calFactor);
}
void ADS1210:setCalOffset(float calOffset) {
m_calOffset = calOffset;
Config::setFloat(m_eepromAddr + CONFIG_CAL_OFFSET, m_calOffset);
}
void ADS1210::exec() {
if (0 == digitalRead(m_drdyPin)) {
union {
@ -78,13 +88,13 @@ 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 >> SKIPPED_BITS);
m_value = (res.out >> SKIPPED_BITS);
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 + calOffset) * calFactor;
m_u = (((float)m_value) / ((float)vMax)) * U_REF;
m_rRaw = ((((float)vMax) / ((float)m_value)) - 1.0) * R_REF;
m_r = (m_rRaw + m_calOffset) * m_calFactor;
}
}