Go Down

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

arslankhan

#30
Apr 25, 2013, 06:33 am Last Edit: Apr 25, 2013, 06:43 am by arslankhan Reason: 1
Thanks @Cybernetician...You did absolutely right. Actually this is a matter of uint8_t rawlen and uint16_t i. At last I got my result. Mitsubishi AC working fine with my IR sending code.  
IR Remote library code for sending .
changes in IR RemoteInt.h
Code: [Select]

#define MITSUBISHI_HDR_MARK 3400  
#define MITSUBISHI_HDR_SPACE  1550
#define MITSUBISHI_BIT_MARK 425
#define MITSUBISHI_ZERO_MARK  524
#define MITSUBISHI_ONE_SPACE 1150
#define MITSUBISHI_ZERO_SPACE 380

changes in IRremote.cpp
Code: [Select]

void IRsend::sendMitsubishi(unsigned long data1,unsigned long data2,unsigned long data3,unsigned long data4,unsigned long data5)
{
 Serial.write("data: ");
 unsigned long check = 0x80000000;
 enableIROut(38);
 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;
   unsigned long D5=data5;


   Serial.write("Start ");
   mark(MITSUBISHI_HDR_MARK);        // SAMSUNG_HDR_MARK   3400

   space(MITSUBISHI_HDR_SPACE);      // SAMSUNG_HDR_SPACE  1550

   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++)
   {

     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++)
   {
     for (int i = 0; i < 4; i++)
     {
       if (D5 & check) {
         mark(MITSUBISHI_BIT_MARK);
         space(MITSUBISHI_ONE_SPACE);
         Serial.write("1");
       }
       else {
         mark(MITSUBISHI_BIT_MARK);
         space(MITSUBISHI_ZERO_SPACE);

         Serial.write("0");
       }
       D5 <<= 1;
     }

   }

   mark(MITSUBISHI_BIT_MARK);
   space(12000);
   Serial.write(" End ");

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

}


MItsubishi IR Remote sending
Code: [Select]


#include <IRremote.h>

IRsend irsend;

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

void loop() {
 if (Serial.read() != -1) {
for(int i=0;i<2;i++)
{
   irsend.sendMitsubishi(0xC4D36480,0x0024C0F0,0x00000000,0x0CDE0000);
}
   delay(2000);
 }
}

diegt

disappeared after a while I come back here. I have a problem when trying to load the sketch with the modified libraries, I get the following error and i don´t know why "expected primary-expression before ';' token"
thanks a lot

UKHeliBob

Which sketch are you referring to ?
Which line is the error reported to be in ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Cybernetician


disappeared after a while I come back here. I have a problem when trying to load the sketch with the modified libraries, I get the following error and i don´t know why "expected primary-expression before ';' token"
thanks a lot


UKHeliBob said:
Which line is the error reported to be in ?

Me to...

diegt

sorry, I have not posted the entire message.
after modifying IRmote.cpp as arslankhan friend says. I get the following error: IRremote.cpp: In member function 'long int IRrecv :: decodeMitsubishi (decode_results *)':
IRremote.cpp: 819: error: expected primary-expression before ',' token.


the line is:

  / / Success
   results-> bits = (offset - 1) / 2;
   if (results-> bits <MITSUBISHI_BITS) {
     results-> bits = 0;
     return ERR;
   }
   results-> value = data;
 [font=Verdana][font=Verdana]  results-> decode_type = MITSUBISHI;[/font][/font]
   return DECODED;
}

juliopaveif

arslankhan , can you post the receiveing code too??

I'm strugling to get the right data.

The raw code works perfectly but I need to use the same method you're using

arslankhan


sorry, I have not posted the entire message.
after modifying IRmote.cpp as arslankhan friend says. I get the following error: IRremote.cpp: In member function 'long int IRrecv :: decodeMitsubishi (decode_results *)':
IRremote.cpp: 819: error: expected primary-expression before ',' token.


the line is:

  / / Success
   results-> bits = (offset - 1) / 2;
   if (results-> bits <MITSUBISHI_BITS) {
     results-> bits = 0;
     return ERR;
   }
   results-> value = data;
 [font=Verdana][font=Verdana]  results-> decode_type = MITSUBISHI;[/font][/font]
   return DECODED;
}

if your want to decode the IR Remote then follwoing is the skech for Decoding
Code: [Select]

#define IN_PIN 2
#define MAX_CAPTURE 584

//globals
uint32_t now, start, capture[MAX_CAPTURE];
volatile bool flag_complete;
uint16_t i;
int first,second,diff,total;
int counter=0;
int bits=0;
unsigned long data=0;
unsigned long data1=0;
unsigned long data2=0;
unsigned long data3=0;
unsigned long data4=0;
unsigned long data5=0;

//interrupt fires on ir event (rise/fall)
void IRInterrupt(void) {
  now = micros();
  capture[i++] = now - start;
  start = now;
  if (i >= MAX_CAPTURE) {
    detachInterrupt(0);
    flag_complete = true;
  }
}

void setup(void) {
  flag_complete = false;
  start = 0;
  now = 0;
  i = 0;
  Serial.begin(9600);
  attachInterrupt(0, IRInterrupt, CHANGE);
  Serial.println("Ready to capture.");
}

void loop(void) {
  while (1) {
    if (flag_complete) {
      for (i=0; i < MAX_CAPTURE; i++) {   
        counter++; 
        first=capture[i];
        second=capture[i+1];

        if(first>12900 && first<13700){
          break;
        }
  if(counter<2)
  {

          total=first+second;

          if(total<900 && total>700)
          {
            data <<= 1;
          }
          if(total>1600 && total<1800)
          {
            data = (data << 1) | 1; 
          }
          bits++;
  }
  else
  {
          counter=0;
  }
        if(bits==34)
        {
          data1=data;
        }
        else if(bits==66)
        {
          data2=data;
        }
        else if(bits==98)
        {
          data3=data;
        }
        else if(bits==130)
        {
          data5=data;
        }
        else if(bits==146)
        {
          data5=data;
          Serial.print(data1,HEX);
          Serial.print("000");
          Serial.print(data2,HEX);
          Serial.print(data3,HEX);
          Serial.print(data4,HEX);
          Serial.print("0000");
          Serial.println(data5,HEX);
        }

        flag_complete = false;
      }
    }
  }
}


arslankhan


arslankhan , can you post the receiveing code too??

I'm strugling to get the right data.

The raw code works perfectly but I need to use the same method you're using

following the received code of temp 30
C4D364800024C0F0000000000CDE

pndtkd

Hi you all,
i'd like to turn on my Mitsubishi kirigamine air conditioner.
the codes i receive are recognized as Panasonic.
ON:
64800004
Decoded PANASONIC - Address: C4D3 Value: 64800004 (48 bits)
Raw (100): -21006 3500 -1650 450 -1250 500 -1200 500 -350 500 -350 500 -400 500 -1200 450 -400 500 -350 500 -1200 500 -1200 500 -400 500 -1200 500 -350 500 -350 500 -1200 500 -1250 450 -400 500 -1200 500 -1200 500 -350 500 -350 550 -1200 500 -350 500 -350 500 -1200 500 -350 500 -350 500 -400 500 -350 500 -350 500 -350 500 -350 500 -350 550 -350 450 -400 500 -350 500 -350 500 -400 450 -400 450 -400 500 -350 500 -350 500 -350 500 -400 500 -350 500 -1200 500 -350 500 -350 500

OFF:
Decoded PANASONIC - Address: C4D3 Value: 64800000 (48 bits)
Raw (100): -38 3450 -1650 500 -1200 500 -1200 500 -350 550 -350 450 -400 450 -1250 500 -350 500 -350 500 -1200 550 -1200 500 -350 500 -1200 500 -350 500 -400 500 -1200 500 -1200 500 -350 550 -1150 550 -1150 500 -400 450 -400 500 -1200 500 -350 500 -350 500 -1250 450 -400 500 -350 500 -350 500 -350 500 -400 450 -400 450 -400 500 -350 500 -350 500 -400 450 -400 500 -350 500 -350 500 -350 500 -400 450 -400 500 -350 500 -350 500 -350 500 -400 500 -350 500 -350 500 -350 500

this is the same problem of arslankhan.

so i tried to change buf to 240 and to follow your advices modifying the libraries but it doesn't work.
Could you publish the modified libraries and help me to solve the problem?

tnx a lot

Francesco 

pndtkd

#39
Jun 08, 2013, 05:13 pm Last Edit: Jun 08, 2013, 07:34 pm by pndtkd Reason: 1
i saw that you declared the function with 5 arguments:
Code: [Select]
void IRsend::sendMitsubishi(unsigned long data1,unsigned long data2,unsigned long data3,unsigned long data4,unsigned long data5)
but in your arduino sketch you use only 4...so i modified 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);
   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;
       //unsigned long D5=data5;
       
       
       Serial.write("Start ");
       mark(MITSUBISHI_HDR_MARK);        // SAMSUNG_HDR_MARK   3400
       
       space(MITSUBISHI_HDR_SPACE);      // SAMSUNG_HDR_SPACE  1550
       
       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++)
       {
           
           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++)
       {
           for (int i = 0; i < 4; i++)
           {
               if (D5 & check) {
                   mark(MITSUBISHI_BIT_MARK);
                   space(MITSUBISHI_ONE_SPACE);
                   Serial.write("1");
               }
               else {
                   mark(MITSUBISHI_BIT_MARK);
                   space(MITSUBISHI_ZERO_SPACE);
                   
                   Serial.write("0");
               }
               D5 <<= 1;
           }
           
       }*/COMMENTED
       
       mark(MITSUBISHI_BIT_MARK);
       space(12000);
       Serial.write(" End ");
       
       Serial.println();
       Serial.println();
   }
   
}


Therefore the prototype in IRremote.h....
i used your decode sketch but it doesn't work...

help me please....

arslankhan

@pndtkd ...first of all run this sktech and post your output
Code: [Select]

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

#define TIMER_RESET  TCNT1 = 0
#define SAMPLE_SIZE  232

int IRpin = 2;
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);
}

pndtkd

#41
Jun 10, 2013, 01:40 pm Last Edit: Jun 10, 2013, 02:01 pm by pndtkd Reason: 1
ok arslankhan....this is my output pushing ON:
Code: [Select]

Analyze IR Remote
Waiting...
Bit stream detected!
0 0
3536 0
3536 1
5184 1
5184 0
5648 0
5648 1
6912 1
6912 0
7368 0
7368 1
8636 1
8636 0
9116 0
9116 1
9496 1
9496 0
9960 0
9960 1
10364 1
10364 0
10824 0
10824 1
11232 1
11232 0
11692 0
11692 1
12960 1
12960 0
13460 0
13460 1
13828 1
13828 0
14284 0
14284 1
14688 1
14688 0
15196 0
15196 1
16416 1
16416 0
16920 0
16920 1
18144 1
18144 0
18652 0
18652 1
19016 1
19016 0
19520 0
19520 1
20744 1
20744 0
21244 0
21244 1
21612 1
21612 0
22116 0
22116 1
22484 1
22484 0
22988 0
22988 1
24216 1
24216 0
24700 0
24700 1
25940 1
25940 0
26444 0
26444 1
26812 1
26812 0
27268 0
27268 1
28540 1
28540 0
28992 0
28992 1
30256 1
30256 0
30760 0
30760 1
31124 1
31124 0
31588 0
31588 1
31992 1
31992 0
32496 0
32496 1
33720 1
33720 0
34180 0
34180 1
34584 1
34584 0
35088 0
35088 1
35452 1
35452 0
35956 0
35956 1
37176 1
37176 0
37640 0
37640 1
38044 1
38044 0
38504 0
38504 1
38912 1
38912 0
39372 0
39372 1
39784 1
39784 0
40244 0
40244 1
40652 1
40652 0
41112 0
41112 1
41516 1
41516 0
42024 0
42024 1
42384 1
42384 0
42844 0
42844 1
43248 1
43248 0
43736 0
43736 1
44116 1
44116 0
44604 0
44604 1
44984 1
44984 0
45484 0
45484 1
45848 1
45848 0
46352 0
46352 1
46720 1
46720 0
47204 0
47204 1
47588 1
47588 0
48088 0
48088 1
48456 1
48456 0
48960 0
48960 1
49328 1
49328 0
49788 0
49788 1
50192 1
50192 0
50652 0
50652 1
51052 1
51052 0
51560 0
51560 1
51924 1
51924 0
52380 0
52380 1
52792 1
52792 0
53248 0
53248 1
53656 1
53656 0
54112 0
54112 1
54520 1
54520 0
55028 0
55028 1
55392 1
55392 0
55892 0
55892 1
56256 1
56256 0
56764 0
56764 1
57124 1
57124 0
57612 0
57612 1
57992 1
57992 0
58456 0
58456 1
58860 1
58860 0
59324 0
59324 1
59732 1
59732 0
60196 0
60196 1
61460 1
61460 0
61964 0
61964 1
63188 1
63188 0
63652 0
63652 1
64052 1
64052 0
64512 0
64512 1
65772 1
65772 0
66236 0
66236 1
66644 1
66644 0
67108 0
67108 1
67524 1
67524 0
68028 0
68028 1
69248 1
69248 0
69760 0
69760 1
70980 1
70980 0
71440 0
71440 1
71844 1
71844 0
72304 0
72304 1
72712 1
72712 0
73216 0
73216 1
73580 1
73580 0
74088 0
74088 1
74444 1
74444 0
74952 0
74952 1
75316 1
75316 0
75776 0
75776 1
76184 1
76184 0
76644 0
76644 1
77920 1
77920 0
78380 0
78380 1
79644 1
79644 0
80108 0
80108 1
80512 1
80512 0
80976 0
80976 1
82240 1
82240 0
82700 0
82700 1
83104 1
83104 0
83612 0
83612 1
83972 1
83972 0
84476 0
84476 1
84840 1
84840 0
85300 0
85300 1
86560 1
86560 0
87024 0
87024 1
88288 1
88288 0
88752 0
88752 1
89156 1
89156 0
89616 0
89616 1
90024 1
90024 0
90484 0
90484 1
90888 1
90888 0
91352 0
91352 1
92616 1
92616 0
93120 0
93120 1
94340 1
94340 0
94804 0
94804 1
95208 1
95208 0
95668 0
95668 1
96072 1
96072 0
96536 0
96536 1
96940 1
96940 0
97444 0
97444 1
97812 1
97812 0
98320 0
98320 1
98688 1
98688 0
99148 0
99148 1
99548 1
99548 0
100008 0
100008 1
100416 1
100416 0
100920 0
100920 1
101280 1
101280 0
101788 0
101788 1
102148 1
102148 0
102612 0
102612 1
103012 1
103012 0
103476 0
103476 1
103880 1
103880 0
104344 0
104344 1
104748 1
104748 0
105228 0
105228 1
105620 1
105620 0
106080 0
106080 1
106480 1
106480 0
106964 0
106964 1
107352 1
107352 0
107816 0
107816 1
108220 1
108220 0
108684 0
108684 1
109088 1
109088 0
109592 0
109592 1
109960 1
109960 0
110420 0
110420 1
110832 1
110832 0
111292 0
111292 1
111696 1
111696 0
112208 0
112208 1
112572 1
112572 0
113072 0
113072 1
113444 1
113444 0
113900 0
113900 1
114312 1
114312 0
114772 0
114772 1
115176 1
115176 0
115636 0
115636 1
116044 1
116044 0
116504 0
116504 1
116912 1
116912 0
117372 0
117372 1
117772 1
117772 0
118280 0
118280 1
118644 1
118644 0
119104 0
119104 1
119512 1
119512 0
120016 0
120016 1
120380 1
120380 0
120840 0
120840 1
121248 1
121248 0
121704 0
121704 1
122116 1
122116 0
122572 0
122572 1
122984 1
122984 0
123444 0
123444 1
123848 1
123848 0
124308 0
124308 1
124716 1
124716 0
125176 0
125176 1
Bit stream end!

arslankhan

#42
Jun 11, 2013, 06:44 am Last Edit: Jun 11, 2013, 07:14 am by arslankhan Reason: 1

@ arslankhan and diegt

On last weekend i was blackout due to office workload, thats why i start capturing of IR code of my friend Mitsubishi RC and got the same result by putting the value of rawbuf equal to 255

Code: [Select]
#define RAWBUF 255

When rawbuf equal to 400

Code: [Select]
#define RAWBUF 400

or greater than 255 i got the garbage result of IR sample. This is the starting point of story "There is some problem with RAWBUFF value". Ok, First step write/stole some code to capture the IR pulses by using interrupt.

http://ucexperiment.wordpress.com/2012/02/14/reverse-engineering-an-aim-ir-beacon-transmitter/

And by viewing the code it is clear i need the modification in two lines

Code: [Select]

/*
 IR Capture
 Copyright 2012, all rights reserved.
 James M. Eli
 1/14/2012

 project parts:
   (1) arduino 16MHz
   (1) 38KHz IR receiver
   (1) breadboard
   (3) wires

 IR - Arduino
 SIG - D2
 GND - GND
 VCC - VCC
*/

//definitions
#define IN_PIN 2
#define MAX_CAPTURE 584  // Line number 1

//globals
uint32_t now, start, capture[MAX_CAPTURE];
volatile bool flag_complete;
uint16_t i;    // Line number 2 uint8_t to uint16_t Key point of RAWBUF. uint8_t maximum range 255

//interrupt fires on ir event (rise/fall)
void IRInterrupt(void) {
 now = micros();
 capture[i++] = now - start;
 start = now;
 if (i >= MAX_CAPTURE) {
   detachInterrupt(0);
   flag_complete = true;
 }
}

void setup(void) {
 flag_complete = false;
 start = 0;
 now = 0;
 i = 0;
 Serial.begin(9600);
 attachInterrupt(0, IRInterrupt, CHANGE);
 Serial.println("Ready to capture.");
}

void loop(void) {
 while (1) {
   if (flag_complete) {
     for (i=0; i < MAX_CAPTURE; i++) {        
       Serial.println(capture[i]);
       //Serial.print(",");
       flag_complete = false;
     }
   }
 }
}


Quote
uint16_t i;    // Line number 2 uint8_t to uint16_t Key point of RAWBUF. uint8_t maximum range 255


Quote
#define MAX_CAPTURE 584  // Line number 1, Value selected after hit and trial base experiments.


Hurray 8) here is the full IR sample values = 584 samples

Quote
3548,1640,492,1188,492,1192,492,348,492,344,492,348,492,1192,492,348,492,344,492,1192,492,1192,492,344,492,1192,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,1192,492,348,488,348,492,1192,492,348,492,348,492,1188,492,348,492,348,492,348,488,348,492,348,492,348,492,348,492,348,488,348,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,1192,492,348,492,344,496,344,492,348,492,348,492,1188,492,1192,492,348,492,348,492,348,488,1192,492,1192,492,1188,492,1192,492,348,492,344,492,348,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,1192,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,1192,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,1188,492,348,492,348,492,1192,492,348,492,1188,492,1192,492,12916,3544,1640,492,1188,492,1192,492,348,492,348,492,344,496,1188,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,348,492,348,492,1188,492,1192,492,348,492,1188,492,1192,492,348,492,344,496,1188,492,348,492,348,492,1188,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,344,496,1188,492,348,492,348,492,344,496,344,492,348,492,1192,492,1188,492,348,492,348,492,348,492,1188,492,1192,492,1188,492,1192,492,348,492,348,492,344,492,348,492,348,492,1192,488,1192,492,348,492,1192,488,1192,492,348,492,348,492,344,496,344,496,344,492,348,492,348,492,348,492,1188,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,492,348,492,344,496,344,492,348,492,348,492,348,492,348,492,344,492,348,492,348,492,348,496,344,492,344,492,348,492,1192,492,348,492,344,492,1192,492,348,492,1188,492,1192,492,


what is happening in IR code expalned in attached excel file.

Second step finding the issue of IR remote library.

Code: [Select]
typedef struct {
 uint8_t recvpin;           // pin for IR data from detector
 uint8_t rcvstate;          // state machine
 uint8_t blinkflag;         // TRUE to enable blinking of pin 13 on IR processing
 unsigned int timer;     // state timer, counts 50uS ticks.
 unsigned int rawbuf[RAWBUF]; // raw data
 uint8_t rawlen;         // counter of entries in rawbuf
}
irparams_t;


Here it is
Quote
uint8_t rawlen;  maximum range 255


Solution:

Code: [Select]
typedef struct {
 uint8_t recvpin;           // pin for IR data from detector
 uint8_t rcvstate;          // state machine
 uint8_t blinkflag;         // TRUE to enable blinking of pin 13 on IR processing
 unsigned int timer;     // state timer, counts 50uS ticks.
 unsigned int rawbuf[RAWBUF]; // raw data
 uint16_t rawlen;         // counter of entries in rawbuf
}
irparams_t;


And hurray 292 samples

Quote
4718 3550 -1600 500 -1200 500 -1150 500 -350 550 -300 500 -350 500 -1150 500 -350 500 -350 500 -1200 450 -1200 500 -350 500 -1150 500 -350 550 -300 500 -1200 450 -1200 500 -350 500 -1200 450 -1200 500 -350 500 -350 500 -1150 500 -350 500 -350 500 -1150 500 -350 550 -300 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -1150 500 -350 500 -350 500 -350 450 -350 500 -350 500 -1200 500 -1150 500 -350 500 -350 500 -350 450 -1200 550 -1150 500 -1150 500 -1200 500 -350 500 -350 500 -300 500 -350 500 -350 500 -1200 450 -1200 500 -350 500 -1150 500 -1200 500 -350 500 -350 500 -1150 500 -1200 500 -350 500 -300 500 -350 500 -350 500 -1150 500 -350 550 -300 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -350 500 -1150 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 500 -300 500 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -350 450 -350 500 -350 500 -350 500 -1150 500 -350 500 -1200 500 -350 500 -1150 500 -1200 500 -1150 500 -1200 500


why 292 not 584?
reason is, same IR code sent twice with space of 12ms b/w them.

Now it is clear and it will take 10 min to write the code of sendMit of both of you.

Goodluck.

Edit: If you get the raw code after the above modification and send it in raw it will work.

@pndtkd... you have long code and you have to send your code twice with specific space bwteen them.
i.e.xxxxxspacexxxxx.Follow teh above instructions you will com to know. If you have problem with this stuff then post it here.
There are a lot of techniques for decoding IR remote
2 method are discussed here
1: Gnuplot method
2:IR analyser
3:http://ucexperiment.wordpress.com/2012/02/14/reverse-engineering-an-aim-ir-beacon-transmitter/(i prefer you to follow this)
4: Interface your Sound card with the Receiver
5:Oscilloscope
You can decode with any technique that is easy for you

pndtkd

@arslankhan... I don't receive nothing with "your" decode sketch; you receive: C4D364800024C0F0000000000CDE

BUT, i find this: https://github.com/erix/arduino/blob/master/ir_analyzer/ir_analyzer.ino
my results are:

Analyze IR Remote
23CB260100005806166300000000100000FC
23C9260100005806166300000000100000FC
23CB2601002058061663000000001000001C
23CB2601002058061663000000001000001C

what do you think about?
why are they different (before, the first time, my output was:....Address: C4D3 Value: 64800004 (48 bits)..... ) Now i do't have C4D3......but 23CB......
Finally, how can i use the sketch to sende codes?

arslankhan

#44
Jun 11, 2013, 12:15 pm Last Edit: Jun 11, 2013, 12:17 pm by arslankhan Reason: 1

@arslankhan... I don't receive nothing with "your" decode sketch; you receive: C4D364800024C0F0000000000CDE

It may be different as different models of Mitsubishi. but your result, I think something wrong with you.
Quote
what do you think about?

I think its Wrong.
run this Program and come with the output.
Code: [Select]
/*
 IR Capture
 Copyright 2012, all rights reserved.
 James M. Eli
 1/14/2012

 project parts:
   (1) arduino 16MHz
   (1) 38KHz IR receiver
   (1) breadboard
   (3) wires

 IR - Arduino
 SIG - D2
 GND - GND
 VCC - VCC
*/

//definitions
#define IN_PIN 2
#define MAX_CAPTURE 584  // Line number 1

//globals
uint32_t now, start, capture[MAX_CAPTURE];
volatile bool flag_complete;
uint16_t i;    // Line number 2 uint8_t to uint16_t Key point of RAWBUF. uint8_t maximum range 255

//interrupt fires on ir event (rise/fall)
void IRInterrupt(void) {
 now = micros();
 capture[i++] = now - start;
 start = now;
 if (i >= MAX_CAPTURE) {
   detachInterrupt(0);
   flag_complete = true;
 }
}

void setup(void) {
 flag_complete = false;
 start = 0;
 now = 0;
 i = 0;
 Serial.begin(9600);
 attachInterrupt(0, IRInterrupt, CHANGE);
 Serial.println("Ready to capture.");
}

void loop(void) {
 while (1) {
   if (flag_complete) {
     for (i=0; i < MAX_CAPTURE; i++) {        
       Serial.println(capture[i]);
       //Serial.print(",");
       flag_complete = false;
     }
   }
 }
}


Go Up