Created
March 21, 2013 22:04
-
-
Save 3Nigma/5217218 to your computer and use it in GitHub Desktop.
[eAh-AVR1934] Implementare originală a funcției de citire a temperaturii pentru aplicația demo a plăcuței XMEGA-A3BU (versiunea defectă și incompletă)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* \brief Read the actual temperature from the NTC | |
* | |
* This function returns the temperature in Celsius by piecewise linearisation | |
* of the complex transfer function between NTC resistance and ADC codes. The | |
* accuracy of the temperature is somewhat limited. | |
* | |
* \note The result is inaccurate for temperatures outside 5-45 degrees. | |
* | |
* \retval the temperature in Celsius | |
*/ | |
int8_t ntc_get_temperature(void) | |
{ | |
int8_t retval = 0; | |
float ntc_sample = ntc_sensor_sample; | |
if (ntc_sensor_sample > 697) { | |
retval = (int8_t)((-0.0295 * ntc_sample) + 40.5); | |
} if (ntc_sensor_sample > 420) { | |
retval = (int8_t)((-0.0474 * ntc_sample) + 53.3); | |
} else { | |
retval = (int8_t)((-0.0777 * ntc_sample) + 65.1); | |
} | |
return retval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment