Connect with us

Hysteresis needed in 741 Op-Amp circuit

Discussion in 'Electronic Basics' started by CF, Jun 10, 2004.

Scroll to continue with content
  1. CF

    CF Guest

    Yes sorry, I had spelled this out on an earlier draft of the web page, then
    deleted it along with other superfluous stuff...

    This thermostat circuit is hooked up to a cooling fan, so I want the relay
    contacts to close (turn the fan on) when the temperature is high and the
    thermistor resistance is low.


    (Rob Paisley) wrote in
  2. CF

    CF Guest

    Thanks for the circuit Bill, demonstrating the positive feedback for
    hysteresis that we've been talking about. Interested to see the 339's
    output feeding into the transistor, I looked it up. It's output is
    classified as "Open Drain/Collector" (which I presume is similar to the
    331). Thus, your output should be like Rob Paisley's at:

    However, you seem to have a pullup resistor attached to the same pin that
    is apparently sourcing current for the transistor, so I'm confused. What is
    to stop current bypassing the 339 altogether by running directly through
    the 2.2k pullup resistor into the transistor's base?

    Also, you don't have the first IC marked. Is it also an LM339?



    (Bill Bowden) wrote in
  3. CF

    CF Guest

    I have no idea what I'm talking about, but I'm not happy with the way the
    311-based circuits that we've been discussing take their positive feedback
    from an output that is constantly pulled up to a positive voltage when the
    output is supposedly "off". Surely this undermines the whole concept of
    positive feedback?

    The earlier 741-based circuits, those modelled by Terry, and Bill Bowden's
    399 circuit for that matter, are quite different in this respect. They seem
    to provide feedback only when it is appropriate.

    With this in mind, I've tried to take advantage of the option to use a
    "ground-referred" load on the 311's output, and redesigned the circuit at
    the following page. However, I'm uncertain about the polarity of the pins,
    as they are supposedly reversed under these conditions, yet are drawn in
    the same configuration in the spec brochure (see same page). If anyone has
    any insight into this, please let us know.

  4. Me too! In fact, all 3 files seemed to have vanished. Very odd, as I
    checked them all after posting. Anyway, I've just uploaded them again
    and at present they are all accessible.

    Without your thermistor to hand I can't be sure, but if it's that
    sensitive then I expect you're right about the modification making
    adjustment more difficult. I was primarily aiming to demonstrate a
    practical way of adjusting hysteresis over a wide range, as you hadn't
    specified how much you wanted.
  5. CF

    CF Guest

    I can see the images now too. They're very nice outputs that seem to say it
    should work.

    Yes, the thermistor is extremely sensitive, even if not completely linear
    over a wide range. I think I'll try hooking up the feeback pot to pin 3
    without running the main inputs through it. I presume this will still throw
    my dial off very slightly, but if I set the hysteresis pot and then leave
    it, I can recalibrate once and be done.

    Of course, then I'll be tempted to pull it all apart and try the LM 311.

    Thanks heaps for your help.

  6. 'Should'? "And here is a typical actual result from that breadboarded
    circuit (using a triangle wave as input)" Note 'actual'.
    To repeat my earlier recommendation, experiment on breadboard is IMO
    by far the most effective way of developing this sort of circuit. And
    to avoid the trouble (and time) of heating and cooling the thermistor
    for various settings of the hysteresis pot, use another pot. You could
    choose its value, or rather, its value and that of a couple of
    typically equal fixed resistors in series with it, top and bottom.
    Maybe use John Field's formulae, or just start with a 10k pot and
    maybe 6k8 or so series resistors and see how it works. Takes only
    seconds to swap the components and try again.
    All good experience!
  7. CF

    CF Guest

    I hear you Terry. A breadboard has got to be the way to go. I was just
    looking at them in a catalogue today, admiring the concept.

    Sorry about misreading your post. My old newsreader program decided to die
    in the middle of this discussion and it threw things off a bit. I'm amazed
    that you actually wired it up. Glad to know that it's a real result though,
    as I've got the soldering iron heating up right now. I like the idea of
    using a pot in place of the thermistor temporarily too.

    We'll see what happens.


  8. Bill Bowden

    Bill Bowden Guest

    When the 339 output is high, the output pin is completely disconnected
    from the transistor base and resistor because it is a "open collector"
    output. Therefore, the transistor will turn on since it sees a resistor
    connected from base to +V. When the 339 output goes low, the transistor
    turns off because the base is grounded.
    Yes, same chip.
  9. CF

    CF Guest

    Hooray! The 741-based version is working with real hysteresis. Please see
    circuit at:

    Terry, I found that the way you had it drawn, with the thermistor side
    going into the inverting input, it seems to act as a heater control unit.
    This might be because of the negative temperature coefficient of the

    Also, I've got a 500K trimpot on the feedback, and it's barely enough to
    keep hysteresis to 1 degree C. A larger pot would suit me to put this
    figure closer to the middle of its range. By rigging it the way I have, it
    only shifts my scale by less than half a degree compared to having no
    feedback circuit.

    I've found that a 20K resistor is enough to saturate the PNP transistor
    that I'm using too, so the original 1K itemwas overkill.

    Thanks to all who've contributed to this. Next step is to try the 311,
    though I might save this for a few weeks hence. Eventually I'll draw up a
    web page with the two versions detailed for the benefit of others.

  10. Just another thought, the 741 isn't going to be able to turn off the
    current into your relay completely. If you measure the current through
    the pass transistor, you will see some current leakage due to this.
    This wastes power. If you put a 10k resistor from the output of the
    741 to the 12V rail, it'll give the 741 a little lift, and so it'll be
    able to turn off the PNP transistor more effectively.

    Thus, I'd make the circuit look similar to this:

    12V -------o--------o----------------------o----.
    | | | |
    | | | |
    .-. .-. | |
    10k | | | |10k .-. |
    | | | | 10k| | |
    '-' '-' | | |
    | ___ | ___ '-' |
    o--|___|----o--|___|--. | |
    | 3960T | | 330k | | |
    | R1 | | R2 | | |
    | | | |\ | 3.3k | |
    | o--|---|-\ | ___ | |<
    | | | | >--o-|___|---o--| PNP
    | | .---|+/ |\
    | | |/ |
    | | .------|
    | o---. | .--+---.
    NTC .-. .-. | | | Relay|
    10k \ | | | |<-. - | Coil |
    \ | | | ^ | |
    '-' '-' 22k | '--+---'
    | | Adjust for temp | |
    | | | |
    0V -----o--------o--------------------o------.
    created by Andy´s ASCII-Circuit v1.24.140803 Beta

    According to JF's post, the TC of the 10k NTC is about -4%. By
    coincidence, for the circuit above, that works out to about a 1%/C
    swing at the voltage divider, assuming temps are close to the center
    of the range at 25C. That works out to 120mV of hysteresis per degree
    C. So,

    0.120V*T = 10V * R1/330k, so R1(T) := 3960*T.

    where T is the temperature range you need.

    These are ball park figures, based on the 4% NTC of the thermistor.
    Different thermistors will have different TCs.

    Bob Monsen
  11. CF

    CF Guest

    Bob, you were absolutely spot-on. I measured the current leakage as you
    said, and it was 2.3 mA. With a 10k resistor in place as you suggested, it
    was 0. Fantastic!

    Along the same lines of avoiding wastage, I notice that my supposedly 30mA
    (at 12v) relay coil is actually drawing 50mA. I suspect this is because my
    supply voltage is a tad high. I measure 19.3 volts with an open circuit,
    and 16.3 under load. I'm using a transformer I had lying around, which fits
    nicely into my enclosure. I originally measured it at about 14v AC, but it
    seems that the smoothed average DC is quite a bit higher. This might also
    account for high-ish values of the resistors I've added lately too.

    To avoid waste and possibly safely convert to an LM311 one day (sinks 50mA
    max through output), what is the best way to regulate the voltage down to
    say, 13-14 under load? I don't know much about the way that voltage
    regulators and zeners work, but I hate the thought of a component
    constantly throwing away power.

    Thanks for the formula too.

  12. CF

    CF Guest

    (Bill Bowden) wrote in
    Aha! I see now. Current through the 2.2k pullup resistor alternately flows
    to ground either via the transistor or the 339 depending on whether the
    latter is high or low.
    Oh yes, of course!

    Just curious, did you choose the LM339 quad-comparator over, say, the LM319
    high speed dual comparator
    ( for any particular
    reason, or just familiarity?

    Thanks for the explanation.

  13. Rich Grise

    Rich Grise Guest

    If you plan to change to a real comparator, do it right away. There's
    no use in flailing away at a 741 circuit, trying to get a mediocre,
    albeit robust, opamp - which they've tried to optimize for linear
    operation - to act like a comparator is giving yourself an unnecessary
    obstacle before you even start.

    Have Fun!
  14. CF

    CF Guest

    I wish I'd started with a real comparator in the first place with
    hysteresis figured in. I now realise this is du rigueur. Instead, I have
    already built the inellegantly-designed 741 circuit gleaned from the web,
    and the source of much frustration. However, thanks to the great help here,
    it's now at least functional (actually seems to work quite well), and best
    of all, has taught me a lot about electronics that I would have
    conveniently ignored with a good initial circuit.
    I'm having a ball. Part of me says to leave well enough alone, and the
    other part is itching to rip the 741 out of there and do it properly. I
    know which part will win in the long run.

  15. Put an emitter resistor of about 150 Ohms between the supply voltage
    and the pass transistor. That should drop it down to the appropriate
    12V at 30mA.
    You can buy regulated 12V supplies (wall warts) for a song. Or, you
    can use a 7812 voltage regulator, which will drop the voltage to a
    regulated 12V. You are going to lose the power anyway, though, no
    matter what you do, unless you get a new transformer, or you build an

    Getting 30mA through your pass transistor means you'll be wasting 4.3V
    x 0.030A = 129mW. Not too bad.

    Bob Monsen

    PS: Its customary to put replys inline, or at the bottom of the reply
    posting, so that responses make sense to those who use lossy news
    readers. Since almost nobody uses these lossy news readers anymore,
    its not as critical, but folks still appear to insist on it as a
    matter of taste.
  16. John Fields

    John Fields Guest


    Since the LM311 can safely handle supply voltages up to about 36VDC,
    and its output can handle about 50V, there's really no need for a
    regulated supply there. Neither is there a need for a regulator if
    you choose the proper relay to use with the supply you have at hand.

    If you measured the unloaded output voltage from the transformer and
    it was 14VAC, then there's a good chance it's a 12V transformer with a
    regulation of about 17% from no-load to full load.

    With a 14VRMS output, rectifying that in a full-wave bridge and
    smoothing it should result in about 18.4VDC across the filter cap,
    with no other load across it. A 19VDC output smacks of half-wave
    rectification, which is kind of OK for the light loads you're using,
    but it makes the filter cap need to have twice the capacitance as if
    you used a full-wave bridge, plus its ripple-current requirements also
    double (or something like that, anyway).

    Assuming that a 50mA load isn't really enough to change the output
    voltage from the transformer, knowing that you're using a half-wave
    rectifier, a reservoir capacitor and that your load varies from 0mA to
    50 mA, with a 3 volt change in the output voltage we can figure out
    what your filter cap looks like from:

    I t
    C = -----

    Where C = capacitance in farads
    I = the steady-state current into the load in amperes
    t = the period of the ripple waveform in seconds
    Vr = the amplitude of the ripple in volts

    I t 0.05A*0.017s
    so, C = ----- = --------------- = 0.0028F ~ 3000µF
    Vr 3V

    Pretty close?

    Now, here's a shocker for ya; if you switch from a half-wave rectifier
    to a full-wave bridge, you won't need to use filtered DC to run the
    relay, you can do it like this:

    12VAC>--------------------+ |
    | |
    | | |
    | |
    | | |
    | IN |
    +-------------------[78L12] |
    | OUT |
    | | |
    | | |
    | | |
    | +--------+--------+ +-------+
    | | | | |K | O--> |
    | [R1] [10.7K] | [1N4001] [COIL]- | - -|
    | | | | | | | O--->COM
    | | +-[634K]-------+-+-----+ |
    | | | | | +-------->NO
    | | | +------+ |
    | | +----|+ C|----+
    | | | |LM311 |
    | [1000]<-----|----|- E|--+
    | | | +------+ |
    | | | | |
    | [R2] [RT1] | |
    | | | | |

    The reason being that the full-wave rectified AC will be pulsing on
    and off 120 times a second, and the spring trying to return the
    relay's armature to the non-energized position won't have enough time
    to do it in between pulses. You may not need the 78L12 either, but
    it's nice to have a steady voltage to drive the reference and the
    thermistor string, and if you're going to do that you may as well
    regulate the supply voltage to the comparator since it won't cost any
    more to do that as well.

    Looking at the relay supply, since you've got 14VRMS coming out of the
    transformer, that would rectify and filter to about 19.8VDC with
    perfect diodes and a perfect cap, but with the reality of two diode
    drops that'll go to about 18.4V, which is about 13VRMS, which is what
    will be driving the magnetic field being generated in the relay coil.
    That may be fine, but you'll need to look at the relay spec's to make
    sure that 1V of overdrive won't hurt the coil. Otherwise, what you'll
    need to do is put a resistor in series with the relay coil to drop the
    extra voltage. Since you'll want to drop 1 volt at 50 mA, you can
    figure out the resistance you'll need from:

    E 1V
    R = --- = ------- = 20 ohms
    I 0.05A

    and the power the resistor must dissipate from:

    P = I E = 0.05A*1V = 0.05W

    so a standard 20 ohm, +/-5%, 1/4 watt resistor would be fine.

    All that's left is to figure out the capacitance of the reservoir cap,
    C1, and to do that we can use

    I t
    C = -----

    if we can determine the load current of the circuitry attached to it
    and specify the ripple coltage we can stand.

    For the LM311 we'll have 7.5ma worst case, for the thermistor string
    something less than 1mA, for the reference string (I'm not going to
    figure it out, but assuming there'll be no more than 5V dropped across
    the pot puts that current at 5mA), and 5.5mA for the 78L12 brings the
    total to 19, say 20, mA. Just for grins let's say that we can live
    with 50 millivolts of ripple. Then, plugging that in gives us

    C = --------------- ~ 0.0033F = 3300µF

    Interestingly, just about what you had before!

    Now, however, you've got a nice little supply with almost no ripple
    and a pretty reliable relay driver.

    We still need to look at the power the 78L12 is going to dissipate,
    and if we look at the worst case unloaded DC across the filter we'll
    have 18.4V into the 78L12 (so we'll have no headroom problems,
    anyway!) and 12V out of it, so the voltage across it will be 5.6V, and
    with 20mA flowing through it that'll be 112mW it needs to get rid of.

    The 78L12 has a worst case junction-to-ambient thermal resistance of
    160°C/watt, so with a 25°C ambient and 112mW being dissipated by the
    device its junction temp will rise by

    Tj = -------- * 0.112W ~ 18°C
    1 watt

    With an ambient temp of 25°C, then, the junction temp will go to 43°C.

    Piece of cake! The thing won't even _think_ about going into thermal
    overload protection there and, BTW, that's the _only_ power that'll be
    wasted in the circuit, (except for the 50mW being dissipated in the
    relay's series resistor, if you have to use one) which isn't too bad.
  17. John Fields

    John Fields Guest

    Oops... I forgot about the hysteresis. You'll have to refigure it
    because of the increase in the relay driver's peak voltage, and you'll
    need to add a cap to the comparator's output to smooth the 120Hz
    pulses when the relay isn't turned on. Something like this this:

    12VAC>--------------------+ |
    | |
    | | |
    | |
    | | |
    | IN |
    +-------------------[78L12] |
    | OUT |
    | | |
    | | |
    | | |
    | +--------+--------+ +-------+
    | | | | |K | O---> |
    | [R1] [10.7K] | [1N4001] [COIL]- -|- - -|
    | | | | | | | O--->COM
    | | +-[634K]-------+-------+ |
    | | | | | +--------->NO
    | | | +------+ |
    | | +----|+ C|----------+
    | | | |LM311 | |
    | [1000]<-----|----|- E|--+ |
    | | | +------+ | |+
    | | | | | [10µF]
    | [R2] [RT1] | | |
    | | | | | |
  18. CF

    CF Guest

    Thanks for this Bob, I see your point that it's wasted energy one way or
    the other. I don't mind if it's unavoidable. An SMPS is not justified yet!



    PS: I'm all for standardization.
  19. CF

    CF Guest

    John, this is outstanding stuff. I think what I'll end up doing is letting
    the bulk of the circuit run at the higher voltage, which is within range,
    as you point out, for the 311 and even the current 741. I'll just drop the
    voltage for the relay coil, which is what I'm most concerned about. This
    way when the relay is off (most of the time), there's no extra component
    making unwanted heat, etc.

    My power supply circuit does use a full-wave bridge rectifier, but the
    transformer is actually putting out 14.75 volts AC according to my latest
    reading on my (non-true-RMS) multimeter. The reservoir cap is 2200uF. When
    I spoke of the voltage under load, I was actually including a small fan
    too, rated 12v, 0.11A. The transformer is not marked, but looks like a
    typical 150-ish mW unit.

    Talk about electronic detective work! I can't believe you could deduce so
    much from so little info, though the quality of the info was bad.

    Now I'm going to save and print out your formulae and play with it all.


  20. CF

    CF Guest

    OK John, very nice. Any special type of capacitor? I presume I'd be getting
    100Hz pulses where I live (50Hz mains).

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day