cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Accuracy

Nitin24
Associate

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.

2 REPLIES 2
Andrew Neil
Evangelist III

@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:

AndrewNeil_0-1706698166984.png

 

To get that extra row of icons, press this button:

AndrewNeil_1-1706698166987.png

 

 

TDK
Guru

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:

https://www.st.com/resource/en/application_note/an2834-how-to-optimize-the-adc-accuracy-in-the-stm32-mcus-stmicroelectronics.pdf

If you feel a post has answered your question, please click "Accept as Solution".