How to use infrared receiver sensors for collision avoidance

Does a TSOP 4838 work with the code above?

Hello Everyone!

   My question is regarding the code above. Has it been verified to work with a TSOP 4838 38KHz receiver? Or has any one tried it and was successful? If it’s verified to work with a 4838, then if anyone can please point me to the right direction… I have two IR receivers on hand; one is a 4838 and another one is a PNA4602m I salvaged from a broken toy. The 4602m works just fine with the code and circuit specified above but the 4838 doesn’t. I might be missing something… I just bought the 4838 off Ebay, Im beginning to think it’s defective since the 4602 works perfect. I tried different alterations on the code and the circuit like changing the half cycle delay lower and higher; or changing the supply voltage/resistance from the minimum to maximum based on the 4838’s datasheet. Any opinion or comment is very welcome. Thanks in advance! : )

 

It should work with

It should work with TSOP4838, I’ve tested it some time ago. There are 2 things that might not let it work. First, the length of the burst pulse, in the code I used 10ms, perhaps you can shorten it to about 2-3ms. Also, the receiver may need to be shielded from reflected IR light going out from the back of the LEDs or it will switch to low regardless if there is an object in front or not. If the receiver does not switch to low at all, it may be defective.

Thanks

Thanks for the tips. It seems that it is defective or I got the wrong part. I checked the impedance accross pins 1 and 3; I should be getting 30Kohms according to the datasheet, I’m reading close to 100K. I tried shortening the burst length to 2 and 3ms (int i = 0; i <= 115; i++) and (int i = 0; i <= 77; i++), still no response from the receiver (doesn’t go low). I’ll try to get another one and give that seller a - feedback if he doesn’t do something about it. : )

Still can’t figure it out…

Ok so I’ve got a new set of TSOP4838 receivers but I’m still getting the same results like I did with the first receiver I got (it still wouldn’t go low). And again if I switch it with the other module which I believe is a PNA4602m receiver, the proximity sensor works on about 5-6 inbches. I bought a total of 5 TSOP4838s and all of them are doing the same thing. They can’t be all bad… Plus I purchase them from a different store than the first one. After some experementations, I found out that if I use the remote for my Sharp TV, the TSOP4838 is able to pick it up; so with the code and the circuit exactly as above, it would flicker the LED. I did a little research and it seems that Sharp uses the same 38KHz carrier frequency on their remotes. I can’t think of any reason why the TSOP4838 would detect an IR signal coming from the remote and not with the generated one (as indicated above). It also seems that the 4838 requires a shorter burst time; which I also did try with several different cycles but still no effect. It just doesn’t make sense to me. I’m sure I’m missing something. So please if anyone can shed some light, I’m very grateful!

Looks like either your IR

Looks like either your IR LED is of a different light length (it has to be 940nm) or there is something fishy about the connection. Hard to say… I had limited success when using 3mm IR LEDs but it worked great with 5mm LEDs and if I lower the resistance to about 22 ohms I can detect a wall at a couple of meters away. TSOP4838 is what I’m using and it works perfectly, so if you got new sensors and still does not work, it has to be something else. 

To test the sensor even without the microcontroller, you can tie the cathode of a red or green LED to the signal (output) pin of the sensor and the anode through a 220 resistor to the Vcc pin. When the output pin goes low, the LED will light on. If the sensor works with the remote and it doesn’t with the IR LED from the microcontroller then look for the problem there. Either the LED or the code is not quite right. You don’t specify what kind of microcontroller you use, I have assumed you’re using an Arduino, but if you set the fuses yourself, perhaps there might be a problem there (for instance you have divide by 8 checked so the code does not run at the proper clock rate). Also, if you use a breadboard, there might be a bad connection in the breadboard itself, many had problems with that, including me. 

I have same problem where

I have same problem where the receiver works with the remote, but not with my IR led. On the camera I can see the IR LED flashing, but the reciiver doesnt pick it up. I checked the manual and it says “wavelenght 950nm”. You said it has to be 940. Could it be the problem? Because otherwise I dont see what Iam doing wrong.

Noise blocking.

This part:

void IR38Write() {
  for(int i = 0; i <= 384; i++) {
    digitalWrite(IRledPin, HIGH);
    delayMicroseconds(13);
    digitalWrite(IRledPin, LOW);
    delayMicroseconds(13);
  }
}

however I don’t know this programming language, I see this loop repeats 384 times, but the tsop will see this as continuous noise and bock this… Try to change that in:

void IR38Write() {
  for(int i = 0; i <= 5; i++) {
    digitalWrite(IRledPin, HIGH);
    delayMicroseconds(13);
    digitalWrite(IRledPin, LOW);
    delayMicroseconds(13);
  }
}

 

so it repeats only 5 times, what should be enough.

Should it be exactly 940 or

Should it be exactly 940 or is 950 ok too?

From the datasheet, the peak

From the datasheet, the peak sensitivity of the TSOP4838 is at 950nm, and the sensitivity at 940nm is only a few percent less.
In other words anything within about +/-50nm from 950nm and you won’t be able to tell the difference.

Since you’ve checked the IR LED is lighting up with the camera, I’d say the next thing to check is your code, specifically to make sure the frequency that you’re pulsing the LED at is correct. The TSOP4838 expects a signal modulated at 38kHz, and is pretty intolerant of other frequencies.
To give you an idea of how touchy the TSOP4838 is, consider that the sensitivity drops by more than half if your frequency is off by +/-10%. If the modulation frequency is off by +/-30%, the sensitivity is down to less than 1/5th of what it would be at 38kHz.

Sorry I didn’t see your

Sorry I didn’t see your reply earlier. Telefox answered perfectly above. I think you guys both have a different problem. The carier frequency is not spot on for some reason. If you are using an original Arduino, it should work. I am using blank ATmega328 chips and I am setting the fuses and load the bootloader myself. I also used the chip with the internal clock at 8MHz and it still works for me. Another person here replied that emitting the signal for 10 ms is considered noise by the TSOP sensor and it will not go LOW, try reducing the length of the signal to 2ms (replace the 384 value in the for loop with 77). The Sony protocol that the remotes use has a start signal of about 2.4ms so the TSOP sensor will listen to that length for sure. Without an oscilloscope to actually measure the signal on the LEDs it’s hard to tell what’s wrong there.

Awesome
This is one of the best tutorials that I read. Great job.

thanks man !

thanks man !

great tutorial. many thanks

great tutorial. many thanks