Go Down

Topic: Mitsubishi IR AC remote decoding Problem (Read 12 times) previous topic - next topic

techshifter

Looks like your IR pulse is longer than 240 also, turn it up a little further until you don't get any more raw data. That IR library wont work with an IR command that long, it is trying to store it in a single 4 byte block and it doesn't fit. The library will  either need to be heavily modified or best to just start from scratch with only the codes you need.

RB

Hey,

I'm currently going through the same thing of trying to emulate an AC remote control.

I found these two blog posts which might help:

Reading the codes:
http://dduino.blogspot.in/2011/11/improved-ir-code-reciever.html

Sending the codes:
http://dduino.blogspot.in/2011/11/use-sonar-to-control-tv.html

I haven't completely tried these - so do let me know if they work!


As some very helpful posters have mentioned earlier, the buffer limit on line 112 of IRremote.h need to be increased too.

Thanks,
R

arslankhan

#17
Apr 03, 2013, 05:41 am Last Edit: Apr 03, 2013, 06:11 am by arslankhan Reason: 1
After my long struggle I am still unsuccessful, I got the raw data then make hex code but it did not work. I am posting here my work .Kindly tell me the better way to get the exact code.
Code: [Select]
#define RAWBUF 255 // Length of raw duration buffer
Code: [Select]

#include <avr/interrupt.h>
#include <avr/io.h>

#define TIMER_RESET  TCNT1 = 0
#define SAMPLE_SIZE  255

int IRpin = 3;
unsigned int TimerValue[SAMPLE_SIZE];
char direction[SAMPLE_SIZE];
byte change_count;
long time;

void setup() {
 Serial.begin(115200);
 Serial.println("Analyze IR Remote");
 TCCR1A = 0x00;          // COM1A1=0, COM1A0=0 => Disconnect Pin OC1 from Timer/Counter 1 -- PWM11=0,PWM10=0 => PWM Operation disabled
 // ICNC1=0 => Capture Noise Canceler disabled -- ICES1=0 => Input Capture Edge Select (not used) -- CTC1=0 => Clear Timer/Counter 1 on Compare/Match
 // CS12=0 CS11=1 CS10=1 => Set prescaler to clock/64
 TCCR1B = 0x03;          // 16MHz clock with prescaler means TCNT1 increments every 4uS
 // ICIE1=0 => Timer/Counter 1, Input Capture Interrupt Enable -- OCIE1A=0 => Output Compare A Match Interrupt Enable -- OCIE1B=0 => Output Compare B Match Interrupt Enable
 // TOIE1=0 => Timer 1 Overflow Interrupt Enable
 TIMSK1 = 0x00;          
 pinMode(IRpin, INPUT);
}

void loop()
{
 Serial.println("Waiting...");
 change_count = 0;
 while(digitalRead(IRpin) == HIGH) {}                                
 TIMER_RESET;
 TimerValue[change_count] = TCNT1;
 direction[change_count++] = '0';
 while (change_count < SAMPLE_SIZE) {
   if (direction[change_count-1] == '0') {
     while(digitalRead(IRpin) == LOW) {}
     TimerValue[change_count] = TCNT1;
     direction[change_count++] = '1';
   } else {
     while(digitalRead(IRpin) == HIGH) {}
     TimerValue[change_count] = TCNT1;
     direction[change_count++] = '0';
   }
 }
 Serial.println("Bit stream detected!");
 change_count = 0;
 time = (long) TimerValue[change_count] * 4;
 Serial.print(time);
 Serial.print("\t");
 Serial.println(direction[change_count++]);
 while (change_count < SAMPLE_SIZE) {
   time = (long) TimerValue[change_count] * 4;
   Serial.print(time);
   Serial.print("\t");
   Serial.println(direction[change_count-1]);
   Serial.print(time);
   Serial.print("\t");
   Serial.println(direction[change_count++]);    
 }
 Serial.println("Bit stream end!");
 delay(2000);
}

result
Code: [Select]
Analyze IR Remote
Waiting...
Bit stream detected!
0 0
3548 0
3548 1
5180 1
5180 0
5684 0
5684 1
6864 1
6864 0
7364 0
7364 1
8548 1
8548 0
9044 0
9044 1
9380 1
9380 0
9888 0
9888 1
10224 1
10224 0
10724 0
10724 1
11060 1
11060 0
11564 0
11564 1
12744 1
12744 0
13248 0
13248 1
13584 1
13584 0
14084 0
14084 1
14420 1
14420 0
14928 0
14928 1

Copy the result and past it in notpad, save it as dat extension file.
Open this file in gnuplot .(explain in uploaded figure named "gnuplot command"). Press enter to see the graph.
Graph shows mark and spaces.
code decoding is explained in the figure"gnuplot explain"
I got the following hex codes against each button
C4D36480000418D06CDE000000000000 (on button)
C4D36480000418206CDE000000000000  (25 temprature)
Code: [Select]

#include <IRremote.h>

IRsend irsend;


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

void loop() {
  if (Serial.read() != -1) {
   
    irsend.sendMitsubishi(0xC4D36480,0x000418D0,0x6CDE0000,0x00000000);
    delay(3000);
   
  }
}

IRremote.cpp
Code: [Select]

void IRsend::sendMitsubishi(unsigned long data1,unsigned long data2,unsigned long data3,unsigned long data4)
{
Serial.write("data: ");
unsigned long check = 0x80000000;

enableIROut(38);
int counter=0;
unsigned long dataCopy ;

for(int repeat=0; repeat < 1; repeat++)
{
        unsigned long D1=data1;
            unsigned long D2=data2;
            unsigned long D3=data3;
            unsigned long D4=data4;
 
    mark(MITSUBISHI_HDR_MARK);        // SAMSUNG_HDR_MARK   3400
space(MITSUBISHI_HDR_SPACE);      // SAMSUNG_HDR_SPACE  1550
Serial.write("Start ");

for (int byte = 0; byte < 4; byte++)
        {

for (int i = 0; i < 8; i++)
            {
if (D1 & check)
                {
mark(MITSUBISHI_BIT_MARK);                     // MITSUBISHI_BIT_MARK  425
space(MITSUBISHI_ONE_SPACE);                   // MITSUBISHI_ONE_SPACE 1200
Serial.write("1");
}
else
                {
mark(MITSUBISHI_BIT_MARK);                     // MITSUBISHI_BIT_MARK  425
space(MITSUBISHI_ZERO_SPACE);                  // MITSUBISHI_ZERO_SPACE 380
Serial.write("0");
}
D1 <<= 1;
}

}

for (int byte = 0; byte < 4; byte++)
        {

for (int i = 0; i < 8; i++)
            {
if (D2 & check)
                {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ONE_SPACE);
Serial.write("1");
}
else
                {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ZERO_SPACE);
Serial.write("0");
}
    D2 <<= 1;
}

}
         

for (int byte = 0; byte < 4; byte++)
        {

for (int i = 0; i < 8; i++)
            {
if (D3 & check)
                {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ONE_SPACE);
Serial.write("1");
}
else
                {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ZERO_SPACE);
Serial.write("0");
}
    D3 <<= 1;
}
}

for (int byte = 0; byte < 4; byte++)
        {
      counter++;
        for (int i = 0; i < 8; i++)
            {
if (D4 & check) {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ONE_SPACE);
Serial.write("1");
}
else {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ZERO_SPACE);
Serial.write("0");
}
                D4 <<= 1;
}


}
   
    for (int byte = 0; byte < 4; byte++)
        {
      counter++;
        for (int i = 0; i < 8; i++)
            {
if (D4 & check) {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ONE_SPACE);
Serial.write("1");
}
else {
mark(MITSUBISHI_BIT_MARK);
space(MITSUBISHI_ZERO_SPACE);
Serial.write("0");
}
                D4 <<= 1;
}


}


                   
         
Serial.write(" End ");

Serial.println();
Serial.println();
    }

}



But it did not work. I think still some pulses are missing. Any suggestion would be appreciated
Thanks to all

delphino-999

Hmm... I got nothing...
Did you try reading out the RAW Data (with the example sketch, IRrecvDump) and sending it as RAW Data to see if that works?!

Quote
From http://arduinostuff.blogspot.pt/2011/05/receiving-and-sending-ir-with-arduino.html:
Some devices use their own protocols such as Samsung, but you can get the raw data from them. To clean the raw data you get from the dump -demo, you need to erase the first number, then convert all negative numbers to positive and place commas between the numbers.

Here's an example:

Raw data: 4802, -620, 500, -420, 600, -440....

Sending:

unsigned int[68] power_ON ={620,500,420,600,440... ...};
Irsend.sendRaw(power_ON, 68, 38);

68 is the length of the unsigned integer.


I never used RAW Data before, but i assume it should work with about any IR protocol...
Good Luck!

Regards, Delphiño

johnwasser


i don't know why not recognize it as panasonic, I can't change the number of bits
this is that show me:


Unknown encoding: F6F5174A (32 bits)
Raw (240): 31648 3450 -1650 400 -1300 450 -1250 400 -450 400 -450 400 -450 400 -1350 450 -400 400 -450 400 -1300 450 -1250 400 -450 400 -1300 400 -450 400 -450 400 -1300 400 -1350 350 -500 450 -1250 400 -1300 400 -450 400 -450 400 -1300 400 -450 400 -450 500 -1250 450 -400 400 -450 450 -400 400 -450 500 -400 350 -500 350 -500 450 -400 400 -450 500 -350 400 -450 400 -450 500 -400 350 -500 400 -450 400 -450 400 -450 400 -450 500 -350 500 -400 450 -1250 400 -450 400 -450 400 -450 400 -450 400 -450 400 -1300 400 -1300 500 -400 450 -400 400 -450 400 -450 500 -350 500 -350 500 -350 400 -500 350 -500 400 -450 450 -400 500 -350 400 -1300 400 -1300 400 -450 500 -1250 450 -1250 350 -500 400 -450 400 -450 400 -450 400 -450 400 -450 400 -1300 400 -500 350 -500 350 -1350 450 -400 400 -1300 400 -450 400 -1300 400 -450 400 -1300 450 -1250 500 -350 500 -400 350 -500 400 -450 400 -450 400 -450 400 -450 400 -450 500 -350 400 -450 400 -500 350 -500 350 -500 400 -450 400 -450 400 -450 500 -350 400 -500 350 -500 450 -400 400 -450 450 -400 500 -350 500 -350 400 -450 400 -450 400 -500 450 -400 450 -400 400 -450 500 -350 400



It looks like after the header (1600/400) each bit is either 1300/400 or 400/400.

110001001101001101100100100000000000000000000010000011000000000000110110000001001010101100000000000000000000000000000000

I don't see any repeating pattern in that except for long stretches of 0 bits.

Perhaps if you encoded several keys and compared the patterns you would be able to find a key code buried in there.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up