Go Down

Topic: IR Receive - cannot decode SONY signals (Read 117 times) previous topic - next topic

pjakobs

I give up and ask my question here.

I have a basic IR sensor on an ESP8266 (read to the end before suggesting a hardware issue, please).

I have a SONY IR sender and I want to basically just get the code to function mapping from it.
For that I use the basic ESP8266IRreceiver sketch that is functionally identical to the Arduino example.

What I get is this:

Code: [Select]

Encoding  : UNKNOWN
Code      : E2653A5A (32 bits)
Timing[24]:
     + 600, - 650     + 600, - 650     + 600, - 650     + 600, -1250
     + 600, - 650     + 600, -1250     + 600, - 650     + 600, -1250
     + 600, - 650     + 600, - 650     + 600, - 650     + 600, -1250

unsigned int  rawData[24] = {600,650, 600,650, 600,650, 600,1250, 600,650, 600,1250, 600,650, 600,1250, 600,650, 600,650, 600,650, 600,1250 };  // UNKNOWN E2653A5A

Encoding  : UNKNOWN
Code      : E2653A5A (32 bits)
Timing[24]:
     + 600, - 650     + 600, - 650     + 600, - 650     + 600, -1250
     + 600, - 650     + 600, -1300     + 550, - 650     + 600, -1250
     + 600, - 650     + 600, - 650     + 600, - 650     + 600, -1250

unsigned int  rawData[24] = {600,650, 600,650, 600,650, 600,1250, 600,650, 600,1300, 550,650, 600,1250, 600,650, 600,650, 600,650, 600,1250 };  // UNKNOWN E2653A5A

Encoding  : UNKNOWN
Code      : E2653A5A (32 bits)
Timing[24]:
     + 600, - 650     + 600, - 650     + 600, - 650     + 600, -1250
     + 600, - 650     + 600, -1250     + 600, - 650     + 600, -1250
     + 600, - 650     + 600, - 650     + 600, - 650     + 600, -1250

unsigned int  rawData[24] = {600,650, 600,650, 600,650, 600,1250, 600,650, 600,1250, 600,650, 600,1250, 600,650, 600,650, 600,650, 600,1250 };  // UNKNOWN E2653A5A



(three code repeats here)

As you can see, it successfully captures the 12 bit slots and the corresponding timings of .. well, the SONY 12 Bit IR protocol - but for some reason doesn't decode it.

for reference, here's the sketch:

Code: [Select]

/*
 * IRremoteESP8266: IRrecvDumpV2 - dump details of IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 Sept, 2015
 * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
 */

#include <IRremoteESP8266.h>

int RECV_PIN = 5; //an IR detector/demodulator is connected to GPIO pin 2

IRrecv irrecv(RECV_PIN);

void  setup ( )
{
  Serial.begin(115200);   // Status message will be sent to PC at 9600 baud
  pinMode(RECV_PIN, INPUT_PULLUP);
  irrecv.enableIRIn();  // Start the receiver
}

//+=============================================================================
// Display IR code
//
void  ircode (decode_results *results)
{
  // Panasonic has an Address
  if (results->decode_type == PANASONIC) {
    Serial.print(results->panasonicAddress, HEX);
    Serial.print(":");
  }

  // Print Code
  Serial.print(results->value, HEX);
}

//+=============================================================================
// Display encoding type
//
void  encoding (decode_results *results)
{
  switch (results->decode_type) {
    default:
    case UNKNOWN:      Serial.print("UNKNOWN");       break ;
    case NEC:          Serial.print("NEC");           break ;
    case SONY:         Serial.print("SONY");          break ;
    case RC5:          Serial.print("RC5");           break ;
    case RC6:          Serial.print("RC6");           break ;
    case DISH:         Serial.print("DISH");          break ;
    case SHARP:        Serial.print("SHARP");         break ;
    case JVC:          Serial.print("JVC");           break ;
    case SANYO:        Serial.print("SANYO");         break ;
    case MITSUBISHI:   Serial.print("MITSUBISHI");    break ;
    case SAMSUNG:      Serial.print("SAMSUNG");       break ;
    case LG:           Serial.print("LG");            break ;
    case WHYNTER:      Serial.print("WHYNTER");       break ;
    case AIWA_RC_T501: Serial.print("AIWA_RC_T501");  break ;
    case PANASONIC:    Serial.print("PANASONIC");     break ;
  }
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpInfo (decode_results *results)
{
  // Show Encoding standard
  Serial.print("Encoding  : ");
  encoding(results);
  Serial.println("");

  // Show Code & length
  Serial.print("Code      : ");
  ircode(results);
  Serial.print(" (");
  Serial.print(results->bits, DEC);
  Serial.println(" bits)");
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpRaw (decode_results *results)
{
  // Print Raw data
  Serial.print("Timing[");
  Serial.print(results->rawlen-1, DEC);
  Serial.println("]: ");

  for (int i = 1;  i < results->rawlen;  i++) {
    unsigned long  x = results->rawbuf[i] * USECPERTICK;
    if (!(i & 1)) {  // even
      Serial.print("-");
      if (x < 1000)  Serial.print(" ") ;
      if (x < 100)   Serial.print(" ") ;
      Serial.print(x, DEC);
    } else {  // odd
      Serial.print("     ");
      Serial.print("+");
      if (x < 1000)  Serial.print(" ") ;
      if (x < 100)   Serial.print(" ") ;
      Serial.print(x, DEC);
      if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
    }
    if (!(i % 8))  Serial.println("");
  }
  Serial.println("");                    // Newline
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpCode (decode_results *results)
{
  // Start declaration
  Serial.print("unsigned int  ");          // variable type
  Serial.print("rawData[");                // array name
  Serial.print(results->rawlen - 1, DEC);  // array size
  Serial.print("] = {");                   // Start declaration

  // Dump data
  for (int i = 1;  i < results->rawlen;  i++) {
    Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
    if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
    if (!(i & 1))  Serial.print(" ");
  }

  // End declaration
  Serial.print("};");  //

  // Comment
  Serial.print("  // ");
  encoding(results);
  Serial.print(" ");
  ircode(results);

  // Newline
  Serial.println("");

  // Now dump "known" codes
  if (results->decode_type != UNKNOWN) {

    // Some protocols have an address
    if (results->decode_type == PANASONIC) {
      Serial.print("unsigned int  addr = 0x");
      Serial.print(results->panasonicAddress, HEX);
      Serial.println(";");
    }

    // All protocols have data
    Serial.print("unsigned int  data = 0x");
    Serial.print(results->value, HEX);
    Serial.println(";");
  }
}

//+=============================================================================
// The repeating section of the code
//
void  loop ( )
{
  decode_results  results;        // Somewhere to store the results

  if (irrecv.decode(&results)) {  // Grab an IR code
    dumpInfo(&results);           // Output the results
    dumpRaw(&results);            // Output the results in RAW format
    dumpCode(&results);           // Output the results as source code
    Serial.println("");           // Blank line between entries
    irrecv.resume();              // Prepare for the next value
  }
}


nothing out of the ordinary, I would suspect.

I can read the SONY codes from the timings easy enough, but I would rather have the processor do it for me, after all, counting bits and summing them up is what it does best

kind regards

pj

Go Up