Ethernet Instrument Control Tutorial

Publish Date: Apr 28, 2020 | 32 Ratings | 2.62 out of 5 | Print | 5 Customer Reviews | Submit your review


This tutorial shows you how to set up National Instruments hardware and software to communicate with an Ethernet/LAN instrument in LabVIEW.

Table of Contents

  1. Prerequisites
  2. Install NI Software and Drivers
  3. Connect Instrument to Network
  4. Test Network Communication
  5. Configure Ethernet Instrument in MAX 
  6. Test Communication in VISA Test Panels
  7. Install Instrument Driver
  8. Run an Example
  9. Related Links

1. Prerequisites

Consult the documentation for your Ethernet instrument and make sure you have the correct cable to connect the instrument to the network.


Back to Top

2. Install NI Software and Drivers

Install the latest compatible version of LabVIEW and the NI-VISA driver. Refer to the following for compatibility information. 


Back to Top

3. Connect Instrument to Network

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.


Back to Top

4. Test Network Communication

Ping your device to make sure you can communicate with your instrument over the network.

  1. Open the Command Prompt from the Start menu.
  2. Type in the following command:


Where 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.

  1. 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).

Back to Top

5. Configure Ethernet Instrument in MAX 

Use Measurement and Automation Explorer (MAX) to create and configure the VISA TCP/IP Resource used to communicate with your instrument.

  1. Open MAX from the Start menu.
  2. Right-click on Devices and Interfaces and select Create New
  3. In the Create New… window, select VISA TCP/IP Resource. Click Next.  

  1. Select the type of TCP/IP resource to add.

If your instrument conforms to the VXI-11 LAN or LXI instrument specifications, select one of the following:

    • Auto-detect of LAN Instrument – This option provides a list of LAN instruments found on the local subnet.  
    • Manual Entry of LAN instrument - Add the IP address and LAN device name for your instrument manually.

Otherwise, select Manual Entry of Raw Socket to add your Ethernet instrument as a Raw Socket. With this option, you will have to enter an IP address and port number for your instrument. The instrument's port number should be indicated in its Ethernet Interface Specification found in manufacturer documentation. 

  1. Validate and finish the configuration. There should now be a new VISA TCP/IP Resource under Devices and Interfaces >> Network Devices in MAX in one of the following formats: 
    • LAN Instrument - TCPIP[board]::host address[::LAN device name][::INSTR]
    • Raw Socket Instrument - TCPIP[board]::host address::port::SOCKET


Back to Top

6. Test Communication in VISA Test Panels

After set up and configuration, use VISA Test Panels to verify communication with the instrument and test different instrument commands.

  1. In MAX, select the Tools tab >> NI-VISA >> VISA Interactive Control.
  2. Select the VISA TCP/IP resource of your instrument.
  3. In the Test Panel windows, select the Input/Output tab.
  4. 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. 
  5. The display window will outline the write and read operations.


Back to Top

7. Install Instrument Driver

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.


Back to Top

8. Run an Example

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.  

Instrument Driver Examples

If you installed an instrument driver, refer to the following examples:

NI-VISA Driver Example

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.

  1. Drag the snippet directly onto an empty LabVIEW block diagram.  
  2. On the front panel, configure the VISA resource name to be the VISA TCP/IP resource of your instrument previously configured in this tutorial.
  3. Run the VI.

For more information on VISA functions, refer to LabVIEW Help: VISA VIs and Functions.

Back to Top

9. Related Links

More Ethernet Resources

Other Instrument Control Tutorials

Back to Top

Customer Reviews
5 Reviews | Submit your review

VISA/ethernet control in OSX?  - Nov 2, 2010

Is it possible to control an ethernet device with NI-VISA in Apple OSX? I see LOADS of Windows examples; no OSX examples.

VISA libraries required for comms with a serial device via RS232-ENET box?  - Feb 11, 2009

Should software that controlled the device with a direct serial connection have to be modified to use VISA in order for the software control to work?

UDP format question  - Apr 21, 2008

Can I use UDP for ethernet communication or must I add TCP/IP protocols to the UDP protocol? Can you specify the UDP protocol required by the cRIO to communicate via ethernet to a "network" consisting of a cRIO and a single additional computer? Thanks.

  - Oct 17, 2007

If your instrument is assigned an address via DHCP, you should be able to ping the instrument by name. The response will show the IP address of the device.

  - May 14, 2007

Please add information on how to discover an instrument that is assigned an IP address via DHCP.

View more reviews

Bookmark & Share


Rate this document

Answered Your Question?
Yes No