Programming Example: Using VXI11 (LXI) and Python for LAN control without sockets

Posted on: December 14th, 2020 by Doug Lovell

In an effort to meet the demands of remote monitoring and control, modern test instrumentation is leveraging more communications busses and than ever before. Each type of bus can also have numerous layers that can be utilized for specific advantages.

The VXI bus and subsequent software drivers form a convenient software API that can make remote control of instrumentation over LAN quite simple. In fact, it forms the basis of the TCPIP communications used in LXI format that is being implemented across the industry.

For more info on VXI, you can check out the VXI Consortium

VXI has a small installation size and is quite flexible.. especially when compared to VISA based applications. VISA is convenient and does allow for easy bus changes (from GPIB to USB with just a few lines of code), but it is also a large installation that isn’t always easy to use on machines that are not running Windows.

VXI has many flavors.. and can be used with many OS’ and can be used on many instruments that do not have “open sockets” on their LAN connection.

Here is a list of SIGLENT products that have LAN but do not have open sockets:

SDS2000

SDS2000X

SDS1000X/X+

SPD3000X/XE

In this note, we are going to show how to use VXI-11 with Python to control an instrument. This can be used with traditional OS’ like Windows but offer even more when coupled with Linux variants like those running on Rasberry Pis and other single board computers (SBCs).

 

Configuration

First, you will need to download a few programs..

  • Python: https://www.python.org/downloads/release/python-2714/

NOTE: This technique works with version 2.x and 3.x.. in this example, we will use Python 2.7.14 for Windows 64 bit OS’

  • Python VXI-11: https://github.com/alexforencich/python-vxi11

Once downloaded, you can add VXI-11 to your Python instance..

  1. Open the command line program in Windows. You can find it by searching for “CMD” or by going to the Start Menu >  Windows System > Command Prompt as shown here:

2. In another window, find the location of the Python VXI-11 folder that was downloaded previously and find the path for setup.py. In this case, the path on my PC is shown as:

Now, you can click on the “address” to open the exact path:

Here, I suggest opening Notepad and “copy-paste” the path. It will make the transfer easier:

3. Change the directory in the Command line program to match the path from step 2:

Type “cd <PATH>” as shown:

4. Now, the directory has changed to match the path. You can run the setup.py file by typing “python setup.py install” as shown:

5. Close the Command Prompt

Test the installation

Now that everything has been installed, let’s test the communications link.

  1. Connect the instrument to the LAN of the controlling computer and power it on

2. Check the IP address for the product (see the User’s Guide of the specific product for more info), In this case, I am using an SDS2000X oscilloscope. Here is the IP address information:

3. Now, start the Python shell. There are a few ways to start this application. In this case, you can find the Python folder in the Windows start folder.

Open IDLE (A Python GUI):

Now, click Run > Python Shell to open the shell:

4. Now, import the VXI11 library by typing “import vxi11”

5. Now, we can assign the variable “instr” to the instrument as shown:

6. Now, we can use the VXI Ask command to send the identification string (*IDN?), request the response, and print it to the screen:

The VXI11 library features a number of functions to handle writing and reading strings and other formats. You can use this technique to establish communications and control the instrument efficiently.

 

Click here to download a Python file of this example: PythonVXI11_IDN