Hey all!
Since this is my first post i should introduce myself..
My name Karan and i am an engineering student.
I have been working on a project on a project that requires a comparator.
I am using LM324n as a comparator and the circuit is working correctly.
I am using a +5V supply power to the ic but when the output is high i get around 2.1V on the output pin,which is enough to drive an LED but i want to give this output to a PIC18F4520 which will not identify 2.1V as high.
What do i do?
I have tried using a 12V supply for the IC also without any change.
I've been at it for some time and need some help...
I agree, if the output of the LM324 is directly driving the LED sans a series resistor with the LED it sounds to me like you are seeing the forward voltage drop across the LED. Place a resistor in series with the LED and measure the voltage at the output pin. Has it increased? Start with about a 100 Ohm resistor.
and yeah i was driving the LED without a resistor,i followed your advice and connected a resistor in series,Now i get 3.6 V with a 2.2K resistor with o/p pin of lm324 as source and 3.7 V with the o/p pin as sink...
Which configuration should i use?
and if i connect the output pin to the PIC18F4520 as input would the uC identify it as logic 1? (i think it should)
That sounds about right. The LM324 is not a rail to rail operational amplifier so the output voltage swing will be 0 volts to VCC -1.5 or in your case 5 - 1.5 = about 3.5 volts.
Given a choice if you need a LED in there between output and PIC I would let it source and see how that goes. That short of adding a transistor or anything else.
I considered using LM339 but i would have to use pull ups.
Could you suggest a rail to rail amplifier IC or a comparator IC that is easily available and meets the requirements?
I would have used the LM339 since what you want is a comparator. You are only looking at a few resistors added to the circuit and then you are using a chip designed more for what you are after, that being a comparator. As to single supply rail to rail operational amplifiers you may want to give this a read. For a single comparator there is the LM311, for a dual the LM393 and for a quad the LM339 all of which are very common and inexpensive choices.
I considered using LM339 but i would have to use pull ups.
Could you suggest a rail to rail amplifier IC or a comparator IC that is easily available and meets the requirements?
Why not reverse the inputs to the LM324, and wire the LED/resistor between 5V and the LM324 output?
The LM324 can drive it's output within mV of ground when it is sinking current.