cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Measurements of VDD

ramil
Associate II

Dear Community, 

I started investigating issues on one old project that based on STML071xB and has been implemented by another engineer. I got confused with implementation of battery measurements. Here is the thing: 

1. MCU is directly supplied by a battery (working voltage is expected to be in 2-3V range)

2. VREF+ is connected to a battery 

3. ADC internal channel is used to measure VDD level 

Datasheet says that VDD can be measured accurately using internal ADC channel when VREF+ is not connected. Meaning, an internal reference voltage which is 3.0V (bandgap) is used as a reference to measure VDD. But what if VREF+ is connected to a battery voltage, how VDD is supposed to be measured in this case? 

From my understanding, VDD cannot be measured when VREF+ is used as a reference since it will be giving nearly maximal raw values on ADC output. 

What is the most confusing part is when I use external supply to power the device and change output voltage I see accurate measurements of the batter. How is it possible? But on the field we have many devices that are showing suspicious battery readings. 

Please advise what I'm wrong with.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief III

Hi,

just at first think a little bit: how could any ADC measure its own Vref ? It always will be 100% (adc-value).

So only way is to measure a fixed, known reference and ( by doing 3rd class mathematics ) calculate the ADC-Vref (or VDD, because same here) .

So what you found, is the standard way to get the VDD (or Vref) by measuring a known reference and then calculating the actual VDD from this, ( if there is no (working) fixed Vref+ , thats coming from a reference voltage and thus allows measuring the VDD from a voltage divider (from VDD) and using the ADC with fixed Vref ).

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6

Please show the schematic of this arrangement:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228


@ramil wrote:

1. MCU is directly supplied by a battery (working voltage is expected to be in 2-3V range)

2. VREF+ is connected to a battery 


Are these the same battery, or two separate batteries?


AScha.3
Chief III

Hi,

just at first think a little bit: how could any ADC measure its own Vref ? It always will be 100% (adc-value).

So only way is to measure a fixed, known reference and ( by doing 3rd class mathematics ) calculate the ADC-Vref (or VDD, because same here) .

So what you found, is the standard way to get the VDD (or Vref) by measuring a known reference and then calculating the actual VDD from this, ( if there is no (working) fixed Vref+ , thats coming from a reference voltage and thus allows measuring the VDD from a voltage divider (from VDD) and using the ADC with fixed Vref ).

If you feel a post has answered your question, please click "Accept as Solution".

Hi @AScha.3@Andrew Neil,

Thank you for your answers!

That's why I'm really concerned how the battery is supposed to be measure.

If I get you right, what you're saying is regardless whether there is VREF+ connected when I measure internal ADC channel ADC_CHANNEL_VREFINT, it uses internal reference voltage (3.0V), is my understanding correct?

How does the MCU choose what reference to use? I thought it's implemented in HW and depends on if VREF+ is connected. 

Here you go a piece of schematic that I described. VIN comes from the only battery. As you can see VDD and VREF+ are the same in my case. 

 

Screenshot from 2024-12-05 10-29-24.png

Regards, 

Ramil

You still don't get it....

The CPU chooses nothing, only you can choose: what input channel the ADC should convert now ( or by hardware design, where is the ADC vdd and vref+ coming from).

So in your case here, vdd and vref for ADC are connected, so you can only choose, whch input the ADC should convert.

Now you have no fixed and known vdd, so you want to measure this, but only way to get some info from a reference voltage is obviously the internal vref channel. To get it, you measure it as ADC input channel XX and then from the ADC value calculate, what level the actual vdd or vref+ is now.

So difficult to understand?

 

If you feel a post has answered your question, please click "Accept as Solution".
Ozone
Lead II

I don't think the MCU can create a known and stable Vref voltage from an unknown Vdd.
All Vref circuits I know is a stable reference element, and an input voltage above the desired reference voltage.
Detail about Vref conditions are found in the MCU datasheet.

I would recommend the following.
Use a different battery voltage, and a step-up or step-down converter with fixed output voltage.
While the MCU (and Vref) are supplied through the converter, you can monitor the battery voltages directly (probably with a voltage divider).

Or alternatively, you might get away with a Vref voltage substantially smaller than the battery voltage, and again a voltage divider network for battery voltage measurement.

To be honest, a little confusing especially when you faced this for the first time. On other platforms, I worked with, the things were implemented differently and more transparent. This article also helped a lot to understand how things work on ST products. 

I still don't know why measurements are not accurate on the field. But I can exclude ADC measurements now. Thanks everyone for answers!