Blogger

Delete comment from: Ken Shirriff's blog

I noticed several people in the comments section have wanted to use this library to control their air conditioners/heat pumps. These systems generally use very long IR codes to transmit all of the state information (temp, fan, mode, etc.) at each button press.

Ken's library is amazing, but it is not set up to handle extremely long raw IR codes. I managed to work out some easy changes to the library that allowed me to control my new Mistubishi "Mr. Slim" split system.

Following the advice of earlier commenters, I increased the length of RAWBUF in . However, I noticed that no matter how big I made RAWBUF, the codes for the Mr. Slim were filling the buffer. For example, if I defined RAWBUF as 175, I'd get 175 marks using the IRrecvDump demo. Additionally, if I increased RAWBUF past a certain point (which turned out to be 255… getting any ideas?), I would get nonsensical output.

After digging around in the library for a while I noticed that the state machine for gathering the raw codes used a value rawlen as a counter for the entries in rawbuf. In rawlen is defined in the following code snippet:

// information for the interrupt handler
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;

Aha! Since rawlen is is an unsigned 8 bit integer, rawlen couldn't be greater than 255. That's why I was getting garbage when I increased RAWBUF to be any bigger than 255.

Sooo, after all that, it's an easy fix to read -extremely- long codes. Simply change rawlen to a 16 bit integer as follows:

uint16_t rawlen;         // counter of entries in rawbuf

Then, if you also increase the size of RAWBUF, you've got a gigantic buffer for storing marks. My Mr. Slim system ended up using 292(!) marks in each button press.

I hope this helps those of you who couldn't get your AC's under control. Stay cool!

May 2, 2012, 8:43:54 AM


Posted to A Multi-Protocol Infrared Remote Library for the Arduino

Google apps
Main menu