-
Notifications
You must be signed in to change notification settings - Fork 76
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
Wrong ADV REFERENCE when computing Vcc #3
Comments
With this I get very strange readings. Over 5000 mV, as high as 8000 mV. Need to check AVCC_REFERENCE. Cheers! |
Please see 5f2eaae. There was a problem with the logic in AnalogPin::sample when using the VBG mux address. Solved this with a new function; AnalogPin::bandgap(). |
Hi It seem's to be a delay problem when changing ADMUX register. from: Datasheet Atmega 328P If the user has a fixed voltage source connected to the AREF pin, the user may not use the other also : http://capnbry.net/blog/?p=167 a delay of 10ms after changing ADMUX value is need. Pins.cpp uint16_t Guillaume |
Yes, you pacth fix it, but without my post above, you'll have a first wrong result : |
well, you close this issue when I has testing .... |
I have fixed this with a dummy sample in the VCC class. Please see 0fb3f39. Thanks for the great feedback and sorry about missing your latest comment. BW: I have my test setup with ATtiny running CosaVWItempsensor with DS18B20 in parasite mode at 3.3V talking to an Arduino Mini Pro running CosaVWItempmonitor at 8 Mhz and 3.3V. I had to change the pullup resistor for 1-Wire on the ATtiny to 1Kohm to get it working. |
Well, If could tell you : I don't think it's the best choice. guillaume |
an other solution is to backup ADMUX before doing vcc stuff, and restore it after ! |
Sounds like a good idea. I haven't considered the scenarios for the bandgap function and restoring is maybe the best solution. It seems to be the ATtiny that requires additional time (1ms) when reference voltage is changed. I will have to read more before coming to a decision on which way to go. Your input is valuable. I will keep this issue open until there is a better solution. |
It seems to be the 1V1 internal reference voltage generator that needs additional startup time. I added this to AnalogPin::bandgap(). |
Hi,
In CosaVCC.ino
wrong m_vcc = 1126400L / AnalogPin::sample(VBG, AnalogPin::A1V1_REFERENCE);
good m_vcc = 1126400L / AnalogPin::sample(VBG, AnalogPin::AVCC_REFERENCE);
wrong VCC lowPower(1150);
good VCC lowPower(4900) ; // trigger alarm when below 4.9 Volts
We know with 5V VCC we have 1023, and so 1.1V ref is 225 (1023/5*1.1)
Now if we donc know VCC, if we sample 1.1REF, with VCC as ref,
we have vcc = 1126400 / (sample 1.1V with Vcc as REF)
now we can do :
// if vcc under 4.9 Volts = lowbatt trigged
VCC lowPower(4900);
guillaume
PS: as you can see, I'm porting my current project to your libs ;-)
PS: I'll try using pull request for new issue ...
The text was updated successfully, but these errors were encountered: