cancel
Showing results for 
Search instead for 
Did you mean: 

ADC error in reading voltage

MCivo
Associate

Hi everyone,

I'm having troubles with the internal ADC (STM32F072CBTX): a significant offset is present in the values provided by the converter. I performed a set of test measurments on the ADC: the results are shown in Table1.jpg.

Where:

  • Vmis is the voltage measured with a voltage meter at the ADC input pin (voltage drop on a resistor, in a voltage divider).
  • ADC is the value produced by the converter.
  • Vcalc is the correspondent voltage value with 12 bits resolution: Vcalc = Vmis * ADC / 4096
  • Err = Vmis - Vcalc

The values reported in the table of which above have been obtained with the following conditions:

  • VDDA = 3.3V
  • VSSA = 0V
  • No autocalibration

I tried autocalibration as well, by calling HAL_ADCEx_Calibration_Start before starting conversions: strangely, with autocalibration, things get even worse, as shown in Table2.jpg.

Does anyone have any idea on what is going on?

Am I doing something wrong?

Any help is appreciated.

Thanks.

Marco

1 ACCEPTED SOLUTION

Accepted Solutions
AvaTar
Lead

What about the code, especially the sampling time you are setting ?

If this time is short (too short), and you have a high input impedance, conversion results will apear too low.

It is useful to understand the basics of an SAR - ADC to configure it properly.

View solution in original post

2 REPLIES 2
AvaTar
Lead

What about the code, especially the sampling time you are setting ?

If this time is short (too short), and you have a high input impedance, conversion results will apear too low.

It is useful to understand the basics of an SAR - ADC to configure it properly.

MCivo
Associate

Dear Frank,

you are right: it was my fault. Basically I forgot to set up the ADC parameters in Cube.

I was sampling with 12 bits resolution with a sampling time of 1.5 cycles, which is the default value. Obviously, 1.5 cycles is way too short for the SAR, as at least 12.5 cycles are requested with 12 bits, according with STM.

Since I don't have strict constraints in terms of sampling time, I set up the period at 28.5 cycles: now the precision is more than acceptable, and as expected, with autocalibration, the ADC gives its best.

Thanks for your help.

Regards.

Marco