2020-04-06 07:36 AM
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.
Solved! Go to Solution.
2020-04-07 02:54 AM
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!
2020-04-06 08:48 AM
>when nothing is connected to the input
Why do you think the ADC input must be grounded when nothing is connected?
JW
2020-04-06 08:55 AM
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?
2020-04-06 10:58 AM
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.
2020-04-06 11:00 AM
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.
2020-04-06 11:04 AM
What do you meean by 'If "+" is floating, then yes it should be grounded'.
Should I ground the "+"?
2020-04-06 11:08 AM
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.
2020-04-06 11:17 AM
When the voltmeter 's input isn't connected to anything, the ADC pin has 0V.
But it is returning a value around 980.
2020-04-06 01:04 PM
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
2020-04-06 01:15 PM
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?