Ethernet Instrument Control Tutorial
Overview
This tutorial is meant as a starting point for using NI-VISA to communicate with an Ethernet device. It will provide a brief overview of both NI-VISA and the Ethernet bus followed by a tutorial on setting up an Instrument Control System based on the Ethernet bus architecture. After reading this tutorial, you should be able to install an Ethernet device and use NI-VISA to communicate with that device, as long as you understand the device communication protocol.
Overview of Ethernet and NI-VISA
Ethernet is a mature technology widely used for measurement systems in many capacities including general networking and remote data storage. Ethernet offers an attractive option for instrument control because of its flexibility. With connectivity via Ethernet, you can control your instrument from anywhere on the network to which it is connected. Ethernet, defined by IEEE Standard 802.3, offers network configurations that provide theoretical data transfer rates of 10 Mb/s (10BaseT), 100 Mb/s (100BaseTX), and 1 Gb/s (1000BaseT). One main reason Ethernet has become so popular in instrument control is the fact that most companies and laboratories have existing Ethernet networks available for instrument control. LXI is a new standard built on the Ethernet protocol. It was developed to implement synchronization of distributed instruments.
NI-VISA is a high-level application programming interface (API) used to communicate with instrumentation buses. It is platform independent, bus independent, and environment independent. In other words, the same API is used regardless of whether a program is created to communicate with an Ethernet device with LabVIEW on a machine running Windows 2000 or with a GPIB device with C on a machine running Mac OS X. Starting with version 2.5, NI-VISA offers Ethernet communication. For specific information about the NI-VISA API, refer to the NI-VISA Help.
Configuring NI-VISA to Control Your Ethernet Instrument
This section walks through the steps for configuring your Ethernet-based instrument with NI-VISA on a Windows-based computer. At this point, NI-VISA should already be installed on your computer.
1. Testing the Connection to Your Ethernet Device
Your instrument should be connected to your network. You should also be able to “ping” your device. Do this by following these steps.
a. Open a command prompt (Start->Run, then type in “cmd”) in the Open field and click OK.

b. In the Command Prompt window type “ping xxx.xxx.xxx.xxx:yyyy” and press “Enter” (where xxx.xxx.xxx.xxx is the IP Address of your instrument and yyyy is the port). You may not need to include a port number.

If you get a response like that shown above (with replies coming back), then you are able to communicate to that Ethernet device from your PC and you are ready to start configuring the device in Measurement & Automation Explorer (MAX).
2. Configuring Your Ethernet Device in MAX
At this point NI-MAX should be open with the My System tree expanded. There are two places to add your new Instrument as an NI-VISA resource. One is to select Devices and Interfaces with a left click. You’ll notice a Create New... button at the top of MAX. The other way to go about this is to Right Click on Devices and Interfaces then left click on Create New…

In the Create New window that comes up, select VISA TCP/IP Resource and click Next >.

You will then need to choose either VXI-11 LAN Instrument or Raw Socket. Raw Socket will let you communicate with an Ethernet device over a specific port number. VI-11 LAN Instrument is used for instruments that conform to the VXI-11 LAN Instrument specification. If you’re using a VXI-11 LAN Instrument, you will have the option to search your network for that device or add it by IP address. If you choose Raw socket, you will only have the choice of entering an IP address and port number.
Once you input the required information for your particular instrument, you will then have a new VISA TCP/IP Resource added in MAX. You can use the Communicate with Instrument tool to test the communication with your device. Simply send any command the device should recognize, and see if you get the appropriate response in return. If not, you may have entered the set-up information incorrectly or your instrument may be having some problems. If this does work, you are now prepared to write code that communicates with the instrument using the language of your choice. Please see the tutorials below for help on using NI-VISA in many programming languages.
See Also:
Instrument Control Fundamentals Main Page
Instrument Control Fundamentals Hardware Page
NI-VISA Help
Reader Comments | Submit a comment »
UDP format question
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.
- stephen mcgrath, NAWCWD. stephen.mcgrath@navy.mil - Apr 21, 2008
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.
- Oct 17, 2007
Please add information on how to discover an
instrument that is assigned an IP address via
DHCP.
- May 14, 2007
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
