opamp as a comparator

Discussion in 'The Projects Forum' started by baggio2, Jan 6, 2009.

  1. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    hi..i am using TL082 as a comparator but it didnt work on the circuit..i am comparating 2V 20khz sinus and 3V 100 Khz triangle wave...i wanna get a pwm signal but the comparator doesnt work:( is it better if i use LM392? or do u have any advice?
     
  2. Wendy

    Moderator

    Mar 24, 2008
    20,764
    2,533
    Why didn't it work? Schematic please.
     
  3. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    i will post the schematic...it works in schematic..no problem with it...it doesnt work in real...here the schematic..
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    It's more conventional to use a triangle and compare it against a DC level to obtain a variable pulse width. Comparing a sine wave against a triangle, both at different frequencies, will not produce a predictable output.

    A voltage comparator will always function much better than an op amp in this function.
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You should be using a comparator instead of an opamp. You could use the comparator side of the LM392. You could use an LM393/LM2903 dual comparator, an LM339 quad comparator, etc.

    An opamp does not work well when run open-loop (no feedback path) - it's bandwidth is reduced tremendously, and it's outputs are constantly saturated, causing high current draw from the supply and power dissipation in the package.

    Comparators generally have open-collector outputs. This means that you will need a pull-up resistor to V+/Vcc in order for the comparator output to source current.

    Calculate your output's pull-up resistor as: R=Vcc/3mA, or Vcc/.003A
    Use the closest standard value resistor.

    For example:
    Vcc= 7V
    R= 7V/.003A = 2,333.33... Ohms.
    A table of standard resistor values is here: http://www.logwell.com/tech/components/resistor_values.html
    2,200 (2.2K) is a common standard resistor, and would work well for this example.
    To verify the current: I=E/R, so I = 7/2200 = 3.181...mA

    This will give a reasonable trade-off between low current consumption and maximum output voltage swing.
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Your circuit has no resistors on the bases of Q1 or Q2 to limit current. Check your simulation to find out how much current is going into the bases of those transistors.

    Your driver circuit for the MOSFET gates needs work. If Q1 is conducting, R3 and R8 will act as a voltage divider, so the gate of Q4 will eventually settle at 1/3 of your V+. Similar problem with Q2/R4/R9/Q3.

    There is nothing to prevent "shoot-through". This will occur when both Q3 and Q4 are conducting; basically a direct short between V+ and V-. Power MOSFETs typically have a shorter turn-on time than their turn-off time. You need a mechanism to provide "dead time" so that both MOSFETs are off for a brief period.
     
  7. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    so the 4. leg of LM392 is GND and 8. leg is +Vcc...so will i put the resistor between the source and 8. leg? its voltage is 10 V so R=10/0.003 = 3.3K right?
     
  8. bertus

    Administrator

    Apr 5, 2008
    15,634
    2,342
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    We usually refer to the connections to DIP IC's as pins.
    Pin 4 is GND
    Pin 8 is V+
    Pin 1 is the comparator output.
    With Vcc=10v, a 3.3k resistor would be a very appropriate value to connect between pin 8 and pin 1 as a pull-up resistor for the comparator output.

    Note that you should have a 0.1uF capacitor connected between pins 4 and 8 (V+ and GND) to help suppress transients (voltage spikes).

    If you are not going to use the opamp side, you need to make sure it won't oscillate or do other strange things. One way to do that is to connect it up as a voltage follower, and then provide a voltage reference midway between V+ and V- (in this case, V+ and GND).
    To do this:
    1) Connect the inverting input of the opamp side (pin 6) to the opamp output (pin 7)
    2) Create a voltage divider network by connecting a 10k resistor from pin 4 (GND) to pin 5 (non-inverting input of the opamp) and another 10k resistor from pin 5 to pin 8 (V+). You don't have to use precisely 10k; you could use a couple of 47k, 33k, 22k, 5k - basically, whatever you have available that will consume very little current.
     
  10. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    i finished the d class circuit but it didnt work:(:( it is really so difficult to design...i cant get pwm signal from comparator...could anyone please design a 5W class d amplifier??i wanna start from begining....please!!!
     
  11. bertus

    Administrator

    Apr 5, 2008
    15,634
    2,342
    Hello,

    Do you have an oscilloscope ?
    If so, you could measure on the comparator output.
    This would be a PWM signal modulated by the input signal.

    Greetings,
    Bertus

    PS did you look at the links in the page I gave you ?
     
  12. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    i measured on the comparator output by oscilloscope..it is the problem..i cant get pwm
     
  13. bertus

    Administrator

    Apr 5, 2008
    15,634
    2,342
    Hello,

    What is the amplitude of the input signal ?
    Is there an offset on the input signal ?
    What is the amplitude of the triangle signal ?
    (It MUST be larger than the input signal).
    Is there an offset on the triangle signal ?
    What type of comparator are you using now ?

    Greetings,
    Bertus
     
  14. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    100mV input signal (but i amplify it by preamplifier to 2.5V)
    4 V triangle signal
    i used TL082 and LM392 for comparator..

    and no offset on both
     
  15. bertus

    Administrator

    Apr 5, 2008
    15,634
    2,342
    Hello,

    I have seen that SgtWookie has made clear how to connect the LM392.
    Here is a pinout from the LM392.

    [​IMG]

    Can you make a schematic of how things are connected at the moment ?

    Greetings,
    Bertus
     
  16. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Do you still have Q1 and Q2 connected as shown in your original schematic?

    If so, it won't work that way in the real world.
    Temporarily connect the bases to the emitters (or ground them) so that they'll stay in cutoff.
    Remove the wire that connects the output of the comparator to the bases.

    Do you have a pull-up resistor on the output of the comparator?
    If so, you should now be seeing a signal on the comparator output that goes from nearly ground to nearly V+
     
  17. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    ok....please tell me what the wrong is...or redesign according to what Sgtwookie says

    [​IMG] desing.PNG
     
  18. bertus

    Administrator

    Apr 5, 2008
    15,634
    2,342
    Hello,

    In your drawing there is no pull up resistor.
    The output of the comparator is an open collector, without a resistor to the plus voltage you will not see anything.

    Here is the internal schematic of the LM392.

    [​IMG]

    Greetings,
    Bertus
     
  19. baggio2

    Thread Starter Active Member

    Dec 25, 2008
    60
    0
    so could you please put it on my circuit? i am not as good as you at electronic:(
     
  20. bertus

    Administrator

    Apr 5, 2008
    15,634
    2,342
    Hello,

    Here is the schematic with resistor.

    [​IMG]

    Note that I have connected the GND to - 9 Volts.
    (The triangle voltage will go below GND).

    Greetings,
    Bertus
     
Loading...