Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Output analog voltages unstable when analog input assigned
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Output analog voltages unstable when analog input assigned

by RumiTheIsotope on Sun Mar 08, 2020 11:07 pm

Hello,

I am running a Metro M4 with CircuitPython 5: Adafruit CircuitPython 5.0.0 on 2020-03-02; Adafruit Metro M4 Express with samd51j19

All I want to do is assign output voltages to A0 and read input voltages on A1. However, if I assign each pin as such and try to set an output voltage on A0, the voltage will quickly decay away towards zero. There is no load - I only have a voltmeter set up to read the voltage on the pin. There is nothing else connected to the board. It's a new board and has not been abused. I have 3.3v on the IOREF pin, though I have nothing connected to it.

If I only assign an output pin, the voltages are stable. But as soon as I additionally define an input pin, the output voltages decay away towards zero - even if none of the pins are hooked up to anything.

Here's a simple example: If I run the code below, I can step through voltage increases by hitting enter for each step and they will remain stable. However, if I uncomment that one line that defines analog_in, the voltages will not remain stable but instead will decay away. Within a few seconds, I have zero volts on A0 no matter what voltage I try to set it at.

Code: Select all | TOGGLE FULL SIZE
import board
from analogio import AnalogIn, AnalogOut

#analog_in = AnalogIn(board.A1)
analog_out = AnalogOut(board.A0)

while True:
    for i in range(1,65000,100):
        analog_out.value = i
        print(i)
        input("hit enter")


The other thing that happens when it has this decaying-voltage-behavior is that the DAC seems to max out its voltage of 3.3v around 4000 instead of 65000.

I can't figure out what I am doing wrong or maybe I have a faulty board. I'm considering putting CircuitPython 4 on it and trying that. But I thought I would ask here first. Thanks for any ideas.

RumiTheIsotope
 
Posts: 21
Joined: Mon Jan 13, 2020 7:59 pm

Re: Output analog voltages unstable when analog input assign

by RumiTheIsotope on Sun Mar 08, 2020 11:39 pm

Update: I have realized that I do not need to use pin A1 for input and instead have switched to A2. This problem goes away when using the other analog inputs. So for me, my problem appears to be solved by using a different pin. Thanks.

RumiTheIsotope
 
Posts: 21
Joined: Mon Jan 13, 2020 7:59 pm

Please be positive and constructive with your questions and comments.