Unstable value when use analog imput on pyboard v 1.1

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.
Post Reply
letouriste001
Posts: 3
Joined: Wed Jul 20, 2016 2:38 pm

Unstable value when use analog imput on pyboard v 1.1

Post by letouriste001 » Wed Jul 20, 2016 2:50 pm

HI,

I use an analog input. I use with a bridge voltage divider

Theorical :

Vin max = 15v R1 = 68KΩ
Vout max = 2,711 R2 = 15KΩ (i use an electrodoid to get the value)

For testing:

Vin = 8,61 R1 = 67900Ω (measured with a multimeter)
R2 = 15050KΩ (measured with a multimeter)

Code used  boot.py and test.py:

######### boot.py #########
import machine
import pyb

REPL=pyb.UART(1,115200)
pyb.repl_uart(REPL)

pyb.main('test.py')


############ test.py ########
import pyb

# Turn blue LED on
blueled=pyb.LED(4)
blueled.on()

#first port test
#adc = pyb.ADC('X11')

#second port test
adc = pyb.ADC('X19')

def readADC():
print('Raw value on X19')
print(adc.read())
vout = adc.read() * (3.3 / 4096)
print('vout')
print(vout)
vin = vout * ((15050 + 67900) / 15050 )
print("vin")
print(vin)

while(1):
readADC()
pyb.delay(1000)

The analog value readed oscillate between 1877 and 2011, that’s really unstable.

When i test the code on a pyboard V 1.0, all measures are stable and exact.

Why ?
Do you have an idea ?
Does the problem come from a voltage regulator ?
Does the MCP1802 (pyboard 1.0) is better than the MCP1703 (pyboard 1.1) ?
Does the high-speed cristal clock (16Mhz) on pybord 1.1 can be the cause of the unstable measurement ?
How can i stabilise stabilize these values ?

i have reading the post http://forum.micropython.org/viewtopic. ... alog#p2321

the post don't resolve my problem

Thanks a lot.

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

Re: Unstable value when use analog imput on pyboard v 1.1

Post by pythoncoder » Thu Jul 21, 2016 6:01 am

The advice in the link you quoted is good. There is no reason why, under correct operating conditions, the Pyboard V1.1 should be worse than the V1.0 board. I can think of two reasons why you might be experiencing problems.

The most likely is if the 3.3V regulator on your board is producing an unstable voltage: if you have an oscilloscope take a look, or failing that take a series of readings with a multimeter. If the readings are unstable this may be because the input voltage is low or unstable: if you're powering the board from USB, leads and connections can be suspect. (I'm assuming you're not drawing heavy current from the 3.3V line.) One difference between the Pyboard V1.1 and the V1.0 board is that, in the V1.0 board a Schottky diode is wired between the USB 5V line and the voltage regulator, whereas the V1.1 board uses a conventional silicon diode. This will make the V1.1 board more sensitive to a low (out of spec) USB supply. Measure the V+ voltage on the board (although better to use a 'scope as there could be brief spikes causing the regulator to drop out). Or try another USB lead and PC.

The second possibility is electrical noise although this doesn't explain the difference between boards. For test purposes I'd connect an electrolytic capacitor of 47uF or bigger between the ADC input and Gnd, using short direct leads. Repeat the tests, bearing in mind that the cap will slow the response: with 47uF wait 5 seconds before taking a reading. For larger values, proportionally longer.
Peter Hinch
Index to my micropython libraries.

letouriste001
Posts: 3
Joined: Wed Jul 20, 2016 2:38 pm

Re: Unstable value when use analog imput on pyboard v 1.1

Post by letouriste001 » Wed Aug 24, 2016 9:37 am

Thank you for your answer,

I have tested my alimentation with an oscilloscope. I viewed a variation. The variation wasn’t detected with my cheap voltmeter. So, I decided to change my alimentation and the issue was almost resolved because my second alimentation have only few variations. The world isn’t perfect ^^.

I have tested to connect a capacitor : the signal stayed unstable because my source of measurement is my alimentation and it wasn’t stable.

So, have you any idea where i can buy some stabilized supplies not too expensive and rather correct ?

Thank you for all your help.

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

Re: Unstable value when use analog imput on pyboard v 1.1

Post by chrismas9 » Sun Aug 28, 2016 1:26 am

A good test would be to run the Pyboards off 3 or 4 Alkaline cells (4.5V - 6V). If the analog results are good for both boards your power supply is noisy. Pybv1.1 requires slightly higher voltage on Vin and may be more susceptible to switching spikes from a switch mode power supply. The changes to the voltage regulator and silicon diode were to improve standby and leakage current on batteries.

If your power supply is noisy you could add an LC filter. 100uH and 100uF will give about 35db reduction in noise at 100kHz. Alternatively try a 6V power supply which will give more headroom for the regulator to suppress switching spikes.

Post Reply