# Combined ADC level shift/offset and scaling

I'm trying to sense the voltage from a 2 cell Li-ion battery that has a usable range from 2.5 to 4.4 Volts per cell (nominal 3.0 - 4.2 V). The ADC I have has a range from 0 - 1.8 V and is 12 bits. I haven't been able to devise a solution that makes effective use of the ADCs range and scales the battery's voltage linearly. Ideally I would like to sense from 5 - 8.8 V volts rather than 0 - 8.8 V. I have a variety of resistors and an op-amp (LM324) available and have 12 V, 5 V and 3.3 V (and GND) rails available too.

So, what are some feasible solutions that will work well within the constraints?

• I wonder if you're over-thinking things a bit, you'd probably get about 5mV effective resolution depending on the ADC do you really need a lot better than that? – PeterJ Jan 23 '14 at 7:39
• I think I need to make this point a little more clear: I'm measuring 2 cells in series here, so it's a voltage input range of more like 5 V to 8.4 or 8.6 V. Using a simple voltage divider I think I can get about 40% voltage range on the ADC, which from what I've read is pretty poor. Do you think that in this case because of the ADCs resolution I should not worry about only using such a small proportion of the ADCs available range? (10 mV effective resolution will be fine for me). – Mr. Anderson Jan 23 '14 at 20:39

A few other answers have misread the maximum as 4.2V, for 8.8V if you divide by five that will give an input range of 0 - 1.76V to the ADC. For a 12-bit ADC (assuming it's unipolar) you will have a total of 4096 discrete readings possible. For the 1.8V maximum or a reading of 4095 at the ADC that will be 440uV per reading multiplied by five = 2.2mV per reading.

Most ADCs tend to have an error roughly equivalent to the least significant bit being useless which is how I came up with the rough figure of 5mV effective resolution in the comment. However as Andy mentioned this can be improved via dithering. In this case I'd probably take the sum of four samples and divide by two to gain an effective bit of resolution.

The Atmel application note AVR121: Enhancing ADC resolution by oversampling has an easy to understand introduction to dithering. A few other things worth keeping in mind are:

• Make sure you don't use too high a value for the resistor divider (see the input impedance for your ADC) or otherwise use a voltage follower. Sometimes you can get away with exceeding the usual recommended impedance by selecting the ADC channel early and giving the sample and hold cap plenty of time to charge before taking the reading. That is often a useful technique in low-power systems.

• Make sure that the input from the battery to the ADC is well filtered and decoupled. That is usually as simple as adding a capacitor or two after the resistor divider to form a low-pass RC filter.

• If your system has components that have short but high current peak demands (such as a GSM modem) you might find it useful to implement a median filter to ignore the dips caused by that and any potential spikes caused by switching power supplies and the like.

• Did you mean divide by four at the start? Also, I'm trying to follow your working to get the resolution after scaling. I get up to the point where you multiply by five to get a step of 2.2 mV/reading. Where does this x5 factor come from, the divider? Could you also explain the bit about disregarding the LSB and coming up with 5 mV effective resolution? – Mr. Anderson Jan 24 '14 at 8:15
• @user35985 Yes that comes from the divider, 8.4V / 5 = 1.68V so I just picked a round number that makes sure it doesn't go above 1.8V and gives a little safety margin, but you must mutliply it back to get counts per reading. For dithering you can take 4 samples and divide by 2, you get double the reading (which doubles the count per reading) and that helps increase the resolution. Many ADCs have an error of +/- 1 on the LSB plus a few others, you need to check the datasheet to be sure so 5mV is just a guess, but dithering can help there so either way you should be under 5mV. – PeterJ Jan 24 '14 at 8:24
• It can all get a bit confusing but for a start I'd just use a simple resistor divider and see how it goes, then you can make other changes such as the dithering and the low-pass filter and compare versus a multimeter to see how worthwhile those steps are to get the extra resolution. – PeterJ Jan 24 '14 at 8:28

If 4V4 should be the maximum and result in 1V8 , you should divide the voltage with 2 resistors.

Let's say u want 1V1 as maximum, then you can use a 330K-100K resistor in series, the voltage over your 100K will be 1/4th. A 12 bit ADC will give you superb resolution :) Probably a 33K - 22K will do fine to.

D.

• Resistive dividers in the input of an ADC should be determined with regard to the recommended impedance suggested by the ADC device manufacturer in order to introduce a low error. High value divider can prevent the proper charge of the sample & hold capacitor. – alexan_e Jan 23 '14 at 9:39
• Those "4V4" and "1V8" ways of expressing voltage are really annoying to read. This is a English language site, so using a period between the integer and fraction digits is unambiguous. – Olin Lathrop Jan 23 '14 at 13:05

Taking it to extremes, using a 4:1 voltage divider gives you 1.1 volts for an input of 4.4 volts. If 1.8 volts is the max input then 1.1 volts represents 61.1% of full-scale and with 12 bits resolution you have one bit = 4 x 268$\mu V$ = about 1mV.

Given that successive measurements will not give you exactly the same result, you can average to get better resolution - this is called dithering and makes use of the random nature of noise in your measurement system.

Other reference to dithering from wikipedia here