# How can I modify this opamp circuit's logic

I need a system where it follows the input voltage below a set threshold voltage, and it outputs a set voltage above the threshold voltage.

Below is my attempt:

The circuit shown can output a set voltage(set by R1 and R4) above a set threshold(set by R2 and R3); but it outputs zero volt when the input is below the threshold voltage(i.e it doesn't follow the input)

How can I modify this circuit to make the output follows the input for inputs lower than the threshold? A diagram in answer would help better to understand.

Again the logic required for the system I need: The output follows the input below a set threshold, and it outputs a set voltage above the threshold.

Basically the input output will look like this:

Until a set threshold the output will follow the input; and at and above the threshold output will jump to a preset voltage.

How can I modify this circuit to make the output follows the input for inputs lower than the threshold?

Use an analogue switch and a comparator.

When the comparator detects that the input voltage has risen above a "threshold" then it activates the analogue switch so that instead of it connecting its output to the input voltage, it connects its output to a reference voltage (called the set-voltage in the question): -

• Thanks but there are many different types when I google. I never used before. Is the one in your answer "Analogue Switch Single SPDT". If not, does it have a more specific name? Commented May 28, 2018 at 17:18
• SPDT is the switch circuit needed and yes, there are tons of them. Choose one that has power rails that your circuit uses. Also choose that that has a low on resistance to combat loading effects. Most are about 100 ohm and turn off to several Mohms. The comparator you choose will dictate how easily its output interfaces with the analogue switch. Commented May 28, 2018 at 17:23
• I see, Im trying to find a model and simulate this in LTspice. Commented May 28, 2018 at 17:25
• I found this one: uk.rs-online.com/web/p/multiplexer-switch-ics/7979271 But I never used before and I cannot find any model for simulation. If this part makes sense(I checked it is single supply and it is SPDT), do you mind if I ask another question about using this IC? Commented May 28, 2018 at 17:44
• Btw in your circuit wouldn't the input and the threshold must be swapped? I mean we want the comparator ON when the input is above the threshold and then the output to jump to set-voltage. Commented May 28, 2018 at 17:57

One solution would be based on the following principle:

simulate this circuit – Schematic created using CircuitLab

If it's okay to have a gain bigger than 1 for the output, you can leave out $R_3$ and $R_4$. The actual threshold is around $V_{th} + 0.7V$.

As you know, the gain of a non-inverting amplifier (feedback through $R_1$ and $R_2$) is

$$A_v = 1 + \frac{R_1}{R_2}$$

It works by shunting $R_2$ with a low-impedant path once the negative input terminal (which is kept equal to the positive input terminal) goes higher than the threshold voltage. Shunting $R_2$ means that

$$A_v = 1 + \frac{R_1}{R_2} \xrightarrow[R_2 \to 0]{} +\infty$$

This stops the negative feedback, and the output will be saturated to the positive supply voltage.

If you need more control over the set value when the input is larger than the threshold, you can also use the slightly less elegant circuit:

simulate this circuit

It replaces the diode with the B-E-diode of an NPN BJT, which is then used to enable a resistive divider at the output. Note that you will see some glitch where the input crosses the threshold. I'm not sure if this is an issue. The reason for this is that the NPN transistor works slightly faster than the BE-diode to take away the feedback. You can diminish this effect severely by increasing $R_1$ and $R_2$.

So for this circuit you can tune the $V_{th}$ using $V_3$. Make sure the impedance at the emitter of the BJT is low enough if you're using a voltage divider.

$$V_{3} = \frac{V_{th}}{2} - V_{BE,Q1}$$

The set voltage can be tuned by voltage divider $R_3$ and $R_4$. The output voltage is:

$$V_{set} = \frac{V_3R_4 + V_{SAT}R_3}{R_3+R_4}$$

Where $V_{SAT}$ is the maximum output voltage of the opamp ($V_{supply} - 1.5V$ for the LM324).

• This will not work. A TL081 might barely limp along with 10 V supply, but both the input and output headroom requirements make is virtually useless in this circuit. Commented May 28, 2018 at 13:03
• Thanks but your first circuit doesnt work. I tried with LM324 in LTSspice. Please make a DC sweep and check. And the second circuit is amplifying the input signal when the input is below the treshold. Commented May 28, 2018 at 13:03
• @Olin I am aware that a TL081 is not a good choice. It is only the default that CircuitLab chooses for an Opamp... But I'll change it for clarity. Commented May 28, 2018 at 14:27
• @user16307 I assumed the concept was clear with the first circuit. But I'll add the resistive divider if you wish. Commented May 28, 2018 at 14:28
• @SvenB See my edit. That is the kind of output I need. Can you make it such that with 12V supply and Vth = 7.3V roughly and set voltage is 7.7V? So we can DC sweep and obtain something like this: i.sstatic.net/skayk.png Commented May 28, 2018 at 14:42