A command for "Open" and "Close" of the VISA is required only once in the program.
msg.Close
Sample program
Imports
Ivi.Visa.Interop
Public Class
Form1
Dim
rm
As
ResourceManager
Dim
msg
As
IMessage
Private Sub
Form1_Load(
ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles MyBase
.Load
rm = CreateObject(
"VISA.GlobalRM"
)
msg = rm.Open(
"GPIB0::1::INSTR"
, AccessMode.NO_LOCK, 0, "")
'Example: GPIB
'msg = rm.Open(
"MYDEV1"
, AccessMode.NO_LOCK, 0, "")
'Example: Using a alias
'msg = rm.Open(
"USB0::0x0B3E::0x100E::00000001::INSTR"
, AccessMode.NO_LOCK, 0, "")
'Example: USB
'msg = rm.Open(
"TCPIP::169.254.7.8::INSTR"
, AccessMode.NO_LOCK, 0, "")
'Example: LAN
End Sub
'Query the instrument identity
Private Sub
cmdIdn_Click(
ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
cmdIdn.Click
msg.WriteString(
"*IDN?"
)
TextBox1.Text = msg.ReadString(256)
End Sub
'Set the operation mode and voltage
Private Sub
cmdCurr_Click(
ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
cmdCurr.Click
msg.WriteString(
"OUTP 0"
)
msg.WriteString(
"VOLT 13.5"
)
msg.WriteString(
"CURR 150.0"
)
msg.WriteString(
"OUTP 1"
)
End Sub
'Query the instrument identity
Private Sub
cmdMeas_Click(
ByVal
sender
As
System.Object,
ByVal
e
As
System.EventArgs)
Handles
cmdMeas.Click
msg.WriteString(
"MEAS:CURR?"
)
TextBox1.Text = msg.ReadString(256)
End Sub
Private Sub
Form1_Disposed(
ByVal
sender
As
Object,
ByVal
e
As
System.EventArgs)
Handles Me
.Disposed
msg.Close()
End Sub
END CLASS
PAT-T series Communication Interface Manual
KIKUSUI ELECTRONICS CORP.
55/158