Voltage divider with offset

1. Nov 13, 2016

Rx7man

I'm working on an Arduino project to read automotive battery voltage,.. I could use a simple resistor divider circuit, but I'd lose a lot of resolution (you aren't going to see <8V very often)..
Could anyone take a look at this and tell me if it's a reasonable method?..

Channel A (Blue) is 5V/div
Channel C (Red) is 10V/div
Frequency is 1khz, which is plenty fast enough for what I need

It seems to have good linearity from 10-20V, I will use a multiturn trimpot for R3, 1/4W metal film resistor for R1
It should give me a resolution of about .015V in the working range, I'm fine with that.
Is there anything I'm missing that could come back and bite me in the arse?

2. Nov 13, 2016

Averagesupernova

I don't think a zener diode is precise enough to do what you want. Temperature changes will bite you in the butt. You could use a precision reference or a plain old voltage regulator and feed an op amp with both the reference and the divided down sample voltage for a differential amplifier. Set the gain of the amp so you get the range you want. I suppose the alternative would be to use the zener but run it pretty hot to minimize external temperature effects. You will obviously not be using resistor values that you have chosen and will be wasting some power. There are some precision references that are used in circuit similar to a zener diode. That could also work depending on whether or not they are available at the offset you need. If you want a true offset you cannot have the pot where you have it placed when using a zener type device. It will not only have offset but will form a divider. When you dial the pot to correct for the offset you have also changed the ratio of the voltage divider.

3. Nov 13, 2016

Rx7man

Thank you, exactly the kind of bite-my-arse things I wanted to know about...
In this instance I can afford to put some power through it, I changed R1 to 57Ω and trimpot to 100Ω fixed resistor.. This yields about the same curve, but increases the current through D1 to about 200mw average and 50mA

I'm really limited for space for breadboarding this together, which is part of the reason I am trying to keep component count down.
How drastic would the temperature change this? It's primarily for display purposes, though in the distant future it could be for charge control as well, Is the penalty of decreased resolution (20V/1024 = 19mv) from a plain resistor divider going to pay off in thermal stability? It's kinda looking like it to me (and the bonus of even simpler)

4. Nov 13, 2016

Rx7man

I tried referencing the lower leg of R3 to ground instead of the wiper, but what I found was it really affected the linearity in the lower range

5. Nov 13, 2016

Rx7man

Here, Is this more like what you had in mind @Averagesupernova ?

The 2.5V supply would actually be an LT1004-2.5V bandgap reference diode which I just happen to have, though I don't have a model for it http://cds.linear.com/docs/en/datasheet/1004fb.pdf
The op amp I would use is a very linear OP77FP, 140dB gain, 130db CMRR/PSRR (I happen to have some)

6. Nov 14, 2016

Averagesupernova

That looks about right. Set R5 so that the middle of the range you want to measure will put 2.5 volts on the non inverting input. Set R1 to put the range you want to measure within the useable range of the op amps output. Once you have everything dialed in, get rid of the pots and use fixed resistors. Use precision if you think you need them.

7. Nov 14, 2016

rbelli1

The difference in price between 5% and 1% is so small just go for the 1% ones. Even though they are almost double the price they are pennies either way. Unless of course you are making this in bulk. Then it will be a consideration.

BoB

8. Nov 15, 2016

Rx7man

They're so cheap I bought a 1500pc metal film 1% just to have them in stock. I'm not planning on making this in bulk

9. Nov 15, 2016

Staff: Mentor

Important Tip -- it is bad design practice to have the wiper of a potentiometer go into the input of an opamp.

Quiz Question -- Why?

10. Nov 15, 2016

Staff: Mentor

Quiz Question #2 -- What value of Zener diode has almost zero tempco?

11. Nov 15, 2016

Rx7man

I'd love to know the answer to both!

For #1, I can take a stab at it.. If the wiper would somehow fail, it would leave the op-amp input floating?

12. Nov 15, 2016

Staff: Mentor

Nope, but it's not an obvious point at all. I learned the reason many moons ago after I had a potentiometer circuit like yours fail after working fine for over a year. Turns out that potentiometers have a minimum wiper current that is required to keep the contact from corroding. The minimum current is often over what is drawn by opamp inputs (especially FET opamp inputs). Here is the place that I finally found that described:

http://www.bourns.com/docs/default-document-library/bourns_trimmer_primer.pdf

And on #2, try doing a Google search on Zener Diode Tempco and see what the graphs or tables say... Turns out the Zener value with the minimum tempco is just about what you need for your battery offset circuit...

13. Nov 15, 2016

Rx7man

Good read, and I'm going to have to keep it handy for reference.. So from what I see in there my shot in the dark was pretty accurate.. connecting to the wiper alone could cause a floating and unpredictable failure where the output of the op amp could damage downstream devices

I've found something from Micro Semiconductors on Zener tempco.. I'll read it in a bit and study it, and see how temp drift would affect me in this instance

14. Nov 15, 2016

Baluncore

It depends on the manufacture and material, but silicon is usually quoted at about 5.5 volts.
The problem comes in specifying the reverse current used to characterise the zener voltage and the current then used to operate the diode in a real circuit.

15. Nov 15, 2016

Rx7man

So if temperature stability were your goal (more than cost), you'd be better to get a 15V Zener by putting 3x 5V Zeners in series, or a 2x 3V and a 10V depending on the thermal characteristics.. Is that ever done?

16. Nov 15, 2016

Baluncore

Not often used. Better to use a zero tempco current from a TI REF200 or an LM334 current reference with a diode.

If you want for example, a B+ range from 10V to 15V with full resolution, then you must subtract 10V from B+ and use the 0 to +5V range of the A-D converter.

But, you may have some flexibility with the Vhi and Vlo reference points of the microcontroller's A-D converter.
Say you use a 1:3 ratio attenuator made from three identical resistors. When B+ = 15V you will have +5V to the converter. When B+ = 10V you will get 3.333V to the A-D converter. If you then use Vhi at +5V and Vlo at +3.333V you have the extended range with full resolution.
Depending on the impedance of the A-D converter reference inputs, you may produce the 3.333V by using another three identical resistors.

17. Nov 16, 2016

Rx7man

Now we're going far more into this than I think is necessary for the particular application, but I'm learning a lot and enjoying it....
With many A-D convertors, you can't set the Vhi and Vlo for individual inputs, perhaps for a bank (or all) of them it's possible.
Many controllers also have a regulated 3.3V pin as well as the 5V supply, for simplicities sake you could maybe use that as an alternate reference point. I think in most cases you're probably best off pulling the 5V reference power from the microcontroller power (since it's usually linked to that analog Vhi reference), so that changes in supply power are compensated in the ADC.. As for the V-lo pin, Would that usually be called A-Gnd? I'm not sure if all microcontrollers like to have that pin at a significantly different voltage than the rest of the grounds. I do like the idea of it though.. Some controllers have a differential analog input that you could use for the resistor bridge you mentioned as well.

I mentioned the LT1004 reference diode earlier because I have several, they're available in 1.200V and 2.500V

18. Nov 16, 2016

Rx7man

I've been poring over that Bournes pot tutorial posted earlier.. I'm at a bit of a loss at how to avoid connecting the wiper directly to the op-amp when you need a voltage divider... I've gone through my circuit and added another op-amp, and a few other things..

U1A controls the response slope alone, not perfect, but it's fed by a 6.8V limited supply, which clips the output around 5.3V, giving the microcontroller a fighting chance if someone messes up while adjusting. (like that would ever happen)
U2A controls the offset voltage alone, the 1.2V reference is a battery in this case, in reality it'll be the 1.2V LT1004 or similar reference

I'll be able to tweak the trimpot values a little with external resistors

19. Nov 16, 2016

Staff: Mentor

It looks like you've fixed the trimpot issue.

I'd be inclined to do this simply with a 5.1V Zener diode (hint-hint) as the reference, and a voltage divider with 1% resistors for the other side of the differential subtraction opamp stage. Sorry if I missed it in your posts -- what is your desired accuracy? And can you just calibrate it a bit in your uC code?

20. Nov 16, 2016

Rx7man

Yes, the code would certainly have to re-map the values, which is trivially difficult.
Here's what I consider "as good as it needs to be" for my purposes... 7-17V full scale with decent linearity, full clipping at 5.1V.. I changed the final op-amp to a higher quality one and it really helped the linearity.

I might just be getting the hang of this!

21. Nov 16, 2016

Baluncore

Here is a simple circuit that uses Vcc = +5V, along with 4 identical resistors and two identical PNPs to subtract 10 volts from the battery voltage. It produces a 0 to 5 volt Vout.

22. Nov 16, 2016

Rx7man

Interesting... so V1 is your variable source voltage, V2 is fixed 5V?

I'll have to draw that up and play with it a little :)

23. Nov 16, 2016

Baluncore

Yes. V1 is swept from 10V to 15V.

The Q2 emitter is held at Vcc = 5 volts.
Q2 is connected as a super-diode that will have a very similar Vbe to Q1.
The Q1 emitter is therefore also held close to +5V.
R1 sources a current = ( Vbatt – 5V ) / 10k
R2 sinks a current +5V / 10k

The difference current flows through R3.
Vout = 10k * ( ( ( Vbatt – 5V ) / 10k) – ( +5V / 10k ) )
Vout = Vbatt – 5V – 5V

24. Nov 16, 2016

Baluncore

Here is a similar circuit that uses an op-amp to eliminate the temperature variation between transistors.

25. Nov 17, 2016

Baluncore

And another that uses a 1.235V reference to subtract 10 volts from B+. Use a "rail to rail" op-amp to get close to ground.