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 input pin different values with same code

    Scheduled Pinned Locked Moved GPy
    9 Posts 2 Posters 19 Views 2 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.
    • Don-iotD Offline
      Don-iot
      last edited by

      I have made a prototype series with GPys on our own circuitboard. We have used one pin as an ADC-pin to read the battery power and that has worked with a couple of GPys and hand soldered boards. Now when we are making the first test series we have a problem with the battery level. We have 20 pcs with exact same code on them, but unfortunately I think we have a mix of hardware versions on the GPys (1.0r and 1.2) and possible different firmware versions as well. Unfortunately these are soldered permanently to the boards so I can not remove and "have a look" at the differences. The problem we are having is that some of these outputs the correct voltage, some outputs the voltage divided by 1,8. Does anyone know if this could be related to the hardware differences or if it is just firmware version related. So we know how to solve it in the upcoming batch.

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

        @Don-iot A few questions:

        a) which pin on the GPY are you using?
        b) Did you check with a volt meter that the voltage at that pin is the same for the same battery voltage when the GPY reports different values?

        1 Reply Last reply Reply Quote 1
        • Don-iotD Offline
          Don-iot
          last edited by

          @robert-hh a) We are using P16 (expansion board) with 2 x 1MΩ pullup resistors
          b) yes we did. So we have approx 1,9 at the P16 pin across each boards with a fully charged battery. Some of my GPys displays around 2.2 V and some 4.3 V

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

            @Don-iot said in ADC input pin different values with same code:

            2 x 1MΩ pullup resistors

            Do you mean pull-up or voltage divider?
            Can you add for testing a capacitor of about 10nF between P16 and GND?

            Don-iotD 1 Reply Last reply Reply Quote 0
            • Don-iotD Offline
              Don-iot @robert-hh
              last edited by

              @robert-hh True, sorry. These boards are already soldered so it is a bit difficult, we have to look at it at a later stage. But generally speaking, they should display the same value, right?

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

                @Don-iot These two boards should show the same reading with the same input voltage. So I try to verify first that they have the same input voltage. The first check is the static one, with the voltmeter. But the dynamic input impedance may vary too. During ADC conversion, the input impedance of the ADC drops a lot. Can you test with an oscilloscope if the input voltage drops during sampling?

                Other guess: the default bit width is 11 instead of 12 bit for the devices showing the lower voltage.

                Don-iotD 1 Reply Last reply Reply Quote 0
                • Don-iotD Offline
                  Don-iot @robert-hh
                  last edited by

                  @robert-hh Sorry no scope available. 11 and 12 bit, possibly, that could be the issue, but where is that parameter so we can double check?

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

                    @Don-iot said in ADC input pin different values with same code:

                    Sorry no scope available.

                    That's why I suggested to add the capacitor, which would drop the dynamic source impedance.
                    If you do not do so already, you could dedicately initialize the ADC to 12 bit, instead of assuming that it is. That's in adc.init() or the constructor with the keyword parameter: bits=12. There wa a bug that this parameter was ignored, but as far as I recall, it was fixed,

                    Don-iotD 1 Reply Last reply Reply Quote 0
                    • Don-iotD Offline
                      Don-iot @robert-hh
                      last edited by

                      @robert-hh Thanks, no we have not set it to be fixed to 11 or 12 bits, so I assume that needs to be corrected. Super, that may very well be the issue.

                      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