2021-06-02 03:52 AM
Hai,
I am working on the stm32f070c6 , I was configure the adc but it shows some floating values(when I leave the pin as floating) ) and it shows adc values approximately half of the reference voltage around 1.5V to 1.7V(here my reference voltage 3.3V). how can I avoid the floating values when I'm not connecting the any analog sensor, I want to make it as zero when I'm not connect any sensor(in floating state), I just tried with connecting a decoupling capacitor with my adc channel. it shows zero but the values gradually increases when I taking the continuous reading on the channel, how can I make the adc value as zero when I didn't connect(floating state). if anyone have idea please give a suggestion.
Thanks and Regards
Raj
2021-06-02 06:15 AM
Enable the weak pulldown on that pin.
2021-06-11 10:55 PM
Thanks for your reply @TDK is it in hardware or software , if it is in software, how can enable the weak pulldown on that pin . for that what should I do , I am checking with the gpio in the stm cube mx there is a option for gpios to pullup or pulldown, for adc pins there is no option , can you please tell me in detail
2021-06-11 11:36 PM
Not everything can be clicked on Cube. Read the GPIO chapter in RM.
Note, that not all pins allow to switch on the internal pulldown in Analog mode, this depends on pin structure and STM32 model. You can always use an external pull-down.
This all of course means that your signal will be loaded by that pull-down, so you have to consider is impact on the signal.
JW
2021-06-12 01:36 AM
If you leave the pin unconnected to anything, then what is real is the floating value, which drifts around.
Digital multimeters typically have a 10 Megohm resistance between their input pins so they read zero when nothing is connected.
Some of them also have a special "high impedance millivolt" range where they do not have that resistance, and then you will see the input drifting around unless something external is connected that sets the voltage.
Many stm32 don't allow you to have the built-in pull-down enabled at the same time as the input is configured for analog input.
As JW said, you could add your own external pull-down. You get to choose the value so it does not excessively load your analog source, but does get the value sufficiently close to zero. If you find that it doesn't stay close to zero with a value of (say) 1 MegOhm, try also adding (say) 100 pF in parallel. It's all a compromise.
Hope this helps,
Danish
2021-06-12 03:18 AM
> If you leave the pin unconnected to anything, then what is real is the floating value, which drifts around.
The ADC input is not a plain high impedance. Every time you perform a conversion, the sampling capacitor probably charged to half of VREF+ (and possibly discharged if there are delays between conversions) is connected to the input pin for the duration of set sampling period.
JW
2021-06-12 05:20 AM
Personally my solution to this problem was to build all my analogue sensors with a current output (±1.5mA), and bias the analogue inputs to a (low noise) common reference voltage through a 1k resistor. Then any unconnected (or disabled) sensor just reads at the reference voltage. That also allows me to have bipolar signals with a well-defined zero point, and to multiplex many sensors to a single analogue input pin by fitting each with a simple analog switch. Software calibrates the reference zero value by simply switching all sensors off. For DC amplifier drift correction, extending the switch to a cross-point network allows the input to be read in each direction, and differenced in software, effectively making a chopper-stabilised amplifier.
2021-06-12 06:04 AM
Upon further inspection, the reference manual explicitly doesn't support the pull resistors in analog mode.
From the port structure, it seems like they would be able to be activated. I didn't try it. It may or may not work, but CubeMX seems right here not to allow you the option based on the reference manual.
2021-06-12 02:02 PM
> Upon further inspection, the reference manual explicitly doesn't support the pull resistors in analog mode.
I did not remember this correctly: it's the other way round - with TTa pins, in 'F0, the ADC is connected even in non-Analog modes.
https://community.st.com/s/question/0D50X00009XkaBB/stm32f0xx-findings
I don't recommend this mode of operation to be used for ADC, though.
JW