Telonic TEST

Category: Knowledge Base SDS2000X-E Series

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

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

    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

  • Programming Example: List connected VISA compatible resources using PyVISA

    Programming Example: List connected VISA compatible resources using PyVISA

    PyVISA is a software library that enables Python applications to communicate with resources (typically instruments) connected to a controlling computer using different buses, including: GPIB, RS-232, LAN, and USB.

    This example scans and lists the available resources.

    It requires PyVISA to be installed (see the PyVISA documentation for more information)

    ***

    #Example that scans a computer for connected instruments that
    #are compatible with the VISA communication protocol.
    #
    #The instrument VISA resource ID for each compatible instrument
    #is then listed.
    #
    #
    #Dependencies:
    #Python 3.4 32 bit
    #PyVisa 1.7
    #
    #Rev 1: 08302018 JC

    import visa

    def main():

    rm = visa.ResourceManager()
    print (rm.list_resources())

    if __name__==’__main__’:

    main()

    *****

    Here is the code:

    And here is the result of a scan:

    Each connected instrument returns a specific formatted string of characters called the VISA Resource ID.

    The resource ID format is as follows:

    ‘Communication/Board Type (USB, GPIB, etc.)::Resource Information (Vendor ID, Product ID, Serial Number, IP address, etc..)::Resource Type’

    In the response, each resource is separated by a comma. So, we have three resources listed in this example:

    ‘USB0::0x0483::0x7540::SPD3XGB4150080::INSTR’ – This is a power supply (SPD3X) connected via USB (USB0)

    ‘USB0::0xF4EC::0x1301::SVA1XEAX2R0073::INSTR’ – This is a vector network analyzer (SVA1X) connected via USB (USB0)

    ‘TCPIP0::192.168.55.122::inst0::INSTR’ – This is an instrument connected via LAN using a TCPIP connection at IP address 192.168.55.122

  • Programming Example: SDS Oscilloscope screen image capture using Python

    Programming Example: SDS Oscilloscope screen image capture using Python

    Here is a brief code example written in Python 3.4 that uses a socket to pull a display image (screenshot) from a SIGLENT SDS1000X-E scope via LAN and save it to the local drive of the controlling computer.

    NOTE: This program saves the picture/display image file in the same directory that the .py file is being run from. It will overwrite any existing file that has the same name.

    Download Python 3.4, connect a scope to the LAN using an Ethernet cable, get the scope IP address, and run the attached .PY program to save a bitmap (BMP) image of the oscilloscope display.

    You can download the .PY file here: Python_Socket_SDS_SCDP.zip

    Tested with:

    Python 3.4
    SDS1202X-E
    SDS1104/1204X-E
    SDS2000X-E Models
    SDS5000X Models