cancel
Showing results for 
Search instead for 
Did you mean: 

ADC conversion error of more than 20%

Yves Bmnt
Associate III

Hello,

I'm having problems with the adc conversions on my STM32G491.

There is an error of 23-26% higher than measured with scope or multimeter.

I'm using ADC1 & 2 in dual mode with DMA, I have an input signal coming from an opamp voltage follower.

I'll attach the adc file, the signal I used to compare ADC1 & 2 results is DETECT_PAM.

Kind regards,

Yves

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

Not clear .. Could you please provide the reading section of the ADC and how to convert the digital value to the voltage value?

The voltage result needs to be = (Digital reading x Vref)/Digital full scale.

For more details about how to optimize the ADC accuracy, you can refer to the AN2834 "How to optimize the ADC accuracy in the STM32 MCUs"

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

8 REPLIES 8
Yves Bmnt
Associate III

Something I don't understand, maybe because I didn't write the code here, and the person who did is not available, the ADC conversion callback already gives a voltage in mV, not a digital value that I have to convert, and I can't find the calculation factors anywhere. Is that usual with stm32?

Hello,

Not clear .. Could you please provide the reading section of the ADC and how to convert the digital value to the voltage value?

The voltage result needs to be = (Digital reading x Vref)/Digital full scale.

For more details about how to optimize the ADC accuracy, you can refer to the AN2834 "How to optimize the ADC accuracy in the STM32 MCUs"

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hello,

"The voltage result needs to be = (Digital reading x Vref)/Digital full scale" -> yes, this is what is usually done

"Could you please provide the reading section of the ADC and how to convert the digital value to the voltage value?" -> this is what I cannot find out:

In the attached file, you can find call for HAL_ADCEx_MultiModeStart_DMA and definition of the HAL_ADC_ConvCpltCallback.

The mAdcChannelResult[] array is where the DMA is asked to store the results for the conversions, and this value is directly sent by the callback. This value appears to be already in milliVolts, but with an error of close to +25% of the value measured with external instrument.

rtl
Associate II

Have you tried HAL_ADCEx_Calibration_Start() at the end of init functions?

HAL_ADCEx_Calibration_Start() is called for each ADC in the init function (of SEQ_SequencerController.c file attached above)

Yves Bmnt
Associate III

OK, I found out the conversion formula is simply missing from this code, if I add it then everything is perfectly fine :grinning_face_with_sweat::beaming_face_with_smiling_eyes:

Thank you for the support

Could you please share the solution? what was the formula?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Yves Bmnt
Associate III

There was simply no conversion formula and the raw ADC value was used for calculations instead of the actual voltage. So I added the usual conversion formula -> ADC value * Vref / Max ADC value