Pages: [1]   Go Down
Author Topic: How can I pulse a ir led for a reciever?  (Read 1840 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey there,

I've already done some projects with Arduinos but this topic is rather complicated for me.
The project is a lazer tag clone and I have problems to deal with the infrared transmission.

I would be very thankful if you could help me along with these issues.

1. The first thing I am curious about is how to get enough current for the led.
I chose a Osram LD 274 because it is cheap and nearly as "bright" as the Vishay TSAL 6100 which nearly everbody recommends.
In the data sheet there is the description that you could use it with 1 Ampere for 100 microseconds (at 2.5 Volts).
Because the Arduino does not provide that much current, I wanted to use a npn-transistor which can handle 1 A and a capacitor, which can provide 1 A.
Because I am very new to capacitors, could you give me a hint which type is the right for this task?

2. These ir recievers always have bandpasses (for example a 38 khz). How do I deal with this on the emitter side?
Am I writing the transistor base high/low at 38 khz, maybe like
Code:
digitalWrite(outPin,HIGH);
delayMicroseconds(26);
digitalWrite(outPin,LOW);
delayMicroseconds(26);
(because one oscillation at 38 khz is around 26 us)
Is this right? And could the capacitor-, led- and transistor-circuit handle this?

3. Which informations (and how) would I get on the reciever side with a 38 khz reciever (for example the TSOP 31238)?
I read something aboud pulseIn(). The description in the reference is really too short for me, I don't know if I got it.
Is there a possibility to make this with interrupts? Because the code should be able to take a shot even if it is playing a jingle or something.

Again, I would be very thankful for help. It is hard to deal with all the tutorials around because the english used is not very easy for someone who's mother tongue is not english like mine.

Greetings

Alex
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33290
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Am I writing the transistor base high/low at 38 khz, maybe like
I would change the PWM frequency to 38KHz and use an analogue write to turn it on. Then use code like you put to pulse it. Do you want the pulses to carry any information?

Quote
I wanted to use a npn-transistor which can handle 1 A and a capacitor, which can provide 1 A.
The transistor part is easy but the capacitor is not. It is not the way to do it. You need to provide a power supply that will supply that current. One problem with a capacitor is that the voltage drops as it discharges. The other is that you will need a physically very large capacitor.

Quote
Which informations (and how) would I get on the reciever side with a 38 khz reciever
You will see a signal on the digital pin you connect to the receiver, this will match the pulses you send, not the 38KHz modulation.

Quote
I read something aboud pulseIn().
That will only measure the period of the pulse, you know what that is because you sent it. What you want to know is if you have received one or series of pulses if you are receiving data. The only way to do this effectively is by using interrupts.

Given your basic state of knowledge would you not be better off copying some one elses design rather than trying to design your own system?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I would change the PWM frequency to 38KHz and use an analogue write to turn it on. Then use code like you put to pulse it. Do you want the pulses to carry any information? [...] You will see a signal on the digital pin you connect to the receiver, this will match the pulses you send, not the 38KHz modulation.

Alright, I think I already understood it shortly after I posted my question. The 38 KHz pulse is something like a carrier frequency (right?). So if I change the PWM to 38 KHZ, I could use this code:
Code:
analogWrite(outPin, 128);
delay(10);
analogWrite(outPin,0);
delay(10);
to have the ir reciever HIGH for 10 ms?

Quote
You need to provide a power supply that will supply that current. One problem with a capacitor is that the voltage drops as it discharges. The other is that you will need a physically very large capacitor.
I wanted to use something like a 9 V battery as power source. Is it possible to get current around 1 A out of it? I was afraid it doesn't work because of the inner resistance (don't know how high it is).

edit: I just tested it with an AA battery and it were about 1.5 to 1.7 A (and it did not get hot smiley-razz)

Quote
Given your basic state of knowledge would you not be better off copying some one elses design rather than trying to design your own system?
Yeah, I know, it would be easier... But I am too ambitious for it smiley-razz and not that bad smiley-wink

Thank you so far for your answer, it was really helpful.
« Last Edit: July 13, 2011, 09:51:02 am by a_lehmann » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33290
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I could use this code:
Yes. However check the data sheet to see if 10mS is too long for the receiver.

Quote
I wanted to use something like a 9 V battery as power source.
As you say this is not good as you won't get that much current from one, but fine on the AA battery.

Best of luck with this.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Best of luck with this.
Thank you, you helped me very much. I'm now ordering the parts.
Logged

Germany
Offline Offline
Edison Member
*
Karma: 2
Posts: 1363
Here we go!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Look here for some help. It's very good link:

http://www.ladyada.net/learn/sensors/ir.html#testing_your_ir_detector

Bye ,

Fab.
Logged

L'impossibile...richiede solo piu' tempo!

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I love making things because I can (or I can learn to!) with the best of them.

But there are so many wheels to invent out there, that in some cases it just isn't worth re-inventing one that is already "done".

There must be modules with a simple single digital input which causes a beam of modulated IR to shine when the input is taken high?

If an "expert" can point us to the right part numbers/ supplier, I for one would be grateful.

Or just chop open a remote control, take something from it? Not so easy, today, of course... and still, in this case I suspect, still a second best to just spending the $4 (?) for a new part that does it for you.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33290
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But there are so many wheels to invent out there, that in some cases it just isn't worth re-inventing one that is already "done".

Your not re-inventing anything you are just putting a chip and LED together, it is so trivial as to require no invention other than a google search.
You can use an NE555 oscillator and LED, or you can change the PWM frequency and just use an analogue write.

Quote
There must be modules with a simple single digital input which causes a beam of modulated IR to shine when the input is taken high?
I know people can be persuaded to buy almost anything but it is so simple it hasn't occurred to anyone that some people are willing to pay a premium for this.
I await the inevitable link that proves that some people are that cynical and that no one ever went bust underestimating the intelligence of the public.
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

(Skip over this reply if you want "the answer". Somewhat rambling, somewhat philosophical....)

I agree that the hardware side of this is not "rocket science".

And I'll be delighted if the software is also simple. I was worried that getting an adequately precise 38,000 hz might be a challenge, especially if the Arduino is doing other things at the same time. There are system interrupts, even if the user isn't adding any.

Of course, 38kHz may be veerrryyyy sssllllooowwwwww from the Arduino's point of view. I gave up trying to judge these things intuitively years ago.

As to "premium"... yes, of course, someone is going to make money if you use a module. I think I even said as much in a similar discussion going on elsewhere, a thread that suggested that the people there might be having trouble getting a sufficiently precise modulation. I enjoy playing with recording weather by computer....

http://sheepdogsoftware.co.uk/sc2sw.htm

... in that field, there are lots of "expensive" (for what they are) devices.

Pricing always has at least three parts... fixed costs, variable costs, anticipated sales volume. (Plus, as Mike rightly says "fool markup")

I would have thought that the sort of module I am thinking of would have parameters which would make buying one attractive.

As I think about it, it occurs to me that the other half of IR comms... using an Arduino to READ a data stream carried on a pulsed beam makes a perfect example of the fact that there ARE times to just buy the already invented wheel. Anyone care to program an Arduino to not only read the "ons" and "offs" of such a beam, but also to ignore IR signals which are not pulsed at around 38kHz? (For those unfamilar with the concepts: There are TWO sorts of "pulsing" going on here. There is a relatively slow "on" and "off" pulsing that is the data, and a second high frequency pulsing (38kHz being the frequency used as an example in the rest of this post) which is going on with the "on" signals from the sender. Using the high frequency carrier allows the receiver to distinguish between an IR signal coming from the IR source you want it to respond to, and other sources, e.g. your desklamp.)

I went off to find the module for sending 38kHz IR. Along the way I came across....

http://www.trainelectronics.com/artcles/PulsedIR/index.htm

... which, if you skip down a bit, offers you a 555 based answer. But you still have the (minor) hassle of sourcing and connecting up the bits. But at least you've taken from the Arduino (and programmer) the burden of chopping the IR beam up into a stream of 38kHz pulses when it is "on".

(Ironically, that post goes on to suggest using a microprocessor to do nothing more than replace the 555 timer. If you ONLY want the Arduino to do that, then yes, the programming is easy enough!)

Having received no answer to my earlier question... does anyone know of a transmiting module... I couldn't let it go, went digging with Google... and found lots of discussions, no answers! So maybe I'm wrong... maybe all of the high volume applications, the ones that generated the receiver modules, just drive the IR modulation with spare processing capacity in the microprocessor which does the rest of the work. Oh well. If YOU, Gentle Reader, know of a module, I'd still be interested to know where I can get it, what I would pay!

One almost useful thing did turn up... Someplace else, someone else's equivalent of the Arduino "analogWrite()" (which produces PWM pulse trains) allows the user to specify the frequency of the pulse train.... No such luck with the Arduino... but it is no big deal. I only mention it to save you the 30 seconds it took me to check out whether using "analogWrite()" would be an option. I suspect that if you want to delve into the internals of the Atmega chip (and risk upsetting things the Arduino system software expects) you could get the Atmega to generate the 38kHz... but that's not a route I would advocate!

===
Lastly, and even more tangentially.... There's a nice "turn things on and off with your TV remote control" project written up at...

http://embedded-lab.com/blog/?p=3071

It uses a different microprocessor at it's heart, and is about how to RECEIVE the IR signal, but I thought readers of this thread might find bits useful. The author, for some reason that I don't understand... but is it an area where I am inexperienced... does some conditioning of the signal from his IR detector (with 38kHz "window") device. I've used them just connected directly to the Arduino... perhaps it is a matter of which detector, which microprocessor. "My" system, just a write up of the work of others....

http://sheepdogguides.com/arduino/ar3ne1ir.htm
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote from: f.schiano
Thank you, that's a great source of information!

Quote from: tkbyd
There must be modules with a simple single digital input which causes a beam of modulated IR to shine when the input is taken high?
If an "expert" can point us to the right part numbers/ supplier, I for one would be grateful.
Now that I understand infrared transmission, it would not make sense to buy any expensive modules. I spent under 1 € (maybe about 1 $ ) for all the things like ir led, (power) resistor, transistor, etc. And it works great. (just like in the link above)
If I understood you right, you worried about making these things with the arduino because it takes calculating capacity? It would sure be nice to keep the code more clean but this transmission function only needs a few milliseconds in my case. Not a length of time that is very relevant when playing lazer tag smiley

Quote
I only mention it to save you the 30 seconds it took me to check out whether using "analogWrite()" would be an option. I suspect that if you want to delve into the internals of the Atmega chip (and risk upsetting things the Arduino system software expects) you could get the Atmega to generate the 38kHz... but that's not a route I would advocate!
Neither for me, I find it more comfortable to to it with digitalWrite() and delayMicroseconds() than using some kind of AVR code which I found with google and don't understand at all.


By the way it's nice you kept on discussing on this thread and posting links, very informative for me.
Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
I’m no expert, but I play one on the Internet…
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

FYI - If you ever decide you don't want to write it from scratch, check out the IRremote library which supports sending and receiving of IR codes for remote controls. In your case, just choose a code to send and receive.

A Multi-Protocol Infrared Remote Library for the Arduino:
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html

Also, to save some time you can probably hack this keychain remote into your "gun" for the game. It's a little more expensive at just under $4.00, but you get a IR sender that already sends different codes (based on button pressed) and a battery! Hack em up and assign 1 button to each players gun, so you can tell who shot who...

Infrared Keychain Remote Control:
http://www.sparkfun.com/products/10280

willnue
Logged

Lancs, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I recall having done this using mosfets and 555 timers when i was a kid.

Personally I seem to remember much later this requirement being part of a project we did at uni and got transmission rates up from a few cm to the full length of an underground carpark.

Suggest you do the same its entirely straightforward to implement and works reliably.
Logged

Pages: [1]   Go Up
Jump to: