Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LM358 Non-Constant Gain

Status
Not open for further replies.

tom_pay

Member
Hi Guys,

I have been experimenting with a very simple Op-Amp amplifier, based on the LM358. I would like to amplify a small DC signal ranging from about 10mV to approximately 70mV, with a gain of about 48, to be fed into a PIC's ADC. However in doing so I have found that the gain of the amplifier setup changes depending on the input voltage, the gain is not constant.

In an attempt to rectify my problem I have tried lowering the gain, adding supply capacitors and changing the Op-Amp chips, however all of this leaves me with the same problem.

So my question is, is it possible to make the gain nice and constant? Preferably without having to drastically change the setup, or if so, keeping it nice and simple. I have also attached a copy of the circuit I have been using.

Thanks in advance, :)

Tom
 

Attachments

  • Amplifyer.jpg
    Amplifyer.jpg
    36.8 KB · Views: 898
Last edited:
How much does your gain vary by? What is the output impedance of your driving signal (is the input bias current of the op amp loading the signal). Are you measuring the output of the op amp or the digital code coming out of the PIC (ie, could it be an ADC related issue, not an op amp one)? Are you measuring the output of your sensor with a high impedance meter (ie is your meter loading the sensor, so you are actually putting less volts into the amplifier). What does the output look like when you use it in unity gain? Also your gain will be 48
 
hi tom.
With a +5V single supply to a LM358, the maximum output voltage will be ~ 5V-1.5V , ie: 3.5V
Also the output of the LM358 will not go down to zero.

With a gain of 48 [ as shown] the 10mV offset at the input will appear at the output of the LM358 as 0.48V, so you circuit also needs a correcting offset to remove the 0.48Vout

If you used a 8V supply to the LM358, you could get the required +5V output.

A better solution would be a rail to rail OPA, like a MCP6002 [dual], powered from +5V, the outputs would swing 'close' to +5V and 0V.
 
Last edited:
Hi,

As others have noted, there are a few problems with the LM358 op amp. It's really just a general purpose op amp not really made for instrumentation like this without paying strict attention to details.

For one, you'll need a higher supply voltage to get a gain of near 50 with 120mv input, and you'll also need at least a small negative voltage if you need to get the output down to 0.000 volts. There are better op amps that will provide a better output range, but 120mv with a gain of 48 will produce an output of 5.76 volts, so you'd still need a higher power supply voltage like 6 volts at least.
 
Hi Guys,

Thanks for such prompt replies.

The gain varies from about 46, at 10mV, to 51, at about 60mV. At first I thought that it was insignificant, but when I re-did my maths it threw the PIC's reading out to a value that was unacceptable.

I have measured the sensor output voltage with and without the op-amp plugged in. As well as with the voltmeter connected and disconnected. Unfortunately it made no difference. :(

It is not the ADC, I have been doing all of my calculations with a voltmeter.

The 10mV offset is prefferred. The unit is therefore, easily calibrated at around 13mV and has an origin at 0,0.

I assume that the offset voltage of 7mV is the minimum voltage that can be amplified, which the sensors signal will always be greater.

The final output does not have to go to the full 5v, the 3.5V will be adequate.

Is a rail-to-rail chip going to make much difference to the output's linearity? Id rather not have to order in new components, I'm really excited about this project and would like to continue with it as soon as possible. :)

Thanks so much for your help,

Tom
 
hi tom,
For an OPA , the gain should not vary by that amount, 46,51.. There is another problem or perhaps the way you are measuring the input/output voltages.
 
Hi

I was measuring the voltages with a standard DMM on volts setting. As well as this the value the PIC was way off what is should have been.

The whole circuit was made on a bread-board, proto-board, press-in board, thingo, would this make any difference?

Thanks

Tom
 
Last edited:
Hi

I was measuring the voltages with a standard DMM on volts setting. As well as this the value the PIC was way off what is should have been.

The whole circuit was made on a bread-board, proto-board, press-in board, thingo, would this make any difference?

Thanks

Tom

hi,
The BB build will cause any problems on this circuit.

How is the 10mV thru 60mV being generated.?

If its a sensor, do you have details?
 
Last edited:
Hi,

Unfortunately I dont have any details on the sensor.

Instead of using the sensor, as its setup is annoying on the workbench, I have been using a 27K resistor, 1K Pot resistor network over the 5v supply. However, with the actual sensor I was still getting the same non-linear results, to the same extent.

Thanks

Tom
 
Last edited:
Do you have good ground connections? Are all the grounds connected closely together?
 
The wires and contacts strips on a breadboard are antennas that pick up mains hum and radio signals that arer amplified by the opamp.
All opamps have noise and the LM358 has more noise than better opamps. The noise is amplified and appears at the output.
All opamps have an input offset voltage. It is a maximum of plus or minus 7mV for the LM358 and is almost nothing on better opamps. The input offset voltage adds or subtracts from the input before amplification. Single opamps have pins to connect an offset voltage null trimpot.
 
Hi Guys,

Thanks for such prompt replies.

The gain varies from about 46, at 10mV, to 51, at about 60mV. At first I thought that it was insignificant, but when I re-did my maths it threw the PIC's reading out to a value that was unacceptable.

I have measured the sensor output voltage with and without the op-amp plugged in. As well as with the voltmeter connected and disconnected. Unfortunately it made no difference. :(

It is not the ADC, I have been doing all of my calculations with a voltmeter.

The 10mV offset is prefferred. The unit is therefore, easily calibrated at around 13mV and has an origin at 0,0.

I assume that the offset voltage of 7mV is the minimum voltage that can be amplified, which the sensors signal will always be greater.

The final output does not have to go to the full 5v, the 3.5V will be adequate.

Is a rail-to-rail chip going to make much difference to the output's linearity? Id rather not have to order in new components, I'm really excited about this project and would like to continue with it as soon as possible. :)

Thanks so much for your help,

Tom


Hi again,


As i said before, the LM358 op amp is a general purpose op amp and not really made for instrumentation type applications unless it is driven within certain limits and other details that have to be taken care of.

The problem you are seeing is probably due to the input offset voltage of the op amp. The input offset voltage acts to add or subtract up to 3mv from the input, but its effect would show up as non linearity (as you are seeing).
For example, say we have +2mv input offset and a gain of 50. For 10mv and 50mv inputs we get:
10mv: 10+2=12, 12*50=0600, 0600/10=gain of 60
50mv: 50+2=52, 52*50=2600, 2600/50=gain of 52

The above was with an input offset of +2mv, but it very well could be -2mv instead, but the effect shows up as the appearance of a change in gain. There are ways to help correct this to some degree.

This effect shows up more for low inputs like 10mv, but diminishes greatly as the input increases. For an input of say 100mv the effect on the gain would only be about 2 percent.

If you know the precise values of the resistors you can easily solve for the input offset voltage, but if not or there is some doubt you can use this:
Vio=(Vin1*Vout2-Vin2*Vout1)/(Vout1-Vout2)

where
Vio is the input offset voltage, and
Vin1 is the first input test voltage and Vout1 is the output voltage result of that input, and
Vin2 is the second input test voltage and Vout2 is the output voltage result of that input.
So you would apply a voltage say Vin1=10mv and record Vout1, then apply some other input Vin2 and record the output Vout2, then do the math.
 
Last edited:
Hi

I have put input and output low-pass capacitors to help with the noise, but I'm not sure if they were doing much.

So if I were to get a better op-amp with a small input offset voltage would my problem go away? Or reduce the problem to an acceptable degree.

Is it possible to, taking the input offset voltage into account, make the final output linear? Can I do something to my circuit to null the offset voltage?

Just out of curiosity, how it the offset calculated with the resistor values?

Thanks so much for your help,

Tom
 
The LM358 is old and cheap. There are thousands of much better opamps available today with much lower noise and an input offset voltage trimmed at the factory to be anmost zero.

All single opamps have two pins to connect a trimpot for you to null its input offset voltage.

The bias currents at the inputs of opamps that use ordinary transistors also cause an input offset voltage. It can be cancelled if both inputs have the same effective resistor values so that they have the same voltage drops. Opamps that use Jfet inputs do not have any input bias current.
 
Hi

I have put input and output low-pass capacitors to help with the noise, but I'm not sure if they were doing much.

So if I were to get a better op-amp with a small input offset voltage would my problem go away? Or reduce the problem to an acceptable degree.

Is it possible to, taking the input offset voltage into account, make the final output linear? Can I do something to my circuit to null the offset voltage?

Just out of curiosity, how it the offset calculated with the resistor values?

Thanks so much for your help,

Tom


Hi again,


Taking the input offset voltage into account the way it is now and because your input change is quite small, there's a trick we can incorporate that might work for your setup. (See attachment).

It looks like your Vio is negative, so you can try this...
Add a 22 ohm resistor in series with the non inverting terminal of the op amp. Your input voltage now connects to the open end of the 22 ohm resistor, not the op amp terminal.
Add a 100k ohm resistor from the +5v rail to the non inverting terminal of the op amp.
Recheck your gain for inputs of 10mv and 60mv.

The value of the 22 ohm resistor is somewhat arbitrary, and the 100k is approximate so you may have to tweek the 100k a little.
This assumes that your +5v rail does not change too much either, that it is regulated quite well.
If your input offset turns out to be positive, we would have to do something else, but it does look negative right now.
This also assumes that your driving source can drive 100k ohms without any problem. If it cant then you'll have to scale the 22 ohm and 100k up, possibly as high as 220 ohm and 1megohm.
If you change the positive supply rail you have to change the 100k resistor. For every 1v increase, increase the 100k by 20k...so for a 6v rail use 120k.

Im not sure what kind of accuracy you are after there either. You should do a temperature check to make sure the gain doesnt vary too much when the temperature varies over the expected range. This is true for any circuit you use.

One final note, if you swap out the op amp with a different physical package you may have to change one of the resistors (like the 22 ohm) because the input offset could very well be a different value for the new package even though it's the same part number. The values given above were for the op amp package you used when you posted your test results with the 10mv and 60mv inputs.
 

Attachments

  • AMPLIF-01.gif
    AMPLIF-01.gif
    9.8 KB · Views: 494
Last edited:
Hi

Thank-you very much Mr Al, I shall try that this afternoon.

I am not sure how it works, it is modifying the gain on the op-amp or is it adding a positive offset voltage to null the negative offset?

If it was positively offset, would it work by connecting the +5v side of the 100k resistor to ground work?


Thanks so much everyone,

Tom
 
Last edited:
If you connect the 100k resistor to ground then you will not cancel your input offset voltage.
 
Hi

Thank-you very much Mr Al, I shall try that this afternoon.

I am not sure how it works, it is modifying the gain on the op-amp or is it adding a positive offset voltage to null the negative offset?

If it was positively offset, would it work by connecting the +5v side of the 100k resistor to ground work?


Thanks so much everyone,

Tom

Hi again,

You're welcome :)

As audioguru points out, the connection to +5v is so that we can get a small positive voltage at the input to the op amp which hopefully cancels the negative offset. It's designed to be close to +1.1mv which is just the opposite polarity of what we thing is your negative offset for the op amp. If the 100k is connected to ground it wont be applying any positive canceling voltage so it wont work as well.
It does not change the gain very much because the 22 is so very much smaller than the 100k, and it is possible that the gain is already very slightly higher than you want it to be possibly due to imperfect resistors, so you may have to adjust the gain slightly, but that's an independent adjustment to the offset null. I dont know what kind of accuracy you are looking for here though, perhaps i should have asked more directly so we can get an idea what you are after.
 
Hi Guys,

I have tried Mr Al's resistor network and it works quite well the gain varies from about 47.8 to 49.2. So it is much better.

However I think that I should get some proper, low offset, op-amps. I have been searching a catalog of mine and I have found the LM833 which is a low noise dual op-amp. In the spec sheet it states a typical input offset voltage of 0.3mV. I then calculated that this should give me a gain of 48.2 to 49.4. Which whilst it still is not perfect it is acceptable.

Instead of using low offset chips, would two single channel chips with offset null capabilities be better suited? Such as the LM741? Would this give me absolute linearity? Or would the nulling pins not work without a dual supply?

Thanks heaps everyone!!

Tom
 
Last edited:
Hi tom,


Tweeking the 100k resistor should help to improve the linearity even better in case you end up sticking with that.
You might want to mention what it is you are trying to measure also.

With a single supply of only 5v you want to stay away from the 741 and other old style op amps. They have strict input vs power supply requirements which you dont want to get involved with unless you have dual supplies or something like that.

Microchip makes a pretty good very low offset op amp i think it is chopper stabilized. I assume you are measuring DC but maybe not. You could take a look on the Microchip site to find one. They come in dual and single. I worked with this op amp and it's pretty good.

I'll have to take a look at the LM833 next.

LATER:

That 833 looks like it is more for audio than measurement. It also might need plus and minus supplies, and the input offset is not 0.3mv really, it's 0.3mv to 5.0mv which is much higher than you want. 0.3mv is just typical.
Take a look at the MCP6V01 or the dual version 02.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top