unstable values when I use analog inputs
unstable values when I use analog inputs
Hi,
I use an analog inputs, for example a potentiometer, with ADC() class, but every time I get unstable values.
How can I stabilise these values?
Thanks a lot
I use an analog inputs, for example a potentiometer, with ADC() class, but every time I get unstable values.
How can I stabilise these values?
Thanks a lot
Re: unstable values when I use analog inputs
By unstable, how much variation are you seeing?
What value of potentiometer are you using?
And how is it wired up? The ADC inputs are 3.3v.
I moved this to the General topic, since that's where it belongs.
What value of potentiometer are you using?
And how is it wired up? The ADC inputs are 3.3v.
I moved this to the General topic, since that's where it belongs.
Re: unstable values when I use analog inputs
Hi,
thanks to your answer,
By unstable, how much variation are you seeing?
For example, at the min value I read 4,0,4,0,23,1,5... and so on, and at the max value: 4081,4093,4075,4095...
What value of potentiometer are you using?
I tried with 10K, 50K, 100K linear potentiometer.
And how is it wired up? The ADC inputs are 3.3v.
I connected the two ends to 3.3v and GND on the pyboard, central to the ADC pin, for example (X1).
I hope which I can solve this issue
Thanks in advance
thanks to your answer,
By unstable, how much variation are you seeing?
For example, at the min value I read 4,0,4,0,23,1,5... and so on, and at the max value: 4081,4093,4075,4095...
What value of potentiometer are you using?
I tried with 10K, 50K, 100K linear potentiometer.
And how is it wired up? The ADC inputs are 3.3v.
I connected the two ends to 3.3v and GND on the pyboard, central to the ADC pin, for example (X1).
I hope which I can solve this issue
Thanks in advance
Re: unstable values when I use analog inputs
And finally, can you post your code which demonstrates the problem (just to eliminate any issues on that front).
It would also be good to be explicit about which pins you're connecting your inputs up to as well.
Are you using the 3.3v from the pyboard? Or from an external source? Or the Analog 3.3v?
Are you using the ground from the pyboard? Or the Analog Ground?
The A3V3 signal corresponds to X23
The AGND signal corresponds to X24
See: http://docs.micropython.org/en/latest/quickref.html
It would also be good to be explicit about which pins you're connecting your inputs up to as well.
Are you using the 3.3v from the pyboard? Or from an external source? Or the Analog 3.3v?
Are you using the ground from the pyboard? Or the Analog Ground?
The A3V3 signal corresponds to X23
The AGND signal corresponds to X24
See: http://docs.micropython.org/en/latest/quickref.html
Re: unstable values when I use analog inputs
Thanks for your patience.
I tried with pin X1, and I used 3.3v from the pyboard and I used GND from the pyboard.
With this simple code (into the REPL prompt):
And then I tried with all possibilities, I wired the pot with A3V3, AGND and X1 (on the centre of the pot) but the unstable values persists.
I tried with pin X1, and I used 3.3v from the pyboard and I used GND from the pyboard.
With this simple code (into the REPL prompt):
Code: Select all
pot = pyb.ADC('X1')
while True:
pot.read()
pyb.delay(1000)
Re: unstable values when I use analog inputs
I tried this program:
and I see something like this:
Those fluctuations are probably just due to noise on the 3.3v line.
Code: Select all
import pyb
pot = pyb.ADC('X1')
while True:
x = pot.read()
print(x)
pyb.delay(1000)
Code: Select all
837
834
836
833
836
836
837
837
838
836
837
836
837
837
836
837
Re: unstable values when I use analog inputs
It sounds a faulty pot.
Tiny Core Linux (piCore) developer
HAM radio call: HA5DI (Béla)
HAM radio call: HA5DI (Béla)
Re: unstable values when I use analog inputs
Hi all,
I don't understand, but this is a common behaviour? because I saw that you have the same issue with the ADC().
P.S.: I tried with many potentiometers but I get the same behaviour
Thanks a lot
Domenico
I don't understand, but this is a common behaviour? because I saw that you have the same issue with the ADC().
And my final question is: how would you solve this problem?Those fluctuations are probably just due to noise on the 3.3v line.
P.S.: I tried with many potentiometers but I get the same behaviour
Thanks a lot
Domenico
Re: unstable values when I use analog inputs
The range of values shown by @dhylands (~4 out of 4096 possible values) corresponds to a variation of ~0.1%, which really isn't bad for a board that wasn't specifically designed for precision analog data acquisition. That isn't intended as a criticism against the design of the pyboard; the pyboard was designed to pack a lot of general-purpose functionality into a compact and inexpensive package, and in this it succeeded quite well. However, compromises need to be made in any design, and high-precision analog performance really couldn't be within the scope of the pyboard without adding both size and cost to the board.
Your data does show greater variation than Dave's, so it should be possible to improve your precision a bit.
Proper shielding and separation in this case could mean a four-layer board, split ground and supply planes with carefully planned connections between digital and analog domains, separate voltage regulation for the digital and analog domains, shield traces on the signal layers, more and larger bypass capacitors, etc. I could go on; I once made a fairly high-precision USB-powered data acquisition instrument, but as I have implied, it didn't look much like a pyboard and would have been a bit more expensive to manufacture.
-Bryan
Your data does show greater variation than Dave's, so it should be possible to improve your precision a bit.
- Connecting the pot across A3V3 and AGND is a good start; remember to keep your leads short! If they can't be kept short, then twisting the wires together can help to reduce EMF pickup.
- You could also put an additional capacitor on the pot terminals which are connected to the analog supply; ~10uF should suffice.
- A small capacitor (~10nF, depends on your pot resistance and desired sampling rate) between the ADC pin and AGND will serve as a low-pass filter, reducing high-frequency noise.
- Oversampling: take several readings and average them together. If I am doing this at a low level (say on an 8-bit PIC) then I would take 2^N readings, add them together, and bit shift the answer N-bits to the right; although in micropython such an optimization would be kind of pointless.
Proper shielding and separation in this case could mean a four-layer board, split ground and supply planes with carefully planned connections between digital and analog domains, separate voltage regulation for the digital and analog domains, shield traces on the signal layers, more and larger bypass capacitors, etc. I could go on; I once made a fairly high-precision USB-powered data acquisition instrument, but as I have implied, it didn't look much like a pyboard and would have been a bit more expensive to manufacture.
-Bryan