Is differential op amp the way to go

Thread Starter

DonRecardo

Joined Dec 10, 2010
3
Firstly hello to everyone, this is my first time in the forum .
I recently retired and decided now I have more spare time I can try to learn more about electronics . I have never worked in the electronics field , but for many years have dabbled for a hobby. My main interest is programming MCUs

I know I wont learn much by just asking ,how do I do this and sitting back waiting for an answer. I will learn more working through it myself if I can just be pointed in the right direction.

Ok here is where I am stuck.
My aim is to measure a DC voltage and display it on an LCD. My plan would be to input the voltage to the ADC input of a pic chip and then diplay the results on the LCD . Up to this point I have no problem.
Here is where the problem starts . The ADC input has to be no more than 5v or the chip lets out the magic smoke , the voltage I need to measure is up to 30v.
I know I can get around this with a voltage divider , 1 resitor of 7.5k and one of 1.5K means a 0v-30v will reduce to 0v-5v , great just what I need . So where is the problem?
Using the 10bit ADC I can get 1024 steps of measurement, but in practice my input voltage will never drop below 20v so realistically I will only ever use the top 341 of 1024 steps . If I can some how lose the first 20v off the input so I measure only the 20v to 30v swing ( 10v ) then voltage divide that to half its value I still have a 0v to 5v input but the ADC result will be 3 times more precise because I am now using all 1024 steps.
My problem is I dont know how to lose those first 20v. I wanted to try to solve it on my own so did some searching on google . Unless I have lost the plot along the way I think my answer lies in an op amp , a differential input op amp. The trouble is I have never ever used an op amp in my life and I dont know how to go about it . My thought is that if I conect my 20v-30v input to the + input and fed an accurate 20v to the - input that the output would swing between the difference of the 2 inputs , namely 0v-10v. So,,,
1) Is the differential input op amp the best way to go about it
2) if so what would be a good amp to use ( I have 741s but I thought they were only good to about 15v
3) can someone tell me what to do about feedback resistors to set the gain and do I need to null the offset ?
4) if the fixed 20v on the - Input came on before the 20v-30v variable input was established would the output try to go 20v negative and destroy something or would it just sit waiting at 0v

I hope someone can help , I have tried to sort out as much of this as I can by my own efforts , and if what I am trying to do is totally wrong and I missundertood about the op amps operation then please excuse me , I did try my best

Regards
Don
 
Do you need better resolution than the ADC of the MCU is providing?

30V/1024bits ~ 0.03V/bit

Adding a 12bit ADC to the project can also be a fairly simple solution if you need more resolution. It will eliminate a lot of the complexity of the analog circuitry and put it in the programming end.

A resistor divider works well in this application. You will probably need to use a buffer amplifier in between the amplifier and the ADC so the input stage of the ADC does not alter the divider ratio. Make sure the amplifier is "rail to rail" input and output so it can take in and supply voltages from 0 to 5V. Or, are you incorporating other supplies into the project as well.
 

gootee

Joined Apr 24, 2007
447
Don,

Op amps (and analog electronics in general) are a great thing to learn all about. They can do a whole lot. Even if you do as much as possible with digital, the real world is still analog. So if you want to interface with it, then you will need analog electronic knowledge, skills, and abilities.

First, go to national.com and download Application Notes AN-20 and AN-31. They have a lot of the basic opamp circuits, including difference amplifiers (subtractors). Those are basically differential amplifiers, not to be confused with just an opamp by itself, which is rarely used except as a unity-gain buffer (output wrapped directly to negative input, possibly with a resistor to balance with the input impedance).

They don't show it in those appnotes, but you MUST use small capacitors from each opamp power pin to ground. For many applications, a 0.1 uF ceramic is good enough. Often, it's a good idea to parallel that with a 10 uF electrolytic. Connect them as close to the power pin as possible, especially the 0.1 uF.

The opamp model numbers in those appnotes are mostly very old, too. You can almost always substitute modern ones. And throw those 741 opamps away, PLEASE!

To really make it easy on yourself, and probably get much better results much more quickly, take a few days to learn LTspice, which is a free download from linear.com. You can quickly draw circuits and then run them. It's fantastic! There is also a user support group, at yahoogroups.com . (I have some links to thousands of other pspice component models, at http://www.fullnet.com/~tomg/gooteesp.htm .)

Regarding the offset, I would guess "yes", you will probably want to be able to adjust it. The appnotes I pointed you toward have simple circuits for doing exactly that. Regarding your overall approach, I think it should work to subtract 20 V and then divide by two to get 0-5V, then measure it and multiply by two and add 20 in software or firmware before displaying the result. Whether or not it's worth the trouble, for the added resolution (versus the circuit's likely precision), you'll probably want to calculate, or else somehow ensure. You might need to design a precision voltage regulator for the 20V, for example. You will probably want to include a small-value multi-turn trimmer potentiometer or two, somewhere, to calibrate the gain, or else match the resistors very closely out of a larger batch. Ditto for the divider. And, as someone suggested, use a buffer amplifier before the ADC input. Regarding applying the subtracted voltage before the input voltage was applied, the output should just go to or near zero, if you don't have a negative side to the power supply.

Later, you can look at Walt Jung's Op Amp Applications Handbook, which is downloadable in its entirety, from:

http://www.analog.com/library/analogDialogue/archives/39-05/op_amp_applications_handbook.html

Have fun!

Cheers,

Tom Gootee
 
Last edited:
Top