adc.vref looks strange



  • Hi all!
    While I try to automate the calibration of the ADC, I found a strange behaviour. I output the adc.vref with adc.vref-to_pin('P22') and measure it with my Keithley 2001. Expecting something stable around 1.1V, I only get something VERY noisy, at arround 0.7V.
    ADC and DAC work very well. Just the output of vref is pretty bad.

    My hardware is a custom baseboard with a L01 on it. Nothing is connected to P22, except the connector and the Keithley. I switched all radios off.
    Except this special behaviour, the boards work pretty well.

    Any idea?

    Cheers,
    Thomas



  • @robert-hh This was a typo, i meant 100nF (ceramic capacitor with value 104) :-)
    Yes, I understand that the firmware should not be of an issue, this was really strange and inconsistent.
    Regarding vref_to_pin() call, at least for 10-20 secs the 1.1V output seems not to switch-off (i had a voltmeter connected permanently).
    I am also suspecting issues with ground-cabling in the breadboard, but I hope the capacitor would deal with them.
    Anyway, the thing is that I observed really large differences in the observed values when changing modules. For example for a 3.9V battery voltage using 3 different modules I got 3.9V, 3.7V and 3.6V.
    I will re-run the tests and report again.
    Thanks!



  • @agotsis Without any opposite knowledge, I would consider 100µF as capacitor too high. Something like 10nF should be sufficient.
    But I had also observed that the VRef output only seems to stay for a short period, and then it is switched off.
    There should not by any difference in the VRef value depending on the firmware version, since it is a hardware property. But it should vary between devices and eventually with environment factors like the temperature.



  • So, recently I've also noticed some inconsistencies in some ADC measurements (for a battery voltage measurement using a resistor divider) and I tried to come up with a standard verification-calibration procedure: activate vref_to_pin and measure the voltage in another GPIO pin, for example P13. I am also using a 100uF between P13 and GND.

    The code snippet for my tests is:

    import utime
    from machine import ADC
    import machine
    
    _NUM_ADC_READINGS = 50
    _MEAS_PIN = 'P13'
    
    # define measurement pin
    adc = ADC()
    #adc.vref(1100)
    adc_input_pin = adc.channel(pin='P13', attn=machine.ADC.ATTN_2_5DB)
    adc.vref_to_pin('P22')
    
    # Output Vref of P22
    while(True):
    	# measure actual vref : single-shot
    	#print(adc_input_pin.voltage())
    	# multi-shot
    	tmp = 0.0
    	for _ in range(0,_NUM_ADC_READINGS):
    		tmp+=adc_input_pin.voltage()
    	print(tmp/_NUM_ADC_READINGS)
    	utime.sleep_ms(5000)
    

    I am getting significant inconsistencies in the output. Normally I expect to get something close to 1100, right? But depending on firmware version (playing with 1.18.2.r7 and 1.20.0.rc13) and the device (I am playing with LoPy4 modules for now, but I will make some tests with other modules soon).

    In particular, I am getting values either close to 1100 (e.g. 1050) but also really low values, close to 300.
    Any ideas on that?
    If someone could also repeat those tests on his/her modules, that would be helpful.

    Thanks!



  • @robert-hh It's a L01



  • @Thosch42 Well, I tried it again, and it works nice, showing 1.105V. Strange thing: after connecting the probe again after a while, the output was gone, and I had to repeat the vref_to_pin() call.



  • Now I connected an external reference voltage to all adc channels, and adjusted the Vref value iteratively to 1106 mV. All adc channels give me the correct value now.
    As a workaround it's ok, but not as expected.



  • @Thosch42 Which module do you use? I know that I had a similar problem, and I recall that adding a capacitor helped. But I will try again.



  • @robert-hh With 100n to GND, I get very noisy 200mV :-(



  • @Thosch42 Add a capacitor of ~100nF to the output. That helps.


Log in to reply
 

Pycom on Twitter