Connect with us

op amp output

Discussion in 'Electronic Basics' started by frogfot, Apr 15, 2005.

Scroll to continue with content
  1. frogfot

    frogfot Guest

    Hello, I'm trying to make a thermostat circuit that uses an op amplifyer
    in voltage comparator mode. The circuit is here:
    http://www.interq.or.jp/japan/se-inoue/e_ckt25.htm

    The problem is, circuit doesn't work since when op outputs low it gives
    1,35 V (it gives 11,93 V when high, powered from a car battery).. I
    understand that non-ideal op amps suppose to output high and low with
    slight offset.. but 1,35 V is just to much.. how can this be solved?

    Thanks alot
     
  2. One day frogfot got dressed and committed to text
    So what thermistor are you using ??
    Sounds like the comparator is not quite changing over.
     
  3. frogfot

    frogfot Guest

    It does change.. I said in previous post that comparator gives 1,35 V
    when low and 11,93 V when high. The relay driving transistor doesn't
    want to turn on since voltage is to high.. I want the op to give ~0 V
    when low..

    I even tested the op in a more simple circuit by connecting + input to
    a voltage devider: 10k/10k across the 12 V, so this gave about 6 V. To
    the - input I connected a pot so it could give 0-12 V. Turning the pot
    changed the output of op nicely.. but this gave same problem..
     
  4. John Smith

    John Smith Guest

    Change the opamp for one which gives rail-to-rail outputs.
    Or create your own rail-to-rail output using transistors.
     
  5. Chris

    Chris Guest

    Good morning. The LM319 is actually a dual comparator, which is
    optimized to operate as an on-off indicator of the diference between
    the voltages at the - and + inputs. This works kind of like an op amp
    would, except a comparator is made to switch fast and not spend a lot
    of time between "ON" and "OFF".

    Another feature about most comparators including the LM319 is that they
    have open collector outputs. That means that, when the output is low,
    it sinks current. When the output is high, the comparator output
    transistor is off. If you have a pullup resistor, that gives you a
    high output.

    Now, if you look at the datasheet

    http://www.national.com/ds.cgi/LM/LM119.pdf

    you can get some clues about what's happening.


    VCCVCC
    + +
    | |
    - C|
    VCC ^ C|
    + | C|
    | | |
    5.6K.-. | |
    | | | |
    | | '--o
    |\| '-' |
    -|-\ | |/
    | >----o----|
    -|+/ | |>
    |/| .-. |
    | | |
    1K | | ===
    '-' GND
    |
    ===
    GND
    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    Under normal operation, when the comparator is off, you should see a
    voltage divider between the 5.6K and the 1K resistor. For a 13.8V
    battery voltage, that should give you around 2.1V at the output pin.
    When it's on, it's sinking the current from the 5.6K resistor, about
    2mA. The data sheet on p.4 shows that the output vopltage should be
    pretty near zero.

    You're getting pretty close to the full battery voltage when the
    comparator is off, and about 1.3V when on. Again, looking at the
    datasheet, you can see that the comparator transistor "on" voltage
    starts to rise pretty dramatically when it's trying to sink more than
    about 5mA.

    That leads me to suspect that there's too much current going into that
    node, when the comparator is ON or OFF. First guess -- your transistor
    pinout is wrong. with the flat of the TO-92 plastic package facing
    toward you and the pins down, the pinout from left to right is E - C -
    B. As a first guess, I'd suggest you've got it wired up as E - B - C,
    like the 2N3904 and a lot of other small signal NPN transistors. You
    didn't mention what the battery voltage is (12 or 13.8) when you're
    running this, but this would explain what you're describing. Switching
    the collector and base will turn this into a forward-biased diode
    between the relay and the comparator. The current from the relay will
    swamp the voltage divider into a much higher voltage like you're
    seeing.

    Try rewiring and see if it works. You may have smoked either the
    transistor or the comparator, so if it still doesn't work, replace the
    transistor first.

    Good luck
    Chris
     
  6. Lord Garth

    Lord Garth Guest

    If you've built correctly, I would disconnect the output of the op-amp from
    the relay
    driver. The junction of R7 & R8 should have about 9.5 volts WRT ground.
    This is from 12v-Vbe(sat)/R7+R8 = 11.4v/6600 ohms = 1.7mA so 5600 * 1.7=
    9.52 volts at the R7 R8 junction and the relay should pull in.

    BTW, if the relay coil is < 480 ohms, the LM319 can drive it directly though
    its
    operation would be reversed.

    Grounding the R7 R8 junction should open the relay.

    Having verified this operation, install a pull-up resistor to the LM317
    output.
    5600 ohms would be fine. Insure that the junction of the LM317 and the
    resistor
    can swing between 12 volts and very near ground.

    My guess is that you will have a relay driver problem.
     
  7. Chris

    Chris Guest

    Soory -- my ASCII skills improve with a second cup of coffee. Let's
    try something like this:

    ` VCCVCC
    ` + +
    ` | |
    ` | |
    ` - C|
    ` | ^ C|
    ` .-. | C|
    ` 5.6K| | | |
    ` | | '--o
    ` |\| '-' |
    ` -|-\ | ___ |/
    ` | >- o-|___|--|
    ` -|+/ 1K |>
    ` |/| |
    ` |
    ` ===
    ` GND

    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    The above still applies, but you have to add about 0.7V for the Vbe
    drop when the comparator is off, bringing the comparator off/transistor
    on voltage at 2.8V instead of 2.1V.

    Everything else above still holds. Check the transistor pinout first.

    Chris
     
  8. Ban

    Ban Guest

    Maybe you have soldered the transistor in with the E and C changed, or the
    comparator is oscillating. The whole design on this web page doesn't have
    any hysteresis, which should be there. Just solder a 1Meg resistor from
    pin12 OP to pin4 +IN.
    Actually the statements do not make sense, because the relais should be
    triggered when the comparator output is *high* or in the off state, which
    means the value on the +IN is smaller than on the -IN. Voltage on pin 12
    should be around 1.9V and voltage on the relais coil below 0.3V.

    When the comparator is low, the voltage on pin 12 should be less than 0.3V
    with the lowish current draw of the 5k6 pull-up resistor. Thr relais is then
    off. The output should be able to drive the relais directly, if the current
    is less than 25mA.

    The guy descibed his design:

    "The circuit this time isn't doing to the such circuit. However, I changed
    into the drive circuit which used a transistor because it was unstable that
    the relay works. It wasn't worked when it should work.
    When the output of the comparator is ON(It detects below the setting
    temperature), the base of the drive transistor becomes grounding voltage
    approximately. Therefore, the electric current doesn't flow through the base
    of the drive transistor and the transistor becomes OFF condition. The relay
    doesn't work.
    When the output of the comparator is OFF(It detects above the setting
    temperature), the electric current flows through R7 and R8 into the base of
    the drive transistor and the transistor becomes ON condition. The relay
    works."

    So the transistor was put to invert the logic signal, he could have done
    that faster by just exchanging the +IN with the -IN inputs, good grief.

    ciao Ban
     
  9. John Fields

    John Fields Guest

    ---
    You don't need Q1 and, assuming that your thermistor has a resistance
    of around 1000 ohms at your setpoint, this should work:


    +12V>-----+-------+---------+--------+----+-----+
    | | | | | |
    | | | [10k] |K | O------C
    [4k7] [30k] | | [CR1] [COIL]- - -|
    | | +---|--[1M]--+ | | O--> |<--O--NC
    | | | | | +-----+ |
    | | | | | | +-----------NO
    +---+---------+--|+\ | D
    | | | | >------+--+-----G 2N7000
    [RTH] | [10k]<--+--|-/ LM319 | S
    | | | | | | |
    +---+ | | | | |K |
    | | | | | | [Z15V] |
    | [4k7] | [30k][0.1µF]| | |
    | | | | | | | |
    [0.1µF]|[0.1µF]| | | | |
    | | | | | | | |
    GND>--+---+---+---+-----+---+-----------+-------+


    If it has a different resistance, post back with the spec's or a part
    number and over what temperature range you want to be able to vary
    your setpoint.

    The 1 megohm resistor is in there for hysteresis and you may want to
    change it if the thermostat cycles too quickly.
     
  10. Rich Grise

    Rich Grise Guest

    Use a comparator instead of an op amp. Op amps are designed to be analog,
    and so are likely to not be rail-to-rail. The output of a comparator
    is an open-collector transistor, with the emitter either grounded or
    connected to the negative supply (which is probably ground), so can
    pull the output down to Vcesat.

    Cheers!
    Rich
     
  11. frogfot

    frogfot Guest

    Thanks for all replies. I'm pretty sure that all parts are ok and
    connected correctly, I've looked it through several times.

    How stupid of me to forget mention that I used another op, TL082. I've
    tested to change to LM358 and it gave almost 0 on low!
    Huh, I beginned to use an op instead of transistors for this
    application because I thoat this will give simpler circuit.
    But is 1M resistor really needed? I thoat it only decreased the
    precision.. Now I included it.
    The relay coil will drain quite alot. It will control a ~500W boiler.
    The high/low output doesn't change much if I remove all load from the
    op output (if my multimeter isn't counted as a load). But anyway, I'll
    use different op amp.

    Mine NTC is 10k at 25*C and 500 at 100*C. I don't understand why you've
    used an MOSFET (I'm more used to transistors :p ).. and what's the
    purpose of Z15V, is it a zener diode?

    I was going to use this circuit to control temp in a water-bath at
    0-100*C.

    Thanks for your time again.
     
  12. frogfot

    frogfot Guest

    Thanks for all replies. I'm pretty sure that all parts are ok and
    connected correctly, I've looked it through several times.

    How stupid of me to forget mention that I used another op, TL082. I've
    tested to change to LM358 and it gave almost 0 on low!
    Huh, I beginned to use an op instead of transistors for this
    application because I thoat this will give simpler circuit.
    But is 1M resistor really needed? I thoat it only decreased the
    precision.. Now I included it.
    The relay coil will drain quite alot. It will control a ~500W boiler.
    The high/low output doesn't change much if I remove all load from the
    op output (if my multimeter isn't counted as a load). But anyway, I'll
    use different op amp.

    Mine NTC is 10k at 25*C and 500 at 100*C. I don't understand why you've
    used an MOSFET (I'm more used to transistors :p ).. and what's the
    purpose of Z15V, is it a zener diode?

    I was going to use this circuit to control temp in a water-bath at
    0-100*C.
     
  13. frogfot

    frogfot Guest

    Thanks for all replies. I'm pretty sure that all parts are ok and
    connected correctly, I've looked it through several times.

    How stupid of me to forget mention that I used another op, TL082. I've
    tested to change to LM358 and it gave almost 0 on low!
    Huh, I beginned to use an op instead of transistors for this
    application because I thoat this will give simpler circuit.
    But is 1M resistor really needed? I thoat it only decreased the
    precision.. Now I included it.
    The relay coil will drain quite alot. It will control a ~500W boiler.
    The high/low output doesn't change much if I remove all load from the
    op output (if my multimeter isn't counted as a load). But anyway, I'll
    use different op amp.

    Mine NTC is 10k at 25*C and 500 at 100*C. I don't understand why you've
    used an MOSFET (I'm more used to transistors :p ).. and what's the
    purpose of Z15V, is it a zener diode?

    I was going to use this circuit to control temp in a water-bath at
    0-100*C.
     
  14. frogfot

    frogfot Guest

    Thanks for all replies. I'm pretty sure that all parts are ok and
    connected correctly, I've looked it through several times.

    How stupid of me to forget mention that I used another op, TL082. I've
    tested to change to LM358 and it gave almost 0 on low!
    Huh, I beginned to use an op instead of transistors for this
    application because I thoat this will give simpler circuit.
    But is 1M resistor really needed? I thoat it only decreased the
    precision.. Now I included it.
    The relay coil will drain quite alot. It will control a ~500W boiler.
    The high/low output doesn't change much if I remove all load from the
    op output (if my multimeter isn't counted as a load). But anyway, I'll
    use different op amp.

    Mine NTC is 10k at 25*C and 500 at 100*C. I don't understand why you've
    used an MOSFET (I'm more used to transistors :p ).. and what's the
    purpose of Z15V, is it a zener diode?

    I was going to use this circuit to control temp in a water-bath at
    0-100*C.
     
  15. frogfot

    frogfot Guest

    Thanks for all replies. I'm pretty sure that all parts are ok and
    connected correctly, I've looked it through several times.

    How stupid of me to forget mention that I used another op, TL082. I've
    tested to change to LM358 and it gave almost 0 on low!
    Huh, I beginned to use an op instead of transistors for this
    application because I thoat this will give simpler circuit.
    But is 1M resistor really needed? I thoat it only decreased the
    precision.. Now I included it.
    The relay coil will drain quite alot. It will control a ~500W boiler.
    The high/low output doesn't change much if I remove all load from the
    op output (if my multimeter isn't counted as a load). But anyway, I'll
    use different op amp.

    Mine NTC is 10k at 25*C and 500 at 100*C. I don't understand why you've
    used an MOSFET (I'm more used to transistors :p ).. and what's the
    purpose of Z15V, is it a zener diode?

    I was going to use this circuit to control temp in a water-bath at
    0-100*C.
     
  16. John Fields

    John Fields Guest

    ---
    I used a MOSFET because the gate doesn't draw any current, so you
    don't have to worry about the comparator output going out of
    saturation when it's sinking the transistor's base current. If you
    used a transistor you'd want to force beta to about 10, which means
    that for a relay with a 100mA coil the base current would need to be
    10mA, which could pull the LM319 output out of saturation. The Zener
    (15V) is to make sure that any spikes which appear on the MOSFET's
    gate will be clamped to 15V in order to keep the MOSFET from getting
    damaged.
    ---
    ---
    If you mean from 25 to 100°C, then I suggest you do something like
    this:

    +12V>-----+-------+---------+--------+----+-----+
    | | | | | |
    |R1 |R2 | [10k] |K | O------C
    [10k] [10k] | | [CR1] [COIL]- - -|
    | | +---|--[1M]--+ | | O--> |<--O--NC
    | | | | | +-----+ |
    | | | | | | +-----------NO
    +---+---------+--|+\ | D
    | | |R3 | >------+--+-----G 2N7000
    [RTH] | [10k]<--+--|-/ LM393 | S
    | | | | | | |
    | | +-----+ | |K |
    | | | | | [Z15V] |
    | | [R4] | | | |
    | | | | | | |
    |[0.1µF]| [0.1µF]| | |
    | | | | | | |
    GND>------+---+---+-----+---+-----------+-------+

    Notice that I changed the comparator to an LM393, which is a better
    comparator for this application, I believe. (and cheaper,too) The
    value of R4 is going to depend on the the end point resistance of R3
    and should be set so that with the pot (R3) rotated fully toward GND
    the voltage on the comparator - input is the same as the voltage on
    the + input with the water bath at 100°C. Probably close to 500 ohms,
    the 100°C resistance of the thermistor.
     
  17. Chris

    Chris Guest

    Hello again. I was under the impression you were working with a
    comparator and trying to get the circuit to work. Having switched over
    to an LM358 (which will get within a couple hundred mV of GND while
    sinking a couple of mils) should have handled your immediate problem of
    getting the relay transuistor to turn off.

    However, you've got a couple of serious problems that don't have
    anything to do with that. First, the schematic transistor TR1 is a
    current-driven device whose gain will be very dependent on temperature.
    A small change in the ambient temperature around Q1 will cause a large
    change in voltage impressed across the 2K load resistor. Bad news if
    you want to maintain a steady setpoint.

    Second, whether you use an op amp or a comparator to drive the relay
    transistor, you're going to have problems with transistor oscillation
    when the thermistor voltage gets close to the pot voltage. That can be
    hidden a bit by the fact that the relay coil will act to average the
    voltage impressed across it, and that relay coils have inherent
    hysteresis (you usually have to get them up above 50% of rated voltage
    for them to turn on, but once on, they will almost always stay on until
    coil voltage goes down below 25% of rated voltage).

    In short, I think the author of the web page knew more about web page
    design (pretty good, actually) than electronics (inadequate, actually).
    It's a common problem. But there's a pretty good basic circuit on the
    web similar to yours that doesn't have the problems listed above:

    http://www.uoguelph.ca/~antoon/circ/heatsens.html

    This circuit will also have the issue about the turnoff voltage of the
    op amp not being quite low enough to turn off the transistor. It also
    lacks consideration for using a remote thermistor.

    But, considering you've got an LM358 dual op amp to solve the turn-off
    issue, you might want to try something like this (view in fixed font or
    M$ Notepad):


    VCC
    +
    |
    | VCC
    .-. +
    | |47K |
    | | .---o
    '-' | |
    | VCC | C|
    | + - C|
    o--. | 220K ^ C|
    | | 1N914 | ___ ___ | |
    | | - .-|___|-. .--|___|--. | |
    .-. | ^ | 22K | | | | |
    | | | | | |\ | | VCC | '---o
    | | | | '-|-\ | ___ | |\| | |
    '-' | 0.1uF | ___ | >--o-|___|-o--|-\ | ___ |/
    | '------------o---o-|___|-|+/ 10K | >---o-|___|-o-|
    '-----------. | | 22K |/ .--|+/ 2.2K | |>
    Thermistor | --- | | |/| .-. |
    <--o --- - | GND | | |
    Shield | | ^ | 2.2K| | ===
    === === |1N914 | '-' GND
    VCC GND GND | | |
    + ____ === | ===
    | | | GND _V_ GND
    o-|7805|-o----------------------------|___|--.
    | |____| | 50K |
    --- | --- ===
    --- | --- GND
    | === |
    === GND ===
    GND GND
    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    The first op amp is used as a voltage follower to buffer your signal
    from the thermistor. Make sure to use the shield connection as in your
    original art. The second op amp is set up as a comparator, but has a
    220K feedback resistor to provide hysteresis. You can decrease the
    value to 100K or so if you're still getting oscillations at the output.
    However, the more you increase the hysteresis, the moreexcursion
    you'll get on water temperature for this "bang-bang"-type controller.
    Try to use the higher value resistor. The 7805 is a cheap way to get a
    good reference voltage for the 50K pot, so your reference voltage will
    be stable when the relay turns off and pumps current into the power
    line.

    When constructing the circuit, make sure to use a bypass capacitor on
    the op amp, and make sure your power supply wires are close to the
    board. If not, add a really good (1000uF) cap across the power supply
    to stabilize the power supply. You should also try to avoid contact
    arcing at the relay contacts by either putting a quencharc across the
    resistive heater load, or at least physically moving the relay some
    distance from the circuit.

    The problem with using op amps as comparators is that they have
    relatively slow transistions, and tend not to have logic level highs
    and lows. Of course, the relay open/closure time (one to several ms.)
    is far longer than any delay caused by op amp slew rate. And if you
    use an op amp made for getting output close to the negative supply, you
    won't have a problem with turning off an NPN transistor. The LM358
    isn't a bad choice for this application.

    I hope this has been of help.

    Good luck
    Chris
     
  18. Chris

    Chris Guest

    Sorry -- you'll have much better luck if you feed the 47K/thermistor
    divider with the reference voltage from the 7805. My bad.

    ` +5V
    ` |
    ` | VCC
    ` .-. +
    ` | |47K |
    ` | | .---o
    ` '-' | |
    ` | VCC | C|
    ` | + - C|
    ` o--. | 220K ^ C|
    ` | | 1N914 | ___ ___ | |
    ` | | - .-|___|-. .--|___|--. | |
    ` .-. | ^ | 22K | | | | |
    ` | | | | | |\ | | VCC | '---o
    ` | | | | '-|-\ | ___ | |\| | |
    ` '-' | 0.1uF | ___ | >--o-|___|-o--|-\ | ___ |/
    ` | '------------o---o-|___|-|+/ 10K | >---o-|___|-o-|
    ` '-----------. | | 22K |/ .--|+/ 2.2K | |>
    `Thermistor | --- | | |/| .-. |
    ` <--o --- - | GND | | |
    ` Shield | | ^ | 2.2K| | ===
    ` === === |1N914 | '-' GND
    ` VCC GND GND | | |
    ` + ____ +5V === | ===
    ` | | | | GND _V_ GND
    ` o-|7805|-o----------------------------|___|--.
    ` | |____| | 50K |
    ` --- | --- ===
    ` --- | --- GND
    ` | === |
    ` === GND ===
    ` GND GND
    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    Good luck
    Chris
     
  19. frogfot

    frogfot Guest

    Oobs, sorry for posting same post 5 times.. I'm using mailgate and it
    seems to bug.. I've already deleted more than half of them..
    Wouldn't that 2 op circuit have the same ambient temp dependance?

    I was thinking to go as simple as possible, while keeping the precision.
    Though if this circuit will make no temp drift during the operation, it
    would be preferred above "1 op circuit". Seems like I'm going to use a
    dual op anyway.

    By the way, in that corrected circuit you've posted, should the 1N914
    be connected to +5V too instead of unregulated Vcc? Oh, and what is the
    purpose of those two diodes?
    I was going to use a voltage regulator, while feeding the ralay from
    nonregulated current as you've suggested. The circuit will be powered
    from a small transformer, so that I don't have to change any batteries
    in the final device :p

    Got it, though if I understood the graphs for LM358 (op that Chris
    suggested) correctly, at +10 mA the output should be at maximum 0,2 V.
    And that current should be more than enough for my "coil driver".
    Lol, the reason I try to avoid MOSFETs is because they don't like me..
    First time I bought 2 of them, they died before I could test them.. (I
    heard they're very sensitive to static electricity..)
    And besides, I get most of my transys from my dead tv, there's no
    MOSFETs for some reason :)
    Yp, exactly, I just wanned it to have somewhat wider "regulation window"
    or how to call it..

    Heh, now I really don't know which circuit to use.. :p What would be
    the main differences in this circuit and that 2 op circuit that Chris
    posted? Soz, I'm not that much into electronics to see the difference :p
     
  20. John Fields

    John Fields Guest

    ---
    I like Chris's circuit better, but with these modifications:


    +5V
    |
    | VCC
    .-. +
    | |47K |
    | | .---o
    '-' | |
    | 5V | C|
    | + - C|
    o--. | +----+ ^ C|
    | | 1N914 | ___ 1M _V_ | | |
    | | - .-|___|-. .--|___|--+ | |
    .-. | ^ | 22K | | | | |
    | | | | | |\ | | 5V | '---o
    | | | | '-|-\ | ___ | |\| | |
    '-' | 0.1uF | ___ | >--o-|___|-o--|+\ | ___ |/
    | '------------o---o-|___|-|+/ 1k | >---o-|___|-o-|
    '-----------. | | 22K |/ .--|-/ 390 |>
    Thermistor | --- | | |/| |
    <--o --- - | GND |
    Shield | | ^ | ===
    === === |1N914 | GND
    VCC GND GND | |
    + ____ +5V === |
    | | | | GND _V_
    o-|7805|-o----------------------------|___|--.
    | |____| | 50K |
    --- | --- ===
    --- | --- GND
    | === |
    === GND ===
    GND GND
     
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

-