Comments (10)
With this I get very strange readings. Over 5000 mV, as high as 8000 mV. Need to check AVCC_REFERENCE.
Cheers!
from cosa.
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().
from cosa.
Hi
It seem's to be a delay problem when changing ADMUX register.
It need some time to have the new REF stabilised, so don't launch convertion until
we are shure the new REF is stabilised.
from: Datasheet Atmega 328P
If the user has a fixed voltage source connected to the AREF pin, the user may not use the other
reference voltage options in the application, as they will be shorted to the external voltage. If no
external voltage is applied to the AREF pin, the user may switch between AVCC and 1.1V as reference
selection. The first ADC conversion result after switching reference voltage source may
be inaccurate, and the user is advised to discard this result.
also : http://capnbry.net/blog/?p=167
a delay of 10ms after changing ADMUX value is need.
Pins.cpp
uint16_t
AnalogPin::sample(uint8_t pin, Reference ref)
{
if (sampling_pin != 0) return (0xffffU);
if (pin >= Board::A0) pin -= Board::A0;
loop_until_bit_is_clear(ADCSRA, ADSC);
if (ADMUX != (ref | pin)) {
ADMUX = (ref | pin);
// if ADMUX change, need to wait ms in order to let the new voltage reference stabilise
delay(10);
}
bit_mask_set(ADCSRA, _BV(ADEN) | _BV(ADSC));
loop_until_bit_is_clear(ADCSRA, ADSC);
return (ADCW);
}
Guillaume
from cosa.
Yes, you pacth fix it, but without my post above, you'll have a first wrong result :
CosaVCC: started
1:3264 mV <--- without delay
2:5143 mV
3:5143 mV
4:5143 mV
5:5143 mV
6:5143 mV
from cosa.
well, you close this issue when I has testing ....
I'll open a new one ?
from cosa.
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.
from cosa.
Well,
If could tell you : I don't think it's the best choice.
In lot of project battery powered, we need to know battery voltage (VCC) and some others
ADC inputs. So vcc monitor is often a slow monitoring (once by minute)
and other can be very fast ADC conversion.
With your solution, the very fast ADC convertion can be corrupt by an exit of vcc monitor (ADMUX was changed...)
my patch test for an ADMUX change and make an delay (but you can replace by a dummy convertion if you wants).
It's your code, of course you can do that you wants.
cheers
guillaume
from cosa.
an other solution is to backup ADMUX before doing vcc stuff, and restore it after !
from cosa.
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.
from cosa.
It seems to be the 1V1 internal reference voltage generator that needs additional startup time. I added this to AnalogPin::bandgap().
from cosa.
Related Issues (20)
- Build: Support Arduino 1.6.10 HOT 2
- Release: Create R1.2.1 for Arduino IDE update
- Cleanup: Improve IOStream operators
- Installation on Ubuntu without arduino HOT 2
- Quality: Increase robustness (check const pointers)
- Refactoring: Allow multiple TWI/SPI modules
- USB/CDC no longer works with Mac OS X El Capitan/Sierra HOT 1
- API Documentation link is stale... HOT 4
- IOStream: Cannot print non-dec base without prefix HOT 1
- INET::print_mac and W5x00 compatibility HOT 1
- W5?00: Only first connection works HOT 6
- board .map file could use better namespace allocation HOT 2
- Add support for other MCU e.g SAM, ARM, ESP, etc HOT 2
- Question: Is using Cosa without Arduino based on a Makefile possible? HOT 3
- TWI::Slave broken HOT 12
- please provide examples of async analog read handling HOT 1
- [RFM 69] High-level API for Encryption Key and Frequency Selection HOT 2
- Update toolchain versions in JSON file to IDE 1.8.9 HOT 2
- Hamming codec for cheap radios question HOT 1
- Is this platform still viable ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cosa.