Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning pinMode(pin, INPUT) causes slightly wrong readings? #30

Open
Eheran1 opened this issue Jan 11, 2018 · 0 comments
Open

Assigning pinMode(pin, INPUT) causes slightly wrong readings? #30

Eheran1 opened this issue Jan 11, 2018 · 0 comments

Comments

@Eheran1
Copy link

Eheran1 commented Jan 11, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant