opamp as a comparator

Thread Starter

baggio2

Joined Dec 25, 2008
60
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?
 

beenthere

Joined Apr 20, 2004
15,819
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Thread Starter

baggio2

Joined Dec 25, 2008
60
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?
 

SgtWookie

Joined Jul 17, 2007
22,230
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?
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.
 

Thread Starter

baggio2

Joined Dec 25, 2008
60
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!!!
 

bertus

Joined Apr 5, 2008
22,277
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 ?
 

bertus

Joined Apr 5, 2008
22,277
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
 

Thread Starter

baggio2

Joined Dec 25, 2008
60
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
 

bertus

Joined Apr 5, 2008
22,277
Hello,

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



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

Greetings,
Bertus
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
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+
 

bertus

Joined Apr 5, 2008
22,277
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.



Greetings,
Bertus
 

Attachments

Top