2018-09-06 08:02 AM
Hi, Everyone.
I'm tring to make adc sensor works, to find a temperature.
I found AVG_Slope and V_25 in the datasheet:
AVG_Slope = 0.0046
V_25 = 1.46
And I used V_Ref = 3.0f and N_Bit = 4096f
This is My code (Only for adc_complete conversion)
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
if (hadc->Instance == ADC1 ){
float value;
value = ((float)adc1_buff[3]/N_BIT)*V_REF;
oil_temp = (float)(((V_25 - value)/Avg_Slope)+25);
//oil_temp = value;
//printf("Dato 1 %d, Dato 2 %d, Dato 3 %d, Dato 4 %d", adc1_buff[0], adc1_buff[1], adc1_buff[2], oil_temp);
}
else if (hadc->Instance == ADC2 ){
float val;
float result;
HAL_GPIO_TogglePin(GPIOB, LD3_Pin);
result = HAL_ADC_GetValue(&hadc2);
val = ((float)result/N_BIT)*V_REF;
ntc = (float)(((V_25-val)/Avg_Slope)+25);
}
The problem is that resoult is crazy!
I found about 300° for 3.3 V in, so, surely, I'm doing some mistakes, but I can't find it.
Someone could me help to find them?
Many thanks!
2018-09-08 07:30 AM
Hi Tj, many thanks for your reply.
So I can't use the formula on reference manual, and, later remap the scale changing the V_Ref?