Skip to main content
Visitor II
Jan 31, 2024 10:41 AM UTC
Question

ADC Accuracy

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

    Andrew Neil
    Super User
    Jan 31, 2024 10:49 AM UTC

    @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

     

     

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    TDK
    Jan 31, 2024 2:22 PM UTC

    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""."