Page 2 of 3

Re: ADC measure negative voltage??

Posted: Thu Jun 27, 2019 12:19 am
by starter111
Thanks~ Roberthh

Re: ADC measure negative voltage??

Posted: Thu Jun 27, 2019 5:09 am
by chrismas9
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.

Re: ADC measure negative voltage??

Posted: Thu Jun 27, 2019 12:16 pm
by rcolistete
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

Re: ADC measure negative voltage??

Posted: Thu Jun 27, 2019 4:51 pm
by pythoncoder
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.

Re: ADC measure negative voltage??

Posted: Wed Jul 03, 2019 6:06 am
by starter111
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

Re: ADC measure negative voltage??

Posted: Wed Jul 03, 2019 6:12 am
by jimmo
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()
.

Re: ADC measure negative voltage??

Posted: Wed Jul 03, 2019 6:41 am
by starter111
timer.deinit() looks good.. I will try tomorrow..
Yes! I want high impedance! or isolate, set pin.in() with pin pull up to None??

Re: ADC measure negative voltage??

Posted: Wed Jul 03, 2019 6:43 am
by jimmo
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)

Re: ADC measure negative voltage??

Posted: Wed Jul 03, 2019 6:45 am
by starter111
got it! Thank you so much!!!

Re: ADC measure negative voltage??

Posted: Wed Jul 03, 2019 8:19 pm
by starter111
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