the simplest thermostat with programmable thresholds? - Page 1
Forum section: electronics / beginners

author: exe
author_rank: Unknown
timestamp: February 19, 2018, 06:56:50 pm
content: Hello everybody,I'm trying to design a simple thermostat to control temperature of my power supply. The fan should start at, say 60C and stop at 40C. Ideally I'd like to have two trim pots to independently adjust upper and lower thresholds. I don't know how to better do this. May be someone has an idea? The focus is on ease of use and minimal BOM.Parameters: 12V supply, output current up to 200mA. I tried many approaches and currently running out of ideas. What I believe I need is a Schmitt trigger with programmable hysteresis (resistor divider with thermistor is an input).My best circuit (so far) is attached. It consists of two independent comparators (with resistor dividers to set thresholds), and a small latching (set/reset) switch (D2 is to lift base of Q2 a little bit as opamp cannot pull output low enough for switch to reset due to drop on D2, R1 and R2 add a bit oh hysteresis so opamp do not swing wildly when input near the threshold). Does anyone have a better idea how to do this?

author: Vic20
author_rank: Contributor
timestamp: February 19, 2018, 08:18:37 pm
content: It depends on the sensors used and the range you need to control, but an option could be using a normal hysteresis comparator with two feedback paths, each one with a series of a diode, a resistor and a potentiometer.In each path, the diode will be in a different direction.The basic idea of the hyst comparator you are using is that the (-) input sets the trigger point of the comparator. The positive feedback path just makes this trigger point dependent on the output of the comparator itself. Hence the hysteresis.

author: Vic20
author_rank: Contributor
timestamp: February 19, 2018, 08:40:09 pm
content: Also , to add to my previous post, you can also use two potentiometers and select the one you use for the (-) input of the comparator based on the output of the comparator itself.Just add analog switches to the circuit, for instance.Note that this solution doesn't guaratee that Thigh > Tlow

author: exe
author_rank: Unknown
timestamp: February 19, 2018, 09:29:30 pm
content: Thanks, Vic20!I tried that too, but without much luck. With diodes and potentiometers the behavior was highly non-linear. So I had troubles to have reasonably wide range and ability to precisely trim thresholds. May be I do it wrong.With analog switches it's more interesting. I tried to use mosfet + jfet pair to do this. Seems to be working in sim, haven't tried yet on a breadboard. My biggest concern so far is both switches can become open simulteneusly with unpredictable consequences. May be you have a better circuit? May be there is a better switch than what I'm using? I'm not familiar with analog switches.Quote from: Vic20 on February 19, 2018, 08:18:37 pm

author: Vic20
author_rank: Contributor
timestamp: February 19, 2018, 10:13:03 pm
content: Quote from: exe on February 19, 2018, 09:29:30 pmWell, you can also use a J-K biestable and drive each input with a different comparator.In fact this is quite similar to what the venerable 555 uses to generate square waves.

author: Wimberleytech
author_rank: Super Contributor
timestamp: February 19, 2018, 10:51:04 pm
content: QuoteSomething like this using Nch mosfets. Cross-coupled NOR gates insure that transistors are not on at the same time, while capacitor holds the charge while both transistors are off. The non-overlap time is going to be the prop delay of the gate which may be too fast. There are ways to extend that with additional circuitry. At any rate, this may stimulate some thought.

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2018, 11:16:24 pm
content: A microcontroller?There's an IC designed to do this, but I can't remember the part number! It contains two comparators and a flip-flop, on the same IC.

author: Wimberleytech
author_rank: Super Contributor
timestamp: February 19, 2018, 11:21:33 pm
content: Quote from: Hero999 on February 19, 2018, 11:16:24 pmGood idea...maybe this: TS12A12511

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2018, 11:24:42 pm
content: Quote from: Wimberleytech on February 19, 2018, 11:21:33 pmI found the part. It's the MIC841, which has a built-in, fixed 1.24V reference.http://ww1.microchip.com/downloads/en/DeviceDoc/20005758A.pdf

author: exe
author_rank: Unknown
timestamp: February 20, 2018, 08:48:39 am
content: Thank you guys for help, now I think I understand what are my options.I also found MIC833 (looks very similar to MIC841). Both ICs are 5V only, unfortunately and not easily available.Now I'm thinking how much external circuitry is needed to make such a project from NE555. I already tried a few designs, but didn't succeed.An ideal solution would contain just a few parts and had a high-impedance input. I'm starting to suspect that a cheap MCU with three ADCs could be the most trivial solution (but needs FW). Although, most MCUs are 3.3V, so additional LDO is needed. I don't think I'll go this way as I wanted to thermostat to be as reliable as possible and do not contain any digital circuit. I could do thermal management in software (there is a beefy MCU on the same board), but for reliability I wanted it to be independent.Quote from: Hero999 on February 19, 2018, 11:24:42 pm

author: danadak
author_rank: Super Contributor
timestamp: February 20, 2018, 12:12:32 pm
content: A PSOC 4 has reference, A/D, mux, die temperature, OpAmps, andlots of other stuff.The wall of text -For me what stands out is (PSOC in general) -1) Routability2) Fast 12 bit SAR A/D and slow 20 bit DelSig3) DFB (Digital Filter Block) that is dual channel, handle FIR or IIR filters, or DFBcan be used as a GP fast processor block, similar to RISC block4) MSI logic elements GUI based and/or the UDB Verilog capability. Eg. the FPGAlike capability5) Onboard Vref6) IDAC, VDAC, OpAmps (up to 4), comparator, mixer, switch cap, analog mux....7) LCD, COM, UART, I2C, I2S, One Wire, SPI, Parallel, LIN, CAN, BLE, USB9) Custom components capability, create with schematic capture or Verilog10) DMA to offload processes like filters, COM, Display11) ARM M0 (PSOC 4) or M3 (PSOC 5LP) or 8051 core(PSOC 3) or M0+/M4 dual core PSOC 612) Extensive clock generation capabilities13) All components supported by extensive prewritten APIshttps://www.element14.com/community/thread/23736/l/100-projects-in-100-days?displayFullThread=truehttp://www.cypress.com/documentation/code-examples/psoc-345-code-examplesGreat video libraryAttached component list. A component is an on chip HW resource. Note part dependent.Free GUI design tool with schematic capture, "Creator". Components have rich API library attachedto each component. Compilers free as well.PSOC 4 is low end of family, consider 5LP parts as well. PSOC 4 also has arduino footprint boards (pioneer) as well. PSOC 6 dual core M0+/M4.https://www.elektormagazine.com/labs/robot-build-with-cypress-psochttp://www.cypress.com/products/32-bit-arm-cortex-m-psochttps://brightcove.hs.llnwd.net/e1/uds/pd/1362235890001/1362235890001_5241352463001_2606504288001.mp4?pubId=1362235890001&videoId=2606504288001$ 5 dev board CY8CKIT-049Regards, Dana.

author: Zero999
author_rank: Super Contributor
timestamp: February 20, 2018, 12:30:10 pm
content: I think a PSOC is a little overkill.Quote from: exe on February 20, 2018, 08:48:39 amOn second thoughts, the solution is simple. Use a quad comparator IC, such as the LM339, with two of the comparators for the high and low threshold detectors and one as a flip-flop.See the link below for how to use a comparator as an RS flip-flop. Note that it's negative edge triggered, whilst the flop-flop inside the MIC841/833 is positive edge triggered, so the +/-inputs to the threshold detectors need to be reversed.http://www.circuitous.ca/Comparators.htmlAttached is an example of how it's done. Of course the output can be inverted, if needs be.

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 20, 2018, 03:34:12 pm
content: i tried on my type of thermistor (lower resistance when hotter, about 10Kohm at room temperature) using LM393... fwiw...

author: exe
author_rank: Unknown
timestamp: February 20, 2018, 03:48:17 pm
content: I think, I'll use LM339 circuit, thanks!Other suggestions also neat

author: Teledog
author_rank: Regular Contributor
timestamp: February 20, 2018, 03:51:24 pm
content: Perhaps one of these for 2 or 3 bucks?..they can be set to heat or cool;https://www.ebay.com/itm/DC12V-W1209-Digital-Thermostat-Temperature-Controller-NTC10K-1-3950-Cable/202105356356?hash=item2f0e6b0044:m:mN41Ql5Sh0yNzietsEGbdTAinfo;http://usefulldata.com/cheap-12v-temperature-controller-xh-w1209-with-display-and-probe-review/& lots more info out thereAlso, there's .stl printer files for the W1209 on Thingiverse

author: Wimberleytech
author_rank: Super Contributor
timestamp: February 20, 2018, 04:52:50 pm
content: Quote from: Teledog on February 20, 2018, 03:51:24 pmI ordered a couple of these on ebay last month. Have not arrived and not sure what I will do with it.Thanks for the Thingiverse tip...I will be printing out a box for mine!!

author: Zero999
author_rank: Super Contributor
timestamp: February 20, 2018, 07:08:55 pm
content: Quote from: exe on February 20, 2018, 03:48:17 pmHere's another variation of the LM339 circuit. This time, what was the reference, in the previous circuit, is now the input and the other potential divider taps references: Off_th for the turn off voltage and On_th for the turn on voltage. Obviously Off_th needs to be highr than On_th, otherwise it will be in an indeterminate state. I've simulated it, using the LM393 model which is the same as the LM339, except only dual. Interestingly trying make the circuit non-inverting, by swapping the set and reset flop-flop connections, caused convergence errors in LTSpice, but it should work on the bench.

author: Zero999
author_rank: Super Contributor
timestamp: February 20, 2018, 08:17:43 pm
content: I've solved the issue of the convergence errors. U1a's input voltage range was being exceeded. I feel a bit silly for blindly copying the bistable part off that website.I've added R6 and changed the value of R1. If the supply voltage is reduced, the component values may need to be changed again.Here's the non-inverting version. If you need the inverting circuit, include R6 and use 4k7 for R1.If you use a comparator, with rail-to-rail inputs, then R6 is not needed.

author: exe
author_rank: Unknown
timestamp: February 21, 2018, 08:49:53 pm
content: Thanks, Hero999!I also tried the approach suggested by Mechatrommer, it seems it has the lowest part count. I replaced bjt with a fet (bs170) because I'm not sure how bjts may drift with temperature. (Also wasn't sure if emitter-base voltage is within the limits) . It works like a charm! Downside of this approach: threshold adjustments are not independent. Also small fets are very sensisitve to ESD...

author: danadak
author_rank: Super Contributor
timestamp: February 22, 2018, 02:39:36 am
content: A PSOC may seem overkill, but its got -1) A/D to sense low batt2) Die T sensor3) OnChip V ref4) Pins for buttons to raise/lower settings, or capsense pins, eliminate mechanical buttons5) LCD interface in case you want to display6) Pins to drive LED to indicate on/offLost of other stuff.~ $1.00 at 1KU, PSOC 41XXIn this case maybe 20 lines of code for display-less simple solution.Regards, Dana.

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 22, 2018, 03:01:46 am
content: QuoteAnd not linear on potentiometer rotation. But i tried to avoid user mistake of setting lower temp threshold higher than high threshold,and assume the setting will be done seldomly with presence of dmm and thermistor data. once calibrated the circuit should work. The circuit certainly can be refined,but with increasing comp count i suspect as hero's cicuit.

author: JacquesBBB
author_rank: Frequent Contributor
timestamp: February 22, 2018, 05:22:02 am
content: Why not simply use one of thesehttps://www.ebay.com/itm/40-160-C-Thermostat-Temperature-Thermal-Switch-Normally-Open-Closed-NO-NC-KSD30/292139062263?hash=item4404d853f7:m:mTEsBn21CpkOaNAKyRqBh3w

author: exe
author_rank: Unknown
timestamp: February 22, 2018, 08:16:22 am
content: Quote from: JacquesBBB on February 22, 2018, 05:22:02 amIt's not adjustable, cannot be switched on from MCU (not sure why I want this) and I'm not sure how to mount it. But, I think I'll mount something similar, but normally closed with open temperature at ~80C as a protection measure.Quote from: danadak on February 22, 2018, 02:39:36 amThanks, I'll consider them. I even have two PSoC4 kits (CY8CKIT-049). The problems are: no Linux support, not easy to buy in region, one more thing to learn

author: danadak
author_rank: Super Contributor
timestamp: February 22, 2018, 11:29:20 am
content: Have you tried Virtualbox to run PSOC Creator ?https://community.cypress.com/thread/14665Regards, Dana.

author: Zero999
author_rank: Super Contributor
timestamp: February 22, 2018, 01:37:38 pm
content: Quote from: danadak on February 22, 2018, 02:39:36 amThe application is for 12V. I haven't read the data sheet, but generally programmable devices are limited to 5V, so a regulator (assuming it doesn't have an on chip regulator) and potential dividers are still required to scale the voltage down to something the device can handle.Quote from: exe on February 21, 2018, 08:49:53 pmA MOSFET is probably better, than a BJT here, since it will have a lower on loss, at these low currents.If you just want a minimum part solution, then why not use the traditional comparator Schmitt trigger circuit? The thresholds are notlonger independent, but it's much simpler than that circuit. If you really need minimal parts, use a comparator with a push-pull output and the pull-up resistor can be eliminated.http://www.analog.com/en/analog-dialogue/articles/curing-comparator-instability-with-hysteresis.html

author: danadak
author_rank: Super Contributor
timestamp: February 22, 2018, 01:55:05 pm
content: QuoteYes, supply range is 1.7 to 5.5, so a series zener would probably suffice, and A/D input would require R divider,for battery monitoring. Thats also reason pass transistor base cannot be switched directly. Might be able to usesimple diode clamp and series R along with Open Drain config on PSOC. But for sure, as shown on schematic,low current NPN takes care of that problem.Regards, Dana.