citfta
Posts: 5
Joined: Wed Feb 21, 2024 1:38 am

Dweii board ADC not working properly SOLVED

Sun Feb 25, 2024 9:53 pm

I am new to Raspberry and Pico. I have experience programming Picaxe and Arduino. I recently read about Pico and thought it might be good for a project I am working on. I found some DWEII boards on Amazon at 3 for $12 so ordered them. I have successfully installed MicroPython on 2 of them. The other one doesn't want to go into boot mode. I have been using Thonny and the Thonny guide to learn MicroPython and everything seemed to be going well until I tried to work with the ADC examples in the Thonny guide. I loaded it into the Dweii board and when I ran it the voltage values are not changing in accordance with the pot position. I have connected my digital meter to the input pin and it shows the voltage changing properly. But on the screen print the voltage mostly stays at 3.3 volts which is the high side connection of the pot. The other side is connected to ground and the wiper is connected to pin 28. When the pot wiper is about 1/3 of the way down from the 3.3 volt side my readout will show anywhere from .8 volts up to the 3.3 volts. But my digital meter is correctly showing about 2 volts. It seems like the ADC is just not working correctly. If I turn the pot on down towards the ground side the readout goes back up again to 3.3 volts. There are a couple of pads on the board that say VREF but I haven't seen anything about what they might be for. I haven't been able to find any kind of manual or other information about the board other than some of the buyers on Amazon really liked the board because it has a reset button and markings on both the top and bottom of the board.
Here is the program I am trying to run:

import machine
import utime
potentiometer = machine.ADC(28)
conversion_factor = 3.3 / (65535)
while True:
voltage = potentiometer.read_u16() * conversion_factor
print(voltage)
utime.sleep(2)

The project I am working on requires the ability to read the value of a pot so I need to figure out how to get this to work properly.
Thanks for any help anyone can give.
Carroll
Last edited by citfta on Mon Feb 26, 2024 7:06 pm, edited 1 time in total.

User avatar
neilgl
Posts: 7819
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Dweii board ADC not working properly

Sun Feb 25, 2024 10:52 pm

Can you post a link to the exact DWEII board on Amazon that you have?

citfta
Posts: 5
Joined: Wed Feb 21, 2024 1:38 am

Re: Dweii board ADC not working properly

Mon Feb 26, 2024 12:40 am

Thanks for your reply! This is what I bought.

https://www.amazon.com/gp/product/B0CG9 ... image&th=1

hippy
Posts: 16110
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Dweii board ADC not working properly

Mon Feb 26, 2024 2:31 pm

citfta wrote:
Sun Feb 25, 2024 9:53 pm
But on the screen print the voltage mostly stays at 3.3 volts
Sounds to me like the ADC is saturating, reporting a maximum reading when Vin is greater than Vref, and Vref not being connected could lead to the inconsistent behaviour seen.

Determining the ADC reading using successive approximation, as the RP2040 does, can fail when Vref changes during conversion which I expect partly explains things. There is an error bit to show when a conversion has failed but the datasheet doesn't detail how it is set and Pico SDK and MicroPython ignore that bit when reporting a result.

citfta
Posts: 5
Joined: Wed Feb 21, 2024 1:38 am

Re: Dweii board ADC not working properly

Mon Feb 26, 2024 3:16 pm

Thank you Hippy!!!

You nailed it. There were two pads on the board next to each other that were marked VREF. So I soldered the two of them together and now the ADC program correctly reads the voltage from the pot.
Do I need to mark this thread as solved like some of the other forums I belong to? And if so how do I do that?

Thanks again for the quick help.
Carroll

hippy
Posts: 16110
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Dweii board ADC not working properly

Mon Feb 26, 2024 4:11 pm

citfta wrote:
Mon Feb 26, 2024 3:16 pm
Do I need to mark this thread as solved like some of the other forums I belong to? And if so how do I do that?
You don't need to but it is often appreciated and helpful to do so. On your first post there should be a left-most 'edit' pencil icon. Click that, alter the 'subject' title at the top to include "[Solved]" or similar, click 'submit', job done.

Return to “Other RP2040 boards”