Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    adc.vref looks strange

    Scheduled Pinned Locked Moved Discussion
    10 Posts 3 Posters 497 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      Thosch42
      last edited by

      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-hhR 2 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Thosch42
        last edited by

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

        T 1 Reply Last reply Reply Quote 0
        • T Offline
          Thosch42 @robert-hh
          last edited by

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

          1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @Thosch42
            last edited by

            @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.

            T 1 Reply Last reply Reply Quote 0
            • T Offline
              Thosch42
              last edited by

              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.

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @Thosch42
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  Thosch42 @robert-hh
                  last edited by

                  @robert-hh It's a L01

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    agotsis
                    last edited by

                    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-hhR 1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @agotsis
                      last edited by

                      @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.

                      A 1 Reply Last reply Reply Quote 0
                      • A Offline
                        agotsis @robert-hh
                        last edited by

                        @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!

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom