cancel
Showing results for 
Search instead for 
Did you mean: 

Battery measurement.

dennisvantienhoven
Associate II
Posted on September 27, 2011 at 13:26

Good morning all,

First of all, my project:Measure the voltage, current en temperature with an ADC from the STM32 Value Line Discovery. Sending this data to the computer with UART (RS232). The load on the battery is a switchable resistive load bank with a maximal withdraw of 40A.

Now my problem.

The ADC in the STM32F100RBT6B is an 12bit,

16 channels

without

an Vref pin (package LQFP64) on a STM32 Value Line Discovery board.

How can I measure the voltage of my battery (2*12V = 24V, max specified = 30V).

My thought went out to:

0 � 30V range divide in two different parts (2 channels of the ADC) like:0 � 15V and 15 � 30V, because I need to read the voltage at 10mV accuracy.How to:Vref = VDDA = VDD = 3,3V if I�m right?So if I make two different voltage dividers I could get my specified voltage.

0 � 15V = (10K / (40K+10K)) * 15V = 0V min - 3V max.

15 � 30V = (10K / (90K+10K)) * 30V = 1.5V min - 3V max.

1)

     

How to solve the second voltage divider?

2)

     

How to solve the problem with my Vref? I don�t know how its mounted on the board but I think the power supply could effect my readings because Vref and VDDA would change with the power supply.

3) I want to use an voltage regulator for creating an 3.3V-5V or an DC/DC converter for

3.3V-5V. What is the best option? I'm affraid that the pulsed DC/DC supply would create interference on my ADC reading.

Any idea�s thoughts or comments would be helpful!

Greets,

Dennis.

#stm32 #value-line-discovery
7 REPLIES 7
raptorhal2
Lead
Posted on September 27, 2011 at 15:24

Glad to see you spotted the ADC Glitches discussion. It is a good example of the types of problems you are up against.

The document is ST application note AN2834 on best ADC accuracy, available on the ST web site. If following all the guidelines on this AN doesn't result in a 10 mv accuracy, consider using an external 16 bit ADC.

Splitting the voltage into two ranges as you have done does not improve accuracy, unless the 10 mv requirement is only for the 0 to 15 V range. To get better accuracy for the 0 to 30V range, subtract 1.5V and then use a gain of 2 to get a 0 to 3.3V conversion range.

VRef is available internally as ADC channel 17.

Feeding 12V from the low side battery to a 5V regulator to the VL board 3.3V regulator to the ADC internal reference voltage regulator should provide good isolation.

Cheers, Hal

dennisvantienhoven
Associate II
Posted on September 27, 2011 at 16:46

@baird.hal.001

Yep spotted the discussion and reading the AN2834 (almost done) and it answers indeed a lot of my questions.

What do you mean with this: To get better accuracy for the 0 to 30V range, subtract 1.5V and then use a gain of 2 to get a 0 to 3.3V conversion range. 30Vmax/2^12 = 7.3mV accuracy but the last bit will toggle, so when I delete this bit: then you will get 30/2^11=14.6mV and then I won't achive my specification.. Or is it possible to maintain the last bit?

 

VRef is available internally as ADC channel 17.

I don't fully understand that part yet. My thoughts: you can measure the internal Vref so you can use this value with your ADC calculations.

I found the regulator used on the VL Discovery (user Manual page 21) regulator: LD1117DT33C with internal maximum

line regulation of 0,4%

Could you explain me why the voltage divider idea isn't accurate enough?

THANKS!

Greets,

Dennis.

raptorhal2
Lead
Posted on September 27, 2011 at 17:37

What do you mean with this: To get better accuracy for the 0 to 30V range, subtract 1.5V and then use a gain of 2 to get a 0 to 3.3V conversion range.

This has to be done in the analog circuitry before conversion to get the better accuracy. Also, I erred slightly. Subtract 1.65 V.

Could you explain me why the voltage divider idea isn't accurate enough?

It is accurate enough. 30V is being converted to a 7.3 mv resolution. My point was why bother creating a 0 to 15V range with a 3.6 mv resolution if your requirement is 10 mv resolution ?

I found the regulator used on the VL Discovery (user Manual page 21) regulator: LD1117DT33C with internal maximum

line regulation of 0,4%

I believe the 0,4% regulation applies to an unregulated input. Feed it with a 5V regulator and the variance will be smaller.

VRef is available internally as ADC channel 17.

 

I don't fully understand that part yet. My thoughts: you can measure the internal Vref so you can use this value with your ADC calculations.

My view is you need to go implement your ideas now and see what kind of accuracy you can achieve. In the analog to digital world, there are more sources of error than resolution.

Cheers, Hal

dennisvantienhoven
Associate II
Posted on September 27, 2011 at 23:29

@baird.hal.001

It is accurate enough. 30V is being converted to a 7.3 mv resolution. My point was why bother creating a 0 to 15V range with a 3.6 mv resolution if your requirement is 10 mv resolution ?

 

&

 

My view is you need to go implement your ideas now and see what kind of accuracy you can achieve. In the analog to digital world, there are more sources of error than resolution.

I was thinking to remove the last bit of the ADC measurement to make the calculation an bit more accurate, but if I do this there would be 11bits left 2^11= 2048 steps. 30/2048 = 14.6 mV per step. now I won't make the requirement.

The second option is to measure a couple times and fill an array, then calculate the average and then I won't have to delete the LSB (bit12).

There is an on-board temperature compensation logic (didn't read that far in the manual yet..) and an other compensation software logic, would this be enough with my second option to achieve the 10mV accuracy?

(I'll be using 1% resistors and an 1% potential meter for the voltage divider circuit).

Over the internal (on the board) voltage divider, yes exactly thats why I called it the maximum line regulation.

My plan for the supply voltage is a bit the same as the on-board version, only this would be stable 5V.

Thanks for you help!

I trying to put my idea's together now, it becomes a bit clearer for me now.

dennisvantienhoven
Associate II
Posted on September 29, 2011 at 15:00

It is accurate enough. 30V is being converted to a 7.3 mv resolution. My point was why bother creating a 0 to 15V range with a 3.6 mv resolution if your requirement is 10 mv resolution ?

 

Well I'm not sure if its possible to measure 7.3mV because there will be noise right?

Or isn't that a problem? I'm affraid I won't mange that 10mV spec.

Greets,

Dennis

 

donald2
Associate II
Posted on September 29, 2011 at 23:48

If you don't have high frequency reporting requirements (and you likely don't, given that the results are reported over a serial port), just average multiple samples.  A common approach is to sum 16 conversions and do a logic shift.  With this approach a little uncorrelated LSB noise will improve the result.  By a loose application of theory you should get an extra 4 bits, although you shouldn't expect any extra resolution, just gaining back the LSB.

Adding active input buffering risks adding noise and errors.

My expectation is that you can hit your voltage resolution spec with two simple resistive voltage dividers.  You'll improve your conversion results by adding a small capacitor (20x to 100x the internal A/D sample capacitance) to each input pin.  This will both act as a RC filter to reduce high frequency noise, and lower the source impedance to reduce the effect of charging the sample cap.

Use the same resistor values, from the same batch, for both voltage dividers.  Do not specialize their input range.  You'll get better matching.  With 1% resistors you'll always lose absolute accuracy, but resistors from the same batch gives you a very good chance for matching errors.

How are you measuring current?  50mV shunts?  They can be a challenge to get low-noise results.   At 40A you can still use conduct-through Hall effect current sensors.  Any higher and you are starting to move into the range where you will need loop-around hall sensors. 

dennisvantienhoven
Associate II
Posted on September 30, 2011 at 09:56

@Donald Becker

I think about getting an 16bit ADC working on I2C (so I can use LM92 = I2C temperatuur sensor) With this 16bit, I could remove last 2-4bits and maintain my accuracy.

How do I know if the resistors are from the same batch? (I'm buying my components at farnell.)

How are you measuring current?  50mV shunts?  They can be a challenge to get low-noise results.   At 40A you can still use conduct-through Hall effect current sensors.  Any higher and you are starting to move into the range where you will need loop-around hall sensors. 

Yep 50mV shunt, I need an accuracy on them at about 100mA so this seems to me as the best option.

Same ADC as the votlage ADC.

Think this would be a good solution?

Greets,

Dennis.