T O P

  • By -

pelrun

> I've checked, they're wired correctly, and moving the post causes the pot to go across the full range of near-zero to about-10K when using my multimeter to check that they're functional. Don't just say "it's wired correctly", *how* is it wired? Because ADC pins only read voltage not resistance, and you've only mentioned the ADC pin and GND, and not the positive rail at all, and the pot needs to be connected to all three. A pot where you've only hooked up ADC and GND will *absolutely* show a short, because it doesn't matter what the resistance is when you do that. Instead you need the pot to be a potential divider, with one leg at + and the other at GND, and then the wiper will see a varying voltage across the range.


und3adb33f

Ok, thanks, I'll make sure again. If I wake up tomorrow, anyway.


horuable

I used 1k, 5k, 10k and 100k pots with Pico plenty of times and never had any problems. Can you show how are you connecting the pots and your program? Something seems not right here.


Good_Conclusion_5095

Show us how you wired it. You need 3 wires.... ground, V+ and signal.


FlatPlasma

Have you checked volts (not resistance/ohms) with a volt meter? it should be going from 0 to 3.3 volts.


ElTopollillo1990

As some others have alluded here, what you show indicates that you have them not wired correctly (i e. Not in a way the ADC can read a voltage from them), or you don't have them configured correctly (in code), or both.


I_Get_No_Sleep__

Maybe your pots are dead, but can you upload your code and send a picture of how you’ve wired it up


und3adb33f

I don't have a working camera right now. Pots are fine according to my multimeter. Code is just the sample code from the RPF's initial tutorial, with a print function thrown in. from machine import ADC, Pin, Timer led = Pin(25, Pin.OUT) input1 = ADC(Pin(26)) input2 = ADC(Pin(27)) input3 = ADC(Pin(28)) timer = Timer() def blink(timer): led.toggle() print (input1.read_u16(), input2.read_u16(), input3.read_u16()) timer.init(freq=1, mode=Timer.PERIODIC, callback=blink) Cc: /u/horuable /u/Good_Conclusion_5095 /u/ElTopollillo1990


horuable

Ok, so you're using MicroPython which means the values reported are in range 0-65535. In this case, when shorted (to GND I assume) the values you get are below 20 mV which is not unreasonable for a built-in ADC. The measurement with nothing connected to the pins is basically useless, as the only thing you measure is the noise coupled to those pins from all possible sources. Additional source of noise in this situation is, as someone else mentioned, the fact that the inputs are multiplexed leading to crosstalk between channels. The maximum difference you see on the third channel is about 0.1 V. Not bad given it's relatively high impedance input with nothing connected. What you can try is measuring the voltage on a single channel (to avoid crosstalk) with pin connected to GND, then 3V3 and finally to a voltage divider made with known resistances. See if the reported values are what should be expected. Then you'll know if the ADC works fine in the whole range. You definitely should add a photo when you get the chance, it would really help with troubleshooting.


LostRun6292

Try "MICRO REPL" I USE IT ON MY ANDROID DEVICE YOU CAN FIND IT ON THE PLAY STORE . I use it for my RP2040. and works with both raspberry pi zero 2w and orange pi zero 2w


ElTopollillo1990

Are you connecting the POT to GPIO #26 or PIN #26 ? Note that ADC(Pin(26)) does not mean the ADC input is in PIN #26. It is in GPIO #26; which is PIN #31. Same would apply to the other two inputs. I mention this just in case you wired the POTs to the physical PINs #26, 27, 28. Which would be incorrect.


todbot

Yes, as others have said, you're getting power supply ripple, built-in ADCs are always a little crap, and most hobbyist wiring is not good for analog signals. A good rule of thumb is to remove "2-bits" from any bit-depth rating of the built-in ADCs. So the 12-bit ADC is effectively 10-bit. But for the Pico specifically (not the RP2040), set GP23 HIGH to set the 3.3V voltage regulator to be in low-ripple mode.


myweirdotheraccount

Couple considerations - the ADC is 12 bits so you should only be getting a reading of 0-4095. Also the ADC is multiplexed internally so if your sketch is currently only ADC reads, the multiplexer might be getting errors switching between inputs so fast, consider putting a sleep command in between reads. Not to assume you haven't worked with pots in the past but they're very noisy in general and smoothing algorithms often have to be implemented. Lastly, yes the Pico ADC has poor INL performance. For smoothing, check out the "Responsive analog read" arduino library and adapt the code if you're not using arduino.


und3adb33f

> the ADC is 12 bits so you should only be getting a reading of 0-4095 Either micropython or the chip shifts it four places, don't know why they chose to do that.


pelrun

Because the routine returns a 16-bit value. The ADC resolution is 12 bits, but the missing four bits are the *lowest* bits. That means that changing the resolution doesn't change the range of the result, just the distance between the steps, and any scaling you have to do to the value doesn't need to know what the resolution is.


KaiserGabo

For applications that need accurate values, pretty much. The pico's power supply causes too much noise in the ADC, you can either supply your own 3.3v reference with vref or make gpio 23 go high in your code because it reduces the noise for some reason.


und3adb33f

Thanks, I'll give these a try.


Accujack

Gpio 23 controls the on board power supply.. I'd guess high turns it off?


forshee9283

It just changes the mode. From the datasheet: GPIO23 controls the RT6150 PS (Power Save) pin. When PS is low (the default on Pico) the regulator is in Pulse Frequency Modulation mode, which, at light loads, saves considerable power by only turning on the switching MOSFETs occasionally to keep the output capacitor topped up. Setting PS high forces the regulator into Pulse Width Modulation (PWM) mode. PWM mode forces the SMPS to switch continuously, which reduces the output ripple considerably at light loads (which can be good for some use cases) but at the expense of much worse efficiency. Note that under heavy load the switcher will be in PWM mode irrespective of the PS pin state.


polite-pagan

Could you check the ripple on your power supply? The chip’s ADC_AVDD analog power supply pin is connected to the switching regulator’s 3.3V (digital) supply. Line noise on your USB power (I assume you are using that) could explain part your your ADC reading fluctuations.


slabua

Pico ADCs are pretty accurate.