2024-01-31 02:41 AM
Dear ST Community,
I am currently working with the STM32L433RC board, specifically utilizing its 12-bit ADC. Despite my efforts in writing a simple program, I have encountered accuracy issues with errors exceeding 4.5%, and in some instances, even surpassing 30%.
Code :-
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
adc_value = HAL_ADC_GetValue(&hadc1);
float vin = adc_value * (3.3/4095);
sprintf(msg2,"vol = %.3f \r\n",vin);
HAL_UART_Transmit(&huart2, (uint8_t *)msg2, strlen(msg2), HAL_MAX_DELAY);
HAL_Delay(1000);
I am also attaching excel sheet to see the difference between Vin and Vout.
2024-01-31 02:49 AM
@Nitin24 wrote:I have encountered accuracy issues with errors exceeding 4.5%, and in some instances, even surpassing 30%.
How, exactly, do you measure that?
Use this button to properly post source code:
To get that extra row of icons, press this button:
2024-01-31 06:22 AM
Note that the ADC must be calibrated before it can be used, on every startup.
Note that sampling time tends to be the most important factor--larger sampling times will lead to more accurate values.
See here for general ways to improve accuracy: