2015年1月13日 星期二

[Arduino] Use IRrepeator to capture IR raw code of kbro TV box's remote control

[Arduino] 用 IRrepeater 抓取 kbro 凱擘遙控器的 IR raw code (Chinese)

Due to Sony Locationfree already stop supported by Sony. My kbro TV box's remote control IR code set didn't in out-of-box IR code set of Locatoinfree, that causes I can not using Locationfree to control TV box. And, the Locationfree LF-BOX1's out-of-box IR code set is also limited, except it doesn't support kbro TV box, some buttons of Tivo's remote control also doesn't work.

So I want using Arduino to make a IR translator. To translate the Tivo IR code that emitted by Locationfree to be the IR code of kbro box. Then Locationree can support any new TV box through this Arduino translator. The same feature is also useful on Slingbox, you don't need worry for how to create the Slingbox bin file for new IR code.

Before making IR translator, grab the IR codes of remote control of Tivo and kbro is the most important preliminary work. This article introduces how to capture IR code by Arduino. The traditional method is using IRrecvDump in IR remote library of Arduino to capture IR codes. But, it doesn't work to kbro's remote control. I will introduce another useful way to grab the IR code, that's using IRreperter program.

First, I still using the most popular program, IRrecvDump to capture code. The following picture is my wire layout of breadboard: I used 3 pin stereo connector to connect to IR receiver. The red wire connected to 5v output pin of Arduino nano, black wire connect to GND pin, white wire connect to digital 11 pin for data input:



More detail: Red wire to 5V, Black wire to GND, White wire to D11

Runing Arduino IDE, select Arduino Nano w/ ATmega328 in "Board" selection:

More detail steps please google, there have bunch of articles introduced that. Please remember copy IRremote library to libraries folder in Sketchbook then Arduino IDE can find it when restart.

Please open IRrecvDump example in IRremote library, compiler and upload to Arduino. Then please launch Serial monitor to watch the IR code that captured. The printing result as following:

Decoded NEC: A10C7807 (32 bits)
Raw (68): -23088 8950 -4450 550 -1650 550 -550 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -550 550 -550 550 -500 600 -500 550 -1650 550 -1650 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -1650 550 -1600 600 -500 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1650 550 -1650 550 -1650 550
A10C7807

If program parser IR code type success, it will print out the type like the above NEC words, and follow a hash number of raw code and raw code data. You can using IR type and hash number, or direct using raw code. If it didn't parser out type, you still can using raw code with raw length to emit IR code. Please write down those codes.

When using Raw code, plesae remove the first number. As the above example, -23088 should discarded, please don't paste to your IRsend program. Then please modify all negative number to positive number, the whole length is 68-1. Then you can paste whole raw numbers to IRsend code to be a unsigned int array for testing. As the above example, it will be like:

8950 4450 550 1650 550 550 550 1650 550 550 550 550 550 550 550 550 550 1650 550 550 550 550 550 500 600 500 550 1650 550 1650 550 550 550 550 550 550 550 1650 550 1650 550 1650 550 1600 600 500 550 550 550 550 550 550 550 550 550 550 550 550 550 550 550 1650 550 1650 550 1650 550

Paste those numbers to program to be array, please remember add comma between 2 numbers. The code like this:
https://github.com/smallbeetw/arduinosketch/blob/master/Panasonic2KbroIRtrans/Panasonic2KbroIRtrans.ino#L50

The following are IR coddes of Tivo's Channel up/down button. I do not list raw code because Arduino captured the NEC type has no problem:

TIVO
    Channel up:        NEC: A10C7807 (32 bits)
    Channel down:    NEC: A10CF807 (32 bits)
Remote control of Tivo like this:



After got IR odes, then we cn try to using IR LED to emit IR code for receiving by devices (TV or set-top box). If devices done corresponding action after received IR code, that menas the code is correct. The layout of breadboard is really simple. Just connect the long pin of IR LED to D3, the short pin to GND:




Here is s stupid story of me.  The first time I try IR LED, I direct connect the long pin to 5v ouptut fro Arduino, then LED blasted immediately. That's my first time saw the LED blasted, it's dangerous to my eyes.
As you see in the above picture, I didn't add resistance in long pin because current didn't continue output through D3 pin, so should not like direct connect to 5v pin. But, add resistance is still a better idea for safety

The sofeware of emit IR code is easier than dump, just need jsing IRsendDemo in Arduino IDE. Modify the code type and hash number. Compiler and upload to Arduino, open Serial Monitor and key-in any character to trigger IR code emitting.  Waiting the reopnse of set-top box to verify the code correct.

if you wan to check does IR LED really work. Due to infrared ray could not see by human being. You can using a digital camera to monitor it.

The above steps is the popular way from internet to capture IR code through IRrecvDump. But this way doesn't always work, some remote control's codes are hard to capture by IRrecdump. I don't know why, maybe that has problem in IR remote library. I am not a IR expert, and I am no oscilloscope to check that.

Unfortunately,the remote control of kbro TV box on my hand is this kind of thing:



For grab the IR code of kbro remote control, I spend whole day until 2 am. Finally I find the way to capture IR code more easily. I modified my IR repeater program, add codes for print out IR raw code:
https://github.com/smallbeetw/arduinosketch/blob/master/IRrepeator/IRrepeator.ino

The advantage of this program is like merged IRreceDump and IRsend. That means Arduino grab the raw code then emit immediately through sendRaw() from IR LED. So, I call it IRreperter. This kind of device sale on many store on internet. It's useful to extend the IR receive window on device. e.g. if the IR receive window of TV covered by speaker, or DVD player put in cabinet. Then this device is useful to repeat IR code to other direction or space.

The breadboard layout as following, just put IR receiver and IR LED on the same board:

The simply circuit as following:



The benefit of IRrepeater is for some remote control that Arudino SOMETIME can capture IR code, but the success rate is not too high. Then we can just put button continuously, IRrepeater will emit IR code to set-top box continuously until we saw box response the code. Then we can confirm the code is valid and write it down.

Simply say, when using IRreperter, user can test the raw code immediately. Don't like the IRreceDump, need paste raw code to IRsend program to check, then using IRrecvDump capture again if the code invalid.

Through this way, I captured raw code of the channel up/down button, I will post other keys when I have time. (found the fail rate is really high for grab the code of kbro remote control):

KBRO
  Channel UP:         250,850,250,1000,250,700,250,750,200,750,250,2450,250,750,200,750,250
  Channel DOWN:   250,850,250,850,250,750,200,750,250,700,250,2600,250,750,200,750,250

I used 
sendRaw(sendRawCodes,17,38), and add delay(40). Confirm the above codes are available. Some information from internet say the 38 hz for IR is because this frequency does not use in the nature, it can avoid too many noise.

Except the way to use IRreperter to grab the remote control for SOMETIME work. Some other solutions may worth to try: like some Sony remote control used 40 hz, or Samsung's raw code length sometimes longer then the default size of RAWBUF 100 (Please modify the RAWBUF length define in IR remote library from 100 to 400). And set a longer delay when testing, using 1000 to avoid too fast to emit next code of next cycle. The above are some hints from internet that can try when IRrecDump doesn't work to you.

In this time, I also capture the IR codes of Sony Locationfree LF-Box1's RM-Box1 remote control. This remote control is special and not easy to find on market. So, list the IR codes here for reference:



RM-BOX1
  UP:                    Decoded SONY: 4EB31 (20 bits)
  DOWN:             Decoded SONY: CEB31 (20 bits)
  LEFT:                 Decoded SONY: AEB31 (20 bits)
  RIGHT:               Decoded SONY: 2EB31 (20 bits)
  決定:                  Decoded SONY: 6EB31 (20 bits)
  畫面xxx:             Decoded SONY: 14B31 (20 bits)
  右下:                   Decoded SONY: 34B31 (20 bits)
  左上:                   Decoded SONY: ACB31 (20 bits)
  戾xxx:                  Decoded SONY: 54B31 (20 bits)
  電源:                   Decoded SONY: A8B31 (20 bits)
  入力切換:           Decoded SONY: A4B31 (20 bits)
  畫面表示:           Decoded SONY: 44B31 (20 bits)
  設定:                   Decoded SONY: 4B31 (20 bits)
  XXX電源:           Decoded SONY: A90 (12 bits)
  入力切換(左上): Decoded SONY: A50 (12 bits)
  音量(+):               Decoded SONY: 490 (12 bits)
  音量(-):                Decoded SONY: C90 (12 bits)
  消音:                    Decoded SONY: 290 (12 bits)

more: 
[Arduino] Make a IR translator to translate IR code of Panasonic TV to Kbro TV box