Gain variation problem using LM358P

Hello,

I have designed a PCB to read oxygen galvanic sensors, the output for this sensors is in mV (0-100mV).

I'm using the attached schematic connection. (Non inverted amplifier)

-Sensor positive to the non-inverted input of the LM358P and parallel with a 10k pulldown resistor.

-Sensor Negative connected to ground

-Inverted input connected to 1K to ground and to the output through a 10k resistor. (gain of 11).

-The output is connected to the uC analog input.

As the chip has 2 amplifier i'm connecting 1 sensor to each.

The kind of resistors Im using for this are an array of resistor for the 10k pulldown and RF resistors (this ones: 10k array resistor) and another array resistor for the 1k resistor (this one 1k array resitor). As I needed to read 10 sensors.

The problem is that when I connect one sensor the measurement is ok, but when I connect more than one the measurement is not accurate. The gain varies down and different on each Opamp. Why would be this happening?

Im also attaching the PCB layout.

Thanks beforehand for any help

IMG-9285.jpg|3618x1285

PCB O2 LO.png|999x781

Your links aren't working for me, but check those resistor arrays with an Ohmmeter to make sure they are connected correctly.

The 1K resistor packs can have a common connection (to ground) with 9 resistors in a 10-pin package. The 10K feedback resistors have to be isolated with 5 resistors in a 10-pin package.

If your op-amps are socketed remove them for more accurate resistor measurements.

Looking at the PCB layout, I can't see a connection to pin 1 of the resistor network that you have designated as R3.

If this is not connected to GND, then there will be complex interactions between all the opamps.

Here are the links corrected:

10k array resistor

1k array resistor

Hey, thanks for the link corrections.

The GND pin you see without connection is connected through the plane to Ground but I shelved it to a better visualization. Sorry for not quoting that.

I will measure the resistors tomorrow and post what I found. Thanks for the answers and ideas!

Your schematic does not show the power supplies. The LM358 does not work rail-rail so you will need to provide a negative supply voltage to the op amps.

Alternatively you could pull the op amps and replace with something like MPC6002 which will work rail-rail, and just use +5 and 0V for the op amps.

Using Operational Amplifiers in your Arduino project

Hello, I have measured the resistors and the 1k resistors measure 1k only in the last pin but the others are almost 2k. It seems to be well soldered and I have other boards and have the same issue. Don't know whats going wrong on the design, it should work according to what I know. What could I be missing?

Hey Johnerrington, my power supply for the opams are 5V for VCC and 0 for Ground.

johnerrington: Your schematic does not show the power supplies.

I think they've been included now - however the rail traces are too thin and there's no decoupling supply traces should be wide to reduce their inductance and resistance and every chip needs decoupling close by.

The LM358 does not work rail-rail so you will need to provide a negative supply voltage to the op amps.

No, the LM358 specifically works down its -ve rail for inputs and outputs - its not rail-to-rail, its "single-rail".

Should I add some decoupling capacitors to the input VCC pin of the Lm358p? which values could you suggest?

I'm posting a larger view of the pcb layout, with and without the planes. The planes are GND top and GND bottom. It is to layers PCB. The width of the tracks are 0.3mm, which width would be ok on this case?

|500x307

|500x419

ext_pcb.png|691x425

ext_pcb2.png|695x583

0.3mm is 12 thou, 32 or 40 thou is more common for supply traces, ie 1+mm. If you
look at a few commercial PCBs you’ll see this is standard practice. Its also handy for
troubleshooting as you can spot the supply traces for probing voltage easily without having
to cross-reference the layout all the time.

If the Vcc of the opamps is shared with digital I’d add 100nF ceramic and bulk decoupling
like 47µF…220µF electrolytic.

Decoupling is something you are expected to know about in electronics, yet many introductory
examples are oversimplified and ignore it. To my knowledge the LM358 is too fussy about
decoupling, but many faster opamps require it as a matter of course.

BTW you never said how much gain variation you are seeing, nor whether you’ve checked for
input offset variation (which is a different thing).

The resistors you use are +/-2% so the worse case difference between channels could be upto 8%
just from the resistor tolerances - you do realize? In practice the worst case is unlikely, but possible.

The worse case offset voltage for the LM358 is +/-7mV, which after 11-fold gain will show as +/-70mV,
in other words a worse case channel difference of 140mV.

I have measured the resistors and the 1k resistors measure 1k only in the last pin but the others are almost 2k.

That would lead me to think you have the resistor pack connected incorrectly.

Hi, Have to breadboarded your project before going to PCB. Have you checked that just one of your O2 sensors signal will be amplified to your needs?

Can you please post a schematic of your project so we can compare it to your PCB?

This is the OPs resistor array.

|374x500

|365x500 Thanks.. Tom... :)

resistarray.jpg|449x599

resistarray1.jpg|435x595

Hi, What Arduino controller are you using? Are you reading each analog input sequentially together, that is read A0 read A1 read A2 read A3 etc.

You may be having the typical analog read problem that follows the use of these ADCs. The Arduino has ONE ADC, it multiplexes the inputs to this ONE ADC. There is a bypass capacitor on the input of the ADC, it causes a lag in the change in values from the analog inputs and causes errors in readings. The solution is to read each input twice, to give the ADC time to stabilise to the next input. For example

read A0 read A0 read A1 read A1 read A2 read A2 read A3 read A3 etc.

We need to see your code. What happens if you remove the sensors and place say 50mV DC on every second input, and let the others go to gnd.

Have you checked that 0mV reads as 0mV on the output of the op-amp?

Tom... :) PS. As mentioned you badly need to add bypass capacitors to each of the op-amp chips.

TomGeorge: Hi, What Arduino controller are you using? Are you reading each analog input sequentially together, that is read A0 read A1 read A2 read A3 etc.

You may be having the typical analog read problem that follows the use of these ADCs. The Arduino has ONE ADC, it multiplexes the inputs to this ONE ADC. There is a bypass capacitor on the input of the ADC, it causes a lag in the change in values from the analog inputs and causes errors in readings. The solution is to read each input twice, to give the ADC time to stabilise to the next input.

This trick is entirely unnecessary here, as its only needed if the source impedance is larger than 10k, and the output of an opamp is about 0.1 ohms.

The real issue is that the sample/hold capacitor (14pF) has only about 2µs to equilibrate with the signal when you change to a new analog pin in analogRead. For 10k or less the timeconstant is <= 140ns, allowing settling to full 10 bit accuracy during the 1/2 period of the ADC clock (2µs) between the analog multiplexer switching and the ADC conversion starting. If you read again on the same pin the time available to settle is 110µs, so source impedances of 0.5M ohms are handled if you read twice.

For 0.1 ohm or so of an opamp output, not an issue in the slightest.

Hey guys, I'm reading all your suggestion and taking notes so I can try everything and come back to post the results. I will post the schematic, and the code.

I'm using an Atmega2560 with a crystal of 16Mhz.

Thanks for all your answers.

I don’t know to which extent it can be problematic but with this kind of sensors some would say that you need electrical isolation between probes. I can’t explain it but somehow electrical current going into your galvanic cell can also move in the water and interfer with the other sensors around. At*as-Scient**ic sell isolator for this exact purpose when for example you want to measure oxygen and conductivity in the same sample. With 8 side by side probes, you may need this? One way to test for this effect would be by putting each probes in a separate container and see if the problem persist?

good luck

Hey guys I'm back with some updates. One of the boards is ok, I have measured the resistors on this one and their values are as they suppose to be. So in conclution, the problem are the resistors on the other ones.

Anyhow, this helped me to take note of some improvements I need to do like making the supply tracks wider and to use decoupling capacitor for the opamps.

I'm very greatful with you all because you gave me ideas to start checking and good advices.