Programming Manual UTG1000X Series
Instruments.uni-trend.com
43
/
51
EndIf
' Now we will open a session via TCP/IP device
status = viOpen(defaultRM, "TCPIP0::" + ip + "::inst0::INSTR", VI_LOAD_CONFIG, VI_NULL, instrsesn)
If (status < VI_SUCCESS) Then
resultTxt.Text = "An error occurred opening the session"
viClose(defaultRM)
tcp_ip_test = status
ExitFunction
EndIf
status = viWrite(instrsesn, "*IDN?", 5, count)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error writing to the device."
EndIf
status = viRead(instrsesn, outputBuffer, VI_FIND_BUFLEN, count)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error reading a response from the device." + CStr(i + 1)
Else
resultTxt.Text = "read from device:" + outputBuffer
EndIf
status = viClose(instrsesn)
status = viClose(defaultRM)
tcp_ip_test = 0
EndFunction
LabVI
EW Example
Environment: Window system, LabVIEW
Description: Access the instrument via USBTMC and TCP/IP, and send "*IDN?" command on
NI-VISA to query the device information.
Steps:
1.
Open LabVIEW software and create a VI file.
2.
Add control, press the front panel interface, select and add VISA resource name, error input, error
output and partial indetifier on control flow diagram.
3.
Open diagram, press VISA resource name and then select and add function VISA Write, VISA Read,
VISA Open and VISA Close on pop-out menu.
4.
VI open a VISA session of USBTMC device and wrote *IDN? command and read back the response
value. When all communication is complete, VI will close the VISA session.
As shown in the
following figure.