Make adc range scalable

This commit is contained in:
Ben V. Brown
2022-05-24 23:31:45 +10:00
parent 7c6534a339
commit 9fd1d366b9
6 changed files with 21 additions and 19 deletions

View File

@@ -36,7 +36,7 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool ski
uint32_t vddRailmVX10 = ADC_VDD_MV * 10; // The vreg is +-2%, but we have no higher accuracy available
// 4096 * 8 readings for full scale
// Convert the input ADC reading back into mV times 10 format.
uint32_t rawInputmVX10 = (rawADC * vddRailmVX10) / (4096 * 8);
uint32_t rawInputmVX10 = (rawADC * vddRailmVX10) / (ADC_MAX_READING);
uint32_t valueuV = rawInputmVX10 * 100; // shift into uV
// Now to divide this down by the gain
@@ -90,7 +90,7 @@ uint32_t TipThermoModel::getTipInF(bool sampleNow) {
}
uint32_t TipThermoModel::getTipMaxInC() {
uint32_t maximumTipTemp = TipThermoModel::convertTipRawADCToDegC(0x7FFF - (21 * 3)); // back off approx 5 deg c from ADC max
maximumTipTemp += getHandleTemperature(0) / 10; // Add handle offset
uint32_t maximumTipTemp = TipThermoModel::convertTipRawADCToDegC(ADC_MAX_READING - (21 * 3)); // back off approx 5 deg c from ADC max
maximumTipTemp += getHandleTemperature(0) / 10; // Add handle offset
return maximumTipTemp - 1;
}