PDA

View Full Version : IR software & hardware basics



flotulopex
- 4th May 2007, 11:05
Hello,

I've been looking around this forum and the Internet about basic information on IR communication. But there's so much information I can't make up my mind what kind of components I should get started with and, hence, what software method I should apply.

For a start, I have 2 questions.

A.- As IR-emitter, one use IR-LEDs. As IR-receiver, one can use IR-LEDs, phototransistors or IR-Modules. What makes the difference between all these receivers?

B.- Some IR-LED's datasheet mention pulse frequencies (mostly 38kHz and 40kHz), other don't. Why, what's the difference between those LEDs?

Here are some of the sites I already visited:
http://www.rentron.com/Infrared_Communication.htm
http://www.winpicprog.co.uk/pic_tutorial5.htm
http://www.ustr.net/infrared/infrared1.shtml

skimask
- 4th May 2007, 15:51
A.- As IR-emitter, one use IR-LEDs. As IR-receiver, one can use IR-LEDs, phototransistors or IR-Modules. What makes the difference between all these receivers?
B.- Some IR-LED's datasheet mention pulse frequencies (mostly 38kHz and 40kHz), other don't. Why, what's the difference between those LEDs?


If this is what you wanted to know:
TX:
IR emitter - could be just an IR LED, could be a premodulated IR LED with a built in oscillator running at 38khz (give or take, it varies)
IR LED - just that, an infrared LED, generally, if you want to use it in an IR comm scheme, you have to modulate it.
RX:
IR LED - not really a receiver, but you could use it in the way that I used them in my touchless sensor project.
IR phototransistor - = IR detector, does just that, detects IR, turns on a transistor, generally doesn't to any 'detecting' of a 38khz carrier
IR modules - have a built in IR phototransistor/diode and a filter to detect a 38khz carrier wave, generally pulls an output to ground when a carrier is detected.

The datasheets that mention 38khz/40khz/whatever mean that the specific module is set up to either TX or RX an IR beam modulated at that frequency. If you're just dealing with a 'beam breaking' application (like a garage door sensor), you don't need to modulate anything. If you want to send some data, you want to modulate the signal.
Think AC vs. DC. You can't send any useful information over a DC line. Once you start changing the DC line, it becomes AC and you can send info. (and I'm using AC kinda wrong in this instance, I should be calling it pulsing DC).

Don't know if it helps much. I've done a little bit with IR Tx and Rx, modulated a carrier, detected a carrier here and there. I used the old Sony IR protocol to handle the data transfer, works for me... I guess I need more info from your end on what you want to accomplish...

flotulopex
- 5th May 2007, 15:53
Thanks for all these infos, skimask.

I've started a simple remote control project.

The TX side is not an issue curently.

For the RX side, I found some "old" phototransitors (could be SFH309).

The problem I see now, is the reception sensitivity.

I use my TV remote as test IR generator and can measure some signal for a maximum of 30 centimeters away from the phototransistor. above this distance, I can't se any more signal.

Is there any trick to make the receiver more "sensible"???

dhouston
- 5th May 2007, 18:40
I recommend starting with a TSOP1100 which is a wideband receiver (33-57kHz carrier, 940nM which is the wavelength used by consumer IR devices) and connect it as shown here...http://davehouston.net/learn.htmbefore trying more complex things like a phototransistor.

flotulopex
- 5th May 2007, 19:43
Dave,

Why do you think a phototransistor is "complex"?

I connected it just like you show it up in your webpage and it works. I have connected a BC237 to amplify the phototr's signal but this doesn't make it more reactive.

The only problem is sensibility. Or am I wrong and maybe I should measure the sensibility another way?

I don't know to make it better...

Nevertheless, I'm going to by some IR modules to make some tests.

skimask
- 5th May 2007, 19:45
Dave,
Why do you think a phototransistor is "complex"?
I connected it just like you show it up in your webpage and it works. I have connected a BC237 to amplify the phototr's signal but this doesn't make it more reactive.
The only problem is sensibility. Or am I wrong and maybe I should measure the sensibility another way?
I don't know to make it better...
Nevertheless, I'm going to by some IR modules to make some tests.

Do you have any lenses in the way of the emitter or detector?
How much ambient light do you have in the room?
What kind of lights do you have in the room where you are doing your testing?
All of these can kill an IR signal...

flotulopex
- 5th May 2007, 20:05
I tried (only receiver - not emitter) this way up to now:
- no direct light from outside;
- incadescent lamp about 1 meter away from the IR phototransistor;
- used two different remotes (TV and one for home-lightning);
- did not program any carrier frequency - just looking for any kind of signal.

How should I setup my system to make valid tests?

In fact, what distance should I expect? Is it 30 centimeters, is it 3 meters, is it more?

Since my TV and other equipments can be controlled over 5 meters, my assumings are that the remote I use to make my tests is powerfull enough to make my phototransistor to react at such distances. I may be wrong...

skimask
- 5th May 2007, 21:19
Since (according to your 1st post) you want to end up with some sort of IR communication, I'd suggest getting rid of that phototransistor and getting an IR receiver module as dhouston suggested earlier.

If you do a search on 'GP1U' at www.digikey.com, you'll get a bunch of hits for various IR detectors.

The GP1UM261RK (which just happens to be the one that I use for a lot of my projects and it works very well) is sensitive to IR modulated at 38Khz.

At the transmitter end, I use a 555 timer tuned to 38Khz @ 50% duty cycle (actually nowadays I'm using a 10F200 for the same function and it's more accurate). I run the output of that to an input of an AND gate, the other input of that same AND gate goes to a serial output pin on the PIC. The output of the AND gate (which is the 38Khz carrier, switched on and off by the PIC), goes to the IR LED unit (which is usually either one IR LED or a few IR LEDs switched by a MOSFET).

At the receiver end, I have the above mentioned IR detector unit hooked up. The output has a 1K pullup on it, and is connected to a PIC pin used for serial input.

According to the datasheets, this detector takes about 8 cycles of 38Khz to lock on (.21ms), so baud rate is limited by the carrier frequency. In the very best of circumstances, the highest baud rate you'll achieve is 1200 baud. I use 300 baud when I need to 'move' data, and usually stick with something around 100 baud if I'm just switching something on or off.

This is the code I use in my MP3 player that I built. I used an old Pioneer sound system remote control to run it:


'IR sensor - Digikey Part # 425-1147-ND, GP1UM281QK, 38KHz,
'side mount, 2 22uF tantalum cap's paralleled across
'power/ground, 47ohm resistor in series between power source and power pin
'PIC18F4620 @ 40Mhz, pulsin will change according to oscillator frequency

remotecheck:
irdata1 = 0 : pulsin irbit , 0 , temp1w
if ( temp1w > 1200 ) then
if ( temp1w < 3300 ) then 'header pulse is about 2.2ms, check for
'a pulse a bit longer than a binary 1, but
'shorter than 1 1/2 header pulses
getnextpulse1:
for temp1 = 0 to 11
pulsin irbit , 0 , temp1w : orbits = 0
if temp1w < 275 then orbits = 1
if temp1w > 1650 then orbits = 1
if orbits = 1 then
goto remotecheck
else
if temp1w < 825 then irdata1.0[temp1] = 0
'Sony IR Remote Signals - Unit, T=550us,
'Header = 4T Pulse followed by 1T space,
'Binary 0 = 1T Pulse followed by 1T space
'Binary 1 = 2T Pulse followed by 1T space
if temp1w > 825 then irdata1.0[temp1] = 1
endif
next temp1
'irdata1 has any data received and decoded by ir detector, 12 bit sony code
endif
endif

dhouston
- 5th May 2007, 21:48
Dave,

Why do you think a phototransistor is "complex"?

I connected it just like you show it up in your webpage and it works. I have connected a BC237 to amplify the phototr's signal but this doesn't make it more reactive.

How are you measuring/detecting the output?

With a phototransistor you will receive the carrier frequency, usually in the 36-40kHz range. It's difficult to measure the amplitude of a 25-28µS pulse and the output of the phototransistor circuit will be a series of bursts at the carrier frequency. You'll have to count the number of such pulses to determine the duration of the bursts and decode the transmission. Or, you'll have to use a low pass filter to demodulate the signal to recover the data envelope.

An IR receiver demodulates the transmission and outputs the baseband data envelope with the width of the spaces (it's active low) proportional to the duration of the bursts. It's an order of magnitude or two simpler to deal with.

I suggest the TSOP1100 (available from Mouser) because you don't have to worry about matching the carrier frequency of the IR remotes you might come across. Read the datasheet for the TSOP1100 - it's got a lot stuffed into that small package.

flotulopex
- 5th May 2007, 21:49
Thanks a lot skimask,

I'm gonna try an IR module.

I've seen on rentron's web site that he used a NAND.

Going to check this out - didn't read this carefully enough.

May I ask you over which distance you got good & reliable results?

Dave, just saw your post. Yup, going for a module!!

dhouston
- 5th May 2007, 22:07
May I ask you over which distance you got good & reliable results?The receiver filters out ambient IR from sunlight, incandescent lights, fluorescent lights, etc. If it's narrow-band it only reacts to IR that is modulated at the carrier frequency it is designed for. It's also designed for a specific wavelength (your phototransistor is 900nM while most consumer IR uses 940nM). Your test setup is about as bad as one could imagine.

A few years back I designed a CF card that fit an iPAQ and acted as a Consumer IR transmitter. With a single IR emitter and 3.3V it regularly got 30 meters range but that's about 5 times what I expected.

skimask
- 6th May 2007, 03:58
Thanks a lot skimask, I'm gonna try an IR module.
I've seen on rentron's web site that he used a NAND. Going to check this out - didn't read this carefully enough. May I ask you over which distance you got good & reliable results? Dave, just saw your post. Yup, going for a module!!

Maybe I did use a NAND gate, don't remember at the moment...
Some people use gates, some people actually switch the PICs internal timer that generates the 38Khz on and off really fast.

mister_e
- 6th May 2007, 09:57
And there's those which build their own serial IR routine... or modify the existing SEROUT/DEBUG etc etc. To me the AND gate is sure an option... but not needed when you can do everything in software... with some head-banging for sure.

I remind that Darrel already did something like that here modifying the SERIAL macro in the PBP files, i will try to find it.

mister_e
- 6th May 2007, 10:05
well, it was for XOUT, but there's an interesting concept.
http://www.picbasic.co.uk/forum/showthread.php?t=3057&highlight=signal+stronger