So before adding an op-amp buffer between sensor and the non-inverting input of a schmitt trigger, if the output of the sensor was for example 0.4V, the moment I connected it to the non-inverting input somehow the output of the sensor would suddenly become about 2V. Ater I added the buffer the problem was solved and the output of the sensor didn’t change anymore. So I have done some reading on buffers applications but can’t really understand what’s going on here and why buffer was the solution.
\$\begingroup\$ what is your load R , C , L (Zf) ? more than OPAMP rating? \$\endgroup\$– Tony Stewart EE75Mar 26, 2018 at 22:49
1\$\begingroup\$ what is the output impedance of this sensor? \$\endgroup\$– user16222Mar 26, 2018 at 22:49
\$\begingroup\$ Most sensors need a buffer and possibly amplification and scaling as well. No surprise here. Read the datasheet on the sensor for hints that a buffer is needed. \$\endgroup\$– user105652Mar 26, 2018 at 23:01
\$\begingroup\$ I don’t know the answer to these, I’d appreciate some general clues as to what could be happening so I could do further reading on them, don’t want to dig too much into the details as it will probably be too advanced for me. \$\endgroup\$– BigRedMachineMar 26, 2018 at 23:02
\$\begingroup\$ BRM: In your schematic what is the "buffer"? I'm imagining it is the NPN transistor connected to the output of the op-amp/Schmidt trigger? But you don't explicitly state this. Also, is this the "before" schematic of the circuit that didn't work, or the "after" schematic of the one that did work? \$\endgroup\$– FiddyOhmMar 26, 2018 at 23:19
Your sensor has a high output impedance.
Imagine the sensor as a voltage source in series with a resistor Rout. If the output of the comparator is high, you get the following equivalent circuit:
simulate this circuit – Schematic created using CircuitLab
Here, V_OpAmp is the output voltage of the op amp. I've assumed it's railed high at 5V. The open-circuit voltage V_sensor of the sensor is 0.4V, but because of it's got a high output impedance, the op amp output voltage pulls it high - what you actually measure at the output of the sensor is V_sensor_out = 2V.
I have picked some resistor values that replicate the measured results you mention. Knowing Rin and Rf, you could easily calculate the actual value of Rout.
Adding the buffer presents the sensor with a high-impedance load, and the Schmidt trigger with a low impedance driver, effectively eliminating the effect.
\$\begingroup\$ Thanks really like this explanation, the part that sounds complicated to me is what’s exactly pulling a voltage high and what’s its relevance to the output high impedence ? \$\endgroup\$ Mar 26, 2018 at 23:26
1\$\begingroup\$ @BigRedMachine, are you asking a question because you still do not understand or are you making a statement about what you did not understand (but now you understand it)? \$\endgroup\$– jsotolaMar 26, 2018 at 23:37
\$\begingroup\$ @BigRedMachine If you're still confused, maybe you can clarify what exactly you don't understand? I feel like I have addressed both of those questions in my answer, and I'm not sure how I can explain them any better without some more info from you on what you don't understand. \$\endgroup\$– SelvekMar 26, 2018 at 23:50
\$\begingroup\$ I believe now I do have a understanding of why the buffer is needed in this circuit , it’s just this part “because of it's got a high output impedance, the op amp output voltage pulls it high” that I’m not sure what you’re saying. \$\endgroup\$ Mar 27, 2018 at 0:14
\$\begingroup\$ @BigRedMachine Are you familiar with superposition? From superposition, you have two cases: 1) V_sensor only (V_OpAmp is a short circuit). Solving that circuit gives you V_sensor_Out_1 = 0.4V * (30k / (16k + 30k)) = 0.261V. Case 2) V_OpAmp only (V_sensor is a short circuit). Solving that gives V_sensor_Out_2 = 5V * (16k / (16k + 30k)) = 1.739V. Adding those together gives V_sensor_Out = 2V. So you see that the contribution from the op amp output is much stronger than the contribution from the sensor output. \$\endgroup\$– SelvekMar 27, 2018 at 3:52
For clarity, what you have shown on your drawing is a comparator with a positive feedback, which makes it a Schmitt trigger.
Without a positive feedback, the comparator output goes to its maximum voltage (up to VCC for some comparators), when the voltage on its non-inverting input exceeds the voltage on its inverting input and it goes to its minimum voltage (Vss or ground), when the voltage on its inverting input exceeds the voltage on its non-inverting input. If the voltage between the compartor inputs is close to zero, its output could be switching back and forth chaotically and confuse everyone.
The positive feedback is used to avoid this chaotic switching by reinforcing the initial difference between the inputs. If it was positive to start with (i.e., the non-inverting input was higher than the inverting input), the output will go high and a fraction of it, through the positive feedback, will make the non-inverting input a little higher and the difference more positive. If it was negative, the output will go low and will make the non-inverting input a little lower and the difference more negative.
A simple version of a comparator/Schmitt trigger circuit that you could use in your application is shown below:
It is very similar to your circuit, except that the sensor is connected to the non-inverting input. With this circuit, you can calculate precisely how much the switching output will affect the non-inverting input, since it is just a resistive feedback network.
In your circuit, the effect of the feedback is more difficult to predict because the sensor is a part of the feedback network and its impedance may be changing over time (e.g., when it senses something).
In addition, the behavior of such circuit could confuse you: when you see the voltage on the output of the sensor increasing, you might think that this is because the state of the sensor has changed, when in fact it may be caused by the comparator output switching from low to high with a fraction of that voltage showing on the output of the sensor.
Of course if the sensor has very low output impedance, the positive feedback will be more predictable and will be determined by the ratio of Rf and Rin. The buffer, as you already know, would also isolate the sensor from the positive feedback, but it is an extra component.
In summary, if you want to make your circuit work more predictably without adding a buffer, you can use the inverting input for the sensor and let the non-inverting input do its thing.