Go Down

Topic: Problems finding Vcc using bandgap voltage method (Read 12 times) previous topic - next topic

Nick Gammon

OK well I made up this sketch to find it out:

Code: [Select]
// Find internal 1.1 reference voltage on AREF pin
void setup ()
{
  ADMUX = _BV (REFS0) | _BV (REFS1);
}
void loop () { }


Measuring the AREF pin I got 1.084. After changing the sketch to read:

Code: [Select]
const long InternalReferenceVoltage = 1084L;

I got the voltage displayed: 504 (compared to measured 5.03) so that is OK I suppose.

Then on the bare bones board I measured 1.088 on AREF. Adjusting for that, and then re-uploading the main sketch I got 480 (compared to measured 4.995) so that wasn't as far out, anyway (around 4%).

It seems that the bandgap idea is fairly sensitive to getting the reference voltage right. I suppose that makes sense. If you were going to deploy this in the field you probably need to calibrate each unit (perhaps keep the figure in EEPROM).

retrolefty

#6
Jan 26, 2012, 04:51 am Last Edit: Jan 26, 2012, 04:55 am by retrolefty Reason: 1
Quote
It seems that the bandgap idea is fairly sensitive to getting the reference voltage right. I suppose that makes sense. If you were going to deploy this in the field you probably need to calibrate each unit (perhaps keep the figure in EEPROM).


Yes EEPROM could hold the band-gap constant value for a given specific chip, it's not like those two thing could become separated.  ;)

I think it kind of depends on the application. If your just interested in a low Vcc alarming function then it's not really all that important that the Vcc value is 'accurate' or not, as long as it's repeatable, linear, and sensitive enough for the function, which it is, as the error is just with the constant value being used, it's not a 'variable error' with any more measurement uncertainty then if the constant value was right on value. So you could just use 1100 millivolts as the constant and just compensate for the 'error' in the setpoint value used to use to test against the reading you get.  That is, is the result greater or less then the alarm setpoint value. Also as a low battery alarm a lot depends on the battery chemistry used. Lead acid and li-po have a reasonably linear discharge voltage slope, where as nicads an nimh have a very flat discharge voltage until very near the end of the charge capacity. However if the application is dealing with using the analog input pins for sensor inputs, in the presence of a gradually falling Vcc voltage, then proper calibration is probably desirable and useful.

The main thing is that this demonstrates that there is a method to maintain reasonable accuracy and calibration for reading of the analog input pin even with a variable Vcc/Avcc voltage without requiring any external components.




Nick Gammon

Right, thanks!

I've modified my posts here about power savings:

http://www.gammon.com.au/forum/?id=11497


Included are the effects of lowering Vcc, detecting low battery, battery self-discharge, and so on.

av8or1

#8
May 04, 2013, 05:37 am Last Edit: May 04, 2013, 01:59 pm by av8or1 Reason: 1

Right, thanks!

I've modified my posts here about power savings:

http://www.gammon.com.au/forum/?id=11497


Included are the effects of lowering Vcc, detecting low battery, battery self-discharge, and so on.


Nick,

Great information, thank you!  After reading several threads about this notion of giving a warning if the battery voltage gets low, I am still curious about something: is the *only* way of measuring the Vbg (band gap voltage) to run the sketch that sets the ADC to measure AVcc and then use a DVMM (multimeter) to measure the voltage at the AVcc pin, and it is that voltage reading that is then your Vbg?  There seemed to be reference to a way of determining Vbg by software (by changing an initial approximated Vbg up or down based on some math calculations).  I understand of course that the actual Vbg will vary from chip to chip, so it needs to be measured on each unit.  The question I am attempting to get a definitive answer on is whether or not you need to use a DVM to measure the Vbg and that's the only way of determining it.  Do I have that right?

Thanks!

Jerry

Nick Gammon

Measure it once you mean? The rough approximation is probably OK (ie. no measurement), but if you measure it you get a more precise result. I don't know about "the only way". You could probably set up a reference voltage with a special reference voltage chip or zener diode to work it out a different way.

Go Up