Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange IRRemote behaviour
07-08-2016, 08:19 PM, (This post was last modified: 07-08-2016, 08:21 PM by Hershell.)
#1
Strange IRRemote behaviour
Hey
This sketch:
Code:
/*
* DecodeRemote: demonstrates decoding IR codes from a remote control
* An IR detector/demodulator must be connected to the input IRSENSOR.
* Version 0.1 March, 2014
* Author : Regis Blanchot
*/

#define IRSENSOR 7 // pin 0, can be any digital pin

// VOLUME 9E0A10FF
// first 2ADE08A3

char brand[][10] = {"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI"};

decode_results results; // Results returned from the decoder

void setup()
{
IRremote.enableIRIn(IRSENSOR); // Start the receiver
IRremote.blink(true); // Built-in led will blink at reception
CDC.print("Hey ");
}

void loop()
{
if (IRremote.decode(&results)==DECODED)
{
if (results.decode_type>10)
results.decode_type = 0;
else if(results.decode_type < 0)
results.decode_type = 0;

CDC.print("Decoded ");
CDC.printNumber(results.value, HEX);
CDC.print(" (type ");
CDC.print(brand[results.decode_type]);
CDC.print(")\r\n");

/// or

//CDC.printf("Decoded %ld (type %s)\r\n", results.value, brand[results.decode_type]);

IRremote.resume(); // Ready to receive the next value
}
}
Is giving me such result:
Code:
Decoded 3101091A  (type UNKNOWN)
Decoded A4D1FC72  (type UNKNOWNDecoded 57C55B89  (type Decoded 55D6C0DA  (type UNKNOWNDecoded C2D0BFF  (type UNKNOWN)
Decoded 867B93B  (type )
Decoded 11FCDAB5  (type UNKNOWN)
Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type UNKNOWNDecoded 8EEF4B83  (type )
Decoded 8EEF4B83  (type UNKNOWNDecoded 9E0A10FF  (type UNKNOWN)
Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type UNKNOWNDecoded 9E0A10FF  (type UNKNOWNDecoded 9E0A10FF  (type Decoded 9E0A10FF  (type UNKNOWNDecoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type UNKNOWN)
Decoded 9E0A10FF  (type Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type )

I have tested various remotes. It's always "UNKNOWN" but codes are coresponding to buttons. Is this some kind of bug? Why the string data in terminal is corrupted (sometimes TYPE is missing)?

PS: Pinguino 2550, 16MHz.
Reply
08-08-2016, 12:25 AM,
#2
RE: Strange IRRemote behaviour
(07-08-2016, 08:19 PM)Hershell Wrote: Hey
This sketch:
Code:
/*
* DecodeRemote: demonstrates decoding IR codes from a remote control
* An IR detector/demodulator must be connected to the input IRSENSOR.
* Version 0.1 March, 2014
* Author : Regis Blanchot
*/

#define IRSENSOR 7 // pin 0, can be any digital pin

// VOLUME 9E0A10FF
// first 2ADE08A3

char brand[][10] = {"UNKNOWN", "NEC", "SONY", "RC5", "RC6", "DISH", "SHARP", "PANASONIC", "JVC", "SANYO", "MITSUBISHI"};

decode_results results; // Results returned from the decoder

void setup()
{
IRremote.enableIRIn(IRSENSOR); // Start the receiver
IRremote.blink(true); // Built-in led will blink at reception
CDC.print("Hey ");
}

void loop()
{
if (IRremote.decode(&results)==DECODED)
{
if (results.decode_type>10)
results.decode_type = 0;
else if(results.decode_type < 0)
results.decode_type = 0;

CDC.print("Decoded ");
CDC.printNumber(results.value, HEX);
CDC.print(" (type ");
CDC.print(brand[results.decode_type]);
CDC.print(")\r\n");

/// or

//CDC.printf("Decoded %ld (type %s)\r\n", results.value, brand[results.decode_type]);

IRremote.resume(); // Ready to receive the next value
}
}
Is giving me such result:
Code:
Decoded 3101091A  (type UNKNOWN)
Decoded A4D1FC72  (type UNKNOWNDecoded 57C55B89  (type Decoded 55D6C0DA  (type UNKNOWNDecoded C2D0BFF  (type UNKNOWN)
Decoded 867B93B  (type )
Decoded 11FCDAB5  (type UNKNOWN)
Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type UNKNOWNDecoded 8EEF4B83  (type )
Decoded 8EEF4B83  (type UNKNOWNDecoded 9E0A10FF  (type UNKNOWN)
Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type UNKNOWNDecoded 9E0A10FF  (type UNKNOWNDecoded 9E0A10FF  (type Decoded 9E0A10FF  (type UNKNOWNDecoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type UNKNOWN)
Decoded 9E0A10FF  (type Decoded 9E0A10FF  (type )
Decoded 9E0A10FF  (type )

I have tested various remotes. It's always "UNKNOWN" but codes are coresponding to buttons. Is this some kind of bug? Why the string data in terminal is corrupted (sometimes TYPE is missing)?

PS: Pinguino 2550, 16MHz.
are you trying to decode a ir remote?
Reply
08-08-2016, 12:37 AM,
#3
RE: Strange IRRemote behaviour
yes, I want to decode, but the library is working in a strange way.
It should say "RC5" or something like that, like the original one in Arduio IDE...
Why do you ask?
Reply
08-08-2016, 12:59 AM,
#4
RE: Strange IRRemote behaviour
(08-08-2016, 12:37 AM)Hershell Wrote: yes, I want to decode, but the library is working in a strange way.
It should say "RC5" or something like that, like the original one in Arduio IDE...
Why do you ask?

are you using v12 boot loader 4?
Reply
08-08-2016, 01:28 AM,
#5
RE: Strange IRRemote behaviour
replace IRremote "c" with my file save your file with a different name.
i am using v12 boot loader 4 18f4550  with xc8 compiler


Attached Files
.c   IRremote.c (Size: 34.45 KB / Downloads: 2)
Reply
08-08-2016, 09:36 AM,
#6
RE: Strange IRRemote behaviour
It works.... bootloader v4.
I am using v11.
What did you change in the code?

But.. the CDC output is still corrupted:
Code:
Decoded 25  (type RC5)
Decoded 25  (type RC5Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5Decoded 25  (type RC5Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5Decoded 25  (type RC5)
Decoded 825  (type RC5)
Decoded 825  (type RC5Decoded 825  (type RC5Decoded 825  (type )
Decoded 825  (type RC5)
Decoded 825  (type )
Decoded 825  (type RC5)
Decoded 825  (type RC5)
Decoded 825  (type RC5Decoded 825  (type RC5)
Decoded 825  (type RC5Decoded 825  (type RC5)
Decoded 825  (type )
Decoded 825  (type )
Decoded 825  (type RC5)
Decoded 25  (type RC5)
Decoded 825  (type RC5)
Decoded 25  (type RC5)
Decoded 825  (type RC5)
Decoded 25  (type RC5Decoded 825  (type RC5)
Decoded 29  (type RC5)
Decoded 29  (type RC5)
Decoded 29  (type RC5)
Decoded 29  (type RC5)
Decoded 81C  (type RC5Decoded 81C  (type )
Decoded 81C  (type RC5)
Decoded 81C  (type RC5Decoded 81C  (type RC5)
Decoded 31  (type RC5Decoded 31  (type RC5Decoded 31  (type RC5)
Decoded 31  (type RC5)
Decoded 824  (type RC5)
Decoded 824  (type RC5)
Decoded 824  (type RC5Decoded 23  (type RC5)
Decoded 23  (type RC5)
Decoded 23  (type )
Decoded 23  (type RC5Decoded 833  (type RC5Decoded 2E  (type RC5Decoded 2E  (type RC5Decoded 2E  (type RC5Decoded 826  (type RC5)
Decoded 826  (type RC5)
Decoded 826  (type RC5Decoded 26  (type RC5Decoded 26  (type RC5)
Decoded 26  (type RC5Decoded 811  (type RC5)

PS: this time it took me around 10 attemps to open a CDC port (with plugging in and out the board).
Reply
08-08-2016, 12:20 PM,
#7
RE: Strange IRRemote behaviour
(08-08-2016, 09:36 AM)Hershell Wrote: It works.... bootloader v4.
I am using v11.
What did you change in the code?

But.. the CDC output is still corrupted:
Code:
Decoded 25  (type RC5)
Decoded 25  (type RC5Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5Decoded 25  (type RC5Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5)
Decoded 25  (type RC5Decoded 25  (type RC5)
Decoded 825  (type RC5)
Decoded 825  (type RC5Decoded 825  (type RC5Decoded 825  (type )
Decoded 825  (type RC5)
Decoded 825  (type )
Decoded 825  (type RC5)
Decoded 825  (type RC5)
Decoded 825  (type RC5Decoded 825  (type RC5)
Decoded 825  (type RC5Decoded 825  (type RC5)
Decoded 825  (type )
Decoded 825  (type )
Decoded 825  (type RC5)
Decoded 25  (type RC5)
Decoded 825  (type RC5)
Decoded 25  (type RC5)
Decoded 825  (type RC5)
Decoded 25  (type RC5Decoded 825  (type RC5)
Decoded 29  (type RC5)
Decoded 29  (type RC5)
Decoded 29  (type RC5)
Decoded 29  (type RC5)
Decoded 81C  (type RC5Decoded 81C  (type )
Decoded 81C  (type RC5)
Decoded 81C  (type RC5Decoded 81C  (type RC5)
Decoded 31  (type RC5Decoded 31  (type RC5Decoded 31  (type RC5)
Decoded 31  (type RC5)
Decoded 824  (type RC5)
Decoded 824  (type RC5)
Decoded 824  (type RC5Decoded 23  (type RC5)
Decoded 23  (type RC5)
Decoded 23  (type )
Decoded 23  (type RC5Decoded 833  (type RC5Decoded 2E  (type RC5Decoded 2E  (type RC5Decoded 2E  (type RC5Decoded 826  (type RC5)
Decoded 826  (type RC5)
Decoded 826  (type RC5Decoded 26  (type RC5Decoded 26  (type RC5)
Decoded 26  (type RC5Decoded 811  (type RC5)

PS: this time it took me around 10 attemps to open a CDC port (with plugging in and out the board).

your cdc output is correct RC5 types have two codes per key i use these types on my ir robots and they work great. 
i changed this.

// nb cycles for 50us
   _tmr_reload_val = ( System_getPeripheralFrequency() / 1000 / 1000 ); // 1us = 12 cycles @ 48MHz
   _tmr_reload_val *= 24; // 50us = 50 * 12 cy @ 48MHz  
   _tmr_reload_val = 0xFFFF - _tmr_reload_val;
Reply
08-08-2016, 08:10 PM,
#8
RE: Strange IRRemote behaviour
So it has to be changed for each crystal type?
For example, if I now switch from 16MHz to 12MHz it won't work again correctly?

Anyway, I also tested NEC with current setup, take a look:
Code:
Decoded 49E106EC  (type UNKNOWN)
Decoded 2D04DFBB  (type UNKNOWN)
Decoded EE5F76C5  (type UNKNOWN)
Decoded 12582EE1  (type UNKNOWN)
Decoded E33ADE1D  (type UNKNOWN)
Decoded B3924190  (type UNKNOWN)
Decoded 90053B36  (type UNKNOWN)
Decoded 825A7411  (type UNKNOWN)
Decoded 3EA7FE59  (type UNKNOWN)
Decoded 4CE98B7B  (type UNKNOWN)
Decoded B62255F2  (type UNKNOWN)
Decoded F1C95194  (type UNKNOWN)
Decoded E6B5607  (type UNKNOWN)
Decoded 7C290770  (type UNKNOWN)
Decoded 2D83D743  (type UNKNOWN)
Decoded 81091E2B  (type UNKNOWN)
Decoded 6ABC4FBC  (type UNKNOWN)
Decoded 20DF0CF3  (type NEC)
Decoded 20DF0CF3  (type NEC)
Decoded 20DF0CF3  (type NEC)
Decoded 20DFD02F  (type NEC)
Decoded 20DFD02F  (type NEC)
Decoded 20DFD02F  (type NEC)
Decoded 20DFD02F  (type NEC)
Decoded 20DFD02F  (type NEC)
Decoded 20DFD02F  (type NEC)
Decoded 20DFD02F  (type )
Decoded 20DFD02F  (type NECDecoded 20DF0FF0  (type NEC)
Decoded 20DF0FF0  (type NEC)
Decoded 20DF0FF0  (type NECDecoded 20DF0FF0  (type NECDecoded 20DF0FF0  (type NECDecoded 20DF0FF0  (type NEC)
Decoded 20DF0FF0  (type NEC)
Decoded 20DF8877  (type )
Decoded 20DF8877  (type NEC)
Decoded 20DF8877  (type NECDecoded 20DF8877  (type NEC)
Decoded 20DF8877  (type NEC)
Decoded 20DF8877  (type NECDecoded 20DF48B7  (type NECDecoded 20DF48B7  (type NEC)
Decoded 20DF48B7  (type )
Decoded 20DF48B7  (type NEC)
Decoded 20DF48B7  (type NEC)
Decoded 20DF48B7  (type NECDecoded 20DF48B7  (type )
Decoded 20DF48B7  (type NEC)
Decoded 20DFC837  (type NECDecoded 20DFC837  (type NEC)
Decoded 20DFC837  (type NECDecoded 20DFC837  (type NEC)
Decoded 20DFC837  (type NEC)
Decoded 20DFC837  (type NECDecoded 20DF28D7  (type NEC)
Decoded 20DF28D7  (type NECDecoded 20DF28D7  (type NECDecoded 20DF28D7  (type NEC)
Decoded 20DF28D7  (type NEC)
Decoded 20DF28D7  (type )
Decoded 20DFA857  (type NEC)
Decoded 20DFA857  (type NECDecoded 20DFA857  (type NEC)
Decoded 20DFA857  (type NEC)
Decoded 20DFA857  (type NECDecoded 20DFA857  (type )
Decoded 20DFA857  (type NECDecoded 20DF6897  (type NEC)
Decoded 20DF6897  (type NEC)
Decoded 20DF6897  (type NECDecoded 817E5AAC  (type UNKNOWN)
Decoded 20DF6897  (type NEC)
Decoded 20DF6897  (type NEC)
Decoded 20DF6897  (type NEC)
Decoded 20DFE817  (type NEC)
Decoded 7C177A74  (type UNKNOWN)
Decoded 20DFE817  (type NEC)
Decoded 20DFE817  (type NECDecoded 20DFE817  (type NEC)
Decoded 20DFE817  (type )
Decoded 20DFE817  (type NEC)
Decoded 20DFE817  (type NEC)
Decoded 20DFE817  (type NEC)
Decoded 20DFE817  (type NECDecoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type )
Decoded 20DF18E7  (type NECDecoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF18E7  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NECDecoded 20DF9867  (type NECDecoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type )
Decoded 20DF9867  (type NECDecoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DF9867  (type NEC)
Decoded 20DFCA35  (type NEC)
Decoded 20DFCA35  (type NEC)
Decoded 20DFCA35  (type NEC)
Decoded 20DFCA35  (type NEC)
Decoded 20DFCA35  (type NEC)
Decoded 20DFCA35  (type NEC)
Decoded 20DFCA35  (type NECDecoded 20DF08F7  (type NECDecoded 20DF08F7  (type NECDecoded 20DF08F7  (type NEC)
Decoded 20DF08F7  (type NECDecoded 20DF08F7  (type NEC)
Decoded 20DF08F7  (type )
Decoded 20DF  (type JVC)
Decoded 20DF08F7  (type NEC)
Decoded 20DF08F7  (type NEC)
Decoded 20DF58A7  (type NEC)
Decoded 20DF58A7  (type NECDecoded 20DF58A7  (type NEC)
Decoded 20DF58A7  (type NECDecoded 20DF58A7  (type NEC)
Decoded 20DF58A7  (type NECDecoded 20DF58A7  (type NEC)
Decoded 20DF58A7  (type NEC)
Decoded 20DF58A7  (type NEC)
Decoded 4E75F678  (type UNKNOWN)
Decoded 7158B729  (type UNKNOWN)
Decoded FFFFFFFF  (type NEC)
Decoded 20DF40BF  (type NECDecoded 20DF40BF  (type NECDecoded 20DF40BF  (type NECDecoded 20DF40BF  (type NEC)
Decoded 20DF40BF  (type NEC)
Decoded 20DF40BF  (type NEC)
Decoded 20DF40BF  (type NEC)
Decoded 20DF7887  (type NEC)
Decoded 20DF7887  (type NEC)
Decoded 20DF7887  (type NECDecoded 8225FADB  (type UNKNOWNDecoded EB2FAA21  (type UNKNOWN)
Decoded 20DF00FF  (type NEC)
Decoded 20DF00FF  (type NEC)
Decoded 20DF00FF  (type NECDecoded 20DF00FF  (type NEC)
Decoded 20DF9E61  (type )
Decoded 20DF9E61  (type NEC)
Decoded 78F5F61F  (type UNKNOWN)
Decoded 20DFC03F  (type NEC)
Decoded 20DFC03F  (type NEC)
Decoded 20DFC03F  (type NEC)
Decoded 20DFC03F  (type NEC)
Decoded 20DFC03F  (type NECDecoded 20DFC03F  (type NEC)
Decoded 20DF906F  (type NEC)
Decoded 20DF906F  (type NECDecoded 20DF906F  (type NEC)
Decoded 71B93203  (type UNKNOWN)
Decoded 71B93203  (type UNKNOWN)
Decoded FFFFFFFF  (type NEC)
Decoded 4AC5C169  (type UNKNOWN)
Decoded 169CDC1F  (type )
Decoded 20DF807F  (type NECDecoded 169CDC1F  (type UNKNOWN)
Decoded FFFFFFFF  (type NEC)
Decoded FFFFFFFF  (type NEC)
Decoded 20DF807F  (type NEC)
What is happening? Is this a correct output for NEC remote?
Reply
08-08-2016, 08:28 PM,
#9
RE: Strange IRRemote behaviour
not sure about NEC  but i have tried with philips remote and the make ir remote and had sucess. once you get a few codes try a pde to turn on/off  an LED.
Reply
08-08-2016, 08:37 PM,
#10
RE: Strange IRRemote behaviour
Code:
/*
* IRremote lighting controller
* written by Fred Warden
* Version 1.0 February, 2014
* ir arduino library by Ken Shirriff
* ir pinguino library modified by Régis Blanchot
*/

int RECV_PIN = 7;   // can be any digital pin

decode_results results;

void setup()
{    
   pinMode(8,OUTPUT);
   
   IRremote.enableIRIn(RECV_PIN);
  IRremote.blink(TRUE);

}

void loop()
{  
   if (IRremote.decode(&results))
   {
   
       if (results.value == 0x25|| results.value == 0x825) {  // button 1
   digitalWrite(8,HIGH);
   
   }
  if (results.value == 0x31 || results.value == 0x824 ) {// button 2
digitalWrite(8,LOW);
 
     }
   
   
 
 }
       IRremote.resume(); // Receive the next value
}
}
try this with your RC5 controller
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)