Skip to main content
Jpark.22
Associate
January 20, 2020
Question

Why ADC isn't correct?

  • January 20, 2020
  • 6 replies
  • 1598 views

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

This topic has been closed for replies.

6 replies

Ozone
Principal
January 20, 2020

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

Jpark.22
Jpark.22Author
Associate
January 20, 2020

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?

​

Ozone
Principal
January 20, 2020

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.

Mike_ST
ST Technical Moderator
January 20, 2020

Hello,

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.