:DATA Subsystem

Flex Apps:
FlexPLL

FlexPLL's :DATA (Data) subsystem allows you to return the X and Y data points as well as the total number of points for a displayed plot. The plot can be a Response, Response (Model), Memory, or Memory (Model) plot.

Returning Response and Memory Data

Use the :DATA:SOURce command to select the Response or Memory plot for which you want to return data. A Response and Memory plot must be displayed before you can return data for the plot. Use the following :RESPonse subsystem command to display Response plots:

Use the following :RMEMory subsystem commands to display Memory plots:

Use the :DATA:POINts command to return the number of data points in the selected plot.

Use the :DATA:STATus? query to determine the validity of the plot data.

To return Response or Memory plot values in ASCii, use:

To return Response or Memory plot values in double floats, use:

Returning Response (Model) and Memory (Model) Data

Use the :DATA:PLLModel:SOURce command to select the model plot for which you want to return data. A Response (Model) and Memory (Model) plot must be displayed before you can return data for the plot. Use the following :RESPonse subsystem commands to display Response Model plots:

Use the following :RMEMory subsystem commands to display Memory Model plots:

Use the :DATA:PLLModel:POINts command to return the number of data points in the selected plot.

Use the :DATA:PLLModel:STATus? query to determine the validity of the plot data.

To return Response or Memory plot values in ASCii, use:

To return Response or Memory plot values in double floats, use:

ASCII Data Example Program

The following Python program returns ASCii x and y data values for the JTF plot in Memory 1. The x and y values are displayed for each data point.

Copy

model_JTF_ascii_transfer.py

# -*- coding: utf-8 -*-
""" This script transfers Memory 1 (Model) ASCII JTF data from the FlexPLL
application. The source is response memory 1.
The data is returned in binary format using ':DATA:PLLModel:ASCii:XDATa?' and
':DATAPLLModel:ASCii:XDATa?'. """

import pyvisa as visa  # import VISA library

ADDRESS = 'TCPIP0::localhost::hislip1,4880::INSTR'


def open_flexpll_connection(address):
    """ Opens visa connection to FlexPLL. """
    print('Connecting to FlexPLL ...')
    try:
        rm = visa.ResourceManager()
        connection = rm.open_resource(address)
        connection.timeout = 20000  # Set connection timeout to 20s
        connection.read_termination = '\n'
        connection.write_termination = '\n'
        inst_id = connection.query('*IDN?')
        print('\nFlexPLL connection established to:\n' + inst_id, flush=True)
    except (visa.VisaIOError, visa.InvalidSession):
        print('\nVISA ERROR: Cannot open instrument address.\n', flush=True)
        return None
    except Exception as other:
        print('\nVISA ERROR: Cannot connect to instrument:', other, flush=True)
        print('\n')
        return None
    return connection


def get_data_points(FlexPLL):
    """ Returns ASCii x and y data for response memory.
    """
    xdata = []
    ydata = []
    FlexPLL.write(':DATA:PLLModel:SOURce JTF1')
    points = FlexPLL.query(':DATA:PLLModel:POINts?')
    xdata = FlexPLL.query(':DATA:PLLModel:ASCii:XDATa?').split(',')
    ydata = FlexPLL.query(':DATA:PLLModel:ASCii:YDATa?').split(',')
    xypoints = list(zip(xdata, ydata))
    return points, xypoints


FlexPLL = open_flexpll_connection(ADDRESS)
points, xypoints = get_data_points(FlexPLL)
print('\n\nLength of JTF Response data: {0:s} points.\n'.format(points))
for i, point in enumerate(xypoints, 1):
    print('{0:d}. x = {1:s} Hz, y = {2:s} dB'.format(i, point[0], point[1]))
FlexPLL.write(':SYSTem:GTLocal')
FlexPLL.close()

Binary Data Example Program

The following Python program returns binary x and y data values (doubles) for the Model JTF plot in Memory 1. The x and y values are displayed for each data point. Notice that FlexPLL's current byte order (endianness) setting is saved, set to little-endian for the script, and then restored to FlexPLL's original setting.

Copy

memory1_JTF_binary_transfer.py

# -*- coding: utf-8 -*-
""" This script transfers Memory 1 (Model) binary JTF dat from the FlexPLL
application. The data is returned in binary format using
':DATA:PLLModel:DOUBle:XDATa?' and ':DATA:PLLModel:DOUBle:XDATa?'.
Requires that JTF plots for Response Memory 1 must be displayed before
script is run. """

import pyvisa as visa  # import VISA library

ADDRESS = 'TCPIP0::localhost::hislip1,4880::INSTR'


def open_flexpll_connection(address):
    """ Opens visa connection to FlexPLL. """
    print('Connecting to FlexPLL ...')
    try:
        rm = visa.ResourceManager()
        connection = rm.open_resource(address)
        connection.timeout = 20000  # Set connection timeout to 20s
        connection.read_termination = '\n'
        connection.write_termination = '\n'
        inst_id = connection.query('*IDN?')
        print('\nFlexPLL connection established to:\n' + inst_id, flush=True)
    except (visa.VisaIOError, visa.InvalidSession):
        print('\nVISA ERROR: Cannot open instrument address.\n', flush=True)
        return None
    except Exception as other:
        print('\nVISA ERROR: Cannot connect to instrument:', other, flush=True)
        print('\n')
        return None
    return connection


def get_data_points():
    """ Returns binary x and y data for response memory. """
    global FlexPLL
    xdata = []
    ydata = []
    FlexPLL.write(':DATA:PLLModel:SOURce JTF1')
    points = int(FlexPLL.query(':DATA:PLLModel:POINts?'))
    endiansetting = FlexPLL.query(':SYSTem:BORDER?')
    FlexPLL.write(':SYSTem:BORDER LENDian')
    FlexPLL.read_termination = ''
    FlexPLL.write_termination = ''
    command = ':DATA:PLLModel:DOUBle:XDATa?'
    xdata = FlexPLL.query_binary_values(command, datatype='d', container=list, is_big_endian=False, header_fmt='ieee')
    command = ':DATA:PLLModel:DOUBle:YDATa?'
    ydata = FlexPLL.query_binary_values(command, datatype='d', container=list, is_big_endian=False, header_fmt='ieee')
    FlexPLL.read_termination = '\n'
    FlexPLL.write_termination = '\n'
    FlexPLL.write(':SYSTem:BORDER ' + endiansetting)
    xypoints = list(zip(xdata, ydata))
    return points, xypoints


FlexPLL = open_flexpll_connection(ADDRESS)
points, xypoints = get_data_points()
print('\n\nLength of JTF Response data: {0:d} points.\n'.format(points))
for i, point in enumerate(xypoints, 1):
    print('{0:d}. x = {1:e} Hz, y = {2:f} dB'.format(i, point[0], point[1]))
FlexPLL.write(':SYSTem:GTLocal')
FlexPLL.close()