When interfacing my gadgets to the physical world, I often need to deal with IR of all sorts: air conditioners, TV, audio equipment, media center and so forth. These are all of different brand, so naturally the IR protocol that the remote controls have is different. Some of the more popular ones can be decoded by Ken Shirriff’s IR library, but many aren’t. I have spent previously weeks on decoding the IR remote protocol of my Daikin Air Conditioner, that was a tough one. Typically air conditioners are the hardest to deal with because they encode the whole state of the unit, not just a button press.
I know many use Lirc, but I prefer a pure hardware solution that is under my control.
Anyway, for other appliances it would not make sense to decode the protocol, but rather use the raw IR codes. Capturing these is easy using Ken’s library, I created a sketch that would read the raw IR timings and dump then on the serial. The same sketch would also read from the serial for raw IR timings, parse them and emit them. The format of incoming serial data is simple:
SEND [IR frequency in kHz] [repeat count] [pulse timing pairs...] [.]
The ending period is important, no trailing spaces are allowed. The SEND function expects the modulation frequency, repeat count and the pulse timing pairs obtained from the IR capturing. The whole command ends with a “.” period.
I tested this setup and while it worked on my satellite receiver box, it would not work on my JVC TV. Odd. I hooked the IR receiver to the oscilloscope and got a visual clue:
My code was capturng the first of four transmissions only, the one with lead-in bursts as described in the JVC IR protocol. Further investigation showed that Ken’s library stops recording the raw IR after certain gap size is reached, so it stopped after the first of four bursts pictured above. I edited the IR library file IRRemoteInt.h to increase that gap parameter:
#define _GAP 35000 // Minimum map between transmissions [WAS 5000] #define GAP_TICKS (_GAP/USECPERTICK)
Now repeated the test and it captured the whole four bursts. A detail on JVC and Sony protocols is that they require that a code is repeated three times, or it will get ignored. Precaution of some sort obviously.
With this small modification I repeated the test, Funky v2 hooked to Raspberry Pi’s USB port dumps the raw IR data to a CDC virtual serial port:
I then just copy the raw IR timings, put a header “SEND 38 1 ” to tell the Funky we need sending @38kHz and one repeat, then added a trailing “.” to signify the end of data. It takes couple lines in python to send that IR code:
Then I ran the sending script and it works nicely.
Page views: 4957