Infrared / Optical Sensor Larger Range Calculation

Hi All,

I have a project that I've based around the TCRT5000 optical sensor: http://www.vishay.com/docs/83760/tcrt5000.pdf. This sensor is capable of reading up to 15mm +/- a few mm in practice, but this isn't sufficient for my needs (I need something in the ballpark of 50mm). I understand that one could replicate this type of sensor with any infrared LED and a phototransistor, but I can't seem to find a forum that talks about how one would be able to know how much distance the sensor would detect.

Could someone point me to a phototransistor or something similar that I could use to meet my requirements or explain to me how I could compute this myself? The reason I've used the TCRT5000 is also because of how small it is, which is something that's critical to the project. I don't have the time or budget to be purchasing parts blindly, so I'm hoping I could get a little guidance!

Thanks in advance for the help, I'm excited to finally have made an account and being able to contribute to such an awesome community!

The problem is not with the "calculation", that's easy, it's based on the speed of light. the problem lies with the actual ability of your LED light to illuminate and detect a return from the target object.

Pololu sells a variety of distance sensors like the one you have, but optimized for different ranges. There is one for 0.5-5 cm, 10-80 cm, etc. You could use two (on different input pins) to cover a large range of interest. Pololu - Sharp Distance Sensors

That makes sense, michinyon. So I need a stronger LED basically? And thanks, jremington, that's a good option as well, although slightly bigger and more expensive than I'd like.

So now I'm looking to purchase a "brighter" LED, but what specs should I be looking for to define that? Intensity? Is the forward current proportional to the brightness of the LED?

Is there some reason you do not want to use a carefully engineered commercial distance sensor?

Sorry, should've added that. I guess I'll describe my project in a little more detail, but basically I want to build a small infrared based synthesizer, that only has to output 8 different notes, but needs about 25 sensors to accurately tell what note the user's hand (or foot) is intending to hit. The synthesizer is also going to output volume data based on how close the user is to the sensor.

Before I go any further, I'd like to say that I'm not a beginner to Arduino, and have a fully working prototype with the TCRT5000, which allowed me to get a head start on all of that programming. Now the issue is the sensors aren't strong enough for my needs. One of the other problems I found with the sensors that you posted to the forum is that the most ideal one for my needs has a range of 0.5 to 5cm, but ideally, I'd like to have that extra 0 to 0.5 range like I do with the sensors I have now. Realistically, I'm only going to need up to maybe 3cm maximum distance, but the 1.2cm max I get now is definitely too weak.

So there are two issues, one is finding a more ideal range, and two, minimizing cost by buying simple emitters / phototransistors so I can pay ~$1 a sensor as opposed to $7. I also already have all the phototransistors (or photodiodes?) that I need, assuming I just need a brighter LED like what was recommended here. I figured customizing my sensors like most moderate/advanced projects seem to do is the way to go, but let me know of any recommendation you might have. Thanks for the quick reply!

If you pulse an LED, you can put much more current (in come cases, 10x) through it than is allowed under steady state conditions. You just have to make sure that the average power dissipation of the LED does not exceed the maximum allowed value.

To do this you will need a transistor LED driver, because the Arduino I/O pins cannot handle more than about 20 mA and also synchronize the detector with the "on" pulse. A cheap source of high-power LEDs are old IR remotes that you can get at thrift shops (or your junk drawer). The circuit boards also contain appropriate current limiting resistors and driver transistors that can be reused.

Wow, really didn't think of pulsing the LEDs, that's a great idea. I've just had them hooked up to the Arduino's 5V, so I'll get the LEDs hooked up to a couple shift registers and hook a transistor up to the power source (I have a couple already laying around). I'm going to go experiment now, but by doing this I'm assuming you're saying that the LEDs I already have should be able to become "brighter" with a pulse, right? At least to get an extra 10 or so millimeters out of them... Or will I still need to potentially purchase other LEDs? Thanks again!

Just about any LED can handle 100 mA for 100 microseconds and during that time will be about 5x as bright as an LED with 20 mA current. For a 5V source, use a transistor and a 27 or 33 ohm resistor in series with the LED. You need to make sure that the duty cycle is less than 5%. Here is what Cree (LED manufacturer) recommends for long term reliability:

Based on the 1-KHz pulse testing we have reviewed in this application note, Cree suggests the following guidelines for pulsed current operations:

For duty cycles between 51-100%, do not exceed 100% of the maximum rated current;
For duty cycles between 10-50%, do not exceed more than 200% of the maximum rated current;
For duty cycles less than 10%, do not exceed more than 300% of the maximum rated current.

I see, so I should be turning on the LED for about 100 microseconds and turning off for about 2000 microseconds for the 5% duty cycle, correct? I just hooked up the transistor to a 39 ohm resistor in series with 5V from a separate power source, with the drain connected to my LED, and a 10k resistor hooked up to my Arduino pin which goes to the base of the transistor. I'm using a NPN transistor and believe this circuit to be correct, but I'm not getting any improvement from the sensor. I'll post my code, although very simple, and maybe you could see if I've made an error somewhere. Otherwise, I'm not really sure what could be going wrong, because the theory you've stated should definitely work. Do I need the base of the transistor to be hooked up to one of the Arduino PWM I/Os? It's hooked up to pin 13 right now.

void loop() {    
  
  digitalWrite(ledPin, HIGH);
  delayMicroseconds(75);
  sensorValue = analogRead(sensorPin); 
  digitalWrite(ledPin, LOW);  
  Serial.println(sensorValue);
  delayMicroseconds(2000);
  
}

EDIT: This isn't my code for the above mentioned synthesizer project, just a simple code to test and verify that pulsing the LED works with one emitter/phototransistor before moving to the series of 25 that I have.

The other problem you will have, is time. Light travels a lot faster than sound. The time it takes for your light pulse to travel a few cm and back is very quick, and hard to measure.

If you need something in the vicinity of 50 mm, it is probably easier to measure sound.

If pulsing the LED didn't make a difference, I think the problem is likely to be in the light sensor. What are you using for the light sensor, and how is it connected to the Arduino?

If it is a phototransistor, your setup should look something like the attached. What value of resistor (R3) do you have connected between the phototransistor collector and Vcc?

Finally, you can use the same pulse trick with the TCRT5000. The data sheet says that the LED emitter can handle an absolute maximum to 3 amperes as long as the pulse is less than 10 microseconds long and the time-averaged current is less than 60 mA. I would recommend to use less than 1 ampere peak. If you go that route, the light wavelengths for the emitter and receiver should be well matched.

photogate.png