Programming Guide

Table Of Contents
SIGLENT
SVA1000X Programming Guide 75
Dim count As Long
' First we will need to open the default resource manager.
status = viOpenDefaultRM (defaultRM)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Could not open a session to the VISA Resource Manager!"
TCP_IP_Test = status
Exit Function
End If
' Now we will open a session via TCP/IP device
status = viOpen(defaultRM, "TCPIP0::" + ip + "::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
Exit Function
End If
status = viWrite(instrsesn, "*IDN?", 5, count)
If (status < VI_SUCCESS) Then
resultTxt.Text = "Error writing to the device."
End If
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
End If
status = viClose(instrsesn)
status = viClose(defaultRM)
TCP_IP_Test = 0
End Function
3) Button control code:
Private Sub exitBtn_Click()
End
End
Sub
Private
Sub tcpipBtn_Click()
Dim stat As Long
stat = TCP_IP_Test(ipTxt.Text)
If (stat < VI_SUCCESS) Then
resultTxt.Text = Hex(stat)
End If
End
Sub
Private
Sub usbBtn_Click()
Dim stat As Long
stat = Usbtmc_test
If (stat < VI_SUCCESS) Then
resultTxt.Text = Hex(stat)
End If
End
Sub
4.1.3 Example of MATLAB
Environment: Win7 32bit system, MATLAB R2013a
The function of this example: Use the NI-VISA, to control the device with USBTMC or
TCP/IP access to do a write and read.
Follow the steps to complete the example:
1 Open MATLAB, modify the current directory. In this demo, the current directory is