LM324N IR black and white line detector

Thread Starter

ApacheTB

Joined Dec 6, 2019
1
Good day everybody,

Im currently building a set of line detection sensors using infrared sensors and a comparators which output are connected to a PIC microcontroller for a line following robot. The figure below is a schematic I found online which uses a LM358 OP AMP, however I thought of using 2 LM324N OP AMPs instead of 3 LM358 as its more cost effective.
IR-Sensor-Circuit.jpg

The figure below shows a schematic of 4 sets of IR sensors connected to a LM324N which operating principle is based on the figure above.
LM324N infrared sensor need help.JPG
+5V = from LM7805 voltage regulator
Tx = IR transmitter diode
Rx = IR receiver diode
R = resistors
RV = 25 multiturn 10k trimmer (3296)
D = LEDs to indicate output HIGH or LOW
U = LM324N OP AMP
J = single female pin header to connect to input ports of PIC microcontroller

I have built this configuration on a breadboard and generally there are no problems.
However, when I fine tune the circuit to detect the black and white surface at a close distance (2cm) by adjusting the 25 multiturn trimmers, I will encounter a problem. Adjusting 1 or 2 trimmers will not give me any problems but adjusting the 3rd or 4th trimmers will cause the output of the previous 2 sensors to become either LOW or HIGH (opposite value from previous adjustment).

Therefore now Im stuck in a never ending cycle of adjusting the exact value of the trimmer every time I power it and this is not a practical way. I have run out of ideas on how to solve it as I do not know what is the problem.

Any suggestion/ improvements are welcomed. Thank You
 

KeithWalker

Joined Jul 10, 2017
3,097
Any suggestion/ improvements are welcomed. Thank You
You are using the amplifiers as comparators, with no negative feedback. The LM324 has very high open loop gain. When you adjust the the potentiometers to the switch-over point, the amplifiers are operating in the linear amplification region of their gain curve. They will oscillate unless you take precautions to decouple the power supply for each amplifier and arrange the components carefully to minimize capacitive coupling (see power supply recommendations and layout guidelines in the data sheet).

Regards,
Keith
 

AnalogKid

Joined Aug 1, 2013
11,055
Agree about the hysteresis. For each amplifierr circuit, add a large value resistor between the output and the non-inverting input. Something in the 100K - 470K range to start.

Also, my guess is that there is only about 1.5 mA through each output LED. Bright enough at that low current?

ak

ps. Technically, the comparators/amplifiers without hysteresis do not oscillate. When the two inputs are very close together in value (less than 1 mV difference), the output stage comes out of saturation and the circuit becomes a linear amplifier even though it has no negative feedback to stabilize the gain. The noisy gorp on the output is not oscillation, it is input noise amplified by the opamp's open-loop gain value at whatever the noise frequencies are.
 

TeeKay6

Joined Apr 20, 2019
573
Good day everybody,

Im currently building a set of line detection sensors using infrared sensors and a comparators which output are connected to a PIC microcontroller for a line following robot. The figure below is a schematic I found online which uses a LM358 OP AMP, however I thought of using 2 LM324N OP AMPs instead of 3 LM358 as its more cost effective.
View attachment 193898

The figure below shows a schematic of 4 sets of IR sensors connected to a LM324N which operating principle is based on the figure above.
View attachment 193903
+5V = from LM7805 voltage regulator
Tx = IR transmitter diode
Rx = IR receiver diode
R = resistors
RV = 25 multiturn 10k trimmer (3296)
D = LEDs to indicate output HIGH or LOW
U = LM324N OP AMP
J = single female pin header to connect to input ports of PIC microcontroller

I have built this configuration on a breadboard and generally there are no problems.
However, when I fine tune the circuit to detect the black and white surface at a close distance (2cm) by adjusting the 25 multiturn trimmers, I will encounter a problem. Adjusting 1 or 2 trimmers will not give me any problems but adjusting the 3rd or 4th trimmers will cause the output of the previous 2 sensors to become either LOW or HIGH (opposite value from previous adjustment).

Therefore now Im stuck in a never ending cycle of adjusting the exact value of the trimmer every time I power it and this is not a practical way. I have run out of ideas on how to solve it as I do not know what is the problem.

Any suggestion/ improvements are welcomed. Thank You
@ApacheTB
It is my belief that the photodiodes will conduct only a very small current due to reflected light. Thus, the voltage across R6 (e.g.) will almost certainly be well below 1V, perhaps below 0.1V--how much depends on the LED and photodiode types, separation, reflectivity, etc. However, RV1 will set the detection level over the full range of 0 to 5V; thus only when the trimpot wiper is very close to ground will the opamp inputs be equal and that will make trimpot adjustment difficult. Inserting a resistor between RV1 and +5V will give an easier adjustment. You may have to experiment to decide on the best resistor value. Likewise, you may need to experiment to find the best value for R6, etc, to give a good signal with your components and whatever line and background the light will be reflecting from. I suspect that 10K is low.

Your indicator LEDs (D1-D4) will be much more easily driven if you place them between the LM358/LM324 output and ground; those opamps output will not reach more than 4V under load; however, those outputs will pull to less than 0.1V from ground. (Of course this will change the logical sense of the outputs and the + and - opamp inputs would need to be interchanged.)

An LM358/LM324 can certainly oscillate. The output signal can couple capacitively back to an input if the input has a sufficiently high impedance. Also, a poor grounding path can allow the output signal to create an input signal. Finally, insufficient power supply bypassing can allow an output load to cause a power supply change that couples internally within the opamp or to components that couple to the opamp inputs.
 
Last edited:
Top