Pages: [1] 2   Go Down
Author Topic: Receiving Different IR Codes From Same Remote/Button  (Read 2432 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am working on a project that detects what button was pressed and displays it on a LCD screen.

I am using this library for handling receiving the IR codes: https://github.com/shirriff/Arduino-IRremote

Everytime I press the same button on my Time Warner Cable remote I get different results.

What is the cause of this and how can I account for it?

Code:
#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume();
  }
}
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3865
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure it's always different?

I found that I got two different codes with some buttons, and it alternated between the two.

For example the "down" button produces either a 1041 or 3089 and I just used the || (the "or") in my code like this:

Code:
   if (results.value == 1041 || results.value == 3089)
      {
         // do stuff
      }
Logged

The Elders of the Internet know who I am.....

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

I just pressed the same button 25x and these are the values I received,

3653895 - 14 Times
421066283 - 1 Time
615415119 - 2 Times
604317718 - 2 Times
1358155102 - 1 Time
35434315 - 1 Time
609534435 - 2 Times
325791992 - 2 Times
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3865
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, you got me stumped there. No idea why that could be, but I have limited experience of using the IR I must say.
Logged

The Elders of the Internet know who I am.....

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

It has stumped me too. I have tried multiple different remotes and they all work like expected with only one code per button but this Time Warner Cable remote keeps sending different values...
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3865
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps it's some kind of proprietary security thing, where the receiver can unravel the "arbitrary" string and act on it, without having to know in advance what strings might arrive. But then, why does the one string score 14/25....

Logged

The Elders of the Internet know who I am.....

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

So there really isn't a way to get a 100% recognition rate for the codes?
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3865
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well you could do your 25 click test a few more times until you think you have seen them all, and then "or" them like I had above.

But it could just simply be that the remote you have doesn't work on the "one button- one (or two) code" principal? Have you any documentation on what that remote is supposed to produce?
Logged

The Elders of the Internet know who I am.....

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

I am not sure where I would find that information. The booklet that it came with is available here: http://www.universalremote.com/resources/pdfs/UR5U-8520L.pdf  but there's no information on such and I'm not sure where else to look.
Logged

Offline Offline
Jr. Member
**
Karma: 4
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this sketch to spit out a nicely formatted list of on/off pulses in microseconds:

https://github.com/smokeyser/Remote2/blob/master/Contrib/rawirdecode.ino

It's just the ir decode sketch from adafruit.com with a function added (printpulses3) which spits out the pulses in array format that can be copied and fed into the IRremote lib's sendRaw function.  You can take a look at the rest of the project if you want to see how I used it.  The issue you're experiencing may be more obvious when you look at the received signals in a less condensed format, though.

Around here the cable company (comcast) has started to use the XMP protocol which makes decoding a bit trickier.  I had no luck reading it with adafruit's ir sensor and had to order a new one from digi-key that supports XMP.  So if changing the formatting of the output doesn't help solve/spot the problem, you may want to google your remote and find out if it's using XMP or some other protocol.  FWIW, you don't really need to be able to properly decode their protocol.  You just need to understand it well enough to get a good signal recording that you can duplicate.

Oh, one last thing...  The ir decoders from vishay are pretty sensitive. If that's what you're using, you may want to wire it up according to the datasheet's example with the cap and resistor to clean up the output a little if you haven't done that already.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5358
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure it's always different?

I found that I got two different codes with some buttons, and it alternated between the two.

For example the "down" button produces either a 1041 or 3089 and I just used the || (the "or") in my code like this:

Yep. This is so you can tell when the user lifts his finger and presses the same button again (as opposed to holding the button down and sending the same code multiple times).

« Last Edit: February 17, 2013, 10:03:04 pm by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3865
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
you don't really need to be able to properly decode their protocol....

True.... but he does need to know that he's covered all the possibilities with enough testing to ensure that in a few weeks a button doesn't generate a code he didn't see in testing and thus didn't cater for.

I guess that's what you meant by:

Quote
understand it well enough to get a good signal recording that you can duplicate
Logged

The Elders of the Internet know who I am.....

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5358
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just pressed the same button 25x and these are the values I received,

3653895 - 14 Times
421066283 - 1 Time
615415119 - 2 Times
604317718 - 2 Times
1358155102 - 1 Time
35434315 - 1 Time
609534435 - 2 Times
325791992 - 2 Times


Maybe it's because the receiver frequency doesn't match the transmitter frequency very well so you get glitches (IR remotes don't all use the same modulation frequency).

« Last Edit: February 17, 2013, 10:05:53 pm by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3865
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Maybe it's because the receiver frequency doesn't match the transmitter frequency very well

Good point: when I bought my 38 receiver, they shop had 37.5 as well.
Logged

The Elders of the Internet know who I am.....

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5358
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Maybe it's because the receiver frequency doesn't match the transmitter frequency very well

Good point: when I bought my 38 receiver, they shop had 37.5 as well.

My VISHAY IR receiver datasheet lists variants at 30, 33, 36, 36.7, 38, 40 and 56 kHz. They use a bandpass filter so there's a bit of tolerance but maybe that remote is transmitting at 33 or 40kHz.

PS: You could hook an oscilloscope to the transmitter LED to find out...

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: [1] 2   Go Up
Jump to: