Hi everybody,
I'm trying to build a IR reflective proximity sensor.
Here you can find the circuit layout and the code:
To pulse the led at 38khz (the IR receiver has a Band-pass filter) I'm using a TIP120.
It's a bit overkill for this application, but that's what I had at home
The Forward Voltage is around 1.6V so:
R = (5 - 1.6) / 0.1 = 34
I used a 39 ohm resistor
The sensor doesn't seem to sense the light even if I can tell the LED is on (my phone's camera detect a bit of IR light).
BUT, if I use a 220 ohm resistor it works, although the sensor is not very sensitive.
I measured the current in the LED:
With the 220 ohm resistor it's around 7mA (I was expecting 15, but I guess as I'm pulsing the led with a 50% DC, 7 is correct)
With the 29 ohm resistor it's around 33mA
I don't know why the sensor is not working with the 39 ohm resistor, I guess there could be some transient somewhere (the TIP120 maybe?) and the LED doesn't blink at 38khz..
if I use a 220 ohm resistor it works, although the sensor is not very sensible.
What does it do, wear a silly hat? Or you could mean the word sensitive instead.
That circuit is crap. There is no decoupling capacitor or resistor on the sensor. In fact I can't tell what sensor it is as there is no part number attached. So take the sensor you are using, look up the data sheet and apply the decoupling circuit it tells you to use.
Edit:- There is no resistor in the base of the TIP120 either.
Your circuit should work, even with more reduced LED current. For currents below 40mA you can omit the transistor, and power the LED from a digital output and the current limiting resistor.
You also may try various (alternating) currents, from e.g. 2 digital outputs with different resistors. Then you can send with either current, or their sum or difference, depending on whether you pulse one or both outputs, or make one an input (not affecting current). This could give a better distinction of near-by or far away objects.
Lacking a circuit diagram, do you power the sensor with the proper voltage? Mine (YL-55 module) require 3.3V, don't work on 5V.
Grumpy_Mike:
What does it do, wear a silly hat? Or you could mean the word sensitive instead.
English is not my first language. Apologies
Grumpy_Mike:
That circuit is crap.
Thanks!
Grumpy_Mike:
There is no decoupling capacitor or resistor on the sensor. In fact I can't tell what sensor it is as there is no part number attached. So take the sensor you are using, look up the data sheet and apply the decoupling circuit it tells you to use.
Edit:- There is no resistor in the base of the TIP120 either.
this is the sensor: https://cdn-shop.adafruit.com/datasheets/tsop382.pdf
I already used it in another project to decode remote signals and it worked perfectly without decoupling.
Also I found other tutorials for that sensor and they are not using decoupling either.
Grumpy_Mike:
Edit:- There is no resistor in the base of the TIP120 either.
int led = 13;
int IRled = 2;
int sensor = 3;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(IRled, OUTPUT);
pinMode(sensor, INPUT);
noInterrupts();
}
// the loop routine runs over and over again forever:
void loop() {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRled, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(11); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IRled, LOW); // this also takes about 3 microseconds
delayMicroseconds(9);
digitalWrite(led, digitalRead(sensor));
}
DrDiettrich:
Your circuit should work, even with more reduced LED current. For currents below 40mA you can omit the transistor, and power the LED from a digital output and the current limiting resistor.
You also may try various (alternating) currents, from e.g. 2 digital outputs with different resistors. Then you can send with either current, or their sum or difference, depending on whether you pulse one or both outputs, or make one an input (not affecting current). This could give a better distinction of near-by or far away objects.
Lacking a circuit diagram, do you power the sensor with the proper voltage? Mine (YL-55 module) require 3.3V, don't work on 5V.
The circuit IS working with the 220 ohm resistor, but It's not with the 39 ohm.
I wanted to use the 39 ohm to have 100mA in the LED and get a more sensitive sensor.
The sender current depends on what you consider "sensitive". The higher the current, the more reflections will arrive from more distant objects. How do you test the "sensitivity"?
I think you are getting bitten by something I ran into a while back. Some sensors are designed for continuous signals (at the correct frequency), others only work properly if the signal is modulated (say a 1khz modulation of the 38khz gated). The following from the data sheet seems to confirm my suspicion:
Some examples of disturbance signals which are suppressed are:
• DC light (e.g. from tungsten bulb or sunlight) • Continuous signals at any frequency
• Strongly or weakly modulated noise from fluorescent lamps with electronic ballasts
(see figure 15 or figure 16
OK this looks like it is going to be a long haul because everything about this project is wrong.
First the good news that the thing you complain of in the title of the post can be cured by simply fitting a tube over the IR emitter and another one over the receiver. The problem is light spillage at the side of the emitter.
Now for your real problems:-
emanuele:
I already used it in another project to decode remote signals and it worked perfectly without decoupling.
Also I found other tutorials for that sensor and they are not using decoupling either.
Look at page 1 of the data sheet for that sensor at the Application circuit, that shows what you need. I couldn't give a flying fig what you find on the internet, there is a lot of crap out there, you can even find people saying the Earth is flat, because it is on the internet doesn't make it true. I also don't care that you have made something which you claim functions without it, those components are needed for proper operation. You probably don't have the test equipment to see it is going wrong. Do not confuse functionality with correctness.
I actually had a 10k resistor in the base of the TIP120
Sadly there are a lot of errors on this site too, the people who wrote that do not know what they are doing, they are educators not engineers. It is one of the things we have been trying to change for years but to no avail.
Finally gpsmikey is correct, that sensor is not designed for continuous pulsing, if you want one that is then you need the TSOP 4038. Look at page 5 of that data sheet. Look at the table at the bottom of the page that tells you about the maximum number of data bursts you can have. When you exceed this the output stops responding.
Thanks gpsmikey and Grumpy_Mike, you are right, this sensor is not designed to receive a continuos burst.
I should probably use a different sensor, but out of curiosity I want to try to add a 10 cycles delay every 70 cycles as they suggest in the table at page 5 (or 12 every 60, just to be safe).
Edit: I didn't see this: Maximum number of continuous short bursts/second = 1800
So even if I add a 10 cycles delay it won't work
Make sure which one you get - for the TSSP4038, the 3rd character indicates useage (see the data sheet for options). "O" = IR receiver applications, "M" is for repeater/learning applications and "S" is for Sensor applications.