IR obstacle avoidance - Page 1
Forum section: electronics / beginners

author: Trooperettes
author_rank: Newbie
timestamp: March 28, 2020, 07:14:22 pm
content: Hi there, this is my first posting on this forum, and I am writing here because I need a little help in figuring out why my super simple IR obstacle avoidance circuit is not working as I would have expected it to.I am trying to build a simple circuit with an IR LED that illuminate the space in front of it and an IR Transistor that that changes state if there is anything in front based on the reflection of the light from the LED. See attached image for circuit diagramI am using a standard 950nm IR LED (TSUS5400) and a 38kHz TSOP4838 IR Receiver (https://www.vishay.com/docs/82459/tsop48.pdf). I am controlling the detection distance by applying more or less resistance on the LED circuit. I am also generating the pulse (38000Hz) and reading the sensor using an Arduino Nano (the same).My code looks like the following:Code:void loop () {tone(irLedPin, 38000, 8);delay(1);Serial.println(digitalRead(irDetectPin));...}I get it to work, but when I move the obstacle into "view" slowly, it is not detected. I am quite sure that it has to do with the detector as I had the same circuit working with a different detector, which worked great. I find this quite strange and do not understand what is going on. I do not understand the duty cycles, which might be the problem. Still a n00b in the fieldAny advice is greatly appreciated!- Hans

author: GerryR
author_rank: Frequent Contributor
timestamp: March 29, 2020, 11:01:07 am
content: First, why the 220 resistor in the output line? The unit is active low, NPN to gnd. Not knowing the rest of your circuit, this may be affecting you. Secondly, and more importantly, the unit responds to bursts of 10 to 70 cycles and requires a gap time between bursts of at least 12 cycles, so you should be generating an output of 10 to 70 pulses and then shutting down for at least 12 cycles (at 38 KHz, ~316 usec) before sending another burst. If you are doing that, then it should be working.

author: Trooperettes
author_rank: Newbie
timestamp: March 31, 2020, 11:44:03 am
content: Thanks for your quick reply GerryR. The resistor was placed there because of an example I started out from. I have run it with and without, with the same results. I had a hunch that the timing was the problem (lack of pauses in the pulses) but wasn't sure how to mitigate that. I will try with some delays and see if I can't get the cycles right. I found it really confusing that the speed of which the obstacle entered the field had an effect though. Which is why I just had to ask the professionals

author: Manul
author_rank: Super Contributor
timestamp: March 31, 2020, 03:16:39 pm
content: I think you want the type of IR receiver which is made to receive continuous wave. Because TSOP4838 is for data packets and rejects constant signal as noise. You want something like TSSP4038 which is a light barrier receiver. You can look some of them below. Filter by application "Presence sensors, fast proximity sensors".http://www.vishay.com/ir-receiver-modules/show-all/In general, if you see some "control circuit" in a block diagram, it means it is not for constant signal. Here is block diagram of TSOP4838:

author: Siwastaja
author_rank: Super Contributor
timestamp: March 31, 2020, 04:57:57 pm
content: TSOP4838 is for remote controls, i.e., sending small data packets. Abusing it for obstacle avoidance is likely possible, but of unnecessary complexity.I'd suggest, either go super simple and, in conjuction with the IR LED, use a bare plain old phototransistor: just connect the emitter to ground, and pull the collector up with a resistor, measure collector voltage, either with an ADC pin, or just a digital input pin. Adjust the pullup resistor value to set the sensitivity.Or, if you want to go fancier than that, buy ICs for actual distance measurement. ST has a nice portfolio of completely integrated, one-chip solutions based on time-of-flight principles, ranging up to about two meters in centimeter accuracy. These work on I2C bus.

author: Trooperettes
author_rank: Newbie
timestamp: April 01, 2020, 06:59:56 am
content: Thanks a bunch Siwastaja and Manul! I will try to get a hold of some TSOP4038's. I think I need some sort of filtering to get rid of potential fluorescent lighting disturbance as well as sunlight disturbance.I am making an obstacle alarm for a forklift to avoid hitting the storage racks with the top of the lifting arm. I had first made one using an ultrasonic module (Parallax Ping) but the detection area was too narrow, so I thought I'd use IR instead as the distance to be detected is less than 10 cm. If I have a module that can detect at about 90 deg I should be fine. Also, I had about 20 TSOP4838's lying around. Which is why I picked thoseUnfortunately interpreting the data sheets are a bit out of my league..Thanks for all the help!

author: Manul
author_rank: Super Contributor
timestamp: April 01, 2020, 11:35:52 am
content: Quote from: Trooperettes on April 01, 2020, 06:59:56 amNot TSOP4038's, butTSSP4038.Anyway, it is not hard to recognize them, they are described as light barrier, fast proximity, presence detection, etc. And as I said, they (as far as I know)don't have"control circuit" in a block diagram. Take a look at the suggested TSSP4038:https://www.vishay.com/docs/82458/tssp40.pdfSunlight should not be a big problem, because it is not modulated. And fluorescent lights should not have significant harmonics at 38khz. It should work reasonably well. If not, go for other solutions, as Siwastaja mentioned.

author: Siwastaja
author_rank: Super Contributor
timestamp: April 01, 2020, 01:06:10 pm
content: Take a look at VL53L1X from ST, if the 27 degree FOV is too narrow, maybe you can put two pointing at different directions?I think Adafruit or some similar company have modules, possibly even software libraries for these ST's integrated ToF products.These could react well before the last 10cm, and should work OK in strong ambient light. It's an actual distance measurement not depending on the color of the target.If you just measure the amount of light, and adjust the threshold properly for an object of a certain color, then darker objects fail to give you warning early enough, and brigth objects give you nuisance trips.

author: StillTrying
author_rank: Super Contributor
timestamp: April 01, 2020, 02:47:34 pm
content: The TSOP4838 IR Receiver would be terrible for obstacle avoidance because of its large AGC, it would give the same digital output from a nearby object or a distant reflective wall.For detecting at one distance, rather than both the transmitter and receiver facing forward, they'd probably be better with some space between them and angled ~45 degrees.

author: Trooperettes
author_rank: Newbie
timestamp: April 01, 2020, 07:33:40 pm
content: Thanks StillTrying!I have done some tests with a different "IR receiver with light barrier". I am not sure which component it is as it only states B440 on the packaging. Though I suspect it being a PNA4602M. It worked really well and I could quite easily control the detection range by adding or subtracting resistance to the emitting diode. Unfortunately I only had one and have been unable to source more of those.In my hunt for them I found a post saying that I could replace it with a Vishay TSOP4038 (http://www.robotroom.com/PNA4602M-Replacement-1.html). Then I found a bunch of Vishay TSOP4838's that from what I could tell were pretty much the same (only shows how poorly I interpret the datasheets). I did get them to work but only if I had a lot of motion in front of the circuit. Slow movement towards the setup went undetected. Which is why I am hereNow I see I am way out of my league and have learned a lot about the internal workings of IR Receivers, but am still very confused as to which to go for. I will try to order TSOP4038 and TSSP4038's and see if any of these bring success. If that does not work. I will have to crawl back to the safe arms of Lady Ada and Adafruits products. But it will cost pride