ADC input pin different values with same code
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-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.
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,
@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?
@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.
@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?
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?
@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
@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?