Hello
I am playing with "reading" and "writing" infra red remote control signals, for ordinary TVs, set-top boxes, stereos etc. it's going ok. Capturing pulse timings from all the remotes that I've tried has worked, and resending these captured signals through an ir emitting LED does work, but apparently not for all devices.
For instance, my TV set responds well, but my virgin "plus"box does not.
I know there might be lots of reasons for this. Perhaps my LED is not an ideal colour, or perhaps the frequency of the carrier pulses is different. But it also occurred to me that maybe I have chosen too "high"a resistor, and that my LED is only shining dimly. Is that possible? How should I read the LED data sheet to understand what is the optimum current to allow through it?
Thanks
It is unlikely to be the resistor. Test this by moving it close to the target.
How should I read the LED data sheet to understand what is the optimum current to allow through it?
Look for the forward current rating and the forward voltage drop at that rating.
Subtract the supply voltage from the volts drop, use that voltage, divide by the current to get the resistance you need to use.
Note you should not ty and get more than 40mA from an arduino pin as that will damage it.
Thanks for that. I suspect you're quite right, and that it's not the resistor at all. But at least i'll be able to get it right,now.
I suspect my problem is the frequency at which the equipment expects the led to be pulsed. My receiving ic is centred on 38kHz, and it seems to receive everything that I've pointed at it. But then when I send signals, I am doing my own pulsing, at specifically 38kHz, and I wonder if some of the receiving devices are fussier than my ic?
I am doing my own pulsing, at specifically 38kHz,
How?
Are you using timers and interrupts ( best ) or just a loop ( not so good )
Yeah, I'm just using a loop. When you say timers and interrupts would be better, do you mean using some external timer, and using that to interrupt when it's time to switch the led on and off. Why is it better? Because the timings would be more accurate?
Thanks for this, by the way.
do you mean using some external timer,
No using the internal timers. This code uses timer 2 to generate 38KHz and there is no code overhead. It can easily be tweaked for other frequencies.
/* Code to pulse pin 3 with a modulated signal
* Can be used to drive an IR LED to keep a TSOP IR reciever happy
* This allows you to use a modulated reciever and a continious beam detector
* By Mike Cook Nov 2011 - Released under the Open Source licence
*/
volatile byte pulse = 0;
ISR(TIMER2_COMPB_vect){ // Interrupt service routine to pulse the modulated pin 3
pulse++;
if(pulse >= 8) { // change number for number of modulation cycles in a pulse
pulse =0;
TCCR2A ^= _BV(COM2B1); // toggle pin 3 enable, turning the pin on and off
}
}
void setIrModOutput(){ // sets pin 3 going at the IR modulation rate
pinMode(3, OUTPUT);
TCCR2A = _BV(COM2B1) | _BV(WGM21) | _BV(WGM20); // Just enable output on Pin 3 and disable it on Pin 11
TCCR2B = _BV(WGM22) | _BV(CS22);
OCR2A = 51; // defines the frequency 51 = 38.4 KHz, 54 = 36.2 KHz, 58 = 34 KHz, 62 = 32 KHz
OCR2B = 26; // deines the duty cycle - Half the OCR2A value for 50%
TCCR2B = TCCR2B & 0b00111000 | 0x2; // select a prescale value of 8:1 of the system clock
}
void setup(){
setIrModOutput();
TIMSK2 = _BV(OCIE2B); // Output Compare Match B Interrupt Enable
}
void loop(){
// do something here
}
Lovely, thanks for that! Am away from home at the moment, so only on the phone, but I'll give that a try when I get back to a computer.
In the meantime, I've managed to get the data for my ir led from maplin's website.
Forward current is listed as 130mA, and forward voltage is 1.3v, so...
5v arduino supply minus 1.3v drop across the led gives 3.7v
Then 3.7 divided by the 0.130 amp forward current is about 28 ohms. Have I got that right? I was using 270 ohms in think.
But, heeding your warning from earlier, 130mA is much too much for the arduino to supply, so I need to be more sophisticated, do I, and transistor control my led current?
so I need to be more sophisticated, do I, and transistor control my led current?
Yes you will need a simple transistor with a base resistor to drive your LED that hard.
Forward current is listed as 130mA,
Is that the working current, peak current or absolute limit?
Since you are going to need some external components anyway you may find that it is simpler to use a 555 timer to both generate the 38KHz and drive the LED. You would then use the Arduino to turn the 555 on and off to create the pulse stream.
Don
The NE555 (ST_Thompson) will source 100 mA @ 5V (200 mA @ 12V) however @ 5V it will only sink about 8 mA @ 5V, (@ 12V it will source or sink 200 ma) according to the data sheet (this was an issue for me in designing an inverter for an EL back-light recently)... Use a transistor... a 2N4401 has an Ic of 500 mA and a Beta of 100 - 300 @ 150 mA Ic... So a 2K2 base reistor would be adequate (2150 ohms for 2 mA Ib, from the Fairchild data sheet for a 2N4401, a 2N3904 or a 2N3906 would work but 130mA is a little close to the max Ic of the part. IMO
Doc
The 555's that I am familiar with have TTL compatible outputs and will source or sink 200mA.
Don