# Any advice to make this Op-Amp temperature controller circuit work?

• Wrichik Basu
In summary, as part of a practical in Physics major, students were required to draw the calibration curve of an NTC ##10~\mathrm{\Omega}## thermistor and construct a circuit to maintain the temperature of a water bath. The circuit used two LM741 Op-Amps with specific resistances and a potentiometer. The goal was to create a temperature controller at 63°C by setting the voltage at the inverting input of the second Op-Amp. However, the circuit did not work properly and the students faced difficulties for two days. The professor suggested loose connections as the cause of the problem, but the students also faced issues with the voltage and the working of the transistor. The use of banana connectors was also questioned,

#### Wrichik Basu

Gold Member
As part of our UG curricula in Physics major, we have a practical in which we have to draw the calibration curve of an NTC ##10~\mathrm{\Omega}## thermistor, and then construct a circuit to maintain the temperature of a water bath.

The calibration curve of our thermistor. The Prof. said that this is more or less fine.

The circuit, shown below, uses two LM741 Op-Amps. The first Op-Amp is a non-inverting amplifier, which amplifies the voltage ##V_t##, the potential difference across the thermistor. The second Op-Amp acts as a comparator.

We have used ##R_1 = 2.2~\mathrm{k\Omega}##, ##R_2 = 22~\mathrm{k\Omega},## ##R_L = 5~\mathrm{k\Omega},## ##R_B = 15~\mathrm{k\Omega},## and a ##1~\mathrm{k\Omega}## potentiometer.​

Suppose we want to create a temperature controller at 63°C. First, using the calibration curve, we find the potential difference (##V_t##) across the thermistor at this chosen temperature. The voltage at the output of Op-Amp 1 will be ##A_v V_t##, where $$A_v = 1 + \dfrac{R_2}{R_1} = 11$$ is the gain of the non-inverting amplifier. This voltage will be applied at the non-inverting input (##V_{2+}##) of Op-Amp 2. Next, using the potentiometer, we set the voltage at the inverting input of Op-Amp 2, ##V_{2-}##, to very close to, but slightly less than ##V_{2+}##. When switched on, the comparator is supposed to output either ##+V_\mathrm{sat}## or ##−V_\mathrm{sat}## based on the differences in the input. This voltage will be applied to the base of the transistor CL-100, which will turn the relay on accordingly. The relay controls the electric heater which heats the water bath.

Simple enough? Yes, theoretically. We have been facing a really hard time for the last two days (nearly seven hours total) in trying to make this circuit work.

At first, we were not getting the required gain from the first Op-Amp. The Op-Amp output was just getting saturated. The Prof. said that it might be due to loose connections. We re-did the circuit today, and the gain was coming okay. But then, the second Op-Amp never gave a proper output. We checked voltages everywhere; things were getting erratic. The thermistor was voltage ##V_t## was not coming to the first Op-Amp, if it did come, the output saturated. If we fixed that, the set voltage at ##V_{2-}## floated away. The Prof. sat with us and checked everything; the circuit was perfect. But the voltages were erratic. He couldn't help us, and blamed us and on our patience.

We use a lot of banana connectors — connections to the thermistor, to the power supply and to the relay. The Prof. said that these were having loose connections as the wires were not soldered inside them. But the lab assistants won't solder. I will try to have a word with the HoD to see if I can bring the male banana connectors home for soldering.

Other than that, is there anything which we can check to troubleshoot? We will get just one more day for this.

DeBangis21
The input offset voltage of a 741 is very large (1+ mV) W.R.T. your thermistor voltage. That may not be your only problem, but it's definitely one of them.

Wrichik Basu and berkeman
Did you check whether your CL100 BJT is still functional? Your circuit will reverse bias the emitter-base junction of that BJT when the output of the second op-amp goes negative. Reverse biasing the emitter-base junction of a BJT usually destroys it.

DaveE, Wrichik Basu and dlgoff
First thing I would do is add a bunch of bypass capacitors to that circuit. One at every IC power pin to ground, as close as possible. Also a capacitor in parallel with R2 and the thermistor. Something like 0.1 - 0.001uF. This is a DC circuit, you don't want anything to oscillate. Theoretically, you don't need any of these. In practice, you might, especially with your long PS leads.

Also, you MUST put a clamp diode across the relay coil to give the coil current a path to flow when the transistor turns off.

Banana plugs will make good enough contact, soldering them is a waste of time.

Can you show us a picture of your circuit? Construction details can be important.

As @Dullard said, the 741 isn't a great choice for the first stage, but it should work better than what you've described. The offset voltage will make long term stability and temperature stability a problem.

Wrichik Basu and hutchphd
All the above, plus;

The relay drive transistor will be dead by now. It requires a signal diode across the base-emitter to conduct during negative drive, to prevent break-down of the base when more than -7 volt reverse bias is applied. It also requires a power diode across the relay to catch the inductive flyback spike whenever the relay turns off.

Part of the problem could be the second op-amp being applied wrongly as a comparator. Op-amp inputs must be kept at very similar voltages, comparator inputs must be able to operate with big voltage differences.
That op-amp "comparator" has no hysteresis, positive feedback to make it switch cleanly like a Schmitt-trigger. There is no integrator, or low-pass filter capacitor, in the signal path to remove noise.

Wrichik Basu and DaveE
Baluncore said:
All the above, plus;

The relay drive transistor will be dead by now. It requires a signal diode across the base-emitter to conduct during negative drive, to prevent break-down of the base when more than -7 volt reverse bias is applied. It also requires a power diode across the relay to catch the inductive flyback spike whenever the relay turns off.

Part of the problem could be the second op-amp being applied wrongly as a comparator. Op-amp inputs must be kept at very similar voltages, comparator inputs must be able to operate with big voltage differences.
That op-amp "comparator" has no hysteresis, positive feedback to make it switch cleanly like a Schmitt-trigger. There is no integrator, or low-pass filter capacitor, in the signal path to remove noise.
Yes, a good point about the transistor base diode. Do that too.

You should check the 741 comparator application by checking to see if the 1st stage output voltage exceeds the allowable common-mode range of the 2nd stage. It's in the data sheet, and I think it's a problem. But I'm too lazy to check instead of you. A resistive voltage divider will fix that but you have to adjust the thresholds accordingly. Otherwise op-amps can be used as comparators, it will work, but they don't do it well, as @Baluncore described. The slow or erratic switching might be hard on the transistor.

Wrichik Basu
Also, not really related to your lab exercise, but good design practice would require a voltage reference to set thresholds, not the power supply voltages, they are noisy and unstable. One nice approach for this sort of circuit is a wheatstone bridge. But you'll just want to make this one (sort of) work and move on I think.

Wrichik Basu
Dullard said:
The input offset voltage of a 741 is very large (1+ mV) W.R.T. your thermistor voltage. That may not be your only problem, but it's definitely one of them.
Can't change the Op-Amp, so will implement the offset null removal circuit.

phyzguy said:
Did you check whether your CL100 BJT is still functional?
Nope.
Baluncore said:
The relay drive transistor will be dead by now. It requires a signal diode across the base-emitter to conduct during negative drive, to prevent break-down of the base when more than -7 volt reverse bias is applied. It also requires a power diode across the relay to catch the inductive flyback spike whenever the relay turns off.
DaveE said:
Also, you MUST put a clamp diode across the relay coil to give the coil current a path to flow when the transistor turns off.
Will add this diode. This diode should be connected with p-side to the emitter and n-side to the base, right? Also, will something like 1N5408 work, or should I use a schottky diode?

Last edited:
DaveE said:
First thing I would do is add a bunch of bypass capacitors to that circuit. One at every IC power pin to ground, as close as possible. Also a capacitor in parallel with R2 and the thermistor. Something like 0.1 - 0.001uF. This is a DC circuit, you don't want anything to oscillate. Theoretically, you don't need any of these. In practice, you might, especially with your long PS leads.
Yeah, I always add these for circuits at home. Not sure why college doesn't have them. I'll bring a bunch from home anyway.

Should I add one between ##-V_{EE}## and GND as well?

Last edited:
DaveE said:
Banana plugs will make good enough contact, soldering them is a waste of time.
I was talking about soldering the hookup wires to the base of the banana plugs. In our lab, the wires are just twisted through the hole, not soldered.

DaveE
DaveE said:
Can you show us a picture of your circuit? Construction details can be important.
Let me see if the lab will be open today.

Wrichik Basu said:
Should I add one between −VEE and GND as well?
Yes, all power supplies at each device. Think of them as something every IC manufacturer should have provided, pretty much always. Every IC in every circuit, from now until you die. And, yes, many will be unnecessary. It's like insurance against weird problems.

Wrichik Basu
Wrichik Basu said:
This diode should be connected with p-side to the emitter and n-side to the base, right? Also, will something like 1N5408 work, or should I use a schottky diode?

1) Across the BE juction of the transistor. With the anode (p-side) at the emitter. 1N5408 will work but it's overkill. Actually nearly any (single) diode will work. I would use a small one, like 1N4148.

2) Across the relay coil with the anode at the transistor. 1N5408 is OK here, although it's larger than you need. It only has to carry the coil current on a transient basis when the transistor turns off. It will never see much more than 12V. It will never see more current than the relay coil has (whatever that is).

Wrichik Basu and Baluncore
Wrichik Basu said:
Will add this diode. This diode should be connected with p-side to the emitter and n-side to the base, right? Also, will something like 1N5408 work, or should I use a schottky diode?
There are two diodes needed in this case, and replace the CL100.

1N5408 across the relay, reverse biased, cathode 'bar' to +12V, with anode to the collector of CL100. That catches the reverse spike.

1N4148 or 1N914 (or 1N5408 etc if that is all you have), reverse biased, cathode 'bar' connected to the base, anode to the emitter. That prevents negative base breakdown.

Rb is 15k which limits base current to 1 mA. Minimum current gain of CL100 is only 40, which implies less than 40 mA could get to the coil.
What current does the relay need? Usually more than 40 mA.
Replace Rb with something 2k2 to 5k6 to get sufficient current to switch the relay.

Wrichik Basu and DaveE
A fine point here that is sometimes overlooked (don't feel bad about missing it).

As @Dullard pointed out in post #4, the Input Offset Voltage of op-amps can be a problem. If the offset voltage of either stage is positive on its "+" input, then your circuit must supply a Negative correction voltage to that input. I don't see how that is possible with your present circuit.

Another option is to use use 741's with Offset Adjust inputs and null the offsets that way, read the Data Sheet or Application Notes for details.

Welcome to the Wonderful(?) World of Analog Design!

Cheers,
Tom

DaveE and Wrichik Basu
Tom.G said:
As @Dullard pointed out in post #4, the Input Offset Voltage of op-amps can be a problem. If the offset voltage of either stage is positive on its "+" input, then your circuit must supply a Negative correction voltage to that input. I don't see how that is possible with your present circuit.

Another option is to use use 741's with Offset Adjust inputs and null the offsets that way, read the Data Sheet or Application Notes for details.
We use the offset pins of LM741. Never thought about negative correction, though. Is this possible with the offset pins?

Baluncore said:
Rb is 15k which limits base current to 1 mA. Minimum current gain of CL100 is only 40, which implies less than 40 mA could get to the coil.
What current does the relay need? Usually more than 40 mA.
Replace Rb with something 2k2 to 5k6 to get sufficient current to switch the relay.
I told that to the Prof. the last day. He is afraid that anything more than 1mA will damage all the components.

DaveE
DaveE said:

1) Across the BE juction of the transistor. With the anode (p-side) at the emitter. 1N5408 will work but it's overkill. Actually nearly any (single) diode will work. I would use a small one, like 1N4148.

2) Across the relay coil with the anode at the transistor. 1N5408 is OK here, although it's larger than you need. It only has to carry the coil current on a transient basis when the transistor turns off. It will never see much more than 12V. It will never see more current than the relay coil has (whatever that is).
Ok, so I got hold of an 1N4148. Unfortunately, I found that I have used up all the 1N5408 diodes I had, but I do have some 1N4007, which I guess should work here (given that it has 1kV maximum repetitive peak reverse voltage)?

Wrichik Basu said:
Ok, so I got hold of an 1N4148. Unfortunately, I found that I have used up all the 1N5408 diodes I had, but I do have some 1N4007, which I guess should work here (given that it has 1kV maximum repetitive peak reverse voltage)?
The 1N4007 will do as a flyback diode. When a flyback diode is used, the current is only momentary, the relay current, while the voltage is only the supply voltage or 1 volt during flyback. The only disadvantage of a 1kV flyback diode is the marginal extra cost in production.

Wrichik Basu said:
I told that to the Prof. the last day. He is afraid that anything more than 1mA will damage all the components.
More than 1 mA may be a problem with a reverse biased base-emitter junction, but the diode solves that.

The uA741 maximum output current limits the base drive to the power transistor.
If the collector current is limited by beta, then the power transistor will not be in saturation, so it will get hot while the relay is on, or the relay might not pull in. Cross your fingers and hope for a higher than minimum beta.

DaveE and Wrichik Basu
DaveE said:
Can you show us a picture of your circuit? Construction details can be important.
Here you go (3 images):

Someone early on did mention using positive feedback and making the output opamp into a Schmidt trigger circuit, but that doesn't seem to have been followed up. IMO it is important. Temperature sensors often produce a very slowly varying signal. So the opamp comparator stage passes slowly through its transition region and is prone to oscillate.
The fact that the open-loop gain varies considerably with variations in supply, chip temperature (and sometimes, apparently for no reason at all!) adds to instability in the transition region.
It also seems to me that your design also has a feedback route from the relay to the sensor. As the temperature falls, the sensor voltage rises, and eventually switches on the relay. This extra current draw must slightly lower the supply voltage and therefore the sensor voltage, maybe taking it below the threshold again - when it will switch off the relay, allowing the supply voltage to rise, etc., etc. A bit of hysteresis in a Schmidt stage can cure that as well. Just raising the gain of the first stage, only makes this problem worse.

I'm happy with all the other suggestions, but think the offset adjustment won't help much. It moves the transition region, but doesn't remove it. Only positive feedback will do that.

Wrichik Basu and DaveE
Shall be implementing this today. Wish me luck.

Merlin3189 said:
Someone early on did mention using positive feedback and making the output opamp into a Schmidt trigger circuit, but that doesn't seem to have been followed up. IMO it is important.
I get it, but I am not allowed to use a Schmitt Trigger circuit because it hasn't been officially taught in the curricula.

If it were at my home, I would've done things differently. But in college, certain meaningless rules have to be followed.

Merlin3189 said:
Someone early on did mention using positive feedback and making the output opamp into a Schmidt trigger circuit, but that doesn't seem to have been followed up. IMO it is important.
I pointed it out in post #5, because it would be important in the real world, but not in an educational project with so many fatal design problems, and the time deadline.

The designer of the circuit will examine the student's circuit construction. We must KISS, so the examiner can recognise the result, and can award full marks for following instructions, and getting the basic design to work.

When I thought about the design, I realised that the pull-in and release time of the relay limited the switching frequency, in effect becoming hysteresis. Circuit-noise dithers the set-point, so the lack of a Schmitt-trigger would turn a bang-bang controller into a PWM controller, which would probably work beautifully, and let the user know that something was happening, as it very closely regulated the temperature without measurable introduced hysteresis.

Wrichik Basu
If you want to add some hysteresis to the comparator (a really good idea, IMO), you can just add two resistors, like this.

PS: Oops, probably too much. I'd make that 1K more like 100Ω which will give you ±1.2mV hysteresis at OP1 out, which is about ±100μV at the thermistor.

Wrichik Basu
The circuit worked today.

Yes, there were ups and downs. Initially, the first Op-Amp was not giving the expected gain. But it did work fine after tweaking here and there. Unfortunately, however, I had set up the relay circuit in the opposite direction, so the transistor got excessively hot, and I literally burnt my index finger when I touched it.

On the brighter side, after replacing the transistor a second time, things started to work out. The β of these two new transistors that I bought yesterday were nearly 198-200. Using the trimpot over a potentiometer was a great idea because we could get variations in the voltage ~ few mV. We didn't have to implement the offset null arrangement.

Later, we felt that our breadboard was a bit faulty, but we could get decent readings and concluded the experiment.

Thanks to everyone who patiently helped me out, once again. Without your experience and advice, we would have not been able to complete this. Learnt numerous new things, which I will surely keep in mind for circuits next time.

I am trying to arrange some lab equipment so that I can try this experiment at home with my better equipment. Definitely, it will be a Schmitt Trigger circuit rather than a comparator. I will post a second thread in due time for your suggestions on the new circuit.

By the way, I learnt from one of the lab assistants, who has been working for the last 12 years, that every single year, students face a really very hard time with this experiment. And we would not have been the first one to not have completed this experiment.

DaveE, Tom.G, Baluncore and 1 other person
Wrichik Basu said:
Definitely, it will be a Schmitt Trigger circuit rather than a comparator.
A Schmitt Trigger isn't necessarily a device, it's any comparator (or logic gate) circuit that has hysteresis via positive feedback. The circuit I posted before is a Schmitt Trigger made from a LM741. It has the advantage that you can control the amount of hysteresis in the design process. The best version would be a comparator, like LM311, LM339, etc. with some positive feedback as I sketched before.

Wrichik Basu said:
we felt that our breadboard was a bit faulty
Honestly, those solderless breadboards are awful. I wouldn't use them for anything more complicated than 1 IC that I only need for about 1/2 day. In our EE labs, you couldn't even find one, they were never used. We would solder everything onto a breadboard PCB as shown below. No intermittent connections, no accidental unplugging of parts, still works if you drop in on the floor or tug too hard on a probe. If it's worth the time to build it's probably worth keeping for several days. You can build these nearly as fast as plugging things into your breadboard once you get used to it, especially if you count troubleshooting and redoing things. They also absolutely don't work at high frequencies.

DaveE said:
A Schmitt Trigger isn't necessarily a device, it's any comparator (or logic gate) circuit that has hysteresis via positive feedback. The circuit I posted before is a Schmitt Trigger made from a LM741. It has the advantage that you can control the amount of hysteresis in the design process.
Yes, I meant using the LM741 as a Schmitt trigger rather than a comparator. But I think I will use something better than the LM741, like the OP07 which was recommended in one of my past threads.
DaveE said:
The best version would be a comparator, like LM311, LM339, etc. with some positive feedback as I sketched before.
Will check those out.
DaveE said:
Honestly, those solderless breadboards are awful.
For us hobbyists, breadboards are still the way to go. If I am continuously changing components without any simulation, soldering and de-soldering would be really inconvenient. In addition, I don't know how much reusable the desoldered components are, unless desoldered by someone who has a lot of experience. In a college lab where students are making the same circuits every other semester, soldering would be a waste of money for the Dept. Plus, many students would definitely cause injury to themselves if they are not careful. (For instance, today another group burnt out an immersion heater running on AC mains by pulling it out of water and keeping it that way till it smoked.)

DaveE
Wrichik Basu said:
Yes, I meant using the LM741 as a Schmitt trigger rather than a comparator. But I think I will use something better than the LM741, like the OP07 which was recommended in one of my past threads.

Will check those out.

For us hobbyists, breadboards are still the way to go. If I am continuously changing components without any simulation, soldering and de-soldering would be really inconvenient. In addition, I don't know how much reusable the desoldered components are, unless desoldered by someone who has a lot of experience. In a college lab where students are making the same circuits every other semester, soldering would be a waste of money for the Dept. Plus, many students would definitely cause injury to themselves if they are not careful. (For instance, today another group burnt out an immersion heater running on AC mains by pulling it out of water and keeping it that way till it smoked.)
OP07 is a better op-amp than LM741. But it will be better to use a comparator. The built in dominant pole compensation in op-amps isn't good for switching applications, as @Baluncore previously explained.

Wrichik Basu
BTW, for these low frequency mV level sensors, we would use one of the single supply auto-zero op-amps for the input stage, like the OPA335. Undoubtedly not available for schools, and not necessary for learning in the lab. But in the pro EE world you would normally choose one of the thousands of op-amps that fits the need best. Op-amps like the 741, 324, OP07, etc. really only fit the low cost niche, there are better choices for nearly any spec on the data sheet.

What most analog EEs spend their time doing is reading datasheets, choosing appropriate parts, and designing "on paper", then maybe simulating the tricky bits (or not), and only then building it. Many routine portions of a circuit are never breadboarded or simulated if you are confident in your design work. Still, students do have to learn how to work in the lab. Also, maybe, the cost and pain of doing it wrong. All of us have destroyed more parts than we can count, LOL.

BTW, the days of +/- power supplies for op-amps is mostly past. Extra power supplies cost a lot and usually aren't necessary.

Wrichik Basu
DaveE said:
The best version would be a comparator, like LM311, LM339, etc. with some positive feedback as I sketched before.
I was going through the datasheet of the LM311, but failed to see its advantage over a good op-amp with a transistor. This is the schematic of the LM311:

At the end, it's basically an op-amp with a transistor in a single package. Maybe a goof op-amp, much better than LM741. And maybe will result in less wiring. But other than that, what's the advantage of these over regular op-amp + transistor circuit?
DaveE said:
BTW, the days of +/- power supplies for op-amps is mostly past. Extra power supplies cost a lot and usually aren't necessary.
Then how do you power the op-amps? I am almost going to buy an SMPS (Morsun LM60-12A15 with ±15 V, 2A) so that I can use op-amps at home. Even the LM311 requires a -15V supply.

Wrichik Basu said:
what's the advantage of these over regular op-amp + transistor circuit?
Comparators are basically op-amps without the internal dominant pole frequency compensation. This compensation lowers the gain at high frequencies to make them inherently stable. However, it also slows them down. The LM311 can switch from -15V to +15V in 115nsec (slew rate = 260V/μsec). The OP07 has a slew rate of 0.3V/μsec. So it's much slower, both in switching and the delay to get to the active region of the next stage. This means that the inputs stay in/near the linear (active) range longer for the op-amp with positive feedback. In some designs you can eliminate the external positive feedback because of this, although I would usually include it, especially for slowly changing inputs.

Many comparators also have stronger output stages to drive more current which helps with capacitive loads, although the LM311 isn't a great example of that.

However, with external positive feedback in a slow application like yours, I don't think there's much wrong with using an op-amp. You'll see people do this when they want parts commonality for low cost or size. Like with a dual or quad op-amp IC. If the designer knows the difference and the consequences, I think it can often work well.

You are correct that the extra gain of the transistor makes this less important.

Wrichik Basu said:
Then how do you power the op-amps?
You choose one that works well with a single power supply. Even the LM324 does, which is ancient. Although there are better, newer versions, like rail-to-rail versions. There are some issues that you need to pay attention to with single supplies and/or low voltage operation though.
https://www.ti.com/lit/ml/sloa030a/sloa030a.pdf?ts=1680287582984

Same for comparators, BTW.

Wrichik Basu
DaveE said:
Comparators are basically op-amps without the internal dominant pole frequency compensation. This compensation lowers the gain at high frequencies to make them inherently stable. However, it also slows them down.
The fundamental difference between a voltage comparator and an op-amp is the design of the input, gain, and output structures.

An op-amp is designed to operate with little input voltage difference. Some early bipolar op-amps would invert their output when the inputs differed by more than a few volts, while the input bias current would then also rise significantly.

Some voltage comparators have an internal 1 mV of hysteresis in the gain stage, that is used to speed up their response. That is never done with op-amps.

The output stage of a voltage comparator is a bipolar digital driver.
The output stage of an op-amp is a linear voltage follower.

Don't get voltage comparators and op-amps confused. Their only similarity is that they can share the same symbol on a circuit diagram.

DaveE and Wrichik Basu
Baluncore said:
Some early bipolar op-amps would invert their output when the inputs differed by more than a few volts
Yes, but only if you exceed the common mode input range. It's really the same thing, they just write the spec to cover their...

This reminds me of a run-in I had with the LM6144. They included a great feature to eliminate this "phase reversal" (that's the jargon to search for), to increase slew rate for large input differences, and drive capacitive loads well. That all sounds great in the intro text on the data sheet. What they don't say on the first page is that they do that by diverting current from the input stage which blows up the input current specs. It's buried in the datasheet. I spend about 2 days being confused about why things weren't right in my circuit. That's like 18 hours spent in the lab on one single amp stage, which practicing EEs don't have time for.

It reminds me of the old grad school saying "3 weeks in the lab can save you from spending an hour in the library". Read the datasheet. The whole thing. Even the footnotes (especially the footnotes!). Don't stop when you think you know enough. Some things like this are buried.

I will never use an LM6144 again, mostly because of PTSD. They aren't bad parts if you know what they do, but I rarely would need that.

PS: Anyway... The op-amp specs I think newbies don't really pay enough attention to, and absolutely should, are the input range and output stage drive (I-V) specs. This very much applies to both the single supply issues and the comparator/op-amp differences.

Last edited:
Wrichik Basu