2015年1月24日 星期六

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

[Arduino] 製作紅外線遙控轉換器 IR translate Panasonic 電漿電視轉 Kbro 凱擘 (Chinese)

Base on last article [Arduino] Use IRrepeator to capture IR raw code of kbro TV box's remote control, the real purpose is make a device to transfer/translate Tivo IR code to be the code of Kbro TV box. Then I just need setup Lotactionfree client to control Tivo, IR translator will transfer Tivo IR code and emit Kbro IR code for controlling Kbro TV box. The same approach is useful to let Sony Locatoinfree remote control any non-supported machines. (Please look at the video record in the end of this article if you want.)

The same situation, I make this device to transfer the IR code of Panasonic remote control to be the Kbro code. Due to my Panasonic TV provides the features of Skype, Youtube and screen size changing, so using the original Panasonic remote control is more convenient to me:


Looks the type of Panasonic remote control is N20AYB:

The IR codes of Panasonic remote control captured by IRrecvDump as following. Due to Arduino IR library could not recognize type of the code, so it prints Unknow type. The length of following raw data are 100, the hash codes are useful to put into program for comparing the received signatures, so I put all raw data in the note of this article:

Channel UP: Unknown encoding: 4DE74847 (32 bits)
Channel DOWN: Unknown encoding: B8781EF (32 bits)
ONE 1: Unknown encoding: F7283C77 (32 bits)
TWO 2: Unknown encoding: 757FB4DF (32 bits)
THREE 3: Unknown encoding: B33B4597 (32 bits)
FOUR 4: Unknown encoding: 3C03E507 (32 bits)
FIVE 5: Unknown encoding: E705551F (32 bits)
SIX 6: Unknown encoding: A4A58EC7 (32 bits)
SEVEN 7: Unknown encoding: E2E45F7F (32 bits)
EIGHT 8: Unknown encoding: 6BACFEEF (32 bits)
NINE 9: Unknown encoding: E88E91F (32 bits)
ZERO 0: Unknown encoding: 7D168BCF (32 bits)
OK: Unknown encoding: BB0ED9E1 (32 bits)
RETURN: Unknown encoding: D28EF217 (32 bits)
POWER: Unknown encoding: F61E2A57 (32 bits)

After Kbro TV box setup by cable company, I need use this specific remote control to watch TV. I really don't like that because I already have 2 remote control, Panasonic TV and Tivo. So my plan is do not use it, put it to drawer.

Due to Arduino IRremote library also could not recognize the code type of the above Kbro remote control, so I need raw data to be the source of emitting IR signature. The same, I list the raw data of Kbro IR codes in the end of this article, the length is 18.

Then is the hardware part, it's fully the same with IR repeater in my laster article:

The architecture is really simple, connect IR LED power pin to D3 of Arduino Pro mini. And, IR receiver data pin connect to D11 pin of Arduino Pro mini.

The components list:

Arduino mini pro, IR LED, IR receiver (PL-IRM0101-3, datasheet), USB male plugUSB. The total cost of components almost $130 NTD (around $4.5 USD):


IR receiver, I bought PL-IRM0101-3, please note different model has different define of 3 pins. Please check appropriate datasheet. There have 3 pins: Vcc, Vout and GND. Connect Vout to D11 of Arduino pro mini:

USB male plug used to connect 5V DC input to Arduino mini pro, connect the power pin on USB male to Vcc pin:

The leading role, Arduino mini pro, 70 NTD (around $2.2 USD). The cost is OK for DIY but still expensive for production:

Arduino pro mini need a USB program upload, take a picture of it:

Connect with upload:

The connection hint of DuPont lines
upload  connect Arduino mini pro
       DTR connect DTR
       RXI  connect TXO
       TXO connect RXI
       VCC connect VCC
       GND connect GND  


After connected by DuPont lines, then using Arduino IDE to complier and upload.

As description in last article, I already tested circuit by breadboard. So I start create use single side matrix board to layout. My design is put IR receiver behind of Arduino, the IR LED put on the side near the IR receive window of Kbro TV box:

The relative position between the USB port of Kbro box and IR window:

Paste a picture of the final position to see the IR LED status:

The layout of welding as following picture:

The left side, welded IR LED, the LED turn toards to IR receive window of Kbro box:

The right side, I welded female pin slot. It give the option to us for removing Arudino mini pro to other purpose:

The end of board, IR receiver is behind Arduino:

The front of Arduino has USB male, it used to get the 5V DC power:

Ya! Done! It's easier than my another project of reform the x61 IR UltraBase dock. Next is testing:

Of course not just hardware, we need upload program:
https://github.com/smallbeetw/arduinosketch/blob/master/Panasonic2KbroIRtrans/Panasonic2KbroIRtrans.ino

The program is easy, we make a mapping table that's used to map Panasonic IR hash code with kbro raw codes. The program compares the IR code that's received by  IR receiver with the Panasonic hash code in mapping table,   then it emits appropriate kbro raw code when found that match.

After a couple of testing, I modified the part of program is delay time, using 30 got the best result.

This is the video record of result:

The same device can used to transfer the Tivo IR code emitted by Locationfree to be Kbro IR code, so don't need worry for any IR codes didn't support by Locationfree. The approach can applied on SlingBox to solve the problem of non-supported IR code because those kind of devices almost supported Tivo IR code. Just need base on Tivo IR code to transfer to the codes that's we want. Then we can continue to use our expensive Locationfree or SlingBox.


2014-12-12 add:
The original program doesn't binding the power button of Kbro remote control with the power button of Panasonic TV. So I need set my Kbro box always power ON, otherwise I will need use Kbro remote control to power on TV box:

The default setting is auto-shutdown after 24 hours didn't control by human:

So I updated the program to binding power button. Due to my TV box put in TV cabinet, there have a distance between IR receive window of TV. It not always synchronous when power on. So I bind the power button of TV box to DTV/TV button on Panasonic remote control. Please check my code.

After power power binding, then I set the auto-shutdown time to 12 hours:

2014-12-20 add:
Today I used simple USB power meter to measure:

The USB slot on Kbro box looks fine to provide 5V output:

The ampere value smaller than the minimum resolution:


2015-01-10 add:
Add some pictures of USB male pin fore reference how to get 5V input to Arduino:




more: [Arduino] 以 nRF24L01+ 和 RF24 library 製作無線電端點



Notes:
Raw data of Panasonic remote control:

Channel UP:
Unknown encoding: 4DE74847 (32 bits)
3450,1750,450,400,450,1300,450,400,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,1300,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,400,450,450,400,1300,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,1300,450,400,450,1300,450,1300,400,450,450,400,450,450,400,450,450,1300,400,450,450,1250,450,1300,450,400,450,1300,450,

Channel DOWN:
Unknown encoding: B8781EF (32 bits)
3400,1750,450,400,450,1300,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,400,450,1300,450,400,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,1250,450,450,450,400,450,400,450,450,400,450,450,400,450,450,400,450,450,1300,400,450,450,1250,450,450,450,1250,450,1300,450,400,450,450,450,1250,450,450,400,1300,450,450,400,1300,450,1300,450,400,450,1300,450,

ONE 1:
Unknown encoding: F7283C77 (32 bits)
3400,1750,450,450,450,1250,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,1250,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,400,450,1300,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,1250,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,1300,450,400,450,450,450,1250,450,

TWO 2:
Unknown encoding: 757FB4DF (32 bits)
3450,1750,400,450,450,1300,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,1300,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,1300,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,1300,450,450,400,450,450,400,450,1300,450,400,450,400,450,450,450,1250,450,450,450,400,450,400,450,1300,450,400,450,450,400,1300,450,

THREE 3:
Unknown encoding: B33B4597 (32 bits)
3400,1750,450,450,400,1300,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,1250,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,1300,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,1300,450,450,400,450,450,1300,400,450,450,400,450,400,450,450,450,1250,450,450,450,400,450,1300,450,400,450,400,450,1300,450,

FOUR 4:
Unknown encoding: 3C03E507 (32 bits)
3400,1750,450,400,450,1300,450,400,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,1300,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,450,450,1250,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,1300,400,1300,450,450,400,450,450,1250,450,450,450,400,450,400,450,1300,450,1300,450,400,450,400,450,1300,450,400,450,450,400,1300,450,

FIVE 5:
Unknown encoding: E705551F (32 bits)
3400,1750,450,400,450,1300,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,400,450,450,400,1300,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,1300,450,400,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,1250,450,450,450,1250,450,450,450,400,450,400,450,450,450,400,450,1300,400,450,450,1300,400,450,450,400,450,1300,450,

SIX 6:
Unknown encoding: A4A58EC7 (32 bits)
3400,1750,450,400,450,1300,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,400,450,450,400,1300,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,1300,450,400,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,1300,450,400,450,1300,450,400,450,1300,450,400,450,400,450,450,450,1250,450,450,400,1300,450,450,400,1300,450,450,400,450,450,1250,450,

SEVEN 7:
Unknown encoding: E2E45F7F (32 bits)
3400,1750,450,400,450,1300,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,1300,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,1250,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,1300,450,1300,400,450,450,1250,450,450,450,400,450,400,450,450,450,1250,450,1300,450,400,450,1300,450,400,450,450,400,1300,450,

EIGHT 8:
Unknown encoding: 6BACFEEF (32 bits)
3450,1750,400,450,450,1300,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,1300,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,1300,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,1250,450,1300,450,1300,400,450,450,1250,450,450,450,400,450,400,450,1300,450,1300,450,1250,450,450,450,1250,450,450,400,450,450,1300,400,

NINE 9:
Unknown encoding: E88E91F (32 bits)
3400,1750,450,400,450,1300,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,1300,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,1300,400,450,450,400,450,450,400,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,1300,450,1250,450,450,450,400,450,400,450,450,400,450,450,400,450,1300,450,1300,400,450,450,400,450,1300,450,

ZERO 0:
Unknown encoding: 7D168BCF (32 bits)
3400,1750,450,400,450,1300,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,450,450,400,450,400,450,1300,450,400,450,450,400,450,450,400,450,450,400,450,450,400,450,400,450,450,450,1250,450,450,450,400,450,400,450,450,450,400,450,400,450,450,400,450,450,1300,400,450,450,400,450,1300,450,1300,400,450,450,400,450,400,450,1300,450,400,450,450,450,1250,450,1300,450,400,450,450,400,1300,450,

OK:
Unknown encoding: BB0ED9E1 (32 bits)
Raw (100): -27668 3450 -1750 450 -400 450 -1300 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 400 -450 450 -400 450 -450 400 -450 450 -400 450 -1300 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 400 -1300 450 -450 400 -450 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 450 -1250 450 -450 450 -400 450 -1300 400 -450 450 -400 450 -1300 450 -400 450 -1300 450 -400 450 -400 450 -1300 450 -400 450 -450 450 -1250 450 -1300 450

RETURN:
Unknown encoding: D28EF217 (32 bits)
Raw (100): -20988 3450 -1700 450 -450 400 -1300 450 -450 400 -450 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 400 -1300 450 -450 400 -450 450 -400 450 -450 400 -450 450 -400 450 -450 400 -450 450 -400 450 -1300 450 -400 450 -400 450 -450 450 -400 450 -400 450 -450 400 -450 450 -400 450 -1300 450 -1300 400 -1300 450 -400 450 -1300 450 -1300 450 -400 450 -400 450 -1300 450 -1300 400 -1300 450 -450 400 -1300 450 -1300 450 -400 450 -1300 450

POWER:
Unknown encoding: F61E2A57 (32 bits)
Raw (100): -15610 3400 -1750 450 -450 450 -1250 450 -450 400 -450 450 -400 450 -450 400 -450 450 -400 450 -450 400 -450 450 -400 450 -450 400 -450 450 -1250 450 -450 450 -400 450 -400 450 -450 400 -450 450 -400 450 -450 400 -450 450 -400 450 -1300 450 -400 450 -450 400 -450 450 -400 450 -400 450 -450 450 -400 450 -400 450 -1300 450 -400 450 -1300 450 -1300 400 -1300 450 -1300 450 -400 450 -400 450 -1300 450 -400 450 -1300 450 -1300 400 -1300 450 -1300 450 -400 450 -1300 450


The Raw data of Kbro remote control (already removed the first number of serial, length is 18-1=17):

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

POWER:
250,850,250,700,250,750,200,750,250,750,200,2750,250,750,200,750,200

ONE 1:
250,850,250,2650,200,750,200,750,250,750,200,900,200,750,200,750,250,

TWO 2:
250,850,250,2450,250,750,200,750,250,700,250,1000,250,750,200,750,200,

THREE 3:
200,900,200,2400,200,750,200,750,250,750,200,1150,200,750,250,750,200,

FOUR 4:
200,900,200,2250,200,750,200,750,250,750,200,1300,200,750,250,700,250,

FIVE 5:
250,850,250,2100,200,750,250,700,250,750,200,1400,250,750,200,750,250,

SIX 6:
250,850,250,1950,200,750,250,750,200,750,200,1600,200,750,200,750,250

SEVEN 7:
200,900,200,1850,200,750,250,750,200,750,200,1700,250,700,250,750,200,

EIGHT 8:
250,850,250,1650,250,750,200,750,250,750,200,1800,250,750,200,750,250,

NINE 9:
200,900,250,1550,200,750,200,750,250,750,200,1950,250,750,200,750,200

ZERO 0:
200,900,200,2800,200,750,200,750,250,750,200,750,200,750,250,750,200

OK:
250,850,250,1800,250,750,200,750,200,1050,200,1450,200,750,200,750,250

RETURN:
250,850,250,1300,200,750,200,750,250,1000,200,2000,200,750,200,750,250

2015年1月21日 星期三

[樂高] 用樂高製作 IR receiver 外殼

這篇是個小DIY, 算是自己紀錄一下做法. 和 Arduino 也沒有直接的關係. 但既然和我做的 IRtranslater 有關, 就也放在 Arduino 分類裡面.

這篇介紹的是幫 IR receiver 用樂高零件製作殼. 由於一般我們 IR receiver 通常用洞洞板或者杜邦線接起來之後, IR receiver 都是裸露在外, 有些不好看. 我的做法是用樂高幫它做個殼. 當然用3D列印也可以做得更加符合需求, 但是樂高做殼還是有零件可重用性高, 成品容易修改的特性.

首先就是材料:
IR receiver *1: 我買到的是 PL-IRM0101-3

記得要找出datasheet上的接腳定義:

再來就是拿來做殼的樂高, 都是露拍上買到的:
    4x2 薄片 *2
    1x2x2 牆壁 *3
    1x2x2 透明牆壁 *1

當然還有三 pin 的立體聲母座  *1
所有材料包含IR receiver加起來大約 50 元新台幣左右.

首先把一個 1x2x2 的樂高牆壁鑽孔, 用小電鑽鑽完之後圓形挫刀擴孔,孔的大小直到立體聲母座的頭鎖得上去就可以了;

從這幾個照片可以看到我直接將 IR receiver 上的三個 pinj 腳焊接到立體聲頭上面, 至於順序沒差, 只要自己紀錄下來到時候接到 Arduino 上的 Vcc, GND, data 三個 pin 接對就可以了:

從另一個角度:

三支腳和立體聲座焊接好的狀況:


 從前面看:

後面樂高牆壁和立體聲座扣圜的接合, 由於立體聲座有個鐵圜可以旋轉固定在我們開出來的孔上面, 鎖緊之後完全不需要任何黏膠就很牢固的和LEGO牆壁接在一起:

把和立體聲座以及IR receiver 接好的牆壁和 4x2 薄板拼起來:

側面用一個薄 1x2x2 牆壁擋起來:

另一邊也是用 1x2x2 牆壁拼上

這個圖很清楚可以看到把 IR receiver 剛好可以包在裡面:

前面再用一個透明的 1x2x2 薄牆壁擋起來:

俯視圖:

拿另一個 2x4 薄板從上面蓋下去, 就可以搭出一個很牢固的樂高盒子出來, 把 IR receiver 和立體聲座包進去:

前視圖:

另一個角度:

屁股:

接下來就可以開始使用了, 用三pin的立體聲線和 Arduino 接起來. 立體聲線可以自己做, 也可以買現成的, 記得買頭有三節的那種, 可以走 3 條線在裡面. 立體聲線自己做和現成的其實價差不會太大: 自己做的好處是長度可以自己控制:

更近一點的照片, 在 Arduino 這邊也是用立體聲座,只要三個 pin 不要接錯就行了. 下圖紅色接 Vcc, 黑色接 GND, 白色接 Arduino 11 pin, 也可以接 8 pin(軟體要改). 軟體用 IRremote library 裡面的 IRrecDump example 測試就可以了.
 

樂高的好處就是彈性大, 可以做成黑色和家電搭配:


樂高做殼有彈性大易修改的特性, 但是缺點就是兜出來的殼沒辦法很完全的match, 在一些場合用3D printer 還是會比較好. 至於成本就要看東西, 用 3D printer 印不一定就比較便宜. 尤其是大的東西或者常修改的.

more: [樂高] 製作 EeePC 701 VESA 螢幕背掛架