3
\$\begingroup\$

I have an input voltage signal from a conductivity sensor (output between 0 to 2.3V) which I am need to measure using the ESP32 ADC input. Unfortunately the ADC on the ESP32 is pretty crappy and can only measure signals greater than 0.15V. Therefore I am trying to scale the input signal and add a small offset to it so that I can measure low values as well.

To do this I have made a three resistor voltage divider which I found online. If I remove the op-amp, this works perfectly. However I need the op-amp as without it the load affects the voltage output from my sensor.

The problem I am facing with this design is that at low input voltages, the LM324 does not seem to work. I have played around with various resistor values and my findings are below:

schematic

simulate this circuit – Schematic created using CircuitLab

Testing results

In the case of lower resistors, the circuit was unusable till the input voltage was 0.4V. In the second case with higher resistors, the problem only occurred below 30mV, but still occurs.

From my research, I understood that the LM324 has a limitation of going near the upper rail, but not the lower rail (ground). In my case as well, if I remove R3, then the opamp successfully works perfectly and as expected even at a 10 mV input signal.

Can somebody please help me to understand what is happening. If I want to solve this, can I make some changes to the circuit, or do I need a different op-amp? In that case, what specification in the op-amp datasheet do I need to be looking for? I dont understand very much about opamps yet but am trying to learn!

Thank you!

\$\endgroup\$
1
  • \$\begingroup\$ Why dont you add the offset voltage to the input of the OpAmp? \$\endgroup\$
    – Daniel K
    Commented Nov 10, 2021 at 13:05

3 Answers 3

2
\$\begingroup\$

If you do something like this, you will be able to get much closer:

schematic

simulate this circuit – Schematic created using CircuitLab

The above circuit will give you approximately Vin*0.315+0.165V, with some slight error below 50mV in.

Probably good enough for the lousy ADC in that chip.

Below about 600mV out the LM324 has only a (nominal) fixed 50uA current sink to pull the output low, and even that will saturate at some tens of mV.

enter image description here

I would generally not trust even R-R output op-amps very close to the supply rails, the gain and other characteristics change significantly and you could get oscillation, for one example which I have observed. A CMOS-output part might be a better bet than a bipolar R-R output part. You could consider adding two op-amps if the divider is deemed too high impedance for the ADC input, one just as a buffer.

If, at some point, you need real precision near 0V, there's no substitute for bipolar supplies. Or a negative voltage reference. A 7660 + LM4040 would make short work of this for a bit more cost.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for the detailed analysis. I will try out the circuit you have suggested and post my findings shortly. \$\endgroup\$
    – ankGT
    Commented Nov 11, 2021 at 10:29
  • 1
    \$\begingroup\$ Apologies for the delay in marking this as the accepted answer. Got busy with other things so couldn't try it it. It seems to be working though. Had to add an additional buffer in the end as you suggested! \$\endgroup\$
    – ankGT
    Commented Jun 1, 2022 at 6:52
1
\$\begingroup\$

Andy already addressed the problem with the expected values, so I'll point out another limitation regarding the op. amp.

 "if I remove R3, then the opamp successfully works perfectly 
 and as expected even at a 10 mV input signal."

When you do that the op. amp. output will only source current to GND through R1 and R2. Check the current direction in this simulation when R3 is connected and V1 varies from 0V to 2.3V:

enter image description here

enter image description here

A possible explanation for the difference you see when using resistors with larger values is the current sinking capability of the op. amp., which is quite low for the lower voltages:

enter image description here
Source: TI datasheet for the LM324

You did well by checking the input and output voltage limitations, but current limitation may also be a problem.

The op. amp. you mentioned in the comment also has similar limitations (and this is what you should always expect):

enter image description here

You can find op. amps. which can really accept 0V at the inputs (or even a few hundreds mV below), but don't expect the same reach at the output. You may also consider other issues, like input voltage offset. Is it worth measuring 20mV with an op. amp. which may have \$\pm\$4mV offset?. I'd like to suggest that you (re)evaluate your precision requirements to know if you can simply ignore these errors at the lowest part of the measurement range or maybe reconsider the circuit topology.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Thanks for the analysis. It makes sense. Unfortunately even with the smaller values I still have an error in my output when the input is smaller than 30mV. I am trying to find an alternative amplifier which will sink more current but I can’t seem to find this data easily. For example the MCP6001 part which I found in digikey does not seem to specify this. Are you aware of any part which might work? ww1.microchip.com/downloads/en/DeviceDoc/… \$\endgroup\$
    – ankGT
    Commented Nov 10, 2021 at 16:27
  • \$\begingroup\$ @ankGT Added some info to the answer. I'd like to kindly recommend that you evaluate your requirements to decide if you need a different circuit (e. g. split supply, changing the sensor connection etc); \$\endgroup\$
    – devnull
    Commented Nov 10, 2021 at 16:56
  • \$\begingroup\$ @ankGT To be clear: the smaller resistor values are the ones with the worst error due to current outputs. When you increased the resistor values, the circuit behaved closer to what you expected. \$\endgroup\$
    – devnull
    Commented Nov 10, 2021 at 17:04
0
\$\begingroup\$

In the left hand side of your table you have this scenario: -

  • R1 = 1k
  • R2 = 3k
  • R3 = 10k

And, when the input voltage is 0 volts, you have an expected output voltage of 245 mV. This has to be wrong because, when Vin = 0 volts, R1 and R2 are in parallel and have a net resistance of 750 Ω (1000 || 3000 = 750).

This forms a potential divider with R3 (10k) and, with 3.3 volts at the top of R3 you should get this: -

$$3.3\text{ volts}\cdot\dfrac{750}{10000 + 750} = 230\text{ mV}$$

So, there is an error at the beginning of your calculations because you are expecting 245 mV.

I suggest you go through some more calculations then, check the resistor values you have fitted.

\$\endgroup\$
1
  • \$\begingroup\$ Apologies, I had mistakenly copied the wrong table. I edited the post to reflect the correct data. Also, the "expected value" is what I have actually measured using only the voltage divider, a voltage calibrator for the input signal, and my fluke multimeter to check the output. \$\endgroup\$
    – ankGT
    Commented Nov 10, 2021 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.