//====================================================================================
// Description: Averaging samples from ADC, calculating temperature in Celsius
//====================================================================================
float Get_Temperature(void)
{
uint8_t i;
for(i = 0; i < NS; i++)
{
Sample_ADC_Raw[i] = ADC_Raw[i];
}
Sort_values(Sample_ADC_Raw, NS);
ADC_Average = 0;
for(i = SR/2; i < NS-SR/2; i++)
{
ADC_Average += Sample_ADC_Raw[i];
}
ADC_Average /= (NS-SR);
Temp += ADC_Average;
Temp *= 3;
Temp /= 4095;
Temp -= (float)0.76;
Temp /= (float)0.0025;
Temp += (float)25.0;
Temp -= Calibration_Value;
return Temp;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.