You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a voltage divider here to read the voltage of a lithium ion cell:
Vbatt ->33k -> pin -> 100k -> GND
(100µF cap via pin -> cap -> GND, high impedance is not the issue)
Ohms law says that Vbatt = (33k + 100k) / 100k * Vpin
However, the pin is reading high. Both in the µC as well as when using a multimeter on pin<->GND compared to the correct Vbatt<->GND.
Not much, but the reading is about 5% high.
It took me way too long to find out that said pinMode causes this problem.
Removing the pinMode declaration removed the issue, the ready is now <1% off the multimeter.
While trying to figure out what is going on I also found that I was unable to have ADC_0 at 16bit resolution and ADC_1 at 10bit. They were always both at 16bit.
And what does the compare mean... I tryed to turn that on and off for both ADCs and it didnt change a thing. So why "always call it"? // always call the compare functions after changing the resolution! //adc->enableCompare(1.0/3.3*adc->getMaxValue(ADC_0), 0, ADC_0); // measurement will be ready if value < 1.0V //adc->enableCompareRange(1.0*adc->getMaxValue(ADC_0)/3.3, 2.0*adc->getMaxValue(ADC_0)/3.3, 0, 1, ADC_0); // ready if value lies out of [1.0,2.0] V
The text was updated successfully, but these errors were encountered:
I have a voltage divider here to read the voltage of a lithium ion cell:
Vbatt ->33k -> pin -> 100k -> GND
(100µF cap via pin -> cap -> GND, high impedance is not the issue)
Ohms law says that Vbatt = (33k + 100k) / 100k * Vpin
However, the pin is reading high. Both in the µC as well as when using a multimeter on pin<->GND compared to the correct Vbatt<->GND.
Not much, but the reading is about 5% high.
It took me way too long to find out that said pinMode causes this problem.
Removing the pinMode declaration removed the issue, the ready is now <1% off the multimeter.
While trying to figure out what is going on I also found that I was unable to have ADC_0 at 16bit resolution and ADC_1 at 10bit. They were always both at 16bit.
And what does the compare mean... I tryed to turn that on and off for both ADCs and it didnt change a thing. So why "always call it"?
// always call the compare functions after changing the resolution! //adc->enableCompare(1.0/3.3*adc->getMaxValue(ADC_0), 0, ADC_0); // measurement will be ready if value < 1.0V //adc->enableCompareRange(1.0*adc->getMaxValue(ADC_0)/3.3, 2.0*adc->getMaxValue(ADC_0)/3.3, 0, 1, ADC_0); // ready if value lies out of [1.0,2.0] V
The text was updated successfully, but these errors were encountered: