# Calculate transfer function H(w) of Schmitt trigger with RC at inverting input

I have got the following Schmitt trigger circuit implemented already on a breadboard. As seen, the input signal at the non-inverting and inverting terminals of the op amp is the same, but with the addition of a RC circuit in the inverting terminal. In this way, I am comparing the input signal with a delayed version of the same signal such that I can identify peaks. I got the idea from here. simulate this circuit – Schematic created using CircuitLab

I wanted to obtain its transfer function so as to analyse more carefully the influence of the RC network (and ultimately, the circuit itself). I obtained an expression for $H(w)$, created some code in Matlab to plot the transfer characteristic (magnitude and phase) of the circuit, and also implemented the circuit in TI-Tina simulator. Using the Tina's AC analysis, I also plotted the transfer characteristic... and my Matlab results differ from Ti-Tina's results.

Here the results from Matlab: And here the results from TI-Tina: For this reason I wanted to ask whether the following set of equations to obtain $H(w)$ is correct.

The voltage $V_{+}$ is:
\begin{equation} V_{+} = V_{in}\dfrac{R_{f}}{R_{1} + R_{f}} + V_{o}\dfrac{R_{1}}{R_{1} + R_{f}} \end{equation}

Considering admittances, $V_{-}$ is $V_{-} = V_{in}\dfrac{G_{2}}{G_{2} + sC_{1}}$. Putting $s = jw$ and $R_{2} = 1/G_{2}$, we have:

\begin{equation} V_{-} = V_{in}\dfrac{1}{1 + jwC_{1}R_{2}} \end{equation}

As $V_{+}=V_{-}$, the following expression can be obtained:

\begin{equation} V_{o} = V_{in}\dfrac{1-jwC_{1}R_{2}R_{f}/R_{1}}{1 + jwC_{1}R_{2}} \end{equation}

Therefore,

\begin{equation} H(w) = \dfrac{V_{o}}{V_{in}}=\dfrac{1-jwC_{1}R_{2}R_{f}/R_{1}}{1 + jwC_{1}R_{2}} \end{equation}

Any insights? I would appreciate your help. Many thanks.

If useful, the code I've used in Matlab is:

%--- We fix Rf and R2 and vary C1
R1 = 10;
Rf = 10e6;
R2 = 10e3;
C1 = [1 10 100 1000] .* 1e-9;

opts = bodeoptions;
opts.Title.String = '';
opts.Title.FontSize = 12;
opts.Xlabel.FontSize = 12;
opts.Ylabel.FontSize = 12;
opts.TickLabel.FontSize = 10;
opts.FreqUnits = 'Hz';
opts.Grid = 'on';

H = [];
for i=1:length(C1)
H = [H tf([-C1(i) * R2 * Rf / R1,1],[C1(i)*R2,1])];
end

figure
hold on
for i=1:length(C1)
bodeplot(H(i),opts);
end

legend_t = cell(length(C1), 1);
for i=1:length(C1)
legend_t{i} = sprintf('C=%snF', num2str(C1(i) * 1e9));
end

legend(legend_t);
title({'Transfer function of Inverting Schmitt Trigger', ...
sprintf('Rf=%dMOhm, R1=%dOhm, R2=%dkOhm', Rf/1e6, R1, R2/1e3)});

• A Schmitt trigger is a non linear circuit. $H(\omega)$ is describes the transfer of a linear circuit. So you cannot use $H(\omega)$ to describe the full behavior of this circuit. The simulator assumes a certain DC-state of the circuit and linearizes that state, that's the bodeplot you get. But that cannot fully describe the behavior of the circuit. Feb 1, 2018 at 16:59
• Ah! It is true, it is a non-linear circuit! and somehow I had missed it! Therefore, I guess the only chance to understand the circuit is to look at its transfer characteristics (i.e., histeresys, input offset, etc.)? Feb 1, 2018 at 17:07

As already told by others, its not useful to apply linear frequency analysis to this, heavily non-linear circuit. Do time domain simulations with different input signals to see the behaviour.

A qualitative analysis of one, probably interesting case:

If the time constant R2 * C1 is so long that it virtually kills all variation of the Vin, you have only the average Vin at he inverting input of the opamp. This can make the circuit useful as a level detector with self-adjusting treshold.

If Vin has long periods of "no change" and the idle Vin is far from the average Vin of the active periods, you get errors when the changes start, because there's wrong average in C1.

BTW. Your Rf and R1 give only about 3uV hysteresis. I bet it's useless for anything practical. You should have bigger R1 or smaller Rf or both. The hysteresis = (R1/Rf)*Output peak to peak swing.

• Thanks @user287001, the case you point out is interesting indeed. One question, what do you mean with "you get errors when the changes start, but there's a wrong average in C1."? Feb 1, 2018 at 18:09
• @sigur_ros Lets assume your signal is noisy and its amplitude varies, you need a schmitt trigger. Let's assume the signal has bursts of positive pulses which you want detect, but between the bursts the signal is long time =0V plus the noise. The treshold slides to 0V and you can finally detect some noise peaks. When a burst starts, the treshold is at first too low, it takes some time until the treshold rises to the average. Some low voltage states can be left undetected in the beginning.
– user136077
Feb 1, 2018 at 19:43
• @sigur_ros I added a notice that can be interesting.
– user136077
Feb 2, 2018 at 1:20
• thanks for pointing this out. In fact, I was looking into how to best choose the values of Rf and R1, and I had come across one of many sources like this that explain such issue. Feb 2, 2018 at 12:12
• Hi @user287001, I hope you're still around! My question is about: "If the time constant R2*C1 is so long that it virtually kills all variation of the Vin, you have only the average Vin at he inverting input of the opamp.This can make the circuit useful as a level detector with self-adjusting treshold." How does time R2*C1 relate to "variation" of Vin? We set the hysteresis to a given range, and when Vin is close to the min range value, the circuit responds as a level detector and not a peak detector. This seems to be related to your answer, but would you know how I could quantify "variation"? Sep 20, 2018 at 9:01