Fan control with opamp in a problematic way

I want to control a small 12V case fan. I will set values of R1, R2 and R3 so that the fan will work above temperatures 40oC.

I understand that in these kind of systems, there will be an indecisive region in which the comparator output will be fast changing between high and low. In this practical case, when the temperature is in the vicinity of 40oC, there will be an unstable behavior.

Is there any way of make this circuit work in schmitt trigger mode (e.g.; stop under 38oC, start above 42oC, and keep previous state between 38oC and 42oC) by changing it as little as possible, and without using any schmitt trigger logic gate.

  • \$\begingroup\$ Your request is understood BUT you have a dead region from 40 to 42 :-). || Basic principle is Case 1: to add "positive feedback" so that when the output goes high the apparent input goes even higher and when the input goes low the apparent input goes even lower. OR Case 2: add negative feedback to the reference so that when the output goes high the trigger point goes lower so that the system has to cool before the trigger point is again reached.|| Case 1: Resistor from Opamp output to non-inv input. Or Case 2: resistor from M1 drain to inverting input. \$\endgroup\$ – Russell McMahon Jun 19 '12 at 17:12
  • \$\begingroup\$ Note that op amp comparators have some drawbacks compared to comparators \$\endgroup\$ – Scott Seidman Nov 6 '14 at 14:36

To create a Schmitt-trigger you have to supply positive feedback, from the opamp's output to the non-inverting input. Usually this input will be the threshold voltage, and it will take one of two values (that's the hysteresis) depending on the opamp's output.

In your case you have the signal on the non-inverting input. You can also make it work this way, but I would suggest you switch both inputs, and also swap R1 and PTC still have the same behaviour: a higher PTC resistance will decrease the inverting input, and when it reaches the threshold the fan will be switched on. So let's do that, and add an R5 from output to the R2/R3 node.

enter image description here

You mention the hysteresis in °C, but we need the voltages. Let's do a theoretical calculation with a \$V_H\$ and \$V_L\$ as thresholds, and assume a rail-to-rail output opamp. Then we have two situations: the high and the low threshold, and three variables: R2, R3 and the added R5. So we can choose one of the resistors, let's fix R2.

Now, applying KCL (Kirchhoff's Current Law) for the R2/R3/R5 node:

\$ \dfrac{12 V - V_L}{R3} + \dfrac{0 V - V_L}{R5} = \dfrac{V_L}{R2} \$


\$ \dfrac{12 V - V_H}{R3} + \dfrac{12 V - V_H}{R5} = \dfrac{V_H}{R2} \$

This is a set of linear equations in two variables: R3 and R5, which is easy to solve if you can fill in actual voltages for \$V_H\$ and \$V_L\$ and a freely chosen R2.

Let's for the sake of argument suppose that at 38 °C you have 6 V on the inverting input, and at 42 °C you'll have 5 V. Let's pick a 10 k\$\Omega\$ value for R2. Then the above equations become

\$ \begin{cases} \dfrac{12 V - 5 V}{R3} + \dfrac{0 V - 5 V}{R5} = \dfrac{5 V}{10 k\Omega} \\ \\ \\ \dfrac{12 V - 6 V}{R3} + \dfrac{12 V - 6 V}{R5} = \dfrac{6 V}{10 k\Omega} \end{cases} \$


\$ \begin{cases} \dfrac{7 V}{R3} - \dfrac{5 V}{R5} = \dfrac{5 V}{10 k\Omega} \\ \\ \\ \dfrac{6 V}{R3} + \dfrac{6 V}{R5} = \dfrac{6 V}{10 k\Omega} \end{cases} \$

then after some replacing and shuffling we find

\$ \begin{cases} R3 = 12 k\Omega \\ R5 = 60 k\Omega \end{cases} \$

I already said it's less common, but you can also use the current schematic, and the calculations are similar. Again, add an R5 feedback resistor between output and non-inverting input. Now the reference input is fixed by the ratio R2/R3, and the hysteresis will shift your measured voltage up and down, which — at least for me — needs some getting used to.

enter image description here

Let's suppose we fix the reference voltage at 6 V by making R2 and R3 equal. Again we calculate the currents at the node PTC/R1/R5, where PTC\$_L\$ and PTC\$_H\$ are the PTC values at 38 °C and 42 °C resp., and R1 and R5 are our unknowns. Then

\$ \begin{cases} \dfrac{6 V}{PTC_H} = \dfrac{12 V - 6 V}{R1} + \dfrac{0 V - 6 V}{R5} \\ \\ \\ \dfrac{6 V}{PTC_L} = \dfrac{12 V - 6 V}{R1} + \dfrac{12 V - 6 V}{R5} \end{cases} \$

Again, solve for R1 and R5.

  • \$\begingroup\$ @Kortuk - Oh, crap! :-) Yes, you're right, I'll add them. Just a minute (or 2, 3...) \$\endgroup\$ – stevenvh Jun 19 '12 at 16:56
  • \$\begingroup\$ @Kortuk - There, done. Happy? :-) \$\endgroup\$ – stevenvh Jun 19 '12 at 17:06
  • \$\begingroup\$ still a bit short :) You probably noticed I did not actually downvote. \$\endgroup\$ – Kortuk Jun 19 '12 at 17:48
  • 1
    \$\begingroup\$ @Kortuk - Yeah, I knew you wouldn't. I think I know you well enough by now to know that you first ask. ;-) \$\endgroup\$ – stevenvh Jun 19 '12 at 17:55
  • \$\begingroup\$ your answer was good enough without schematic, I just thought it a minor improvement, your answer already had an upvote from me. \$\endgroup\$ – Kortuk Jun 19 '12 at 18:06

You have to add a couple of positive feedback resistors to add hysteresis to opamp.

enter image description here

Source of image


enter image description here

This is the most general equation at the \$V_{in}\$ node which comes from the Kirchhoff's Current Law:

\$ \dfrac{V_{in} - V_{dd}}{R_1} + \dfrac{V_{in} - V_{ss}}{R_2} + \dfrac{V_{in} - V_{out}}{R_f} = 0 \$

From opamp characteristics, we know that:

Vin <= VIL ==> Vout = VOL (Low  State)
Vin >= VIH ==> Vout = VOH (High State)

So we can write two separate equations for these two states.

\$ \dfrac{V_{IL} - V_{dd}}{R_1} + \dfrac{V_{IL} - V_{ss}}{R_2} + \dfrac{V_{IL} - V_{OL}}{R_f} = 0 \\ \dfrac{V_{IL}}{R_1 // R_2 // R_f} = \dfrac{V_{dd}}{R_1} + \dfrac{V_{ss}}{R_2} + \dfrac{V_{OL}}{R_f} \\ V_{IL} = (R_1 // R_2 // R_f) \left[ \dfrac{V_{dd}}{R_1} + \dfrac{V_{ss}}{R_2} + \dfrac{V_{OL}}{R_f} \right] \\ V_{IH} = (R_1 // R_2 // R_f) \left[ \dfrac{V_{dd}}{R_1} + \dfrac{V_{ss}}{R_2} + \dfrac{V_{OH}}{R_f} \right] \\ \$


R1  = 100k
R2  = 100k
Vdd = +15V
Vss = -15V
VOH = +13V
VOL = -13V

enter image description here

% Matlab code for the plotting

R1              = 100000;
R2              = 100000;
Vdd             = +15;
Vss             = -15;
VOH             = +13;
VOL             = -13;

RMIN            = 10000;        % 10k
RMAX            = 10000000;     % 10M
VMIN            = -10.0;
VMAX            = +10.0;
POINTS          = (RMAX - RMIN) / 100;

Rf              = linspace(RMIN, RMAX, POINTS);
VIL             = zeros(1, POINTS);
VIH             = zeros(1, POINTS);

for i = 1 : 1 : POINTS
    VIL(i) = 1 / ((1/R1) + (1/R2) + (1/Rf(i))) * ((Vdd/R1) + (Vss/R2) + (VOL/Rf(i)));
    VIH(i) = 1 / ((1/R1) + (1/R2) + (1/Rf(i))) * ((Vdd/R1) + (Vss/R2) + (VOH/Rf(i)));

close all;
hFig = figure;
hold on;
plot([0 10], [0 0], 'Color', [0.75 0.75 0.75]);
plot(Rf/1000000, VIL, 'Color', [0 0 1]);
plot(Rf/1000000, VIH, 'Color', [1 0 0]);
xlim([RMIN/1000000, RMAX/1000000]);
ylim([VMIN, VMAX]);
xlabel('R_f (M\Omega)');
ylabel('VIL & VIH (V)');
hold off;

As commented before, using feedback is the key to archieve hysteresis using Op-Amps.

This article from Albert Lee shows in a practical way how to do it and how do the math to calculate the desired hysteresis levels on the system.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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