infrared obstacle avoidance sensor problem

Thread Starter

cbart52

Joined Feb 23, 2020
13
I ordered some infrared obstacle avoidance sensors from Amazon for a little project I'm working on. I am using them to power a relay. I got a 10 pack. I have tested 3. The problem is they don't seem to be working properly. When I plug them into the project, they power the relay when there is nothing in front of them and only turn off the relay when there is an obstacle in front of them. In other words, no obstacle=power output from sensor. Obstacle=no power output from sensor. Am I missing something here? Is it possible they came wrong from the factory? Like backwards?
Thanks!
 

djsfantasi

Joined Apr 11, 2010
6,786
Or perhaps they are working as designed and you misinterpreted the specs. They DO detect obstacles, don’t they? Just that the output is active low. If you want to invert the signal, place an NPN transistor in the output path.
 

crutschow

Joined Mar 14, 2008
25,377
If you connect the relay to the V+ power instead of ground, then that should invert the operation.
(Unless the relay is internal to the sensor and you can't change the coil connections).
 
Last edited:

MisterBill2

Joined Jan 23, 2018
6,973
It appears that the sensors are intended to operate and stop motion when they detect an obstacle. That would be known as "low true" logic.
 

Thread Starter

cbart52

Joined Feb 23, 2020
13
Or perhaps they are working as designed and you misinterpreted the specs. They DO detect obstacles, don’t they? Just that the output is active low. If you want to invert the signal, place an NPN transistor in the output path.
1582505368157.png1582505368157.png1582505368157.png
This is how I have it wired. I have a NPN transistor in the output path.
 

Thread Starter

cbart52

Joined Feb 23, 2020
13

crutschow

Joined Mar 14, 2008
25,377
You should put a diode (e.g. 1N4841) across the relay coil (anode to transistor) to protect the transistor from the inductive transient.
 

MisterBill2

Joined Jan 23, 2018
6,973
One more thought is that since detecting obstacles is a safety thing, the devices are designed to "fail safe". If their power goes off the relay drops and an obstacle is indicated. Really, that is the only smart way that they could work.

It is rather difficult to tell the difference between zero and nothing.
 

Thread Starter

cbart52

Joined Feb 23, 2020
13
You should put a diode (e.g. 1N4841) across the relay coil (anode to transistor) to protect the transistor from the inductive transient.
Sorry crutshow, your talking way above my head. I know next to nothing about this stuff. I just need the relay to switch on when there is an object in front of it and switch off when the object is removed. If I don't protect the transistor from the inductive transient will it blow that transistor?
 

MisterBill2

Joined Jan 23, 2018
6,973
Sorry crutshow, your talking way above my head. I know next to nothing about this stuff. I just need the relay to switch on when there is an object in front of it and switch off when the object is removed. If I don't protect the transistor from the inductive transient will it blow that transistor?
Use the other contact on the relay, as shown both NO and NC are available.
 

TeeKay6

Joined Apr 20, 2019
572
You should put a diode (e.g. 1N4841) across the relay coil (anode to transistor) to protect the transistor from the inductive transient.
You likely meant a 1N4148 diode. The T.S. might not recognize the typo.

@cbart52
Yes, the NPN transistor could (not "would", but "could") be damaged/destroyed by not protecting it against the inductive flyback when the transistor turns off. Without making other changes, why not consider the solution offered by MisterBill2?
 
Last edited:

Thread Starter

cbart52

Joined Feb 23, 2020
13
Use the other contact on the relay, as shown both NO and NC are available.
MisterBill2, Thanks. I really appreciate your input and help. Everyone for that matter. That worked to reverse the operation but..........now I have power to that relay full time and my voltage regulator is getting very hot. Do you know of any way to accomplish this without having power to the relay full time?
 

MisterBill2

Joined Jan 23, 2018
6,973
MisterBill2, Thanks. I really appreciate your input and help. Everyone for that matter. That worked to reverse the operation but..........now I have power to that relay full time and my voltage regulator is getting very hot. Do you know of any way to accomplish this without having power to the relay full time?
Do those sensors demand regulated 5 volts? Can they work on 6 volts from 4 "D" cells? or on the voltage from one or two Li batteries in series? And if the circuits posted in #5 are accurate it looks like you may be able to replace that 2N2222 transistor with a similarly rated bPNP device, and exchange the emitter and collector connections. That would reverse the sense of operation, and if the relay is the main power draw component then the problem would be solved. Unfortunately I do not recall the number of the PNP device similar to the 2N2222. But there is such a device.
 

TeeKay6

Joined Apr 20, 2019
572
Do those sensors demand regulated 5 volts? Can they work on 6 volts from 4 "D" cells? or on the voltage from one or two Li batteries in series? And if the circuits posted in #5 are accurate it looks like you may be able to replace that 2N2222 transistor with a similarly rated bPNP device, and exchange the emitter and collector connections. That would reverse the sense of operation, and if the relay is the main power draw component then the problem would be solved. Unfortunately I do not recall the number of the PNP device similar to the 2N2222. But there is such a device.
I believe that there is a fair chance that the PIR output does not swing rail-to-rail. It may only rise a few volts (or less) above ground. That would never allow a PNP transistor to be off; the relay would always be partially driven. However--the question that remains to be answered is what output swing is available from the PIR device actually being used.
 
Does the module look like this? If so, it does not source much current, it only sinks current. Best to change from NPN to PNP transistor like SamR suggests 2N2907 or 2N3906 etc. An extra clamp diode acorss the relay coil is needed, like 1N4148 or 1N4004. Note this sensor does pick up sunlight and you would have to upgrade to pulsed IR for better performance.
Smart-Electronics-Smart-Car-Robot-Reflective-Photoelectric-3pin-IR-Infrared-Obstacle-Avoidance...jpg
 

MisterBill2

Joined Jan 23, 2018
6,973
The sensor in the post is not similar to the one that the TS has. This one is a reflective object detector, with no relay output.A totaly di9fferent beast.
 

Thread Starter

cbart52

Joined Feb 23, 2020
13
Does the module look like this? If so, it does not source much current, it only sinks current. Best to change from NPN to PNP transistor like SamR suggests 2N2907 or 2N3906 etc. An extra clamp diode acorss the relay coil is needed, like 1N4148 or 1N4004. Note this sensor does pick up sunlight and you would have to upgrade to pulsed IR for better performance.
View attachment 199835
Yes, this is what my sensor looks like. Thank you so much for all of the advice everyone. I am thinking I might just need to find a different sort of IR sensor. To be honest with you a lot of the advice that has been given has gone over my head. I only just started dabbling in this stuff. I do however really appreciate everyone trying to help. I can get the system working using a PIR sensor like the one below but the time delay is unacceptable even at the lowest setting.



1582588003602.png
 

Thread Starter

cbart52

Joined Feb 23, 2020
13
Does the module look like this? If so, it does not source much current, it only sinks current. Best to change from NPN to PNP transistor like SamR suggests 2N2907 or 2N3906 etc. An extra clamp diode acorss the relay coil is needed, like 1N4148 or 1N4004. Note this sensor does pick up sunlight and you would have to upgrade to pulsed IR for better performance.
View attachment 199835
I meant to say that the sensor I am having trouble with is the type prairiemystic posted.
 

MisterBill2

Joined Jan 23, 2018
6,973
The sensor shown in post #16 does not include a relay. That means that relay coil current is not an issue. So now there is confusion on my part. previously there was reference to a relay, and also a circuit that included a relay. If it is just the current through the comparator output resistor then that resistor can be replaced with a higher valued one and feed an external gate to provide compatible drive outputs.
 
Top