_viOpen
Opens a VISA connection to an Instrument/Device
#include <Visa.au3>
_viOpen($s_visa_address [, $s_visa_secondary_address = 0])
Параметры
$s_visa_address | A VISA resource descriptor STRING (see the NOTES of _viExecCommand() above for more info) As as shortcut you can also directly pass a GPIB address as an integer |
$s_visa_secondary_address |
[необязательный] The "secondary GPIB address". Only used if the primary address is passed as an integer. Only some GPIB instruments have secondary addresses. In those cases this optional parameter can be used to specify it. This parameter is ZERO by default, which means NO SECONDARY ADDRESS |
Возвращаемое значение
Успех: | Returns a (POSITIVE) VISA Instrument Handle |
Ошибка: | Returns -1 и устанавливает @error to 1 |
Примечания
As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installedСм. также
_viClose, _viExecCommand, _viFindGpib, _viGpibBusReset, _viGTL, _viSetAttribute, _viSetTimeoutПример
;- This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function
#include <Visa.au3>
Local $h_session = 0
; Query the ID of the instrument in GPIB address 3
MsgBox(4096, "Step 1", "Open the instrument connection with _viOpen")
Local $h_instr = _viOpen("GPIB::3::0")
MsgBox(4096, "Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument
MsgBox(4096, "Step 2", "Query the instrument using the VISA instrument handle")
Local $s_answer = _viExecCommand($h_instr, "*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(4096, "GPIB QUERY result", $s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again
MsgBox(4096, "Step 3", "Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr, "*IDN?")
MsgBox(4096, "GPIB QUERY result", $s_answer) ; Show the answer
MsgBox(4096, "Step 4", "Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection
MsgBox(4096, "Step 5", "Open the Instrument connection using only the address number")
$h_instr = _viOpen(3)
MsgBox(4096, "Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument
MsgBox(4096, "Step 6", "Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr, "*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(4096, "GPIB QUERY result", $s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again
MsgBox(4096, "Step 7", "Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr, "*IDN?")
MsgBox(4096, "GPIB QUERY result", $s_answer) ; Show the answer
MsgBox(4096, "Step 8", "Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection