Can't get a comparator to work.

Status
Not open for further replies.
I ran into a problem with voltage comparator.
I have a LM393N low power dual voltage comparator.
I wired it up like in the picture below.
View attachment 1636

I got a saw thooth wave for my Vinput and i set Vref at 50%.
Why is my output not a square wave?

Also when i have -V supply grounded i see no wave at all on the output but when i disconnect -V supply then i see my sawtooth wave on the output. When i have my Vref a 4V i see a sawtooth wave with the top half choped off. How do i get a square wave. Is i because that i am using wrong comarator?:r:-? :-?
 
080504-1752 EST

Alex:

You did not specify your resistance values. For low frequency experiments make R2 and R3 1 k, and eliminate R1 or move it to Vref.

Use a +/-12 V supply and probably put some 0.1 ufd capacitors close to the comparator. Your output swing will be between near -12 to +12. With the +/-12 power supply your input peak signal levels need to be somewhat inside those voltages. See the spec sheet.

Assuming you connect Vref to common (some call this ground) and your other input swings above and below common by somewhat over the hysteresis value of the LM393, then you will get a square wave output that swings + and -.

.
 
Here is a better circuit drawing of what i am doing.


Another application for the comparator circuit shown is a square-wave converter. Suppose that the input voltage applied to the inverting (-) input was an AC sine wave rather than a stable DC voltage. In that case, the output voltage would transition between opposing states of saturation whenever the input voltage was equal to the reference voltage produced by the potentiometer. The result would be a square wave:
View attachment 1638
Adjustments to the potentiometer setting would change the reference voltage applied to the noninverting (+) input, which would change the points at which the sine wave would cross, changing the on/off times, or duty cycle of the square wave:
View attachment 1639
It should be evident that the AC input voltage would not have to be a sine wave in particular for this circuit to perform the same function. The input voltage could be a triangle wave, sawtooth wave, or any other sort of wave that ramped smoothly from positive to negative to positive again. This sort of comparator circuit is very useful for creating square waves of varying duty cycle. This technique is sometimes referred to as pulse-width modulation, or PWM (varying, or modulating a waveform according to a controlling signal, in this case the signal produced by the potentiometer).
 
080504-2011 EST

dbuckley:

It does not matter which input is the reference. This simply determines the output phasing.

alex:

Do you have your circuit working yet?

.
 
Alex said:
Instead of resistors im useing sawtooth generator for Vinput, a 4 Vdc power supply for Vref, and 12 Vdc for +/-Vsupply
Are all 3 referenced to [the same] ground?
 
All of the grounds are tied together. My sawtooth circuit works perfectly but the comparator is working properly. I tried every thing but nothing seems to work so i am going to buy a new comparator. That might solve the problems.
 
I think this comparator has an open collector output. THat means you need a resistor from V+ to the output. This resistor supplies the voltage and current for the output to go positive. The comparator internal circuit can ground the output, but not connect it to V+.

Again: connect a resistor from V+ to the output.

Steve
 
080505-1200 EST

It is definitely an open collector. My mistake for not looking at the datasheet closely. But note the emitter of the output transistor is tied to the negative supply.

.
 
gar said:
080505-1200 EST

It is definitely an open collector. My mistake for not looking at the datasheet closely. But note the emitter of the output transistor is tied to the negative supply.

.

Yes, when the + input has a higher voltage than the - input, the transistor is off. Then the output is only connected to V+ through the pull-up resistor, and that brings the output voltage up to V+. (Assuming the circuit you are driving isn't pulling any current.)

When the - input has a higher voltage than the + input, the transistor turns on and shorts the output to V-. Thus, the output voltage goes to V- (within a few tenths of a volts).
 
I got it working

I got it working

hey i got it working

I got a new comparator. It's a different model but it works. It's a 741 OP AMP
It works really nice. Thanks for trying to help out.
 
Alex electrical student said:
hey i got it working

I got a new comparator. It's a different model but it works. It's a 741 OP AMP
It works really nice. Thanks for trying to help out.

That's great. But I'm also sure the resistor would have fmade the other op am circuit work also.

The 741 is not an open collector. Instead, it has a second transistor on the output that is tied to V+. That second transistor takes the place of the pull-up resistor that your other op am needed. The 2 transistors work in a push-pull arrangement - one always turns on, while the other turns off. Then vise-versa to reverse the output voltage.

That second transistor also makes the op amp faster and more efficient. The 741 has been around for decades, and is one of the standard workhorse amps for non-demanding applications.

Steve
 
741 vs. real comparator

741 vs. real comparator

Op amp output slew rates are slower than comparators, if you need a high slew rate. There are probably other advantages to using a real comparator when you need one.
 
Lxnxjxhx said:
Op amp output slew rates are slower than comparators, if you need a high slew rate. There are probably other advantages to using a real comparator when you need one.

Yes, and hysterisis (sp?) is another good reason to use a real comparator. The 741 may be prone to some oscillation as the input signal changes polarity. If there is a little bit of noise, the output may toggle back and forth several times right at the crossing point. That's critical if you are driving a counter.
 
Status
Not open for further replies.
Top