How do comparators work?

Thread Starter

jayrare

Joined Aug 14, 2007
7
Sorry if this is the wrong forum, I'm really bad at judging that.

I've just started to get into electronics and am already confused. How do comparators work (in layman terms)? Doesn't it just compare whether pin 2 or 3 (I have LM393) is getting more electricity, and then turn on pin 1 is pin 2 is more? Thats how I understood it, but when I tried connecting two different ohm resistors (which should create differences, right?) nothing interesting happened to the LED I had in the circuit.
If it was already on (which happens if the negative end is the side connected, which I also don't understand why thats the only way it works) it stays on, and if it was off (positive side) it stays off.
The ONLY way I can get the comparator seem to be able to have any affect is if I connect a wire from pin 2 to negative power, which turns the LED off, which I also don't understand.

Can someone please help me understand what I'm doing wrong? I've tried every wire combo I can think of.
 

hgmjr

Joined Jan 28, 2005
9,027
Here is an example of a Comparator experiment located in the AAC Tutorial section that you can try.

You might want to sketch your circuit hookup and post it here. Then the members can comment on hook-up problems you may be experiencing.

hgmjr
 

lightingman

Joined Apr 19, 2007
374
So far you have spoken of linear comparators..... There are also digital comparators such as the CD4063 and the 7485.....These will accept two 4 bit binary numbers, and compare them giving a result of hiher, lower or equal to. Thay can be cascaded to any number of bit's.....Daniel.
 

techroomt

Joined May 19, 2004
198
the lm393 package actually holds 2 comparators inside (a & b). first of all, this type of comparator will use bi-polar supplies (e.g. +10vdc and -10vdc). then the two inputs, + (pin 3) and - (pin 2), are constantly compared. whichever input has the more positive voltage applied (the farthest right on a number line), the output will swing to within a volt of that polarity Vcc. say 6vdc is applied to pin 3 and 5vdc is applied to pin 2, the output (pin 1) will swing to +Vcc minus 1 volt or +9vdc. if 7v were applied to pin 2, the output would swing to -9vdc. since the comparator has only 2 output states, + or - Vcc (minus 1volt), it is often called an analog to digital converter.
 
And don't forget the most important part.....most comparartors have an open collector output......don't forget the pullup;)

It would really help if you post a schematic.
 

Thread Starter

jayrare

Joined Aug 14, 2007
7
Okay, at the risk of sounding like a complete idiot, I really didn't understand what anyone said. I -tried- drawing a schematic, but I'm not really sure how its done, so I had to guess. Also, since I don't get comparators, I decided not even to try and use the symbol.

I've tried many different combinations of connecting the different pieces to either negative or power, and many different values for resistors 2 and 3. After several dead LEDs and two smoking comparators, I've decided against trying anymore combos until I know the correct way.
 

Attachments

hgmjr

Joined Jan 28, 2005
9,027
You have the basic conections correct.

Try taking a resistor of the same value as R2 and connect it between pin 2 and ground. This will give you a reference voltage of half the power source or 4.5 volts. Then change the voltage you apply to pin 3 first to 9V then to ground and see that the LED lights up when pin 3 is at ground and it does not light when pin 3 is tied to the power supply.

If you have a potentiometer, you can use it to vary the voltage at pin 3 and see what happens as you vary the voltage up and down.

You can next swap the inputs so that pin 3 is tied to the 4.5V reference voltage and the potentiometer is tied to pin 2. You will see that the behavior of the LED will be reversed. That is, when you adjust the voltage at pin 2 below 4.5 volts the LED will be off and when you adjust the voltage at pin 2 above 4.5V the LED will turn on.

hgmjr
 

Thread Starter

jayrare

Joined Aug 14, 2007
7
I must be doing something wrong. I switched R2 to ground, and the voltage at it was 0 so how do I get the "reference voltage"?
 

hgmjr

Joined Jan 28, 2005
9,027
I must be doing something wrong. I switched R2 to ground, and the voltage at it was 0 so how do I get the "reference voltage"?
I probably did not explain it that good.

What I meant for you to try was to keep the resistor R2 in its original connection state while taking a third resistor whose value was the same as R2 and connect one end of the resistor to the input that is presently connected to R2 and the other end of the resistor to ground. That will form a voltage divider that will provide the reference voltage of about 4.5 volts. The 4.5V is the reference voltage to which I was referring.

hgmjr
 

Thread Starter

jayrare

Joined Aug 14, 2007
7
Okay, I -think- I got it. Pin 2 should have two resistors of equal value connected to it, one going to ground and the other to power?
 

Thread Starter

jayrare

Joined Aug 14, 2007
7
Thank you, I got it working now. But now that I know how to make it work, I want to make sure I know why it works. Here's what I think is happening....

If one of the pins is connected to both positive and negative power, the power is split between the two. If the resistance is equal, the power is split in half. If one resistor is lower than the other, it gets more power, if higher it gets less (Since I'm not sure of the exact power, is it kind of like the reverse of a fraction? For instance, if its 1/4 the total resistance, it gets 3/4th the power?).

So if you have both pins doing this (pin 2 to both negative and positive, pin 3 to both too), and you allow one pin to have a higher amount of positive power, the comparator "turns that pin on" (Not sure what technical term is). And if pin 2 is turned on, pin 1 is also turned on.... and if pin 3 is turned on, pin 1 is turned off?


Am I on the right track?



EDIT:
Also, I've heard that since is a dual comparator, I can use the other side to turn on when the reverse is true (when pin 3 is higher). Do I just connect a wire to from one side to the other, or do I need to do more things like connect it to positive/negative also?
 

Distort10n

Joined Dec 25, 2006
429
A real easy way to understand how a comparator works is to understand voltage potentials on the non-inverting (+) pin and the inverting (-) pin.

Since either pin can be used as the 'reference', think of it this way:

  • If the voltage on the inverting (-) pin is more positive than the voltage on the non-inverting (+) pin, then the output is low.
  • If the voltage on the inverting (-) pin is less positive than the voltage on the non-inverting (+) pin, then the output is high.

This behavior assumes a push-pull output stage, or an open-collector. There are other caveats to take into consideration besides the basics. Input offset voltage, and overdrive voltage are important as well.

Regarding your resistors, what you are describing is a classic resistor divider. For example, take two 1 kohm resistors and call them R1 and R2. R1 is connected to a 5V supply, and to the non-inverting (+) pin of the comparator. R2 is connected from the non-inverting (+) pin of the comparator to ground. Since they are of equal value, then the node potential at the non-inverting pin is 2.5V. Why? You would use the voltage divider rule to calculate the node potential at the non-inverting pin:

[R2/(R2+R1)]*Vin

Using the above values:

[1 kohm/(1 kohm + 1 kohm)]*5V = 2.5V

Depending on your values, you are indeed correct. The potential at the non-inverting node is a fraction of the supply voltage that is connected (5V in this example) to the resistor divider.
 

hgmjr

Joined Jan 28, 2005
9,027
Thank you, I got it working now. But now that I know how to make it work, I want to make sure I know why it works. Here's what I think is happening....

If one of the pins is connected to both positive and negative power, the power is split between the two. If the resistance is equal, the power is split in half. If one resistor is lower than the other, it gets more power, if higher it gets less (Since I'm not sure of the exact power, is it kind of like the reverse of a fraction? For instance, if its 1/4 the total resistance, it gets 3/4th the power?).

So if you have both pins doing this (pin 2 to both negative and positive, pin 3 to both too), and you allow one pin to have a higher amount of positive power, the comparator "turns that pin on" (Not sure what technical term is). And if pin 2 is turned on, pin 1 is also turned on.... and if pin 3 is turned on, pin 1 is turned off?


Am I on the right track?



EDIT:
Also, I've heard that since is a dual comparator, I can use the other side to turn on when the reverse is true (when pin 3 is higher). Do I just connect a wire to from one side to the other, or do I need to do more things like connect it to positive/negative also?
You have grasped the general idea.

Once you gain familiarity with the terminology you will have it down pat. A good place to start will be to read over knightofsolamnus' description and get comfortable with the terms and description he has used.

hgmjr
 

Thread Starter

jayrare

Joined Aug 14, 2007
7
Thank you so much both of you. I managed to get both sides set up, and added some thermistors to make it variable. Since I'm horrible at remembering technical parts, I'm going to print out knightofsolamnus's post and keep it at my work area. Once again, thank you both for your help.
 
Top