help with voltage comparator

Jaguarjoe

Joined Apr 7, 2010
767
Look at the atached data sheet for your LM339 and find the schematic diagram for it. Now look at the output, pin 3. Follow it back to the collector of Q8, the output transistor. Note that there is no connection between Q8's collector and anything. Not being connected to anything, the LM339 can not have an output voltage by itself.
The pullup resistor completes the circuit between the output transistor and the 5 volt power source allowing the LM339's output to toggle between 0 and 5 volts.

http://www.fairchildsemi.com/ds/LM/LM339.pdf
 

Thread Starter

indianhits

Joined Jul 25, 2009
86
ok now i get it its like transistor as a switch right?
when inverting voltage is high it causes the Q8 transistor to go on,hence current flows through Q8 to ground
when non-inverting voltage is high it causes the Q8 transistor to go off,hence current flows through output

is 10K pull-up resistor enough?
 

Audioguru

Joined Dec 20, 2007
11,249
is 10K pull-up resistor enough?
We don't know what the pullup resistor is driving.
The minimum output current of an LM339 low power comparator is only 6mA. If your supply is 5V then Ohm's Law calculates the minimum pullup resistor value to be 5V/6mA= 833 ohms.
 

Thread Starter

indianhits

Joined Jul 25, 2009
86
the output of LM339 will be connected to input of microcontroller I/O pin

and what is the use of DC bias voltage at i/p pin since we are using dc voltage at i/p pins why do we need bias voltage.
 

tom66

Joined May 9, 2009
2,595
the output of LM339 will be connected to input of microcontroller I/O pin

and what is the use of DC bias voltage at i/p pin since we are using dc voltage at i/p pins why do we need bias voltage.
Then 1k to 10k will work. 4.7k is a good middle ground. In reality you could probably go up into 100's of kilohms before you had difficulty (due to the pin's input capacitance.)
 

Jaguarjoe

Joined Apr 7, 2010
767
http://www.tombot.net/beam/pics/circuits/linedetector.jpg

i found this one this was my first plan thought would never work what do you think?

i will connect the output to microcontroller and not the IC mentioned
This circuit will work fine. Don't forget to set the enable pin low. Are you comfortable with SMT? That's what this chip is. There are other non SMT TTL chips that will do this, I don't have their numbers handy. This uses a phototransistor. You said they were too slow before, now they're not? What are you doing with this photoeye set up?
 

Thread Starter

indianhits

Joined Jul 25, 2009
86
This circuit will work fine. Don't forget to set the enable pin low. Are you comfortable with SMT? That's what this chip is. There are other non SMT TTL chips that will do this, I don't have their numbers handy. This uses a phototransistor. You said they were too slow before, now they're not? What are you doing with this photoeye set up?

na just asking.so now will my circuit work?



you guys make things so accurate how do you do it when i showed my circuit to my instructor he says it will work but when i show it to you i am all wrong and noob :(
and sorry for making this post very long.
 

Audioguru

Joined Dec 20, 2007
11,249
Your circuit will not work because the (+) input pin of the comparator is floating with no DC reference voltage. Since the input transistor is a PNP type then the input will float high which will cause the output to always be high.
If you connect a resistor to ground (try 100k ohms) from the (+) input pin to ground then it will have a DC reference voltage of 0V and light on the photo-diode will cause it to leak current which will cause the (+) input pin's voltage to rise until it trips the comparator.
I am talking about an LM393 dual comparator or an LM339 quad comparator, not a 741 opamp.
 

Jaguarjoe

Joined Apr 7, 2010
767
If you connect a resistor to ground (try 100k ohms) from the (+) input pin to ground then it will have a DC reference voltage of 0V and light on the photo-diode will cause it to leak current which will cause the (+) input pin's voltage to rise until it trips the comparator.
I am talking about an LM393 dual comparator or an LM339 quad comparator, not a 741 opamp.
This is what I said in post #4, 45 posts ago.

You can eliminate the 66k resistor, it does nothing.
 

Audioguru

Joined Dec 20, 2007
11,249
Now you have an IR receiver circuit that works but will probably oscillate at a high frequency when the signal is at the threshold because the circuit is missing hysteresis that is discussed in the datasheet for the comparator IC.
 

Jaguarjoe

Joined Apr 7, 2010
767
It depends upon OP's application. 3 pages ago he said he couldn't use a phototransistor because it was too slow. Generally, the only time you need speed is when you're switching so the diode will either be light or dark. With nanosecond response time it'll zip through the threashold much faster than the microsecond response time of the 339.
If he's not switching and he's measuring varying amounts of light where he's floating around the trip point then he will need some hysteresis.
 

Thread Starter

indianhits

Joined Jul 25, 2009
86
It depends upon OP's application. 3 pages ago he said he couldn't use a phototransistor because it was too slow. Generally, the only time you need speed is when you're switching so the diode will either be light or dark. With nanosecond response time it'll zip through the threashold much faster than the microsecond response time of the 339.
If he's not switching and he's measuring varying amounts of light where he's floating around the trip point then he will need some hysteresis.
i am using this to know whether an Obstacle is front of the device.



just curious will this circuit work

http://www.fairchildsemi.com/ds/LM/LM339.pdf
now referring to the above schematic from the PDF file.the Q1 transistor is PNP now i know the operation of PNP but why do we need to connect the extra resistor to ground in non-inverting terminal but PNP transistor need voltage less than 0.7V in base how does this work can you please explain me i have seen several PNP tutorials but none of them tell this type and i am really confused :confused:
 

Jaguarjoe

Joined Apr 7, 2010
767
The little circuit you show will not work for two reasons:
1) the photodiode will not conduct enough current to turn the transistor on.
2) if you did manage to turn on the transistor, it will become a dead short from 5v to gnd and die a cruel death.

The resistor from the (+) input to gnd performs the same function as the resistor from the (-) input to gnd. They are both legs of voltage dividers.

Let us know what grade we got on your project. Is this high school or college?
 
Last edited:

Audioguru

Joined Dec 20, 2007
11,249
i am using this to know whether an Obstacle is front of the device.
Then if the device moves extremely fast (a jet airplane?) the detection is on and off. but if the device moves at a normal speed then as it approaches something the comparator input from the photo-diode will pass through the threshold voltage and the cpmparator will oscillate at a high frequency because hysteresis is missing. Hysteresis adds a "snap-action".

just curious will this circuit work
Nothing (a base-emitter resistor) keeps the transistor turned off when there is no light so the leakage current of the photo-diode might turn on the transistor. A very low light level will turn on the transistor.

There is nothing to limit the current in the transistor when it turns on so it short-circuits the supply.

now referring to the above schematic from the PDF file.the Q1 transistor is PNP now i know the operation of PNP but why do we need to connect the extra resistor to ground in non-inverting terminal but PNP transistor need voltage less than 0.7V in base how does this work can you please explain me i have seen several PNP tutorials but none of them tell this type and i am really confused :confused:
The PNP input transistor needs input bias current from ground so without a resistor from the input to ground then the input will drift up to near the positive supply voltage. You want the input to be at 0V without light.
 

Thread Starter

indianhits

Joined Jul 25, 2009
86
Then if the device moves extremely fast (a jet airplane?) the detection is on and off. but if the device moves at a normal speed then as it approaches something the comparator input from the photo-diode will pass through the threshold voltage and the cpmparator will oscillate at a high frequency because hysteresis is missing. Hysteresis adds a "snap-action".
na i dont need a fast device.

The PNP input transistor needs input bias current from ground so without a resistor from the input to ground then the input will drift up to near the positive supply voltage. You want the input to be at 0V without light.
can you simplify this statement.please
 

Thread Starter

indianhits

Joined Jul 25, 2009
86
OK in short we divide the voltage across the non inverting terminal right?
so that the photodiode itself will form a resistor and this photodiode will vary the resistance depending on received IR light.
 
Top