cancel
Showing results for 
Search instead for 
Did you mean: 

Why ADC isn't correct?

Jpark.22
Associate

I'm trying to use ADC in stm32g030j6m6 to measure DC voltage.

but, whenever I try to make experiences. I found out that under 3V, The accuracy of adc isn't great. It has a 10% error.

I attached source code that I used in my experience and the table that I get from a experience.

please answer me, which part I have to change or fix to get a accurate ADC values

6 REPLIES 6
Ozone
Lead

> but, whenever I try to make experiences. I found out that under 3V, The accuracy of adc isn't great. It has a 10% error.

How did you evaluate this ?

With inappropriate hardware, you can easily introduce such large errors.

Or with too short sample times.

I used DC source power to measure the ADC, and The Large errors only occurs when the voltage is under around 2V.

The source code was written referring to the example provided in stm32CubeIDE.

so I used the sampling times exactly same compare to example code.

If you can see the source code that I attached, maybe I think you can find which line is wrong.

could you do it for me?

Mike_ST
ST Employee

Hello,

From what I can see, you are using the F0 HAL library for a G0 MCU.

I don't do Cube/Hal.

However, Mike_ST's objection of using the wrong package is probably valid.

Other things in the source that stood out:

A sample time of 5 cycles (ADC_SAMPLETIME_1CYCLE_5) is very short. Do you understand the working principle of a SAR-ADC ?

Better try with a 3-digits sample time.

The G030 is basically a M0/M0+ core, I would avoid floating point if not absolutely necessary.

It's even worse - not 5 but 1,5 cycles. 🙂

Well, ok. Didn't know it does actually go so low.

Cycle-by-cycle control (motor, converter) at 1Msps or more use to ask for that.