Temperature Switch

Discussion in 'General Electronics Chat' started by imbystox, Aug 4, 2012.

  1. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    Hi, I am hoping someone can help me with something that expect is a very simply problem. I am working on my first circuit project ever and it isn't going so well. My goal is to make a switch that will turn on a fan when my attic temperature exceeds the outside temperature.

    My intention is to use two identical thermistors in a voltage divider network and use a voltage comparator (LM393) to trigger a relay switch. It should be so simple but it just doesn't work. I have mocked up the circuit on a breadboard and I can measure the voltages responding exactly as expected. when I heat the thermistor connected to pin 2 the voltage at pin 2 rises above pin 3. When I heat the other thermistor the pin 3 voltage rises higher. The problem is the output voltage remains at about 5V (I am using a 6V supply) regardless of anything I do.

    If I understand correctly, I think that when the voltage at pin 2 is higher than pin 3 (i.e. the temperature on the left thermistor is higher) then pin 1 should have some positive voltage (i don't actually know what that voltage should be). Otherwise if voltage at pin 2 is lower, then voltage at pin 1 should be very near zero (low enough that it wouldn't actuate a NPN transistor). I was trying to use an led to indicate when the output was high but I think I nuked it because it doesn't light up anymore. I am just using my meter now. Clearly though, I'm doing something very wrong. I've been at this on and off for a couple of weeks and scouring the internet for answers. alas, I must now resort to asking for help. If anyone out there can help me it would be so appreciated.

    p.s. I've attached a photo of my breadboard and a schematic of the circuit I'm trying to make.
     
  2. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    Complete lack of limiting resistors in the output stage. BRB while I calculate the answers.

    Will this get you back up and running?
     
    Last edited: Aug 4, 2012
  3. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    Thank you #12 for your prompt reply and for taking the time to consider my question. I think (I hope) I have done just as you suggested by adding a 2.7k resistor and a 270 resistor to the circuit. Updated schematic and photo attached so you can be sure I did as you expected.

    I must confess it isn't clear to me exactly what the added resistors do or what math you did to come up with those values. I suspect this was intended to protect the LED. That may have worked but I don't know for sure because believe it or not I don't have another one at the moment.

    Nonetheless my main problem still exists; the output continues to remain high regardless of what whichever pin has the higher voltage. I still can't seem to make that pin 1 output go low.

    For what it is worth, both pins are typically at about 2.5 volts at room temperature. when I pinch either thermistor with my warm fingers, I can watch the respective voltage climb up to about 3 volts.

    p.s. thank you for providing the data sheet #12. you are most helpful.
     
  4. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    Darn. Missed again. I put the LED on the wrong side. Next drawing attached.
    You did what I told you to do but I was wrong..a bit.

    Theory:
    Condition 1:
    The 393 chip has a very low saturation voltage from pin 1 to ground when the chip is sinking current through its internal npn output transistor. That places the base of the external npn transistor very close to ground, so it does not conduct current. Meanwhile the 393 is dumping 2.22 ma from the 2.7k resistor to ground so it does not drive the external npn transistor to the "on" condition.

    Condition 2:
    When the 393 chip stops conducting current, the 2.7k resistor provides .002 amps to the base of the external npn transistor. Thus, the external npn can saturate as a switch and allow current to flow through the 270 ohm resistor and the LED.

    Math: (6V - .6 volts Vbe)/2700 = .002 amps
    (6V - 1.7V for the LED - .3 Volts collector to emitter of a saturated switch)/270 = 14.8 ma for the LED

    You could lower the 270 ohm resistor to 200 ohms but there is no rule that says you must drive all LEDs at the edge of their maximum allowed current. Besides, they look pretty good at half the rated current (10 ma). So I chose about 15 ma.

    Also, you might have smoked the 393 chip while discovering what it could do with no resistors to limit the output current.
     
    imbystox likes this.
  5. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    Do you really want the fan to come on when the attic is warmer than the outside, even in cold weather? I would think you would want to add another comparator with a lower limit so you don't run the fan when the attic is below a certain temperature.
     
  6. mbohuntr

    Active Member

    Apr 6, 2009
    413
    32
    Don't mean to butt in, I'm certainly not in the expert category. I built a similar circuit using a 741 opamp, and a voltage divider/ resistor + thermister combination so that when the temp exceeds 90 F, the output drives a tip 120 to power a pump. (solar pool heater). The voltage divider uses a variable resistor to adjust the setpoint. I used a high value resistor / thermistor to try and limit self heating.

    This way, it will not run if below the preset temp. It works well in air temps, I haven't finished the plumbing part yet. I edited this post to add a similar circuit, the ldr was changed to a thermister, and t1 is a tip 120. Since the high input is the only variable, it was easier for me. Perhaps the pro's here could look at your thermister and load to design a good circuit. I was never very good at calcs.
     
    Last edited: Aug 5, 2012
    imbystox and #12 like this.
  7. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    #12 Your post is most helpful and insightful. Thank you so much for taking the time to explain what is going on for me. You have gone so out of your way to help and it is very appreciated.

    I have made the changes you suggested (pic and schematic attached) and dropped in a fresh LM393 just in case the old one is smoked (and a new LED too). Here is what is going on now. Again, as before, I can drive up the voltage on either side but no change in voltage is detected at pin 1. This time Pin 1 stays low at an almost unmeasurable voltage. Likewise the voltage measured at the collector of the NPN is also nearly zero. However, the LED remains lit nonstop. For what it is worth (I find this interesting anyway) the voltage at the "front" (the long wire) of the LED is 2.57 while the voltage "after" the LED is just .72V. So much to learn :)

    I am still baffled as to why Pin 1 is not acting like a switch, I would love to see that happen.
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    A common mistake when using comparator circuits is not being aware that LM393 and similar circuits have open-collector outputs. Make sure you have a pull-up resistor (10kΩ) on the output pin.
     
  9. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    Great point Crutschow. In fact that is exactly what I plan for pins 5, 6 and 7. I plan to compare my attic temp to a static resistance equal to 90 degrees. Together with an AND gate somehow, my hope is have a logic that says fan turns on if the attic temp is greater than 90 degrees AND greater than outside temp (plus 3 degrees). Given I can't even get a response when comparing to identical sensors I feel like I am far from my goal.
     
    Last edited: Aug 5, 2012
  10. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    I'm glad you mentioned this mbohuntr. I actually tried to do this same circuit with an op amp and had basically the same failure. Maybe if I'm not able to get anywhere with the voltage comparator, I'll go back to the op amp and try to copy your circuit.

    I am interested to know if your TIP 120 was used to actuate a relay and if so what relay did you use? I bought this little number from Sparkfun thinking that it would work to run my fan (120vac .8 amp at high speed). But once I opened the package and saw how tiny the pins are, it doesn't seem like it will work. I just don't know how this tiny thing wouldn't burn up.
     
  11. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    Thank you Mr. Chips. If I understand pull-up resistors correctly, I think this would be a 10K to 47k resistor from Vcc to pin 1. Is that correct? If so I think I already have a 2.7k resistor there. Should I replace that with a 10K (actually it will have to be 15k because I don't have a 10K)?
     
  12. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    MrChips: I specified a pull-up resistor of 2.7k, and it appears that OP did it correctly.

    imby: The fact that the pin 1 is close to zero volts at all times is normal. When the 393 is not dumping the drive current from the 2.7k resistor down to 1 or 2 tenths of a volt, the base to emitter junction of the external npn transistor will hold that voltage to about .6 volts. (Measure there for me.) If you want to see pin 1 change by several volts, unplug the external transistor. I am thinking you have made a mechanical mistake in assembling, but I can't see it by looking at the photo. Your drawing shows an understanding of the schematic. Perhaps that external transistor is shorted?

    The 1.85 volts measured across the LED is perfectly normal.
     
    Last edited: Aug 5, 2012
  13. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    2.7kΩ to Vcc is ok.
    Can you post a circuit schematic?
     
  14. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    It's in post#7
     
  15. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Why do you need the transistor?
    Why do you need two thermistors instead of just one?
     
  16. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    1) the 393 chip has a current limit of 6ma to 16ma. (Some as low as 6 ma.)
    2) it's a differential thermostat.
     
  17. mbohuntr

    Active Member

    Apr 6, 2009
    413
    32
    If you measure the coil resistance of that relay, and use that to fugure the current thru the tip 120, you'll have your answer. The AC side of the relay is rated at 5A. Well above the current draw of your fan. The relay in the pic shows a "flywheel diode" parallelled with the relay. This is important because of the expected reverse voltage spike caused by the collapsing coil field.

    Whichever way you chose, one thermister or two, make sure these guys look it over for safety.
     
  18. imbystox

    Thread Starter New Member

    Aug 4, 2012
    8
    0
    #12 you're a genius. I swapped out the TIP transistor for a 2n2222 and wouldn't you know, the whole thing works perfectly! If i touch the thermistor right, the led turns on. If I touch the left one, it turns off (It is actually reverse of what I thought would happen. I thought the light would turn on when Pin 2 went high but it doesn't matter either way).

    My next task will be to add a 3 degree hysteresis (a resistor from pin 1 to pin 3 i think) but first I need to measure the equivalent resistance change over 3 degrees on the thermistor. Once I get that to work, I'll add another comparison to measure minimum 90 degrees (plus I plan to use an AND gate before the transistor)

    I'll post a picture of my final prototype this evening.
     
  19. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    The logic probably reversed because adding an external npn will invert the logic. The lucky part is that you can reverse the logic all you want and just choose the other thermister to put in the attic if the first choice doesn't work.

    The hysteresis resistance definitely depends on the 7.4k resistor and the resistance of the thermistor. (Hysteresis resistors usualy turn out to be in the megohm range.)
     
  20. radiohead

    Active Member

    May 28, 2009
    474
    31
    Using temperature sensors with an Arduino Uno to trip a relay will work too.
     
Loading...