Problem send raw signal to Panasonic AC

Everything related to protocols and IR codes
Post Reply
grimmjow
Posts: 1
Joined: Tue Sep 25, 2018 2:22 am

Problem send raw signal to Panasonic AC

Post by grimmjow »

Hello, first of all, thank you for your help across the forum and the web about this particular matter.
I'm a newbie with my arduino uno, and I want to try to decode my Panasonic AC remote, but I hit a bit of a roadblock now.
I try to control my LG tv, and it works just fine either the receiver or the emitter, but I can't do the same with my AC.

I use IRremote library for this, here's the receive sketch I use

Code: Select all

//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>

//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);

//+=============================================================================
// Configure the Arduino
//
void  setup ( )
{
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud
  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->address, 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 ;
    case DENON:        Serial.print("Denon");         break ;
  }
}

//+=============================================================================
// Dump out the decode_results structure.
//
void  dumpInfo (decode_results *results)
{
  // Check if the buffer overflowed
  if (results->overflow) {
    Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
    return;
  }

  // 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->address, 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
  }
}
And this is the result

Code: Select all

Encoding  : UNKNOWN
Code      : 9DCF5C22 (32 bits)
Timing[131]: 
     +3450, -1700     + 450, - 400     + 450, -1300     + 450, - 400
     + 450, - 400     + 450, - 450     + 450, - 400     + 450, - 400
     + 450, - 400     + 450, - 450     + 400, - 450     + 450, - 400
     + 450, - 400     + 450, - 400     + 450, -1300     + 450, - 400
     + 450, - 400     + 450, - 450     + 450, - 400     + 450, - 400
     + 450, - 400     + 500, - 400     + 400, -1300     + 450, -1250
     + 450, -1300     + 450, - 400     + 450, - 400     + 450, -1300
     + 450, - 400     + 450, - 400     + 450, - 450     + 400, - 450
     + 450, - 400     + 450, - 400     + 450, - 400     + 450, - 450
     + 400, - 450     + 450, - 400     + 450, - 400     + 450, - 450
     + 450, - 400     + 450, - 400     + 450, - 400     + 450, - 450
     + 400, - 450     + 450, - 400     + 450, - 400     + 450, - 400
     + 450, - 450     + 450, - 400     + 450, - 400     + 450, - 400
     + 450, - 450     + 400, - 450     + 450, - 400     + 450, - 400
     + 450, - 450     + 400, - 450     + 450, -1250     + 450, -1300
     + 450, - 400     + 450, - 400     + 450, - 400     + 450, - 450
     + 400, - 450     + 450
unsigned int  rawData[131] = {3450,1700, 450,400, 450,1300, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,1300, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 500,400, 400,1300, 450,1250, 450,1300, 450,400, 450,400, 450,1300, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 400,450, 450,1250, 450,1300, 450,400, 450,400, 450,400, 450,450, 400,450, 450};  // UNKNOWN 9DCF5C22

But when I use your sketch here https://www.analysir.com/blog/wp-conten ... als_10.txt
I got a very different result

Code: Select all

Press the button on the remote now - once only

Raw: (439) 3496, -1728, 448, -424, 448, -1292, 448, -420, 448, -424, 448, -420, 452, -420, 456, -412, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 452, -420, 448, -1288, 452, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -1288, 452, -1288, 452, -1288, 452, -420, 452, -420, 448, -1288, 452, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -416, 452, -420, 452, -420, 452, -416, 452, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -1288, 452, -1292, 448, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -11016, 3496, -1724, 452, -420, 448, -1292, 448, -420, 452, -420, 448, -424, 448, -420, 448, -424, 448, -420, 452, -420, 448, -420, 448, -424, 448, -420, 452, -420, 448, -1292, 448, -420, 476, -396, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -1288, 452, -1292, 448, -1292, 448, -420, 452, -420, 448, -1292, 476, -396, 448, -420, 448, -420, 452, -420, 452, -420, 472, -396, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 452, -1288, 452, -1288, 448, -1292, 448, -1292, 448, -1292, 452, -1288, 452, -420, 448, -420, 452, -420, 448, -1292, 448, -420, 448, -424, 448, -420, 452, -1288, 452, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -1288, 452, -1288, 452, -1288, 452, -1292, 448, -1292, 448, -420, 452, -1292, 448, -420, 448, -1292, 452, -420, 448, -420, 452, -420, 448, -420, 448, -424, 448, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -424, 448, -420, 452, -1288, 448, -1292, 452, -1288, 452, -420, 448, -420, 428, -444, 448, -420, 452, -420, 424, -444, 428, -444, 424, -448, 424, -444, 428, -1312, 428, -1312, 452, -1288, 452, -420, 428, -444, 424, -472, 400, -468, 428, -444, 428, -444, 428, -440, 428, -440, 460, -412, 460, -408, 464, -408, 492, -380, 488, -380, 492, -380, 492, -376, 496, -376, 496, -1216, 524, -372, 500, -372, 500, -368, 500, -372, 496, -376, 496, -372, 500, -1212, 528, -372, 496, -372, 500, -372, 500, -368, 500, -372, 496, -372, 500, -372, 500, -372, 496, -372, 500, -1212, 524, -1216, 528, -372, 496, -372, 500, -372, 496, -376, 496, -372, 496, -1216, 524, -1216, 524, -376, 496, -1216, 524, -372, 496, -376, 496, -372, 496, -376, 496, 

The problem is, my AC won't respond to neither of the signal

This is the sketch I use to send

Code: Select all

/*
 * IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 *
 * IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
 *
 * This example shows how to send a RAW signal using the IRremote library.
 * The example signal is actually a 32 bit NEC signal.
 * Remote Control button: LGTV Power On/Off. 
 * Hex Value: 0x20DF10EF, 32 bits
 * 
 * It is more efficient to use the sendNEC function to send NEC signals. 
 * Use of sendRaw here, serves only as an example of using the function.
 * 
 */


#include <IRremote.h>

IRsend irsend;

void setup()
{

}

void loop() {
  int khz = 38; // 38kHz carrier frequency for the NEC protocol
  unsigned int irSignal[131] = {3450,1700, 450,400, 450,1300, 400,450, 400,450, 450,400, 450,450, 400,450, 400,450, 450,400, 450,450, 400,450, 450,400, 400,450, 450,1300, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,1300, 450,1250, 450,1300, 450,400, 400,450, 450,1300, 450,400, 450,400, 450,400, 450,450, 400,450, 400,450, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 400,450, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 400,1300, 450,1250, 450,450, 450,400, 400,450, 450,400, 450,450, 400}; //AnalysIR Batch Export (IRremote) - RAW
  
  irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.

  delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}
I already change the rawbuf to 500, so I assume it's not the problem, the receiver I use is TSOP1838 (I think). And I use a regular IR led emitter, connected to ground and pin3 (with 150ohm resistor) on my arduino.
I try using different IR libraries, but it just messing up my arduino IDE, so I revert back to IRremote. So, like I said earlier, this is kind of a roadblock for me. Don't know what else to do, so I wanna try to calm my head for now and ask here in the forum what is it that I did wrong.

Thank you again for the help.
User avatar
AnalysIR
Site Admin
Posts: 776
Joined: Sat Aug 31, 2013 3:51 pm
Location: Dublin, Ireland
Contact:

Re: Problem send raw signal to Panasonic AC

Post by AnalysIR »

Use the signal recorded with our sketch only.

Then try the following:

Code: Select all

/*
Automatically Generated by AnalysIR - Batch Export Utility
Registered to: xxxxxxxx
Session History
Type : Key : Value : Bits : Carrier Frequency (kHz)
0 : PANASONIC128_216_280AC :  : 40040720000000604004072000FC4401F5000070070000810060D0 : 216 : 0
Note: Be sure to use the correct Carrier frequency, for each individual signal, as(or if) indicated above
*/

// NB: Not all protocols are supported by IRremote or IRLib. You may need to edit the code below manually
// Automatically Generated by AnalysIR for xxxxxxxx, visit https://www.AnalysIR.com/ or email info@....... for further details
int khz=38; //NB Change this default value as neccessary to the correct carrier frequency


uint16_t Signal_0_0[] = {3500,1750,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,1300,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,435,435,435,435,435,435,435,435,435,435,11016,3500,1750,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,1300,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,1300,435,1300,435,1300,435,1300,435,435,435,435,435,435,435,1300,435,435,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,1300,435,1300,435,1300,435,435,435,1300,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,435,435,435,435,435,435,435,435,435,435,1300,435,1300,435,435,435,1300,435,435,435,435,435,435,435,435,435}; //AnalysIR Batch Export (IRremote) - RAW

irsend.sendRaw(Signal_0_0, sizeof(Signal_0_0)/sizeof(int), khz); //AnalysIR Batch Export (IRremote) - RAW
 // AnalysIR IR Protocol: PANASONIC128_216_280AC, Key:  

If you have a copy of AnalysIR you can do all of this automatically. If this does not work then it is likely there is a problem with your IR emitter circuit. Make sure to point the top of the LED directly at the AC and move it close. You could also replace the resistor by 100R or just put 2 150R in parallel.

Finally, if that doesn't work for you check out our range of IR modules on our webshop or get something similar.
Post Reply