to remove this pot, and use just some resistor. This potentiometer is for setting a threshold of a distance for HIGH and LOW on DOUT if I get it correctly. It is 10K. If some value of 1K is ok to me, not sure if should I tie it on GND or VCC. Can someone put some light on here?
A distance of a few centimeters is what I am up to. My guess is smaller the value of the resistance, the smaller the threshold is.
It is easier, I agree. But if I need to make dozens of those with few cm of sense, it is much easier to solder two resistors than one pot. And maybe I should need to trim every pot to set the distance... With two resistors I could have an exact value on IN- for every IR set. Which is what I need. And all I need is HIGH and LOW at the end.
I believe the smaller the value, the smaller the threshold is. Am I right?
Ok.
But do I need it? All I need is to get detection on some 2-3cm distance, or even 5-6. So if I have 20 sets of IRs and the same resistor values, I will get the same distance detection. Am I right? No matter the tolerance. Three centimeters or five does not matter. It does matter if it is 10cm, though.
If I use potentiometers and have to make a correction on them for the right distance, I will have to make it on all 20. This is much harder. Not suitable for a series.
If you use fixed resistors and have to make a correction on them for the right distance, you will have to make it on all 20.
Then you have to haul out a soldering iron instead of a screwdriver. You also have to make the correction right the first time or else repeat resoldering.
If I get the right two of them then I will only have to populate them on all 500 IRs. Or a million.
I will have to choose two of them, only to get the right distance, which should be about 3cm (precision is not that important). If (when) I have the right values, I will never need to correct them. Just populate places on PCBs.
It is not important to have precision measures. But it is important to not have to mess up with the screwdriver on every single IR. And I need HIGH and LOW on the output.
Yes, and if you aren't using the analog input, you can include a 10M or so positive feedback resistor like a comparator should have. See page 14 https://www.ti.com/lit/ds/symlink/lm393-n.pdf
It's a bad idea to allow a comparator to chatter around in its linear region.
Or even use a quad comparator and have 4 IR.
Edit - not two on one comparator, one on the (+) and one on the (-). I hope that is not what you meant. I mean, you can use both comparators in the dual comparator package.
If you are feeding the LM393 output to an Arduino, why not replace it with an op-amp (LM39x) to give a bit of gain with fixed biasing, feed into an analogue input, and set the threshold digitally?
One thing to watch for is that IRs are sensitive to ambient radiation. Sunlight contains a lot of IR (it's hot!), as does incandescent bulb light (not so common today). LED lighting is probably better but you need to check. I have a clock that uses an opto-interrupter to sense the pendulum position, I found it behaved strangely at odd times of day which I tracked down to sunlight on the sensor.
Many industrial IR proximity sensors modulate the LED at a frequency significantly different from mains, preferably higher, then amplify and filter the received signal before synchronously rectifying it. Sounds complicated but can be quite economical with hardware. In about 1980 I designed one of these, we could get 1m range even in bright lighting and up to about 50m with a retroreflector.
It should detect an object on some 5-10mm from IRs. The object is some 2-3cm. So, basically, if it is just in front of it. I don't care if there should be something from 5-6cm and further.
There might be some regular LED light, white I believe. There shouldn't be any daylight at all, or not that much. Especially as the object will be as close as possible to IRs. There will be several sets of IRs on one PCB. There will be several PCBs. A potentiometer might be the best choice, but I don't want to mess with dozens of them. That is why I am up to a straightforward solution. If I can achieve it with resistors, just to see if there is something or not. The fewer components, the better. That is why I asked can I use the B side of a comparator for the second IR.
The values of the resistors I should determine according to the distance.
Well I still think that converting to digits and applying the thresholds in SW would save a lot of messing with multiple pots and resistors. Use a single op-amp to provide a modest gain, put an analogue MUX in front of it, and scan the optos fast enough to get the response time you need.