cancel
Showing results for 
Search instead for 
Did you mean: 

Using ADC to monitor supply voltage down to 1.8 Volts

AMurp.1
Associate II

Hi,

Is it possible to use the ADC to monitor the battery supply voltage down to 1.8V just before the micro stops working. 

Due to the reference (2.048) I can only correctly read down to 2.4V

Thanks am

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Actually, even your readings above 2.0V aren't correct.

VDDA: 3.3V, VREFINT: 1393 --> VDDA = 1.21V * 4095/1393 = 3.56V

VDDA: 3.0V, VREFINT: 1512 --> VDDA = 1.21V * 4095/1512 = 3.28V

VDDA: 2.5V, VREFINT: 1900 --> VDDA = 1.21V * 4095/1900 = 2.61V

Also, your VBAT measurements should always be 4095/4 if VDDA=VBAT=VDD, which they aren't.

Is your sample time sufficient? Make it the longest possible.

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

View solution in original post

13 REPLIES 13
TDK
Guru

Yes, but you can't use the internal voltage reference since it requires 2.4V+.

Tie VREF+ to VDDA. Take readings of VREFINT to calculate what VDDA is currently equal to. Take readings of VBAT and use the calculated VDDA to determine its voltage.

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

Hi TDK,

I have implemented this (including the accurate version) , which is what I think you are suggesting.

https://electronics.stackexchange.com/questions/324715/how-to-use-adc-for-battery-operated-application

It works perfectly (within 30mV) down to 2.4V at which point the digitalVREFINT read starts giving wrong values.

The only way I can think which might work is to have an external Vref of say 1.5V and monitor the supply voltage on a different A/D pin, possibly via a potential divider.

Many thanks for you help

TDK
Guru

In what way are the readings wrong? You're using the 1.21V reference and now the 2.048V reference right?

There are requirements on VREF that you're not going to be able to satisfy through the entire range. Namely, 2.4 V ≤ VREF+ ≤ VDDA.

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

Hi TDK,

As the supply voltage goes below 2.4V the reading starts to go up again and then down, typically at 2.0 volts supply the calculation is 2.5V !

The STM32WD55 has only 2 possible references 2.5V and 2.048V - Wheras other ST processors have internal references down to 1.5V which would be much better.

Many thanks for you help

TDK
Guru

You're misunderstanding.

Option 1) You can enable the internal VREFBUF as the voltage reference and select either 2.048V or 2.4V (plus others on other chips). Don't do this.

Option 2) You can disable VREFBUF (ENVR=0, HIZ=1) and use VDDA/VREF+ as the voltage reference. Do this. This assumes you have it hooked up.

One that is set up, measure the VREFINT channel, which is a constant 1.21V (check datasheet) to calculate what VDDA actually is. Note that despite the name VREFINT, this is not being used as the ADC voltage reference.

Now that you know what VDDA is, measure the channel you actually want to measure, in this case VBAT, and scale by the VDDA value to calculate.

This requires you to constantly update the VDDA reading if it's changing all the time.

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

Hi TDK,

Yea I'm not quite getting something, here is what I have:

I have the supply VDDA of 3.3V connected to VREF+ input pin of the STM32WB55

In CubeMX I have only ticked Vbat channel for ADC1, everything else is Disabled

In CubeMX for VREFBUF Mode I have selected VREFBUF buffer OFF

In my battery read routine for different VDDA supplies - here is what I get:

VDDA ADC_CHANNEL_VREFINT ADC_CHANNEL_VBAT

3.3V 1447 915

3.0V 1554 891

2.5V 1990 801

2.0V 963-1239 795-801

The VBAT channel goes through a potential divider so the the bits will be X3 but I would have expected VREFINT to be much lower and steady (and not to rise for falling VDDA !)

Also in VREF BUF OFF mode the board is taking 100mA instead of 10mA !!

Any thoughts ?

Many thanks, am

Okay, so you are doing what I was trying to explain.
But the current draw of +90mA certainly indicates something is amiss.
I believe you want VREFBUF set to “External voltage reference�?. Check the register settings for ENVR=0 and HIZ=1 bits to verify.
If you feel a post has answered your question, please click "Accept as Solution".
AMurp.1
Associate II

Hi TDK

With VREFBUF set to external voltage ref:

VDDA: 3.3V, VREFINT: 1393, VBAT: 923

VDDA: 3.0V, VREFINT: 1512, VBAT: 893

VDDA: 2.5V, VREFINT: 1900, VBAT: 806

VDDA: 2.0V, VREFINT: 1274-1354, VBAT: 772-778

With the micro now not in VREF BUF OFF mode - the current is back to 10mA

In this mode, just after I have done my 2 reads, I have checked VREFBUF_CSR - ENVR = 0 and HIZ = 1

BUT :

In the previous high current mode: VREFBUF_CSR - ENVR = 0 and HIZ = 0

This is a tough one .. any other thoughts ?

Many thanks, am

Hmm, not sure. Maybe I’m missing something here. It’s be weird for the ADC to be useless below 2V though.
If you feel a post has answered your question, please click "Accept as Solution".