# help with voltage comparator

Discussion in 'General Electronics Chat' started by indianhits, Oct 5, 2010.

1. ### indianhits Thread Starter Active Member

Jul 25, 2009
86
0
Will this circuit work in real time or do i have to modify it?

this is a voltage comparator circuit that i plan to use.If non inverting terminal has more volts than inverting terminal then i want 5V to go to microcontroller port
if inverting terminal has more volts than non inverting terminal then i want 0V to go to microcontroller port

and at the voltage divider i want 3V to appear at inverting terminal

and one more thing is IR LED same as Normal LED when it comes to forward voltage(i.e 3.3V) and current as 30mA?

Thanks!

2. ### Jaguarjoe Active Member

Apr 7, 2010
770
90
The input current for your comparator is probably in the nanoamp range. Thus there will not be enough current flow through the (+) input to light up your LED.
As it stands right now, the (+) input is at a constant oV and the (-) input is at a constant 3V so your comparator output will always be low.
Vf's for LED's vary with color. Google would be your friend here. 20ma is the norm for If for an LED.
Even if your LED would light in the circuit you have shown, how would the (+) input voltage have ever changed?

Last edited: Oct 5, 2010
3. ### indianhits Thread Starter Active Member

Jul 25, 2009
86
0
consider that i am using 5V,200mA from AC plug using a adapter

and sorry its not LED its IR receiving photodiode.

4. ### Jaguarjoe Active Member

Apr 7, 2010
770
90
Is that a regulated 5v A/C adapter? If not, it needs to be.

Obviously a photodiode is not even close to an LED. You need to scrap the 600 ohm resistor and the LED. Now connect the cathode of the photodiode to +5v and the anode to one side of a resistor. The other side of the resistor goes to ground. Connect the (+) input of the comparator to the junction of the diode and resistor.
Your photodiode will have a dark and light current. When dark it is a few nanoA, when light it could be 25uA. You will need to look at the data sheet for your device to get your diodes values. This will determine the value of the resistor in your circuit. You may need to find a new value for the voltage on the (-) input. A trimpot may be good here.
Your comparator must have low input currents for this to work well.

5. ### wayneh Expert

Sep 9, 2010
11,908
2,854
You do mean -5v and not 0v, right? As drawn, your op-amp is either full "on" or full "off". You'd need a single supply to get +5 and zero output states, or need a way to tune a feedback loop to get it dialed into zero at the output.

6. ### mbohuntr Active Member

Apr 6, 2009
413
32
I believe you need a 741 and power it with +5 volts. That way, the output will swing from +5 to 0 volts. Also, try using the IR receiver as a path to ground with these resistor values. This way, you are not using the op-amp to sink current.

Here is the formula for voltage dividers. (Vcc/ (r1+r2)) x r1 = voltage across r1

File size:
15.6 KB
Views:
39
7. ### tom66 Senior Member

May 9, 2009
2,613
213
No, it won't. A 741 is an ancient op-amp and with +5V supply will reach +3.5V maximum, best case.

The correct solution is to use a comparator such as an LM339, LM393 or LM311, which are quad, dual and single comparators respectively.

indianhits likes this.
8. ### mbohuntr Active Member

Apr 6, 2009
413
32
You are right, but the 741 output can be used to switch the digital signal to the port. I tried using the 339's but the sinking output and PNP transistors really confused me. Perhaps a schematic would help. I think you might be better at comparators and digital than I.

9. ### tom66 Senior Member

May 9, 2009
2,613
213
It's pretty easy. Just use a 1k to 10k resistor, one end attached to Vcc and one end connected to the output. The output then either goes to Vcc (being pulled up) or goes to ground (being pulled down.)

10. ### indianhits Thread Starter Active Member

Jul 25, 2009
86
0
OK now that everyone got my attention here is the reason why i want this circuit
i want to "sense" the IR light coming from an other circuit(transmitter).Now this transmitter circuit will keep on sending pulsed signal and i want to get this signal using a photodiode and then i want to compare the signals

and i want least voltage to be 0V and not -5V so for this should i just leave the PINOUT 4 of the opamp(as in 741) to ground or just leave it like that(not connecting anything)

and here is the simplified figure

11. ### tom66 Senior Member

May 9, 2009
2,613
213
Hmm, well there are several problems with this. The op-amp probably won't be fast enough to receive a signal like that. If you use an industry standard IR receiver though, like this one: http://uk.farnell.com/sharp/gp1ux301qs/photodiode-ir-detector/dp/1243866 you will considerably simplify your design and make it cheaper. It would also work properly, whereas the op-amp's slew rate would probably confuse the micro.

12. ### Jaguarjoe Active Member

Apr 7, 2010
770
90
Is the OP sending a 38kHz beam? That Panasonic IR receiver requires it.

May 9, 2009
2,613
213
14. ### indianhits Thread Starter Active Member

Jul 25, 2009
86
0
but can't i simply use a photodiode and resistor combination since i am on a serious budget here and i just want to make it work.

ok when the photodiode sense the incoming IR light the voltage across +VE terminal will be more and +Vcc will be at the output and why does the slew rate gets effected for this?

i never though this would be very complicated!
no small design is easy.

and by the way when i normally use photodiode as receiver what should be the transmitter circuit's IR LED's carrier frequency normally should it be above 40KHZ or can i decrease to like 20KHZ since i think there wont be any noise since i am trying to detect at a range of 5CM maximum(like object detection) and is IR range directly proportional to current in transmitter circuit.

15. ### Audioguru New Member

Dec 20, 2007
9,411
895
The lousy old 741 opamp is designed to use only 30V for its supply. Many of them do not work if the supply is 10V or less. Use an opamp or comparator that work at your low supply voltage. The old 741 opamp has poor high frequency response above only 9kHz.

Your photo-diode is connected backwards so it conducts all the time. Then light does nothing. You need to learn about a reverse-biased photo-diode that "leaks" a current when exposed to light and about a zero-bias photo-diode that generates a small voltage and current when exposed to light.

16. ### Jaguarjoe Active Member

Apr 7, 2010
770
90
The Panasonic part not only requires a 38kHz carrier, it must be sent at certain duty cycles. This will require more parts for the sender than just an LED.

Forget about op-amps, buy an LM339 comparator (which is made for this kinda stuff) at Radio Shack for \$1.99 then go back to post #4 and follow my simple instructions. You will need a pull up resistor connected between the 339 output and +5v. 1k ohm will be OK.

For the transmitter portion use a 330 ohm resistor in series with your LED across your 5v power supply.

Last edited: Oct 6, 2010
17. ### indianhits Thread Starter Active Member

Jul 25, 2009
86
0
i will be using a AC to DC Adapter to 5V,200mA(from wall socket)

also i was looking at LM339 datasheet and found this
Supply Voltage 36 VDC or 18 VDC.So can't i simply use 5V for LM339

Last edited: Oct 7, 2010
18. ### Audioguru New Member

Dec 20, 2007
9,411
895
The first page of National Semi's datasheet for the LM339 says that its Wide supply Voltage Range is 2V to 36V or plus and minus 1V to plus and minus 18V.
The ratings say the absolute max allowed supply is 36V or plus and minus 18V.

So of course it will work perfectly with a supply of 5V.

19. ### Jaguarjoe Active Member

Apr 7, 2010
770
90
There are two types of walwart power supplies- regulated and unregulated. A 5v regulated power supply will maintain a constant output voltage irregardless of the load from 0 to 200ma. It will also have minimal ripple. An unregulated 5v supply will only put out 5v at 200ma. At lower current the output will be a proportionally higher voltage. It will also have much more ripple which will need to be filtered out.
Look at the label on your walwart. If it says" regulated" than that's what it is. If it doesn't than it isn't. If you are not sure, measure its output voltage.

Where is the spec sheet for your photodiode?

20. ### indianhits Thread Starter Active Member

Jul 25, 2009
86
0
good to hear that i didn't knew that one