Forum - MCS Electronics

Author Message
MAK3

Joined: 24 Sep 2010
Posts: 450
Location: Germany

Posted: Sat Oct 29, 2011 8:17 pm    Post subject: Measure Vcc over Bandgap Voltage in Battery powered devices

Hi,

This example show how to measure the Vcc over the Band Gap Voltage (Vbg)
'You especially want or need this when using a battery powered device where you want to react when battery is below a defined value
Then Vcc = Vbatt
'The Value of Vbg can be found in the datasheet and is 1.1 Volt but can differ between 1.0 and 1.2 Volt

So when you set the Reference Voltage for the ADC to Vcc then you can calculate
Vcc = Vbg * 1024/measured ADC Value
Vcc = 1.1Volt * 1024/measured ADC Value

For example measured ADC Value = 470 --> Vcc = 1.1 * 1024/470 = 2.39 Volt
For example measured ADC Value = 375 --> Vcc = 1.1 * 1024/375 = 3.00 Volt

Because the Vbg can differ you can measure the Vbatt with ad DMM and change the Vbg Value to the real value like 1.13 Volt in the following example

This example shows also how you can use the ADC Noise Canceler of an AVR

The serial out is only as debug interface to PC (this would need to much Flash of the ATTINY25)
Without the serial out debug interface enabled this example need 19% of Flash with enough room for your application (or use ATtiny45 or 85)

The Watchdog is activated already in Fuse Bits and the task of the Watchdog in this case is waking up the Attiny from powerdown mode
Because it is a battery powerd device it is sleeping most of the time, wake up after the watchdog interrupt fires run through the program and get back to sleep mode

My Circuit with ATTINY25 need 1mA in active mode and 4.7ľA in PowerDown mode which meets the specs in the Datasheet.
When the serial output is connected to a USB to UART device then the PowerDown mode rise to app. 80ľA.

Disconnect the ISP Programmer before measuring the current !

MAK3

Last edited by MAK3 on Mon Oct 31, 2011 12:52 pm; edited 2 times in total
Ross_ValuSoft

Joined: 20 Nov 2005
Posts: 274
Location: Melbourne, Australia

Posted: Mon Oct 31, 2011 12:44 am    Post subject:

Thanks for sharing.

However, perhaps you could edit your post to correct the error in this ...

 Code: ' For example measured ADC Value = 470  --> Vcc = 1.1 * 1024/422 = 2.66Volt

Cheers,

Ross
MAK3

Joined: 24 Sep 2010
Posts: 450
Location: Germany

Posted: Mon Oct 31, 2011 9:10 am    Post subject:

ross_valusoft,

thanks, I changed it to
 Code: For example measured ADC Value = 470  --> Vcc = 1.1 * 1024/470 = 2.39 Volt

I should also add that not every AVR is able to measure the internal Bandgap Voltage (Vbg). For example with an Attiny13 you can not choose Vbg in the ADMUX (ADC multiplexer) setting and therefore you can not measure it internally.

MAK3
Ross_ValuSoft

Joined: 20 Nov 2005
Posts: 274
Location: Melbourne, Australia

 Posted: Mon Oct 31, 2011 12:02 pm    Post subject: Sorry to be a pest ... but it is still wrong in your code. Someone might only copy your code ... Best wishes, Ross (who sometimes proof-reads technical documents)
MAK3

Joined: 24 Sep 2010
Posts: 450
Location: Germany

Posted: Mon Oct 31, 2011 12:57 pm    Post subject:

Hi ross_valusoft,

 Quote: who sometimes proof-reads technical documents

Well done !

Best Regards,
MAK3
Dave

Joined: 05 Feb 2005
Posts: 271
Location: McMinnville, OR

 Posted: Tue Sep 16, 2014 6:07 pm    Post subject: MAK3 This is a great tip. Extremely useful. Thank you! Dave
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 1 Hour Page 1 of 1

 Jump to: Select a forum BASCOM AVR/8051----------------BASCOM-AVRBASCOM-8051BASCOM-ARDUINOShare your working BASCOM-8051 code hereShare your working BASCOM-AVR code hereBASCOM BETA-SLA BASCOM Related----------------EASY TCP/IPAVR-DOSAR7212KokkeKat FAT-free SD card libBASCOM Project Blog Other Stuff----------------VariousPCB'sRoboticsNew WebSiteAnnouncementsAVR Archive----------------BASCOM-AVR ArchiveBASCOM-8051 ArchiveBASCOM-AVR Unsupported versionsEasy TCP/IP ArchiveBASCOM-EDB
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum