This tutorial shows you how to set up NI hardware and software to communicate with an Ethernet/LAN instrument in LabVIEW. Consult the documentation for your Ethernet instrument and make sure you have the correct cable to connect the instrument to the network.
Install the latest compatible version of LabVIEW and the NI-VISA driver. Refer to the following for compatibility information.
Directly connect the instrument’s Ethernet port to the Ethernet port on the target machine via an Ethernet cable. Refer to your instrument’s user manual for more information.
Ping your device to make sure you can communicate with your instrument over the network.
Open the Command Prompt from the Start menu.
Type in the following command:
Ping xxx.xxx.xxx.xxx:yyyyWhere xxx.xxx.xxx.xxx is the IP address of the instrument and yyyy is the port. Depending on the instrument, you may not need to specify the port. Press Enter.
If you get a reply response back, you are able to communicate with the instrument and are ready to configure it in Measurement & Automation Explorer (MAX).
Use Measurement and Automation Explorer (MAX) to create and configure the VISA TCP/IP Resource used to communicate with your instrument.
Open MAX from the Start menu.
Right-click on Devices and Interfaces and select Create New…
In the Create New… window, select VISA TCP/IP Resource. Click Next.
After set up and configuration, use VISA Test Panels to verify communication with the instrument and test different instrument commands.
In MAX, select the Tools tab >> NI-VISA >> VISA Interactive Control.
Select the VISA TCP/IP resource of your instrument.
In the Test Panel windows, select the Input/Output tab.
In the Basic I/O tab, input a supported command and select Query. Refer to manufacturer documentation for a valid list of commands to use with your instrument.
The display window will outline the write and read operations.
After completing your configuration and verifying communication with the instrument, you can easily transition from interactive mode to programming mode by using an instrument driver.Refer to Choosing the Right Interface to Control Instruments in LabVIEW to determine which instrument driver type is best for your application. Follow the links in the document to install and use the instrument driver.
The instrument driver and NI-VISA driver will install examples and the API required to communicate with your instrument. Use these examples as programming references and an easy way to start using your instrument.Note: Close MAX before you start running a LabVIEW example. Having MAX Test Panels open and running a LabVIEW example simultaneously will result in an access resource error.
If you installed an instrument driver, refer to the following examples:
If you are using NI-VISA, refer to the following LabVIEW snippet. This example opens a session to the Ethernet instrument, performs a write of *IDN?\n, reads the specified number of bytes back from the instrument, closes the session, and handles any errors.
Drag the snippet directly onto an empty LabVIEW block diagram.
On the front panel, configure the VISA resource name to be the VISA TCP/IP resource of your instrument previously configured in this tutorial.
Run the VI.
For more information on VISA functions, refer to LabVIEW Help: VISA VIs and Functions.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.