Weekend Project - op-amp based thermostat / fan controller - Page 1
Forum section: electronics / projects

author: wobbly
author_rank: Regular Contributor
timestamp: September 08, 2024, 04:09:28 pm
content: My garden shed gets stinking hot in summer. So I bought a fan to provide some forced ventilation and it works pretty well, except that I have to flip a switch to turn it on or off. Obviously this needed to be automated!My normal reflex action in cases like this is to lunge for the nearest microcontroller and do it the easy way. Not this time. I'm not so hot at analog electronics (as will soon become apparent when you see the naïve schematic below) so I thought I'd try my hand at using some op-amps to solve this problem.I'm using two ST "uA741" op amps, one to detect the turn-on temperature and another to detect the turn-off temp. A single NTC thermistor serves both op-amps. Turn-on and turn-off temperatures can be independently selected by a pair of 10-turn potentiometers.These two 741's are set up to act as open-loop comparators. So they output low voltage when the temperature is too low, and high when it's too warm. These signals drive a pair of optocouplers which provide a latching mechanism for the relay which drives the 12V fan.I need to work out the best temperature thresholds for the hysteresis band. I'm thinking perhaps 38°C for fan turn-on and 28°C for turn-off.One hack I did need to put in was to add two series diodes after the 741s' outputs because it's not a rail-to-rail op-amp, so when it goes low it still outputs about 2 volts. This causes the two LEDs to light up dimly (which isn't a problem) but it does mean that the optocouplers don't turn off fully, which is a problem. The 2 diodes drop the voltage output just enough that the optocouplers don't turn on prematurely.It works quite nicely... sometimes. I was surprised that it worked at all given my irrational fear of op-amps!Sometimes it just fires up the fan at power on. I'm not sure why, it looks like the 741s are glitching at both power on and power off.This is just a prototype though, I'll be making a PCB for the final design which will have a few tweaks and more safety features such as fuses etc. I'll need to find a suitable power supply for running this from UK mains.Just thought I'd share this so you can all have a good laugh at my ineptitude at anything that doesn't rely on microcontrollers

author: wobbly
author_rank: Regular Contributor
timestamp: September 08, 2024, 04:27:02 pm
content: Another thing that would improve this design is to add a Schmitt trigger after each op-amp output. I could use a couple more 741s for this. I have noticed that the relay can buzz for a moment before the latch takes effect. Op-amps are awesome things!

author: temperance
author_rank: Super Contributor
timestamp: September 08, 2024, 06:48:33 pm
content: You could replace those LM741 with an LM339 dual comparator. Those have open collector outputs. As such you can remove the two opto couplers and drive the relays from a single.QuoteYou will need to add hysteresis around the two comparators. Additional Schmitt trigger won't help if the comparators are oscillating.

author: NiHaoMike
author_rank: Super Contributor
timestamp: September 08, 2024, 07:09:26 pm
content: A single comparator and a MOSFET will work to make a differential temperature controller checking two NTC thermistors (each with its own 10k or so pullup resistor) and a single potentiometer in series with the indoor thermistor sets the differential.