Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Op-amp or comparator?

  1. Sep 28, 2009 #1
    hello guys I'm working on a line follower robot and i built following circuit(with the help of members in this forum :smile:) as line sensor.


    it uses LM324 opamp as a comparator and RED LED as a sensor.
    Circuit does what is built to do-identifying difference between black-white surface but it still has little problem.if i touch the circuit while its working it changes its readings.-its like op amp responds to static charge(or something like that) in my body.

    So i was thinking if I replace LM324 opamp with LM339 comparator IC will this help to solve the problem?


    and is there any quad comparator IC with same pin out as LM324? (LM339 has different pin out so i will have to built circuit all again :cry:)

    thank you

    Attached Files:

    Last edited by a moderator: Apr 24, 2017
  2. jcsd
  3. Sep 28, 2009 #2


    User Avatar
    Science Advisor
    Gold Member

    When you touch the circuit you are probably acting like an antenna and are picking up lots of AC (60Hz) noise. You could check into trying to shield the circuits or just not touch it. I would stay with the LM324.
  4. Sep 28, 2009 #3
    Hi Aruna-
    On the LM324, I believe you need a little positive feedback to make it switch like a comparator. Try 510k from the output (pin 1) to the positive input (pin 3). If this doesn't get rid of the noise, then try 220k.
    Bob S
  5. Sep 28, 2009 #4
    There's something really wrong with your circuit--or the drawing. You have LED 1 being driven by Op Amp input pin 2.
  6. Sep 28, 2009 #5


    User Avatar
    Science Advisor

    This is a follow-on from an earlier thread.

    The LED is used in photo-voltaic mode, so it is generating a voltage depending on reflection of the light from another LED from a white line a robot is trying to follow.

    Sure looks weird because LEDs are not normally used like this. But it works quite well.
  7. Sep 28, 2009 #6
    Thanks vk. And by the way, that's a new one on me.. I didn't know a LED could be used as a photodiode, though it makes some sense. Is that what it is?
    Last edited: Sep 28, 2009
  8. Sep 28, 2009 #7


    User Avatar
    Science Advisor

    It is a bit more like a solar cell. It actually generates a voltage. A photodiode just changes its resistance with light levels. I couldn't get a LED to behave in photoresistive mode.

    It can't produce much current though, so it has to have a high impedance load.

    I put one across a digital multimeter on the 2 V DC range and it could produce up to a volt of output when held near a 60 W lamp. Good multimeters have a 10 Mohm voltage divider and they work better.

    Aruna is getting a lot less than that, of course, but LEDs are cheap and he needed 8 of them to work out where the robot was heading. :)

  9. Sep 29, 2009 #8
    well it couldnt generate much voltage because its lighted by another LED.it will generate more voltage if i use very bright light like vk6kro did. :smile:

    anyway how positive feedback going to solve this. now I'm at campus and will go home day after tomorrow.so till then i cant test positive feedback.so i guess i can learn some theories
  10. Sep 29, 2009 #9


    User Avatar
    Science Advisor

    Need for positive feedback was alreadly indicated here : https://www.physicsforums.com/showthread.php?t=339770&page=2#17

    And and example circuit using positive feedback given here : https://www.physicsforums.com/showthread.php?t=339770&page=2#29

    Positve feedback will make it hold it's present state more reliably with less sensitiveity to noise. If you use too much positive feedback then it may make it completley refuse to change state, so you have to make sure that you only use an amount which is compatible with your available signal levels.
  11. Sep 29, 2009 #10
    oh,i see.

    anyway do you think having little voltage is giving these troubles?
    I saw in a article that small voltages are susceptible for noises?

    if this is the cause how can i change my circuit to get high voltage to opamp input?
    (external voltage+photovoltage)
  12. Sep 29, 2009 #11


    User Avatar
    Science Advisor

    Yes definitely. Not just small voltages but high impedance is also a big factor (as in, high impedance generally gives worse noise immunity). The other huge factor is good layout and grounding. This however is a system wide aspect that can't really be addressed with regard to only this one circuit sub-part.

    The circuit I linked to before was an attempt to give larger voltage swings and a least provide some control over the impedances (to improve the present situation in which the "dark state" is quite close to being a "floating open circuit" in the present design.)

    You could make this situation a whole lot better by using proper photo diodes which could provide a reasonable voltage swing into a much lower impedance. I know that you previously mentioned that you went with LED's as the sensor to reduce the sensitivity to ambient light. If ambient light is the main problem then there are other ways to address this, which I could go into later.
  13. Sep 29, 2009 #12
    I'm kind a getting tired of this circuit.because in this semester I have lot of acedemic work.so do you think i should forget LEDs and go for LDR? (or IR tx rx pair)
    i was thinking that LDR and photodiode gives large difference for evan small light so it will greatly affected by ambient light than using a LED as sensor
  14. Sep 29, 2009 #13


    User Avatar
    Science Advisor

    Well the issue of the ambient light and the photodiode sensitivity should be a relative one. By this I mean that if the photodiode is more sensitive then yes it will respond more to ambient light but it should (see note) also respond proportionally more to your signal. In this regard it shouldn't be a problem, you can just lower the impedance and lower the response to both light sources in proportion.

    NOTE : One possible issue here is that perhaps the LED is more sensitive to specific wavelengths (and in particular to the wavelength of the transmitter LED) which may be why you observed a relative advantage in using a low sensitivity LED as a detector in preference to a more conventional photo-diode. In this case you could try some optical filters or try to find a photodiode type that is more wavelength selective in it's response.
  15. Sep 29, 2009 #14
    Facinating. Can you post the link to the previous thread?

    Did you discover this on your own, or hear of it? I wonder if this a photoelectic effect, so that a red led won't induce a voltage in a green led, for instance.
  16. Sep 29, 2009 #15


    User Avatar
    Science Advisor

    No, I didn't invent it. I first heard about it about 20 years ago, but probably tried it with an analog meter and couldn't get it to work.
    With a much better digital voltmeter, it is easy to get the effect.

    It is worth knowing about, too, in case a LED in some equipment gets bright lights on it when the equipment isn't even turned on. I've driven a LED directly from an expensive Micro chip and yet it could feed half a volt back to the micro with the power turned off.

    The previous thread is still on this page:
    "interfierence with infinite gain op amp"

    Not sure about the interaction of different colored LEDs. At least the colored plastic would favour LEDs of the same color.
  17. Oct 2, 2009 #16


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Hi vk6,

    I think you're confusing a photodiode with a photocell. Photocells change resistance with light level, and are commonly made from cadmium sulfide. They are often used as light sensors in outdoor lighting.

    Photodiodes (typically made of silicon) do generate current and voltage when illuminated, and are basically the same as solar cells.

    EDIT: found this image for a photodiode i-v curve, at different light levels ( from http://www.rp-photonics.com/photodiodes.html ):

    http://www.rp-photonics.com/img/photodiode.png [Broken]​
    Figure 1: Current-voltage characteristics of a photodiode for different optical powers. In the photovoltaic mode (see the line for a 1-kΩ load resistor), the response is nonlinear. In the photoconductive mode, shown here for a simple circuit with a reverse bias applied through a load resistor, a very linear response is achieved. The same holds for a constant reverse bias (not shown)​
    Last edited by a moderator: May 4, 2017
  18. Oct 3, 2009 #17


    User Avatar
    Science Advisor

    Yes, thanks for that.

    So, sure, the LED would be like a photodiode used in photovoltaic mode.
    Doesn't seem to work in photoconductive mode though.
  19. Oct 3, 2009 #18
    Thank you both. I've tried without success to find photoconductive current as a function of optical frequency...
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Similar Threads for comparator
Window Comparator Question