cancel
Showing results for 
Search instead for 
Did you mean: 

My ADC outputs values from 970 and above

Panagiotis
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Panagiotis
Associate III

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!

View solution in original post

10 REPLIES 10

>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

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
Guru

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".
TDK
Guru

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

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

Should I ground the "+"?

TDK
Guru

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

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

But it is returning a value around 980.

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

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?