Instructables

How to use an op-amp?

Hi,
I've got an op-amp, the part number is OP07CP and I am trying to use it to amplify a voltage by around about 200 times. My set up is 6v going into a voltage divider with one resistor of 100ohm and a variable resistor of 10,000-50,000 ohm, so the output is 10mV-50mv. What I want to do is have the op-amp proportionally increase the voltage, so it goes to a voltage range of 1-5v, which an arduino can read. The power supply is  5v (from the arduino) and the powers both the voltage divider and the op-amp. For some reason, following the simple non-inverting op-amp configuration I just can't get it to work. Do I need a separate power source for the amp? I think it might have something to do with the fact that the amp's ground, input and negative are all just going to the arduino's ground. What can I do to fix it? If someone could help or even give me exact values and configurations of components that would be fantastic.

I know that the amp and divider seem like a pointless complication if was just trying to measure the output of the variable resistor, but if you knew the greater extent of my project it would make more sense.

Cheers

So the signal you want to amplify and measure is a small DC voltage, right?

Offset

For op-amps there is typically this small offset voltage at the inputs.  The magnitude of this offset voltage varies depending on the design, model, of the op-amp.  Also some op-amps, including your OP07CP, have some additional inputs for attaching a potentiometer, for the purpose of zeroing this small offset.

I found my copy of datasheet for OP07CP here:
http://www.alldatasheet.com/datasheet-pdf/pdf/27256/TI/OP07CP.html

and in Figure 1, on page 6 of that pdf, there is a circuit showing a 20K pot attached to these adjustment pins on the op-amp.

Low pass filtering

Another thing that might help is to add some large capacitors for to low-pass the DC signal you want.  I mean your laboratory or garage might have large amounts of 60 Hz noise, so you might choose the "corner"  frequency for your low pass to be around 6 Hz or so.

You can also maybe implement some low pass filtering on digital side, i.e. just write the Arduino script so it outputs an average voltage measurement, like over the previous 10 samples, or 100 samples.   A moving average is a kind of low-pass filtering.

Other ideas

There exist other techniques for measuring small DC voltages.  One of these is the "chopper stabilized op-amp".  I have not tried those, but supposedly they use some kind of magic (maybe using feedback?) to eliminate DC offset.

Also the problem of measuring thermocouple voltage is essentially the same problem; i.e measuring a millivolt or microvolt sized DC voltage.  I'm not totally sure how thermocouple instruments are built, but searching for those kinds of circuits might offer some clues.
makincoolstuff (author)  Jack A Lopez1 year ago
Thank you, very informative answer. Also, is it possible to use just the 5v from the arduino, (Although I can only go around 1v under the supply voltage) or do I need to have a positive voltage, negative and ground? Does that make sense? So basically, can I just have ground and negative as the same lead?
I think Steve is right about the about the supply rails, and the fact that this op-amp wants, or rather needs, to run from a dual supply.  In fact that might be the reason why your circuit has not worked so far, and the effects of the stuff I mentioned, input offset, AC noise,  is less important.

I think the easiest way to test this hypothesis would be to build a dual supply using two 9-volt batteries, and also measure the DC output from the op-amp using a cheap digital multimeter, rather than the Arduino's analog input.   Let me know if you want a circuit diagram or picture of what this setup would look like.

Using just a mulitmeter also makes this circuit less complicated than it would be connected to an Arduino, which is maybe also connected to a PC's USB port, if that is how you are actually reading voltages, via Serial.print, or something like that.

It may turn out that this op-amp really does have to have a dual supply for it to work, and I'm sorry if that's annoying, but op-amps that require a dual supply, and those that require supply rails a few volts greater than their input and output ranges,  are kind of annoying in that respect.

BTW,  I think the secret place in the OP07's data sheet, the one I mentioned previously, wherein this ugly truth is revealed,  I think that's on page 4,  on the lines for VICR (common-mode input voltage range) and VOM (peak output voltage).  This whole table was produced using supply rails at +15 and -15 volts,  and for both the input voltage range and output voltage range, those only go to within 1 or 2 volts of +15 and -15.

I admit the data sheets for these things can be arcane and confusing. That's part of the reason I suggest actually testing this op-amp in a circuit with a dual supply (and testing it without one) to see if this offers some clues to how it actually works.
makincoolstuff (author)  Jack A Lopez1 year ago
Ok, i tried the two 9v batteries and a multimeter and it worked with a voltage divider. But when I tried a wheatstone bridge I couldn't get it to work (sorry for the change of mind, but I now realized I need a bridge not a divider) so I was wondering if you wouldn't mind drawing up a diagram on how I could wire that? I think I'll end up just using a 12v NiCd or NiMH battery and tapping three leads in it so I can have a split supply system. I can also use the arduino now to measure the output, but I guess I won't be able to use the arduino as the power supply.
I am glad to hear your op-amp is working, can be made to work.

So you want to measure the DC voltage difference between two nodes of a Wheatstone bridge?  Also this voltage difference is small ( a few 10s of mV) so it would help to amplify that voltage into a signal of a few volts in magnitude.  Also it would help to make this voltage in the range 0 to +5V, so it can be measured by a Arduino's ADC (analog to digital converter).

I have not built many circuits with both Wheatstone bridge and op-amps together, so I thought I'd try Google(r) images, and see what turns up:
https://www.google.com/search?hl=en&tbm=isch&q=wheatstone+bridge+op-amp

I have attached one of these circuits to this reply.  The image search turned up a bunch of circuits similar to this one, but I'd just pick one to attach here.  This image was copied from here:
http://electronics.stackexchange.com/questions/15292/scaling-analog-signal-before-adc-a-low-cost-low-pin-and-component-count-soluti

I have not yet calculated the gain of this circuit, in other words, Vout from the op-amp as a function of those other voltages and R1, R2, R3,R4, R5, but I like the way this circuit looks. 

The thing I like the most , is it looks like it should be possible to choose the resistors so as to make Vin+ on the op-amp close to half the difference between the supply rails.  E.g. if the rails were at +12 and 0, make Vin+ close to +6 volts. 

The reason this is nice is because it puts Vin+ (and also Vin- via feedback) well inside the common-mode input range for your op-amp.

Also, I think, when the bridge is perfectly balanced, the output from the op-amp, Vout, will be the same value; i.e +6 volts.

Then you could use a voltage divider, to divide Vout by maybe 1/2 or 1/3, so Vout-balanced is around 3.0 or 2.0 volts respectively,  to bring it into the 0-5 volt range that can be measured by your Arduino's ADC. 




wheatstone-op-amp-thermistor-amplifier.gif
makincoolstuff (author)  Jack A Lopez11 months ago
Okay, so I had to put the project on the shelf for a while but today I got it working. So I have two half bridge load cells hooked up into a full bridge. Then, I managed to get the op amp to amplify it perfectly. However, I did need to use two 9V batteries to power the amp for + and - and ground. That is not really a problem, but whats annoying is that I couldn't get it to work with just the two batteries. The bridge required a separate battery for excitating, because, since in an inverting op amp the negative side of the bridge is connected to ground, if the negative excitation is also connected to ground it just skips a whole resistor. Any ideas on what I could do to fix / avoid this.

Secondly, The bridge can be off by 3mV from 0, which is bad because it means I'll have less resolution in my arduino. Also, since arduinos can't measure negative voltage, It won't read anything low pressure if the bridge starts in the negatives. Any ideas on how to "zero" it. Maybe with those null pins. Or even better, using the arduino to do it digitally some how, mabey by controlling the null pins

Thanks Again
What are the approximate size of the resistors in your divider or bridge, and by what ratio does it divide the excitation voltage?

I mean if it were a divider with resistors R3 and R4, with R3~=R4 then it would divide the excitation voltage approximately in half. So if it were connected it between +5 volts and 0, the same supply as the Arduino, it's output voltage would be close to 2.5 volts.  

And that would be convenient because you could set the voltage at the non-inverting input of your inverting amplifier to something close to 2.5 volts.  Then the amplifier's output ,when the bridge is balanced, would also be close to 2.5 V.

But even if the ratio in your divider is something different from 1/2, there are other tricks for shifting voltage levels around.  

Usually I solve these things by throwing more op-amps at them.   There is short list, of about 10, basic circuits that can be built from op-amps.  This page
http://en.wikipedia.org/wiki/Operational_amplifier_applications
lists most of them.
For example if the output of one amplifier is at the wrong level, and also needs to be inverted, I can fix that using a summing (inverting) amplifier,
http://en.wikipedia.org/wiki/Operational_amplifier_applications#Summing_amplifier
or maybe a difference amplifier,
http://en.wikipedia.org/wiki/Operational_amplifier_applications#Differential_amplifier_.28difference_amplifier.29
Also if I need a source of some arbitrary constant voltage, I can make that by using a voltage divider followed by a follower.
http://en.wikipedia.org/wiki/Operational_amplifier_applications#Voltage_follower_.28unity_buffer_amplifier.29

Anyway, I hope this helps. 

If you can tell me the approximate, or nominal, size of the resistances in your load cell, and how it divides the voltage you put across it, I am kind of curious about that.

BTW, I have never worked with load cells before, but I found this,
http://www.transducertechniques.com/wheatstone-bridge.aspx
via the Wikipedia page for "load cell"

makincoolstuff (author)  Jack A Lopez11 months ago
Wait, Oh!!!! Figured out the issue about needing lots of batteries. I was using an inverting amplifier set up, this measured between ground and +, however, in a bridge ground is separate the the sensor terminals, so I was needing multiple batteries. With a differential op amp set up I can have ground separate and measure the difference between the two terminals. Only problem I have left now is setting the Load cells to Zero at rest.
makincoolstuff (author)  Jack A Lopez11 months ago
Thank you very much. You don't need to go so in depth, but I'm not complaining. Anyway. The cells have two resistors in them of 1k ohm. With at 20kg I they vary about 1 ohm at the most. I haven't actually done the math to work it out.
+1. The OP doesn't seem to believe me....

The OTHER killer factor people don't know about is "Slew rate"
In this case, with this amp, no, ground and negative can't be the same, and if you want to use the full input range of the ADC, the positive rail needs to be higher too.

There ARE "rail to rail" amps that can do this, but the OP-07 isn't one.
Chopper stabilised amps measure and adjust their own offset voltages using internal switches and capacitors. Great for DC operation
...and add to all that Jack says and point out that the output of the amp can't go closer than a volt or so to the supply, so here, it can never be less than 1volt or more than 4