Blog:
HSI 比 SCPI 更快速、更簡單


您是否希望能夠更快地從示波器中擷取波形資料? 在這篇技術文章中,我們將探討 TekHSI (Tektronix 高速介面) 及其提供的速度改進,並看看一些的範例,瞭解 TekHSI 為何如此簡單易用。

什麼是 TekHSI?

TekHSI 是 Tektronix 4B、5 和 6 (B 和 LP) 系列 MSO 示波器透過最新韌體更新 v2.10 提供的新功能。TekHSI 針對高速資料傳輸進行了最佳化,事實證明,與常規 SCPI Curve 和 CurveStream 擷取方法相比,其速度提高了近 10 倍。這是因為雖然 SCPI Curve 和 CurveStream 受到儀器處理 SCPI 命令的能力的限制,但 TekHSI 使用二進位通訊協定來繞過這個限制。

若要在示波器上啟用 TekHSI,請選擇 Utility -> I/O -> HSI 並開啟 HSI:

The High Speed Interface settings menu featuring a toggle button to enable High Speed Interface, the port number field, and the timeout parameter in seconds.

圖 1: TekHSI 設定功能表

如需瞭解更多有關 TekHSI 如何運作的資訊,請參閱技術簡介《使用 TekHSI 提高生產力》

將 TekScope v2.10 與 TekHSI 結合使用

您可在 tekcloud.com 上取得最新版的 TekScope PC,此版本增加了對此新高速介面 (HSI) 功能的支援。TekScope PC 是開始高速資料傳輸的最快速、最直接的方法。當在連接的示波器上啟用 HSI 時,可以將高速傳輸資料至 TekScope PC。尤其令人驚豔的是,TekHSI 提供的速度增強功能可以在 TekScope 中立即自動顯示,無需其他操作或設定,這對於不想進行任何程式設定但又想利用高速介面進行資料擷取的所有優勢的使用者而言,TekScope PC 理所當然地成為快速又簡便的「無程式碼」選項。此外,啟用 TekHSI 後,TekScope PC 將利用高速資料傳輸來執行所有適用的擷取方法,包括單次、連續和「事件觸發」觸發。

使用TekScope PC 和 TekHSI 提高效能

圖 2 顯示了使用 TekHSI 與使用 i7 或 i9 處理器進行 Curve 擷取相比,TekScope PC 的效能獲得了顯著的提升。請注意單通道使用案例,當將 TekHSI 與配備 i9 處理器的 PC 結合使用時,效能可提高 10 倍以上。在每種使用案例中,TekHSI 都明顯表現出比典型 Curve 擷取更高的效能。

Graph charting the performance of HSI and Curve with both i7 or i9 processors. The data compares the acquisitions per minute at variable sample rates for 1 channel, 2 channels, 4 channels, or 8 channels. Using an i9 processor with HSI has the highest performance with the most acquisitions.

圖 2:TekScope HSI 效能優於使用 i7 或 i9 處理器的傳統方法。



將 Python 與 TekHSI 結合使用

TekHSI 的優勢也可以在 Python 中利用。只需安裝 tekhsi Python 函式庫 (於 2024 年 9 月推出) 即可輕鬆進行。

若要安裝軟體套件,只需開啟命令終端機並使用 pip 即可:

pip install tekhsi

若要在 Python 環境中使用 TekHSI,只需將 tekhsi 匯入 Python 專案即可存取 API。您會注意到,在圖 3 中,這些命令比標準 SCPI 命令更具可讀性,並且執行類似任務所需的命令更少。

TekHSI 範例

import tekhsi
scope = tekhsipy.TekScope('0.0.0.0')
data = scope.read_waveform('CH1')	

SCPI 範例

import visa
rm = visa.ResourceManager()
scope = rm.open_resource('TCPIP::0.0.0.0::INSTR')
scope.write('DAT:SOU CH1')
scope.write('DAT:ENC RPB')
scope.write('DAT:WID 1')
data = scope.query_binary_values('CURV?', datatype='B')

圖 3:使用 TekHSI Python 函式庫與傳統 SCPI 命令進行並排程式碼比較,以收集通道 1 波形資料。

TekHSI 不僅比 SCPI 更快、更有效率,而且使用起來也更方便。如您在圖 3 中看到的,使用 tskhsi 函式庫,無需格式化即可檢索資料。只需使用 scope.read_waveform('CH1') 命令即可檢索您的通道 1 資料。我們目前仍持續微調我們的 Python 套件,因此發布的函式庫可能與上面的範例有所不同。我們預計於 9 月初公開發布這些 Python 套件。
 

使用 Python 和 TekHSI 提升效能

在 Python 應用程式中使用 TekHSI 時可以看到顯著的效能提升。圖 4 顯示,在 Python 應用程式中,使用 TekHSI 比使用搭配 HSI 的 TekScope PC 可以提供更快的資料傳輸。

Graph charting the performance of TekScope HSI, Python HSI and Curve at a record length of 5 million. The data compares the acquisitions per minute at variable sample rates for 1 channel, 2 channels, 4 channels, or 8 channels. Python HSI has the highest performance with the most acquisitions, followed by TekScope PC HSI in second, and then finally curve with the fewest acquisitions per minute.

圖 4:在不同取樣率和 500 萬個記錄長度下,Python 程式設計 TekHSI 和 TekScope HSI 效能優於傳統 Curve 方法 

使用 TekHSI Python 函式庫的優勢顯而易見。TekHSI 在每個取樣率和通道數上的表現都遠優於傳統的 SCPI 資料擷取,且速度還提高了 10 倍。
 

Curvestream 與 TekHSI 對比

現在,讓我們來看看 TekHSI 與 CurveStream 的比較結果。在 TekHSI 發布之前,CurveStream 方法是從示波器收集資料的最快形式。然而,從圖 5 可以看出,CurveStream 很複雜,需要在啟用 CurveStream 之前先對資料進行格式化和編碼。還需要正確擷取和附加資料,這是一個手動程序。

TekHSI 範例

import tekhsi
scope = tekhsipy.TekScope('0.0.0.0')
data = scope.read_waveform('CH1')

Curvestream 範例

import pyvisa as visa
import time
rm = visa.ResourceManager()
scope_address = "TCPIP0::0.0.0.0::inst0::INSTR"
scope = rm.open_resource(scope_address)
scope.timeout = 20000
scope.write("display:waveform 0")
scope.write("horizontal:mode manual")
scope.write("horizontal:mode:samplerate 6.25e9")
scope.write("trigger:a:level:ch1 1")
scope.write("ch1:scale 1")
scope.write("data:encdg rib")
scope.write("data:width 1")
scope.write("data:source CH1")
#turn on all the channels
for k in range(2,9):
	scope.write("disp:glob:ch{}:state 1".format(k))
	scope.write("data:source CH1,CH2,CH3,CH4,CH5,CH6,CH7,CH8")
record = [10000]
data = []
for r in record:
    scope.write("hor:reco {}".format(r))
    scope.write("data:stop {}".format(r))
    #let settings settle
    time.sleep(1)
    #enter curvestream state
    scope.write("curvestream?")
    #check the time
    time_start = time.time()
    #operate for 10 seconds
    while(time.time()-time_start < 10):
        wave = scope.read_raw()
        data.append(wave)
    #stop curvestreaming
    scope.write("*CLS")
scope.close()
rm.close()

圖 5:使用 TekHSI Python 函式庫與 CurveStream 進行並排程式碼比較,並使用 SCPI 命令快速收集通道 1 波形資料。

與 CurveStream 相比,TekHSI 不僅能夠更快地將資料從示波器傳輸至 PC,而且實作起來也更加簡單。