# C# Remote control protcol ４　LXI

2020年9月9日

This blog introduces measuring instrument + programming technology. So far, I have introduced how to program serial, GPIB and USB connections.

This article describes LXI (LAN eXtentions for Instrumentation), a LAN communication method.

LXI is a communication standard for measuring instruments established in 2005 by Agilent Technologies (currently Keysight Technologies). GPIB has long been used for communication of measuring instruments, but GPIB connectors occupy a large area on the back panel, making it difficult to mount them on recently miniaturized measuring instruments.

GPIB’s other communication methods include serial and USB, but since they only support one-to-one communication, they were not a substitute for GPIB.

That’s where LXI came in. LXI uses LAN, so it can be distributed at the hub. Also, since the RJ-45 terminal is used, the occupied area is small. Another advantage is that there are no new costs due to the use of popular devices.

Keysight, at the heart of the alliance, has also released a document describing the 10 benefits of LXI.

It was created in 2005 and has been stable for 15 years.

## Think about networks before LXI programs

LXI is a communication protocol, but requires the use of TCP / IP. Before communicating between devices with LXI, you need to build a TCP / IP network. At least the following items must be set on the instrument.

• Fixed IP or DHCP?
• default gateway

For example, connect a PC and a measuring instrument one-to-one. The procedure for a one-to-one connection is the same as creating a small network. If the network address is 10.0.0.0, the PC is 10.0.0.1, and the instrument is 10.0.0.2, make the following settings.

In case of one-to-one connection, communication is possible in principle if the IP address, netmask and gateway are set. Others are blank. However, some devices may not work unless DNS is set in the device specifications.

If you add one measuring instrument and control two measuring instruments with one PC, it will be as follows. The biggest difference is using a hub. In the case of one-to-one, a cross cable was necessary, but in the case of a hub, all straight cables are used.

In this example, IP addresses between 10.0.0.1 and 10.0.0.3 were used, but this value can be anything. 192.168.0.1 is often used for such a subnet.

## LXI communication program in C #

Actually, the communication program of LXI is almost the same as the way of writing GPIB. Recently, the way of writing C # for GPIB has changed, so the way of writing C # for LXI has changed as well. Please refer to the link below for GPIB changes.

In LXI, the address notation at the time of session open is different from that of GPIB. Specifically: The session Open for GPIB communication is described as follows.

//GPIB
MessageBasedSession mbsession = (MessageBasedSession)(new ResourceManager()).Open("GPIB::10::INSTR");


When this is LXI:

//LXI
MessageBasedSession mbsession = (MessageBasedSession)(new ResourceManager()).Open("TCPIP0::10.0.0.2::inst0::INSTR");


The only difference is the .Open (). Changing the program from GPIB to LXI is easier than expected. Sample code for controlling a digital multimeter with LXI is introduced for reference.

## LXI sample code

In the sample, we will make a program that performs measurement only once using Keysight’s 34461A (digital multimeter). First, set the PC address to 10.0.0.1/255.255.255.0.

Next, set the IP address to 10.0.0.2/255.255.255.0 in the IO setting of the 34461A.

The PC and 34461A are connected with a cross LAN cable or a network hub with a straight cable.

Next, the program creates a C # form application in Visual Studio, creates a button (named “buttonStart”) on the form, and writes the code as follows.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NationalInstruments.Visa;

namespace LXIsample
{
public partial class Form1 : Form
{
MessageBasedSession mbsession;

public Form1()
{
InitializeComponent();
}

private void buttonStart_Click(object sender, EventArgs e)
{
mbsession = (MessageBasedSession)(new ResourceManager()).Open("TCPIP0::10.0.0.2::inst0::INSTR");
mbsession.RawIO.Write(":MEAS?");
mbsession.Dispose();
}
}
}



Add the following libraries to Visual Studio Add References: This procedure is the same as GPIB.

• C:Program Files (x86)IVI FoundationVISAMicrosoft.NETFramework32v2.0.50727VISA.NET Shared Components 5.11.0Ivi.Visa.dll
• C:Program Files (x86)IVI FoundationVISAMicrosoft.NETFramework32v4.0.30319NI VISA.NET 19.0NationalInstruments.Visa.dll

Execute the program and press the button. The measured value of the 34461A is displayed on the button.

This sample uses National Instruments (hereafter NI) driver. This is because I always use NI USB-GPIB-HS, a USB GPIB adapter. However, in the case of LXI, this adapter is not used, so you may not need the NI driver.

## Conclusion

This article introduced LXI, a method of instrument communication. The features of LXI are as follows.

• Because the LAN cable is used, it does not occupy the back panel of the measuring instrument.
• Easy cable management.
• One-to-many communication is possible as with GPIB Uses LAN devices so you don’t have to buy expensive equipment.
• You need to set up the network for the measuring instrument before the program.
• LXI C # programs are not much different from GPIB programs.

LXI is now included in most instruments, but may replace GPIB. I will try to use it a little more and check the good points and bad points.