ADC measure negative voltage??

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

Re: ADC measure negative voltage??

Post by starter111 » Thu Jun 27, 2019 12:19 am

Thanks~ Roberthh

chrismas9
Posts: 152
Joined: Wed Jun 25, 2014 10:07 am

Re: ADC measure negative voltage??

Post by chrismas9 » Thu Jun 27, 2019 5:09 am

On Pyboard Aref is derived from the main 3V3 regulator. If you want really good absolute accuracy connect a reference to another ADC input and scale your reading with the reference reading. Taking a large number or readings and averaging them will help. 4 readings should give about one more bit, 16 readings about two more bits noise free.

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: ADC measure negative voltage??

Post by rcolistete » Thu Jun 27, 2019 12:16 pm

chrismas9 wrote:
Thu Jun 27, 2019 5:09 am
Taking a large number or readings and averaging them will help. 4 readings should give about one more bit, 16 readings about two more bits noise free.
It is called ADC oversampling. Some tutorials/references :
IMPROVING ADC RESOLUTION BY OVERSAMPLING AND AVERAGING
AVR121: Enhancing ADC resolution by oversampling
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: ADC measure negative voltage??

Post by pythoncoder » Thu Jun 27, 2019 4:51 pm

Note that oversampling improves resolution rather than accuracy. It would be interesting to characterise the Pyboard ADC's to see if they have the Gaussian noise distribution required for this technique to work.
Peter Hinch
Index to my micropython libraries.

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

Re: ADC measure negative voltage??

Post by starter111 » Wed Jul 03, 2019 6:06 am

Thank you so much for your reply!
I have two more questions.

1. how do I isolate/turn off pins after use them? Let say I do
p0 = Pin(0, Pin.OUT)
p0.value(0)
how do I turn p0 off? is it Pin.off() ? What is the meaning off "Set pin to “0” output level." Is it mean isolate from outside??
https://docs.micropython.org/en/latest/ ... e.Pin.html

2. I'm using Dave Hylands frequency counter code, it works great! is very accurate! Same question, how do I turn the timer and pin off after I use it??
viewtopic.php?t=3370

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ADC measure negative voltage??

Post by jimmo » Wed Jul 03, 2019 6:12 am

starter111 wrote:
Wed Jul 03, 2019 6:06 am
1. how do I isolate/turn off pins after use them? Let say I do
p0 = Pin(0, Pin.OUT)
p0.value(0)
how do I turn p0 off? is it Pin.off() ? What is the meaning off "Set pin to “0” output level." Is it mean isolate from outside??
https://docs.micropython.org/en/latest/ ... e.Pin.html
It depends what you mean by "off".

Code: Select all

p0.value(0)
is the same as

Code: Select all

p0.off()
- it means that the pin is internally connected to ground (i.e. current will flow into it).

I think what you might want is to make the pin float -- i.e. it looks like it's physically disconnected from the inside of the chip. This is called "high impedance" (or "hi-z") mode. The easiest way to do this is to set the pin to input mode.
starter111 wrote:
Wed Jul 03, 2019 6:06 am
2. I'm using Dave Hylands frequency counter code, it works great! is very accurate! Same question, how do I turn the timer and pin off after I use it??
viewtopic.php?t=3370
See above about the pin, and you can use

Code: Select all

timer.deinit()
.

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

Re: ADC measure negative voltage??

Post by starter111 » Wed Jul 03, 2019 6:41 am

timer.deinit() looks good.. I will try tomorrow..
Yes! I want high impedance! or isolate, set pin.in() with pin pull up to None??

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ADC measure negative voltage??

Post by jimmo » Wed Jul 03, 2019 6:43 am

starter111 wrote:
Wed Jul 03, 2019 6:41 am
Yes! I want high impedance! or isolate, set pin.in() with pin pull up to None??

Code: Select all

p0.init(mode=Pin.IN, pull=None)

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

Re: ADC measure negative voltage??

Post by starter111 » Wed Jul 03, 2019 6:45 am

got it! Thank you so much!!!

starter111
Posts: 40
Joined: Wed Mar 08, 2017 7:24 am

Re: ADC measure negative voltage??

Post by starter111 » Wed Jul 03, 2019 8:19 pm

more questions....

adc = ADC(Pin('X19'))
adc.read() # read value, 0-4095

How to turn off adc ?? I try dir(adc) it give me this.. "['__class__', 'read', 'read_timed', 'read_timed_multi']", looks like no way to do so?
https://test-ergun.readthedocs.io/en/la ... b.ADC.html

Post Reply