Tutorial
Visual Basic 2013
How to use Visual Basic 2013 and the VISA library to communicate with the PLZ-5W Series through its RS232C, USB, and LAN interfaces is explained below.
Setting the "Project"
First, set the communication driver (VISA library) for the Project.
From Solution Explorer, select a project, right-click to show the shortcut menu, select Properties, References, and then Add, and then select the VISA COM you want to use.
Example: Using the VISA COM5.5 Type Library
Communication through RS232C, USB, or LAN
After setting the communication driver, you can communicate with the PLZ-5W through RS232C, USB, or LAN.
The following describes the communication procedure using VISA.
Open the VISA
To communicate with an RS232C, USB, or LAN device using VISA, you have to first open VISA. When you open VISA, specify the I/O resource.
Example: To open VISA by using USB
Dim rm As IResourceManager3 = New ResourceManager()
Dim msg As IMessage
msg = rm.Open("USB0::0x0B3E::0x1042::AB012345::INSTR", AccessMode.NO_LOCK, 0, "")
"USB0::0x0B3E::0x1042::AB012345::INSTR" is the I/O resource.
The I/O resource is specified by the following constructions. The part indicated with [ ] can be omitted. Enter the appropriate values in the parts specified in oblique characters.
Serial (RS232C) |
ASRL[board][::INSTR] Example : The measuring instrument connected to the serial port COM1. ASRL1::INSTR |
|
---|---|---|
USB |
USB[board]::VendorID::ProductID::SerialNumber[::InterfaceNumber][::INSTR] Example: The USBTMC measuring instrument having vendor ID (VID) 2878, Product ID (PID) 4133 and serial number "00000001." USB0::0x0B3E::0x1024::00000001::INSTR |
|
LAN*1 | VXI-11 | TCPIP[board]::hostname[::inst0][::INSTR] Example :The measuring instrument whose IP address (hostname) is 169.254.7.8. TCPIP::169.254.7.8::INSTR You can also set the LAN device name using the host name. |
HiSLIP | TCPIP[board]::hostname::hislip0[::INSTR] Example :The measuring instrument whose IP address (hostname) is 169.254.7.8. TCPIP::169.254.7.8::hislip0::INSTR You can also set the LAN device name using the host name. |
|
SCPI-RAW | TCPIP[board]::hostname::portno::SOCKET Example :The measuring instrument whose IP address (hostname) is 169.254.7.8. (The "portno" setting of the PLZ-5W is normally 5025.) TCPIP::169.254.7.8::5025::SOCKET You can also set the LAN device name using the host name. |
*1: The hostname must be a valid mDNS hostname (a Bonjour hostname that ends in ".local") or a DNS hostname that is managed by an external DNS server (a full-qualified domain name—FQDN). If you are using an mDNS hostname, Apple Bonjour (alternatively, iTunes or Safari) must be installed on your PC.
For VISA, the alias can be used for the I/O resource.
When using the alias for the I/O resource, even if the alias name is hard-coded directly in the application, the alias name can be easily converted to the appropriate I/O resource name.
Example : When using the alias (MYDEV1) for the I/O resource.
msg = rm.Open("MYDEV1", AccessMode.NO_LOCK, 0, "")
When the alias is used, the actual I/O resource is specified by an external configuration table. When using USB (example for KI-VISA):
If you are using a version of VISA other than KI-VISA, see the manual of your VISA version.
Controlling the devices
Next, use "Read" and "Write" commands to control devices. You must include line-feed codes in the command character strings.
Example:
msg.WriteString("CURRent 0.3" & vbLf) 'Set the current to 0.3 A
msg.WriteString("CURRent:PULSe:FREQuency 10" & vbLf) ’Set the switching frequency to 10 Hz
msg.WriteString("INPut ON" & vbLf) 'Load on
Closing the VISA
Close the VISA at the end.
You only need to include one "open" VISA command and one "close" VISA command 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( "MYDEV1" , AccessMode.NO_LOCK, 0, "") ''Example: Using an alias
'msg = rm.Open( "USB0::0x0B3E::0x1024::00000001::INSTR" , AccessMode.NO_LOCK, 0, "") 'Example: USB
'msg = rm.Open( "TCPIP::169.254.178.141::INSTR" , AccessMode.NO_LOCK, 0, "") 'Example: LAN
msg.TerminationCharacterEnabled = True
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?" & vbLF)
TextBox1.Text = msg.ReadString(256)
End Sub
‘Set the voltage and frequency
Private Sub cmdCurr_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCurr.Click
msg.WriteString( "OUTP 0" & vbLF)
msg.WriteString( "VOLT 110" & vbLF)
msg.WriteString( "FREQ 60" & vbLF)
msg.WriteString( "OUTP 1" & vbLF)
End Sub
'Queries the measured voltage
Private Sub cmdMeas_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMeas.Click
msg.WriteString( "MEAS:VOLT:DC?" & vbLF)
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
Related information
A KIKUSUI version of the I/O library (KI-VISA) is available. You can download KI-VISA from the Kikusui Electronics Corporation website (http://www.kikusui.co.jp/en/download/).