顯示具有 AVerMedia 標籤的文章。 顯示所有文章
顯示具有 AVerMedia 標籤的文章。 顯示所有文章

2022年1月9日 星期日

使用繼電器模組切換分享USB外接SSD

AverMedia ER130 具備紅外線遙控,  USB接口. 無網路功能

計畫:

讓 Raspberry Pi 3 成為 ER130 網路後端.

在 ER130 與 Raspberry Pi 3 之間分享USB外接SSD, 將 ER130 錄影檔 copy 到 Pi 上. 後續可用小米盒子上的KODI連入Pi觀看.


核心功能: 

在兩個設備間以無人職守的方式切換分享同一個USB硬碟(使用外接SSD)


實現:

以 四路單刀雙擲繼電器模組 實作. 工作電壓5V. low-level trigger

    每個單刀雙擲繼電器有三個接點:

        共接點: USB SSD

        Normal Close 接點 (預設接點): AverMedia ER130 (Power Pin 除外)

        Normal Open 接點: Raspberry Pi (Power Pin 除外)


接線:

Raspberry Pi 端: GPIO 2, 3, 4 pull-up pin

GPIO 2 -> Relay 1 -> USB Power pin

                  Relay 1:

                      共接點 -> USB SSD power pin 

                      Normal close 接點 -> 5v 外接電源   

                      Normal open 接點 -> 空接 (等於斷電)

GPIO 3 -> Relay 2 -> USB D- pin

                  Relay 2:

                      共接點 -> USB SSD D- pin

                      Normal close 接點 -> ER130 USB D- pin

                      Normal open 接點 -> Raspberry Pi USB D- pin

GPIO 3 -> Relay 3 -> USB D+ pin

                  Relay 3:

                      共接點 -> USB SSD D+ pin

                      Normal close 接點 -> ER130 USB D+ pin

                      Normal open 接點 -> Raspberry Pi USB D+ pin

GPIO 4 -> Relay 4 -> USB Ground pin

                  Relay 4:

                      共接點 -> USB SSD Ground pin

                      Normal close 接點 -> ER130 USB Ground pin

                       Normal open 接點 -> Raspberry Pi USB Ground pin


切換邏輯:

USB SSD 由 ER130 USB 口切換至 Rasbperry Pi USB 口:

原則: Power pin 先接, Data pin 後接

- Pi 發送 IR 訊號控制 ER130 錄影, 錄影完成, Pi 發送 IR code 關閉 ER130.

        若不關閉 ER130, 則需要八路單刀單擲繼電器才能實作切換.

- GPIO 2 = Relay 1 = Power pin 切至 normal open 端, 此處空接

    USB SSD 斷電. 模擬 VBUS 斷電. 否則USB SSD不能reset, 下個設備的host無法enumerate被切換的設備(此處為SSD), 則無法辨識出新設備被hotplug.

- GPIO 4 = Relay 4 = Ground pin 切至 normal open, 連接 Raspberry Pi USB Ground pin

- GPIO 2 = Relay 1 = Power pin 切回 normal close, 連接5v獨立電源

    USB SSD 通電. 使用獨立電源原因在於 ER130 供電不穩. Raspberry Pi USB供電有限 (Pi 3 USB總供電 1.2 A, 不須 max_usb_current=1). Pi 拷貝影片時需要同時存取兩個硬碟 1.2A 不足以負荷.

- GPIO 3 = Relay 2 = D- pin 切至 normal open, 連接 Raspberry Pi USB D- pin

- GPIO 3 = Relay 3 = D- pin 切至 normal open, 連接 Raspberry Pi USB D+ pin


Pi Copy 完成後, USB SSD 由 Raspberry Pi USB 口切回 ER130 USB 口:

原則: Data pin 先斷, Power pin 後斷

- GPIO 3 = Relay 2 = D- pin 切至 normal close, 連接 ER130 USB D- pin

- GPIO 3 = Relay 3 = D- pin 切至 normal close, 連接 ER130 USB D+ pin

- GPIO 2 = Relay 1 = Power pin 切至 normal open 端, 此處空接 USB SSD 斷電. 

- GPIO 4 = Relay 4 = Ground pin 切至 normal close, 連接 ER130 USB Ground pin

- GPIO 2 = Relay 1 = Power pin 切回 normal close, 連接5v獨立電源

- Pi 發送 IR code 開啟 ER130. ER130 開機辨識出 USB SSD. 可以開始下次綠影.

        



實現過程中遭遇的問題和處理:

上面的接線和切換邏輯不是一開始就知道的, 而是處理掉一些問題後的結果

- USB SSD 5V pin (VBUS)必須確實斷電 1 秒以上 

使用單刀雙擲 relay 實作第一個遇到的問題. 卡關最久. 症狀也最詭異. 

症狀: 由 Rasbperry Pi 切換回 ER130 時, ER130 無法辨認 SSD. 此時將 relay 的電源拔除, 瞬間ER130 就能辨認出SSD. 但relay的電源和 SSD 電源應該是隔離的. 至今仍不知為何有這種現象.

解: 初期導入一個MOSFET模組單獨控制SSD的VBUS, 在切換後將SSD特別斷電一秒再復電. ER130就能辨認出SSD. 後期將SSD改為獨立電源後. 拔除MOSFET, 改用四路relay的第一路來單獨控制 SSD 的VBUS pin.

- USB 四個 pin 不能同時切

  要模擬人類插拔 USB 一開始最簡單的想法就是 USB 上的四個pin用relay 一次切過來. 


USB接頭總共有四個ping, 第一和第四pin是電源和接地pin, 就是5v直流電的正負極. 而中間兩條 D-, D+ 是資料pin. 仔細觀察四個pin腳, 事實上四個pin是不等長的, 中間兩條資料pin 比較短. 此處隱含的邏輯就是: 插入USB時, 電源接地先通, 再來才接資料pin. 而拔出的時候則相反, data pin 先退出, 再來才斷電.

最早的實作中, 因為沒有遵守這個邏輯, relay 4 pin 一起切的結果, 在 Raspberry Pi 端會隨機發生EMI錯誤: 

[5410843.300270] usb usb1-port1: disabled by hub (EMI?), re-enabling...

雖然 Linux kernel 會自動修復, 但上層的所有服務都會跳掉需要重啟. 例如 NFS. 修改切換邏輯, 插入時先通電後通資料,  拔出時先退資料後斷電. 就沒再出現 EMI 錯誤.

到了這邊會發現, 因為有 A, B 兩台設備要分享同一個 SSD. 此處為 ER130 和 Raspberry Pi 兩設備分享同一個SSD. 所以單刀雙擲的 relay 是沒辦法同時滿足兩台機器的插拔邏輯. 一旦以A設備為主切換, 則B設備就會違反邏輯. 若用兩套單刀單擲 relay 去實作是比較完整的, 但接線會比較複雜而且需要更多機殼空間.

所以我的作法是將 ER130 端在切換前IR遙控它關機. 完全以 Raspberry Pi 為主來撰寫切換邏輯. 整個程序完成後, 再遙控 ER130 開機. 靠 ER130 的韌體開機enumerate, 將SSD掛回來.

- 設備端的USB供電不穩或供電不足

症狀: 外接SSD 的filesystem常常corrupted. 在ER130端會顯示外接SSD無法移除. 另外有時發生錄影到一半無法寫入, 或者在錄影結束最後階段無法完成最後的檔案寫入.

解: 給外接SSD輔助電源, 但有後續後遺症. 如下.

- 輔助電源的電流逆流至設備端

症狀: 移除 ER130 電源後, ER130電源燈仍會亮.

解: 將外接SSD完全改獨立電源. 與 ER130, Raspberry Pi 的 USB VBUS pin 完全分開.

- ER130 變壓器衰退(?)不足瓦

症狀: IR code 漏接, 無法開始錄影或者停止錄影.

2015年5月4日 星期一

[Tivo] Using AVerMedia ET111 to transfer the output of Tivo from AV to HDMI


I discovered the AVerMedia that hosts a activity to try their new product ET111. So I registered to be a volunteer for testing the quality to transfer the signal output from AV (Composite video connector) to HDMI. After two days testing, currently my comment is: easy for installation, quality of picture output is satisfactory. But I got a small problem.

This time the activity that's hosted by AVerMedia is for collecting world wide use cases of ET11X series. The target products of testing is ET110, ET111 and ET113. I registered to test ET111, it's a AV to HDMI transfor.

I got a box:

Open it:

I found there have a AVerMedia ET111 inside. The package of my received model is English package. There has "Video Converter AV to HDMI Format" wording on front side. Actually the "AV" means "Composite video connector":

Comparing the size of ET111 with pen:

It claim high compatibility, high quality and fewer distortions. For a transfer product, compatibility and fewer distorions are very important. If the transfer result out of the boundry of screen or out of shape. Then it not worth to check the quality of picture:

Back side, the same, it's Enlgish on package:

Here show the characteristic by different language, printed by Chinese:

Tn addition, There have specifictions on back side. Composite Video RCA input, USB DC input, HDMI output resolution: 480p 60 Hz / 576p 50 Hz:

System Requirements, need Composite and Audio Cable, HDMI cable and USB port for taking 5V power:

After open the plastic packaging, I saw the E111 device and a multi-languages guide:

The same, comparing the size of E111 device with pen:

The guide includes 15 different languages that includes Chinese, the Traditional Chinese guide as following. Looks very easy:

English guide:

The HDMI output is female port:

The input of AV line is also female port. You can see the length is not long by comparing with pen. That because it's in case you already have a long AV line. On the other hand, the USB input is male side:

The label behind ET111 has a label that shows model type and certificates:

Next is installation. My TV is a Panasonic plasma TV. There have HDMI, AV and USB port on the left side of my TV. That's very convenient for connecting to ET111 because those ports are close by Panasonic's design.

I collect the AV cable from Tivo to ET111, then collect ET111 to TV's HDMI port by HDMI cable:

And, ET111 need the 5V DC power from USB port. So connect ET111's USB male connector to TV's USB port:

Because my use case is transfer Tivo's AV output, so there have another way is connect ET111 to Tivo's AV and USB port in Tivo's back panel:

Like this. If you don't like the AV cable too long, you can buy 3 RCA male to male connector to transfer the ET111's AV port from female to male. Then you don't need a long AV cable:

Connect ET111's AV and USB cable to Tivo's port on back panel:

Connect HDMI cable from ET111's HDMI output port to TV's HDMI port:

The following video is the picture quality from Tivo's original AV output:

At the begging of the above video, I disconnect my ET111 with TV and connect the Tivo's AV cable to TV. Then playing video, first please looking at the yellow frame of blue selection bar on the Tivo's main page. Please note there have NO any shake on the boundary of yellow frame, but have shake from ET111 output.
Please comparing later's E111 video.

In the TV program, please check the face contour and hair of people, and the shadow below eyes. The picture quality from pure Tivo AV output is not HD, the contour looks fuzzy and easy to identify the blocks of color. Especially when the night scene, looking at the big black block can easy to find the bad quality. But, I think the main reason is because the quality of kbro TV box's AV output that's not really good. The kbro TV box processes the digital signal to avoid the water wave and noise from analog signal, but the presentation of color block doesn't good as analog signal. I thought kbro deliberately reduced the quailty from its AV output.

Anyway, please comparing the with the following output result from ET111 with Tivo, actually that doesn't have big difference. The picture quality and performance from ET111 HDMI output is not bad. I didn't see picture distortion or out of screen boundary. Comparing with pure Tivo output, the quality is not better or optimize. I think that because the bad video source from kbro TV box but not ET111's problem.

Here is the ET111 HDMI output with Tivo:

Looking at the 1:28 in the above video, there have shake on the yellow boundary of the selection bar on Tivo's main page. The shake situation didn't see on the picture of pure Tivo AV output. And, I didn't see shake when playing video on Tivo with ET111, only saw on Tivo's main page.

Then please back to the begging in the TV program in video, comparing the face contour, shadow with pure Tivo output. There doesn't have too many difference. ET111's HDMI output almost the same with Tivo's AV output.

The final topic is I got a random one second black screen problem. The following video is for presenting issue, please ignore the picture quality. (Smoking unhealthy):

Please note there have a first time "one second black screen" at 0:56-0:57, I fallback and replay the same fragments but I can not reproduce the same problem. Then at later 4:45-4:46 happened second time "one second black screen". That can not reproduce issue by playing the same fragments on pure Tivo AV output, I never saw the same situation. Due to ET111 is doing the ADC job to transfer analogy signal (AV) to digital signal (HDMI). So it's possible E111 parer one kind of analogy signal to be black screen.

After I found random one second black screen, I have played another 2 movies that recorded by Tivo. The total playing time from 4 to 5 hours, the situation happened again when I am playing "Ender Gaome". The problem was happened when I just turn on TV to play the movie, looks the problem does not relate to the length of playing time. It's also can not reproduce by replaying the same fragments. My summary is that has "one second black screen" problem but the fail rate is not too high per my experience.

So, if there still have idle AV port (Composite video connector) doesn't used on your TV, then direct connecting your player to AV port makes more sense. Because I think the ET111 doesn't give more picture quality improvement, it's unworthy to waste the power for transferring AV signal to HDMI by another device. But, if your TV only has idle HDMI port, then you should consider using ET111. Per my testing with Tivo, I didn't see picture distortion or  out of screen boundary, the output of ET111's HDMI doesn't have difference with the original AV output from Tivo.

Tivo's AV port may output a kind of analogy signal that causes ET111 parer it to be one second black screen. But the fail rate is not high. If you also got the same black screen problem with high rate, then you may need AVerMedia's help on this problem.

[Tivo] 圓剛 AVerMedia ET111 將 Tivo 的 AV端子轉為HDMI輸出


無意間看到圓剛舉辦活動, 所以參加 AVerMedia ET111 的試用. 主要想試試看把Tivo的AV端子轉成HDMI輸出的效果如何. 在兩天的試用後, 我先講目前的結論: 安裝簡易, 畫質表現中規中矩. 但我有遇到小問題.

這次圓剛 AVerMedia ET11X系列(訊號轉換器) 使用情境全球大募集, 測試 ET110, ET111, ET113 三種轉換器. 我申請測試 ET111, AV端子轉HDMI.

首先收到紙箱:

打開如下:

實際 AVerMedia ET111 的產品在裡面, 可以看到我收到的版本是英文為主的包裝. 正面有 Video Converter AV to HDMI Format 字樣. AV 端子其實就是 Composite video connector:

和西堤牛排原子筆的大小比較:

標榜高相容性, 高品質低失真. 其實使用這類的產品相容性和低失真是很重要的條件. 如果轉出來超出畫面或者變形就很難以使用了, 更不用去談畫質了:

背面, 一樣都是英文, 我拿到的是英文包裝:

有印上簡繁體中文的特色說明:

背面有印上產品規格, Composite Video RCA 輸入, USB 作為 DC 電源輸入, 輸出HDMI解析度為: 480p 60 Hz / 576p 50 Hz:

系統需求, 需要AV端子連接線, HDMI線以及USB線:

打開塑膠包裝泡殼之後很簡單就是說明書和ET111本體:

和原子筆的大小比較:

說明書內容印有包含中文15個國家的語言, 繁體中文安裝說明如下, 很簡單:

英文說明:

HDMI輸出端的接口, 是HDMI母頭:

輸入端的AV端子線也是母頭, 可以看到和原子筆長度比較並不長, 是為了要銜接本來就已經存在的AV端子線. 另外也做了 USB 公頭的輸入:

背面的設備標籤, Model ET111 且通過安規:

接下來就是安裝的部分, 我的電視是Panasonic電漿, 左側有HDMI, AV端子和 USB 輸出/入口.
由於 Panasonic 把這幾個口都設計得很近, 所以很方便接上ET111:

我把 Tivo 輸出的 AV端子線接到 ET111, 然後用一條 HDMI線把 ET111 接到電視的 HDMI 輸入:

除此之外就是電源的部分, ET111需要吃 USB 5V 供電, 所以把 ET111 的 USB公頭接到電視的 USB口:

我的使用狀況是搭配 Tivo, 所以另一個接法是接到 Tivo 背後的 AV 端子以及 USB 接口:

像這樣, 其實如果嫌 AV 端子線留太長, 可以買 RCA 公對公的接頭給 ET111 用, 把 ET111 的AV端子線轉成公頭就可以擺脫太長的AV端子線:

ET111的AV端子和USB頭直接接到 Tivo 背面的接口:

輸出部分, HDMI線接到 ET111 然後接到電視:

接著是畫面表現, Tivo原生的 AV端子輸出:


上面的影片一開始我把原本已經接好的ET111拔掉, 把 Tivo 輸出的 AV端子線接回電視的 AV 輸入. 然後播放影片. 首先看到 Tivo 選單頁的那條有黃邊的藍色選擇條, 注意它黃色邊界的部分. 可以看到沒有類似高頻的跳動, 但是 ET111 輸出的畫面會出現跳動, 可以比對下面ET111的影片.

開始播放後請注意人物臉部的線條輪廓和頭髮, 以及我按暫停後特別照的眼部陰影部分. 基本上這個畫質就是 Tivo 輸出的結果. 畢竟畫質不如HD, 輪廓會模糊而且色塊頗明顯, 尤其是大片黑色像是黑夜鏡頭可以更明顯. 事實上我覺得一部分是凱擘 kbro 機上盒的輸出有刻意降低畫質. 雖然 kbro AV端子輸出避免了以往有線電視的水波紋和雜訊, 但是在色塊的表現卻不如原本的類比訊號. 我覺得 kbro 有刻意把AV端子輸出的畫質拉下來.

總之, 可以比較下面這個 ET111 的輸出結果, 其實差異不大. ET111 算是表現得不錯, 搭配 Tivo 沒有出現畫面變形或出界. 但是畫質部分也並沒有更好更優化, 不過訊源不好也是非戰之罪.

Tivo with ET111 的影片輸出:

上面的影片從 1:28 開始, Tivo 主畫面的選擇條上的黃色邊界可以看到出現跳動. 這個是 Tivo 的 AV端子直出所沒有出現的. 不過播放影片倒是少見到這樣的跳動. 然後回到影片開頭可以比對我上面說的臉部輪廓, 陰影等部分. ET111 和 Tivo 的輸出比較起來差異不大. 算是還滿忠於原味.

最後講到, 我遇到隨機一秒黑屏問題, 下面的影片主要用於展示問題, 請忽略錄影下來的影片畫質(吸菸有礙健康):

請注意0:56-0:57出現的第一次一秒黑屏, 然而倒轉重播類似的片段在 3:57-4:00重播並沒有重現同樣的問題. 在4:45-4:46又出現第二次一秒黑屏. 這些片段在單純使用 Tivo 播放影片從未發現. 由於 ET111 做的事情也是做類比(AV端子)轉數位(HDMI)的轉換工作, 所以對於某種類比訊號ET111解讀為黑屏是有可能的.

在發現有隨機一秒黑屏狀況之後, 我另外觀看兩片Tivo錄製的影片, 斷斷續續大約四到五個小時, 在這其中只有在撥放"戰爭遊戲(Ender Game)"時才又出現一次, 而且那次是才開電視看電影之後很快的出現, 所以似乎和撥放的時間長短沒啥很大的關係, 重播相同的片段也無法重現狀況. 所以綜合我遇到的狀況是有一秒黑屏問題但是頻率不算高.

如果家裡的電視還有AV端子沒用到, 那直接接AV端子仍是比較合理的配置. 因為我認為 ET111 帶來的畫質改善並不明顯, 不值得另外耗電掛一個設備去做AV端子轉HDMI. 但如果你的電視只剩下空的 HDMI 接口可以用, 那 ET111 可以考慮一下. 我搭配 Tivo 使用沒有見到失真變形的狀況, ET111的輸出表現和原本AV端子輸出並沒有什麼差距. Tivo可能隨機輸出會讓 ET111 一瞬間無法處理的訊號而造成一秒左右的黑屏, 但是頻率並不高. 如果你也遇到了隨機黑屏而且頻繁到無法接受的話, 可能會需要圓剛原廠的協助.