Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -r1b0e869c625478905e6e96adb3084f4acbd1d1f1 -rd922241c530d7b21e5de46bda02d777f4edfe902 --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 1b0e869c625478905e6e96adb3084f4acbd1d1f1) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision d922241c530d7b21e5de46bda02d777f4edfe902) @@ -73,8 +73,6 @@ static U32 dataPublishCounter; ///< Thermistors data publish timer counter. static U32 adcReadCounter; ///< Thermistors ADC read counter. -static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE / - (F32)TWELVE_BIT_RESOLUTION; ///< Thermistors ADC to voltage conversion coefficient. static const F32 THERMISTOR_REF_TEMP_INV = 1 / THERMISTOR_REFERENCE_TEMPERATURE; ///< Thermistors reference inverse. // ********** private function prototypes ********** @@ -333,10 +331,8 @@ *************************************************************************/ static F32 calculateThermistorTemperature( THERMISTORS_TEMP_SENSORS_T thermistor, U32 adcValue ) { - // Voltage = ADC x 3 / 2^12 for 12 bits resolution and a 3V ADC - // The value of 3 / 2^12 has been calculated in a const to prevent the division again - F32 thermistorVoltage = adcValue * THERMISTOR_VOLTAGE_CONV_COEFF; - thermistorVoltage = adcValue * ( thermistorsStatus[ thermistor ].voltageReference / thermistorsStatus[ thermistor ].adcBitResolution ); + // Voltage = ADC x (voltage reference) / (ADC bit resolution) + F32 thermistorVoltage = adcValue * ( thermistorsStatus[ thermistor ].voltageReference / thermistorsStatus[ thermistor ].adcBitResolution ); // Calculate the thermistor resistor by solving: thermistorVoltage = (3 x 10) / (10 + R(T)) F32 thermistorResistor = ( ( THERMISTOR_REFERENCE_RESISTOR_AT_25 * thermistorsStatus[ thermistor ].voltageReference ) -