ADC FiPy difficulty



  • I'm having difficulty getting meaningful ADC values with my FiPy and Expansion board 3. I have a 10k pot connected to ground and 3.3v. The wiper I have tried connecting to many different ADC pins such as P12, P,13, P14, P17, P16.

    The values are pretty static regardless of what the position of the wiper is. Even if I short the input pin directly to the 3.3v there seems to be no change. Here's what I'm using:

    from machine import ADC
    adc = ADC(0)
    adc_c = adc.channel(pin='P13', attn=ADC.ATTN_11DB)
    print(adc_c.voltage())
    
    

    Am I doing something silly here?

    The expansion board firmware(3.1) is up to date. I haven't looked into upgrading the FiPy yet.



  • Thanks, I didn't realize the pinout on the expansion board was different from the FiPy. PRINT TOO SMALL :-P



  • @peter_ I Cannot confirm your observation. I extended your little test code as follows (no pot), with a connection between P22 and P13:

    from machine import ADC, DAC
    from time import sleep
    adc = ADC(0)
    adc_c = adc.channel(pin='P13', attn=ADC.ATTN_11DB)
    dac = DAC('P22')        # create a DAC object
    for _ in range( 100):
        dac.write(_ / 100)
        print(adc_c.voltage())
        sleep(0.1)
    

    Not that adc.voltage() requires a calibration for better values, and that the input of the ADC should be low impedance. If you pot has a high impedance, connect a small capacitor (~10 nF) between ADC input and GND,


Log in to reply
 

Pycom on Twitter