cancel
Showing results for 
Search instead for 
Did you mean: 

How can we avoid the adc floating values(when we leave the pin(floating)

VRajk.1
Associate II

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

8 REPLIES 8
TDK
Guru

Enable the weak pulldown on that pin.

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

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

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

Danish1
Lead II

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

> 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

TJack.2
Associate III

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.

TDK
Guru

Upon further inspection, the reference manual explicitly doesn't support the pull resistors in analog mode.

0693W00000BaoO4QAJ.png 

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.

0693W00000BaoO9QAJ.png

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

> 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