Author Topic: IR obstacle avoidance  (Read 1198 times)

0 Members and 1 Guest are viewing this topic.

Offline TrooperettesTopic starter

  • Newbie
  • Posts: 4
  • Country: no
IR obstacle avoidance
« on: March 28, 2020, 07:14:22 pm »
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 diagram

I 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: [Select]
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 field :)

Any advice is greatly appreciated!

- Hans

 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Re: IR obstacle avoidance
« Reply #1 on: March 29, 2020, 11:01:07 am »
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.
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline TrooperettesTopic starter

  • Newbie
  • Posts: 4
  • Country: no
Re: IR obstacle avoidance
« Reply #2 on: March 31, 2020, 11:44:03 am »
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 :)
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1158
  • Country: lt
Re: IR obstacle avoidance
« Reply #3 on: March 31, 2020, 03:16:39 pm »
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:
« Last Edit: March 31, 2020, 03:40:47 pm by Manul »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8760
  • Country: fi
Re: IR obstacle avoidance
« Reply #4 on: March 31, 2020, 04:57:57 pm »
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.
 

Offline TrooperettesTopic starter

  • Newbie
  • Posts: 4
  • Country: no
Re: IR obstacle avoidance
« Reply #5 on: April 01, 2020, 06:59:56 am »
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 those :) Unfortunately interpreting the data sheets are a bit out of my league..

Thanks for all the help!
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1158
  • Country: lt
Re: IR obstacle avoidance
« Reply #6 on: April 01, 2020, 11:35:52 am »
I will try to get a hold of some TSOP4038's.

Not TSOP4038's, but TSSP4038.

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.pdf

Sunlight 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.
« Last Edit: April 01, 2020, 11:46:38 am by Manul »
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8760
  • Country: fi
Re: IR obstacle avoidance
« Reply #7 on: April 01, 2020, 01:06:10 pm »
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.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: IR obstacle avoidance
« Reply #8 on: April 01, 2020, 02:47:34 pm »
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.
.  That took much longer than I thought it would.
 

Offline TrooperettesTopic starter

  • Newbie
  • Posts: 4
  • Country: no
Re: IR obstacle avoidance
« Reply #9 on: April 01, 2020, 07:33:40 pm »
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 here :)

Now 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 :(

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf