Skip to main content
Visitor II
January 31, 2024
Question

ADC Accuracy

  • January 31, 2024
  • 2 replies
  • 1528 views

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.

    This topic has been closed for replies.

    2 replies

    Super User
    January 31, 2024

    @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

     

     

    Super User
    January 31, 2024

    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