Skip to main content
Panagiotis
Associate III
April 6, 2020
Solved

My ADC outputs values from 970 and above

  • April 6, 2020
  • 7 replies
  • 2232 views

I 'm making a voltmeter - amp meter, this one...

I 'm using an STM32F030K6T6.

But when nothing is connected to the input, instead of outputing 0, the ADC gives me a value around 980.

VDDA is tied to VDD.

Boot0 is tied to GND.

These are the ADC 's settings:

ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
Resolution = ADC_RESOLUTION_12B;
DataAlign = ADC_DATAALIGN_RIGHT;
ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
EOCSelection = ADC_EOC_SINGLE_CONV;
LowPowerAutoWait = DISABLE;
LowPowerAutoPowerOff = DISABLE;
ContinuousConvMode = DISABLE;
DiscontinuousConvMode = DISABLE;
ExternalTrigConv = ADC_SOFTWARE_START;
ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
DMAContinuousRequests = DISABLE;
Overrun = ADC_OVR_DATA_PRESERVED;

What have I done wrong?

Any help is welcome.

This topic has been closed for replies.
Best answer by Panagiotis

Analog->ADC->Configuration->Parameter settings->ADC_Regular_ConverstionMode>-Sampling Time.

I changed it's value from 1.5 cycles to 239.5 cycles and works fine!!

It was so simple!

7 replies

waclawek.jan
Super User
April 6, 2020

>when nothing is connected to the input

Why do you think the ADC input must be grounded when nothing is connected?

JW

Panagiotis
Associate III
April 6, 2020

If you look in the schematic (the link I put in my post), the ADC input is connected to a Voltage divider (formed by R2 & R3).

R3 is connected to GND. So the ADC input is grounded via R3.

Maybe I should use, for the voltage divider, low values? (now I have 100k & 18k)

Maybe something like 1k & 180Ω would be better?

TDK
April 6, 2020

If "+" is floating, then yes it should be grounded. Make sure your sample time is high enough. Use a voltmeter and verify the input to the ADC is 0V.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Panagiotis
Associate III
April 6, 2020

What do you meean by 'If "+" is floating, then yes it should be grounded'.

Should I ground the "+"?

TDK
April 6, 2020

Using lower resistor values will cause a high impedance input to be drowned out by the effect from the effective (1k + 180) pulldown. Not ideal for a voltmeter.

"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
April 6, 2020

The schematic uses "+" to denote the voltmeter input.

I'll rewrite what I meant:

If the voltmeter input isn't connected to anything, then the ADC pin input should be 0V and it should be returning very close to 0 counts.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Panagiotis
Associate III
April 6, 2020

When the voltmeter 's input isn't connected to anything, the ADC pin has 0V.

But it is returning a value around 980.

waclawek.jan
Super User
April 6, 2020

Try to short the input hard to GND.

Still 980?

Make sure sampling time is adequate to input impedance. Make sure you preform ADC calibration before using it, according to RM.

JW

Panagiotis
Associate III
April 6, 2020

I shorted it to GND, still 980.

How can I do what you 're suggesting? (sampling time is adequate to input impedance)

And how can I calibrate the ADC?

What is RM?

Panagiotis
PanagiotisAuthorBest answer
Associate III
April 7, 2020

Analog->ADC->Configuration->Parameter settings->ADC_Regular_ConverstionMode>-Sampling Time.

I changed it's value from 1.5 cycles to 239.5 cycles and works fine!!

It was so simple!