Replacing LM324 Op-Amp with LM339 Comparator

In summary, Aruna is working on a line follower robot and he built a following circuit using the help of members in this forum. He used an LM324 opamp as a comparator and a RED LED as a sensor. When he touches the circuit, it changes its readings like the op amp responds to static charge (or something like that). He was thinking if he replaced the LM324 opamp with a LM339 comparator, it would help to solve the problem, but is there any quad comparator IC with the same pin out?
  • #1
aruna1
111
0
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.

https://www.physicsforums.com/attachment.php?attachmentid=20782&stc=1&d=1254182755"

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?

https://www.physicsforums.com/attachment.php?attachmentid=20783&stc=1&d=1254182755"

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
 

Attachments

  • line sensor.pdf
    75.8 KB · Views: 375
  • line sensor-comparator.pdf
    76.2 KB · Views: 331
Last edited by a moderator:
Engineering news on Phys.org
  • #2
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.
 
  • #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
 
  • #4
There's something really wrong with your circuit--or the drawing. You have LED 1 being driven by Op Amp input pin 2.
 
  • #5
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.
 
  • #6
vk6kro said:
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.

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:
  • #7
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. :)

Interesting.
 
  • #8
vk6kro said:
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. :)

Interesting.

well it couldn't 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 can't test positive feedback.so i guess i can learn some theories
:smile:
 
  • #9
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.
 
  • #10
uart said:
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.

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)
 
  • #11
aruna1 said:
anyway do you think having little voltage is giving these troubles?
I saw in a article that small voltages are susceptible for noises?

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.

if this is the cause how can i change my circuit to get high voltage to opamp input?
(external voltage+photovoltage)
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.
 
  • #12
uart said:
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.

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
thanks
 
  • #13
aruna1 said:
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
thanks

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.
 
  • #14
vk6kro said:
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. :)

Interesting.

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.
 
  • #15
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"
or
https://www.physicsforums.com/showthread.php?t=339770

Not sure about the interaction of different colored LEDs. At least the colored plastic would favour LEDs of the same color.
 
  • #16
vk6kro said:
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.

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​
[/URL]
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:
  • #17
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.
 
  • #18
Thank you both. I've tried without success to find photoconductive current as a function of optical frequency...
 

1. Can I replace an LM324 Op-Amp with an LM339 Comparator?

Yes, the LM339 is a pin-to-pin replacement for the LM324 in most applications. However, it is important to read the datasheets carefully to ensure the specifications and functionality meet the requirements of your specific circuit.

2. What is the difference between an Op-Amp and a Comparator?

An Op-Amp is designed for linear amplification and is typically used in closed-loop feedback circuits. A Comparator is designed for comparing two input voltages and providing a digital output based on the comparison. It is commonly used in open-loop applications such as voltage detection and level shifting.

3. Can I use the same circuit design for both an Op-Amp and a Comparator?

In most cases, yes. However, there may be some subtle differences in the input and output characteristics that may require minor adjustments to the circuit design. It is important to refer to the datasheets for both components to ensure compatibility.

4. What are the advantages of using a Comparator over an Op-Amp?

Compared to Op-Amps, Comparators typically have faster response times, higher gain, and lower input offset voltages. They also have higher output current capabilities, making them more suitable for driving loads directly. Additionally, Comparators are often less expensive and more readily available than Op-Amps.

5. Can I use a Comparator as an Op-Amp in a closed-loop feedback circuit?

While it is possible to use a Comparator in a closed-loop configuration, it is not recommended. Comparators are designed for open-loop operation and may exhibit unstable behavior or oscillations when used in a feedback circuit. It is best to use an Op-Amp specifically designed for closed-loop applications in these situations.

Similar threads

  • Electrical Engineering
Replies
3
Views
804
Replies
6
Views
2K
Replies
9
Views
4K
Replies
6
Views
3K
  • Electrical Engineering
Replies
14
Views
3K
  • Electrical Engineering
Replies
6
Views
1K
  • Electrical Engineering
Replies
12
Views
2K
  • Electrical Engineering
Replies
20
Views
6K
  • Electrical Engineering
Replies
7
Views
1K
Replies
8
Views
3K
Back
Top