# How to use ADC for battery operated application?

In my application VDDA = ADC Reference voltage and VDD = Microcontroller supply voltage changes due to battery drain form 3 V to 2 V so because of that my adc count not stable so what can I do to make stable?

• more "?" don't make a question better. Clear structure does! Add punctuation (your sentences end somewhere; a new sentence starts there. Put a "." between.). – Marcus Müller Aug 19 '17 at 13:20
• Use the internal reference voltage to calculate the actual vdda. Then use that for the normal adc conversion. – Bence Kaulics Aug 19 '17 at 13:25
• I will try to add some detail later. – Bence Kaulics Aug 19 '17 at 13:33
• You do not need it actually . Measure the Vdda first using the internal voltage. Then knowing the Vdda do your measurements. – P__J__ Aug 19 '17 at 16:38

The STM32 microcontrollers have an internal voltage reference source, and that can be used to determine an unknown VDDA, VDD value. The necessary informations are found in the datasheet, for example for the STM32F030 series:

it is 1.23 V typically. Now, given that this reference voltage is known to be 1.23 V you can calculate the ADC reference voltage VDDA by reading the internal reference's valute with the ADC.

The formula is the following:

$$\frac{V_{REFINT} \:[V]}{VDDA\: [V]} \times 4096 = digital_{VREFINT}$$

In this equation the following values are known:

$$V_{REFINT} = 1.23\:V$$ $$digital_{VREFINT} = \text{from reading the internal ADC channel}$$

So the VDDA, aka battery voltage can be calculated:

$$\frac{V_{REFINT} \:[V]}{digital_{VREFINT}} \times 4096 = VDDA\: [V]$$

Performing this calculation before your normal ADC readings will give you the reference voltage value you need.

A more accurate value can be calculated using the internal voltage reference's calibration value which is individually measured for each part by ST during production test and stored in the system memory area. It is accessible in read-only mode. Here are the specs:

It is actually the digital value of the internal reference voltage that was measured with VDDA = 3.3 V. The actual VDDA can be calculated as follows:

$$VDDA = 3.3 \: V \times \frac{digital_{VREFINTCAL}}{digital_{VREFINT}}$$

3.3 V is known from the table above, the calibration value from the memory and the actual value by reading the appropriate internal ADC channel.

Generally this is the most cost effective and the easiest way to use the ADC with not constant VDDA.

The solution is to supply VDDA with a stable voltage.

There are linear regulators made specifically for providing the reference voltage to ADCs. Pick one which can operate on your battery range and still provide a stable reference.

These usually have low quiescent current (they don't draw much current for their own operation) and low current output (the ADC doesn't need much current from the reference) so they won't suck your battery down fast.

This of course means that your reference voltage is lower than the lowest battery voltage. You will have to scale your analog signal to match the lowered voltage range of the ADC.

There are some voltage references with enable pins so you can shut them off to save power when the processor is sleeping. Something to keep in mind if you are going for a long run time from a small battery.

Another thing to keep in mind is that some processors have a built in voltage reference. You can either wire it to VDDA, or some a configuration bit or similar that connects the reference voltage internally.

• We require 1.5volt to 1.8 Volt ADC reference so which linear voltage regulator should we use ??? – mulesandip3 Aug 19 '17 at 12:47
• This is an example of what I mean.. That is from Maxim, and is the first I found that would appear to meet your needs. That's just an example. Using that, you can search for related devices. For all I know, the one I linked to is a finicky piece of crap. Check its datasheet, see if it meets your needs. Compare to similar parts from other manufacturers. Check the prices. – JRE Aug 19 '17 at 13:13
• Most, if not all STM32 have an internal regulator providing a stable reference. There is no need for a second one for most applications. These controllers are designed for battery operation. – berendi - protesting Aug 19 '17 at 14:16
• @JRE: the question is tagged as stm32, so I think it's about an STM32 – berendi - protesting Aug 19 '17 at 14:27
• @berendi: Didn't see that. I've added a hint to check for a built in reference. – JRE Aug 19 '17 at 14:35