Closed whitfijs-jw closed 7 months ago
In adc.h:
/* 5V inputs go through voltage divider for 3.3V ADC inputs -- not quite 100% */ static constexpr double REFERENCE_VOLTAGE_DIVIDER = (15.0e3 / (15.0e3 + 8.2e3)); static constexpr double INPUT_VOLTAGE_DIVIDER = (15.0e3 / (15.0e3 + 8.2e3)); static constexpr double VOLTAGE_CONVERSION_CORRECTION_FACTOR = 3.3 / (INPUT_VOLTAGE_DIVIDER * 5.0);
farther down:
/** * @brief Read scaled ADC value * @param channel: adc channel to read * @return current measured voltage */ double readValue(int channel, double vRef = -1) { double volts = ((double)readRawValue(channel) / (double)mMaxVal); if (vRef < 0) { updateReference(); return volts * mVref * VOLTAGE_CONVERSION_CORRECTION_FACTOR; } else { return volts * vRef; } }
Not sure what happened but the multiplication by mVref and division by 5.0 are superfluous and introduce a small error.
In adc.h:
farther down:
Not sure what happened but the multiplication by mVref and division by 5.0 are superfluous and introduce a small error.