enternoescape / Arduino-IRremote-Due

GNU Lesser General Public License v2.1
25 stars 7 forks source link

IRSend on Arduino Due #2

Closed ReqPro closed 9 years ago

ReqPro commented 9 years ago

There seems to be an issue with Arduino Due and IRSend.

I have an IR LED and a short test program, that I have tested on an Arduino Uno. Everything works flawlessly there, connected to pin3. This tells me the IR LED works perfectly, as well as the code... However, on the Due, connected to pin7 (as far as I could gleam from the headers) nothing happens when running the exact same code with the exact same IR LED.

IR LED circuit is as follows: Base connected to pin7 through a resistor (470 ohm). Collector connected to +5V through a resistor (47 ohm) and the IR LED. Emitter is connected straight to ground.

This pulses the IR LED at 1.2V, 80 mA and works perfectly on the UNO.

The test code is as follows, and pops up the menu on a Samsung TV:

#include <IRremote2.h>

IRsend irsend;

void setup()
{  
    Serial.begin(9600);
    while (!Serial) { ; }
}

void loop() 
{
    if (Serial.read() != -1) 
    {
        for (int i = 0; i < 3; i++) 
        {
            irsend.sendSamsung(0xE0E058A7, 32);
            delay(100);
        }
    }
}
enternoescape commented 9 years ago

This was last tested on arduino-1.5.5-r2. If they have changed something in the most recent releases it might break this code since it does a few things with registers that the IDE might now use for other functions. Unfortunately for now I have am not currently using this code, but I will try to get around to looking at this issue. You are of course welcome to submit a patch if you find the problem before me. Short of something needing to be fixed in the code, the only other thought I have is that the Due outputs 3.3v and the Uno outputs 5v. I would verify that the LED will turn on by moving the wire on pin 7 to the 3.3v output and looking at it through a cell phone camera.

ReqPro commented 9 years ago

You make a good point about the difference in output voltage, however I don't see how that would be a problem as the output pin does nothing but drive a transistor... The IR LED is powered by 5V regardless of board.

I tried your advice on moving the wire from pin7 to 3.3V, but unfortunately my iphone 5 cam doesn't seem to show infrared - the LED shows as off on both the UNO and the Due on my camera :(

I guess I should try "downgrading" the arduino release and see if it works in 1.5.5 r2.... If it does, then it is definitely a code issue as you point out. As far as me patching the problem if it turns out to be code: I am a programmer by trade, but I have no experience whatsoever with the workings of the Arduino on a hardware level, so me finding the problem is, at best, optimistic :P (won't stop me from trying, though)

enternoescape commented 9 years ago

I understand based on the description that the LED is being driven the same either way, but my thought was that there may be an off chance that ~3.3 might be too little voltage to trigger the transistor. Do you have any visible light spectrum LED's you could use instead? That would at least work as a sanity check.

ReqPro commented 9 years ago

Well, I finally managed to dig out an ancient webcam from god knows where - it can show IR, so now I have confirmed that the IR LED does, indeed, light up when fed 3.3V directly to the base resistor. There is no pulsing at all when connected to pin7 though. Looks like it might be a software issue :(

ReqPro commented 9 years ago

Just wanted to leave you an update:

I got it working - turns out because of the triple-send I did in my code, the TV rejected the code as garbage.... I can't thank you enough for your input, it has been invaluable - thank you so much :)

enternoescape commented 9 years ago

Awesome. I'm glad you worked it out and it wasn't a new problem in the code. I happened to have an LED on a breadboard in a similar configuration to the one you described and just ran a quick test to verify that the build I'm still using worked and it did, so that got me more concerned about what might have happened in the most recent updates. Thankfully there's nothing to be done.

ReqPro commented 8 years ago

Hi Enternoescape.

I am truly sorry to open this one again, but I seem to have stumbled into an issue with your library used alongside with the Ethernet library.

I have some code running that works flawlessly up to the point where I add in the Ethernet library. I am not sure if there is a timer conflict or what... I can see the IR emitter is lighting up, much in the same fashion as it did before the Ethernet library was added, but nothing happens.... I tried commenting out the Ethernet library without touching any other code and it works perfectly again - so I can only assume there is some sort of conflict, though I'm far from knowledgeable enough to say for sure - hence my desperate attempt to contact you again :)

I truly hope you can help me, and thank you so much for your time.

Best regards

enternoescape commented 8 years ago

Did you already try changing the configuration in IRremoteInt2.h? Try changing the timer clock and/or PWM. Whenever you use multiple libraries, there's always a chance that you will run into these kinds of issues. I haven't been keeping up with the latest changes, so I don't know if they changed anything. If you find a configuration that's more compatible, let me know and I'll update the settings or leave a comment to help the next person out.

elif defined(SAM3X8E) || defined(SAM3X8H)

//#define IR_USE_PWM0 // tx = pin 34 //#define IR_USE_PWM1 // tx = pin 36 //#define IR_USE_PWM2 // tx = pin 38 //#define IR_USE_PWM3 // tx = pin 40 //#define IR_USE_PWM4 // tx = pin 9 //#define IR_USE_PWM5 // tx = pin 8

define IR_USE_PWM6 // tx = pin 7

//#define IR_USE_PWM7 // tx = pin 6

define IR_USE_TC3 // Use timer clock 3.

//#define IR_USE_TC4 // Use timer clock 4. //#define IR_USE_TC5 // Use timer clock 5.