Help with IR Remote library. Hash value?

Hello,

I've got a remote that I'm trying to emulate. Specifically one button. When I did the detect code I received the hex value 0x807fb874 with a NEC manufacture code.
When I try to send that value through an ir led, I keep reading the value 0x4DA41BC3. I can't figure out the relationship of these two values. I did some digging and it got real deep real quick, but I found some code on Ken Sherriffs blog about hash decoding. Don't know what the hell that means, but when I run that code and check the remote the serial spits out a "real" code, which is the one I got originally, and a "hash" code, which is the weird value that my ir led keeps sending.
So how do I get the ir led to send the "real" value?
Thank you for any help!

#include <IRremote.h>
const int switchPin = 7;

int buttonState = 1;

IRsend irsend;

void setup()
{

  pinMode(switchPin, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  buttonState = digitalRead(switchPin);
  if (buttonState == LOW) {
    delay(100);
    irsend.sendNEC(0x807fb874, 32); // TV power code
    Serial.print("sent --  ");
    Serial.println(0x807fb874, BIN);
  }
  delay(300);
}

I guess you are using 2 Arduinos, one configured to send IR codes, and the other to receive them.
If you change the code you send by altering a few hex characters , does the receiver detect a different code, that is other than 0x4DA41BC3 ?

Just a guess but could it be that the LED output has gotten inverted? Perhaps the output LED is wired to +5V instead of Ground? Because the receiver depends on the width of modulated pulses it could produce incorrect but consistent results if the polarity was inverted.

Try showing the raw pulse widths received from both the original remote and the Arduino trying to emulate the remote.

6v6gt:
I guess you are using 2 Arduinos, one configured to send IR codes, and the other to receive them.
If you change the code you send by altering a few hex characters , does the receiver detect a different code, that is other than 0x4DA41BC3 ?

I am just using the 2 arduinos for testing. The device will only use the outputting arduino. When I adjust the hex number for the output slightly, I do get a change in the output. It's mystifying.

johnwasser:
Try showing the raw pulse widths received from both the original remote and the Arduino trying to emulate the remote.

Thanks for your help! The led is wired correctly. As for showing the raw widths, how would I go about doing that? Thank you again!

Sblue_Flyhouse:
As for showing the raw widths, how would I go about doing that?

On the Arduino doing the receiving, run the IRremote example "IRrecvDump". The list of pulse lengths will be labeled "Raw (pulse count):" in the serial output.

OK. Here's what I got. The top value is what I'm attempting to emulate, and the bottom is what my arduino is sending:

807FB874
Decoded NEC: 807FB874 (32 bits)
Raw (68): 8950 -4500 500 -1700 550 -550 600 -550 550 -600 550 -550 550 -600 550 -550 600 -550 550 -550 600 -1650 550 -1700 550 -1650 550 -1700 500 -1700 550 -1700 550 -1650 600 -1600 550 -600 550 -1650 600 -1650 550 -1650 600 -550 500 -600 600 -550 550 -550 600 -1650 550 -1650 550 -1700 500 -600 550 -1700 550 -550 550 -600 550
A20AA84D
Unknown encoding: A20AA84D (32 bits)
Raw (68): 8950 -4550 450 -1800 450 -650 500 -650 450 -650 500 -650 450 -650 500 -600 500 -650 500 -600 500 -1750 500 -1750 500 -650 450 -1800 500 -1750 450 -1800 450 -1800 500 -1750 500 -600 500 -1750 550 -1750 450 -1800 450 -650 450 -700 450 -650 500 -650 450 -1800 450 -1800 450 -1800 450 -650 500 -1750 500 -650 450 -650 500

The pulses are close, but not spot on.

807FB874
Decoded NEC: 807FB874 (32 bits)
Raw (68): 8950 -4500,500,-1700,550,-550,600,-550,550,-600,550,-550,550,-600,550,-550,600,-550,550,-550,600,-1650,550,-1700,550,-1650,550,-1700,500,-1700,550,-1700,550,-1650,600,-1600,550,-600,550,-1650,600,-1650,550,-1650,600,-550,500,-600,600,-550,550,-550,600,-1650,550,-1650,550,-1700,500,-600,550,-1700,550,-550,550,-600,550
A20AA84D
Unknown encoding: A20AA84D (32 bits)
Raw (68): 8950 -4550,450,-1800,450,-650,500,-650,450,-650,500,-650,450,-650,500,-600,500,-650,500,-600,500,-1750,500,-1750,500,-650,450,-1800,500,-1750,450,-1800,450,-1800,500,-1750,500,-600,500,-1750,550,-1750,450,-1800,450,-650,450,-700,450,-650,500,-650,450,-1800,450,-1800,450,-1800,450,-650,500,-1750,500,-650,450,-650,500

I think the problem is that there is too much noise in the Arduino output. The IRremote library uses a 50-microsecond timer so all the times are multiples of 50. There are typically two or three distinct lengths of pulse and, with a clean signal like from the original remote, the lengths usually vary by no more than 50 microseconds either way. You can see that the timings from the original remote show two distinct lengths: 500 to 600 and 1650 to 1700. The timings from the Arduino signal, on the other hand, show the range of short pulses much more spread out: 450 to 700 (the long pulses are 1750 to 1800 so that is good). The short pulses deviate enough that the signal is no longer recognized as NEC and the 'value' that gets reported is just a hash of the pulse lengths. That explains why the value is so different.

Once all of the pulse lengths are normalized (marked as Short and Long pulses) and pulse pairs are converted to bits (Short-Short = 0, Short-Long = 1) the two encodings are the same except for one bit.

Decoded NEC: 807FB874 (32 bits)
Raw (68): 8950 -4500 10000000011111111011100001110100 S
Unknown encoding: A20AA84D (32 bits)
Raw (68): 8950 -4550 10000000011011111011100001110100 S

I don't know why you have so much noise in your output. Perhaps the signal is weak. Are you trying to drive a 100 mA IR LED from a 40 mA Arduino pin? Do you have any other code in your sketch doing interrupts?

Thanks again for your help!

The led I'm using should only be pulling about 20mA. If the problem is noise, wouldn't the value be different, at least slightly, every time I send it?
I think I'll try sending other remote codes and see if the issue is consistent.

Thanks!!!

The NEC protocol calls for the short pulses to be 560 microseconds and the long pulses to be 1690. The library allows for 25% error or more so I'm surprised that your received signal, even with that range of pulse width, is not detected as NEC.

Hi again!

I've solved the issue with a bigger light. Don't know why it worked, but with a stronger ir led I was able to send the signal 90% of the time, which isn't as good as I'd like, but will get the job done.

Thank you for all your input!

Sean

What value of resistor are you using in series with the LED?