打開(kāi) VISA 到某器材/設(shè)備的連接。
#include <Visa.au3>
_viOpen($s_visa_address, $s_visa_secondary_address = 0)
參數(shù)
$s_visa_address | VISA 資源描述符(descriptor)字符串(請(qǐng)查看 _viExecCommand 函數(shù)的注意部分以了解更多信息) 作為一個(gè)更快捷的方式,您還可以直接傳遞 GPIB 地址(整數(shù)) |
$s_visa_secondary_address | 可選:“次要 GPIB 地址”。僅當(dāng)傳遞的主地址是整數(shù)時(shí)才使用。 只有少數(shù) GPIB 設(shè)備具有次要地址。如果有則可使用該地址來(lái)傳遞到此參數(shù)。 此參數(shù)的默認(rèn)值是零,表示沒(méi)有次要地址 |
返回值
成功: - 返回值為(正數(shù))VISA 設(shè)備句柄
注意
所有的 VISA 函數(shù)都要求必須安裝 VISA 庫(kù)(您可以通過(guò)檢查 WINDOWS\system32 目錄下是否存在 visa32.dll 來(lái)判斷)和一個(gè) GPIB 卡(例如 National Instruments(美國(guó)國(guó)家儀器有限公司)的 NI PCI-GPIB 卡或者是 Agilent 82350B PCI 高性能 GPIB 卡)。
相關(guān)
_viClose, _viExecCommand
示例
;- 這個(gè)腳本假定您已經(jīng)把 GPIB 的地址設(shè)為 1
; 本腳本演示了如何單獨(dú)使用 _viExecCommand 函數(shù)以及結(jié)合
; _viOpen 和 _viClose 函數(shù)使用的方法。
; 另外還演示了 _viGTL 函數(shù)
#include <Visa.au3>
Dim $h_session = 0
; 請(qǐng)求設(shè)備的 GPIB 地址3 的 ID
MsgBox(0,"Step 1","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen("GPIB::3::0")
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; 顯示 Session 句柄
; 請(qǐng)求設(shè)備響應(yīng)
MsgBox(0,"Step 2","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; 注意,$h_instr 現(xiàn)在已不再是字符串了!
MsgBox(0,"GPIB QUERY result",$s_answer) ; 顯示結(jié)果
; 再次請(qǐng)求。這時(shí)不需要再次打開(kāi)連接了
MsgBox(0,"Step 3","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; 顯示結(jié)果
MsgBox(0,"Step 4","Close the instrument connection using _viClose")
_viClose($h_instr) ; 關(guān)閉設(shè)備連接
MsgBox(0,"Step 5","Open the Instrument connection using only the address number")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; 顯示 Session 句柄
; 請(qǐng)求設(shè)備響應(yīng)
MsgBox(0,"Step 6","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; 注意,$h_instr 現(xiàn)在已不再是字符串了!
MsgBox(0,"GPIB QUERY result",$s_answer) ; 顯示結(jié)果
; 再次請(qǐng)求。這時(shí)不需要再次打開(kāi)連接了
MsgBox(0,"Step 7","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; 顯示結(jié)果
MsgBox(0,"Step 8","Close the instrument connection using _viClose")
_viClose($h_instr) ; 關(guān)閉設(shè)備連接