This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LM339 as comparator

Other Parts Discussed in Thread: LM339, TLV2704, TLV3404, LM6154, LM6134, LM6144, LM7301, LM7341, LM7321, TLV3401

I have used below ckt. & used LM339 as comparator.

Bat+ voltage is +16V & R1=0.050 ohms. Whenever current flows it causes drop across sense resistor. Now I want to generate a logic high signal whenever current flows.Current flows in either direction so one of comparator will turn on depending upon direction of current flow. Problem is drop across sense is 30mV, but still comparator o/p are low. I don't understand what is the problem & if I am doing something wrong.

Thanks & Regards

Deepak Bansal

  • Hi Deepak,

    The LM339 is not a "rail-to-rail" input device. It cannot sense voltages at the supply rail. The datasheet  "Common Mode input votlage range" line specifies the legal voltage as 0V to (Vcc - 1.5), or from ground to 1.5V below Vcc (or 14.5V in your case).

    You can either use a R-R input device, or level-shift the inputs so that they are below 14V.

    Try a R-R input comparator like the TLV2704 or TLV3404.

    Regards,

    Paul Grohe

    SVA Precision Apps

  • Deepak,

    I see two problems.

    1) The LM339 common mode range does not include VCC+
    2) The comparators need an offset of about 15mV added. So 0mV input is off and 30mV is on.

    High voltage (>6V) comparators with rail to rail (or VCC+) common mode range are very rare.
    The National LM6134, (LM6144, or LM6154) op amps could be used as comparators.

    A second approach is amplifying the Rsense voltage  with an opamp, LM7301, LM7321, LM7341 then using the LM339 to check the current flow.

    Regards,
    Ron Michallick

     

     

  • We generally do not recommend using an op-amp as a comparator. Particularly bipolar op-amps, for several reasons:

    1. The input stages are generally not designed for continuous large differential voltages (> 700mV). Permanent damage can occur over a few volts and the offsets will drift. Some op-amps have built-in anti-parallel diodes across the inputs which will cause issues with the circuit if you do not know about them.
    2. Op-Amps are not compensated for use as a comparator - and will have wildly varying response times, overload recovery times and stability issues.
    3. Bipolar device supply currents can increase if the outputs are railed, due to the output transistor bases being driven hard (particularly if it is a high-current output).
    4. The "linear" nature of the amps output stage can cause a "drifty" or "noisy" output near the zero cross, which can also lead to oscillations.

    In this case - the differential voltage is fairly low - which should not not damage the input.

    Anti-parallel diodes across the inputs and series current limiting resistors can eliminate issue #1 in other apps. But this can affect the circuit operation by creating a clamp path from the reference to the signal paths. Always check the abs-max ratings for differential voltage limits. If it is 2V or less, there may be diodes...

    The speed is slow in this circuit, so #2 may not be an issue. Hysteresis can be added to cure #4 - but #3 is still an issue.

    I would not recommend the LM73xx series as comparators, mostly because of issue 3, since these are high-output current devices. The LM61xx should be okay with proper input protection (actually, the are a good choice due to their "slew enhancement" feature and high AVOL)..

    If you do need to use an op-amp, a CMOS type is preferred to eliminate #3. But the other issues still apply. Unfortunately,  CMOS devices tend to be 16V or less.

    Regards,

    Paul Grohe

    SVA Precision Applications

  • Hi Paul,

    Your concerns are valid, but I'd like to add input to the points

    1) Many new op-amps have limited differential inputs, however the majority of op-amps do not. I did check this.
    2) In an open loop comparator application, stability will not be an issue. Slew rate will limit speed.
    3) Most bipolar OP-amps do not have a significant railed current increase. Perhaps some do.
    4) Unless hyteresis is built into the comparator IC, comparators are just as prone to noisy output near the threshold voltage.

    The best solution is to amplify the sense voltage (think differential amp setup) will can also get the voltage off the positive rail.

    Regards,
    Ron

     

  • Hi Paul Grohe, Ron Michallick

    Thanks very much for inputs. I din't notice its input common mode voltage range.Yes that was the error.

    I want to add some points. Please correct me if I am wrong.

    1.LM339 is an comparator designed specifically for comparator purpose so don't think it will have stability issue as in open loop opamp.

    2. Max diff input voltage is power rail inputs voltage in LM339 i.e 36VDC, as it don't have inbuilt protection diodes as in opamps.so won't affect my ckt.

    3. As Paul have said to amplify voltage first, for that I have to again select opamp having common mode voltage equal to rail voltage?

    Thanks & Regards

    Deepak Bansal

  • Hello Deepak,

    Check out http://www.ti.com/lit/ds/sbos181d/sbos181d.pdf

    Hope this helps,

    JayantD

  • Ron, et al;

    This may help. It is an old (2000) presentation that I made to the Burr-Brown Field Applications Engineers (pre-TI acquisition) about using op amps as comparators.

    It contains bench test data on op amps that were popular at that time and these scope photos will help someone understand what to expect from operating an op amp as a comparator.

    Comparator.ppt
  • Thanks Jayant & Neil for your suggestions.

    Regards

  • Hi,

    I have now used two TLV3401. Below is the schematic:

    Problem is when no current flows U2 is high but U1 gives o/p low. I don't understand why this happens? I checked voltage at inv & non-inv terminal of U1, volatges are same. Then why there is error?  When volatges at terminals of comparator is same then o/p voltgae is high or low?

    But when current flows, it gives right indication in both charge & discharge direction. One goes high  while other low.

  • Deepak,

    With zero differential input voltage, the output state is determined by input offset voltage. The small, random offset voltage of each device can be positive or negative and so the output state with zero input will not be the same with all devices.

    Regards, Bruce.

  • Deepak,

    To ensure the outputs are low when no current is flowing and one is high when there is 30mV across the sense resistor, add a 100k ohm resistor from each non-inverting input to ground. this will lower the non inverting input by 15mV.

     

    Regards,
    Ron Michallick

     

  •  

    If you need more sensitivity (lower current threshold) the added resistor can be increased up to 300k which gives a 5mV offset which is large enough to cover the data sheet VIO range.