Giter Site home page Giter Site logo

Comments (10)

mikaelpatel avatar mikaelpatel commented on August 16, 2024

With this I get very strange readings. Over 5000 mV, as high as 8000 mV. Need to check AVCC_REFERENCE.

Cheers!

from cosa.

mikaelpatel avatar mikaelpatel commented on August 16, 2024

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.

guiguid avatar guiguid commented on August 16, 2024

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.

guiguid avatar guiguid commented on August 16, 2024

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.

guiguid avatar guiguid commented on August 16, 2024

well, you close this issue when I has testing ....
I'll open a new one ?

from cosa.

mikaelpatel avatar mikaelpatel commented on August 16, 2024

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.

guiguid avatar guiguid commented on August 16, 2024

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.

guiguid avatar guiguid commented on August 16, 2024

an other solution is to backup ADMUX before doing vcc stuff, and restore it after !

from cosa.

mikaelpatel avatar mikaelpatel commented on August 16, 2024

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.

mikaelpatel avatar mikaelpatel commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.