Source Modulation Calibration

The following Python example demonstrates how to perform a source modulation calibration to compensate the IQ data to achieve a flat frequency response in gain and phase at the reference plane..

Note: Traditional S-parameter calibration using Cal All... must be performed before performing a Source Modulation Calibration.

See the Modulation Distortion commands.

See Other SCPI Example Programs

import pyvisa as visa

import time

# Custom Exception class for SCPI Errors

class SCPIError(Exception):

    def __init__(self, ex, *args):

        super().__init__(args)

        self.ex = ex

    # Display the Error Messag

    def __str__(self):

        return f'SCPI errors found in the system: {self.ex}'

# Helper function to check for errors

def catchErr():

    numErrors = session.query("SYST:ERR:COUN?")

    if int(numErrors) != 0:

        raise SCPIError(session.query("SYST:ERR?"))

# Change this variable to the address of your instrument

VISA_ADDRESS = 'TCPIP0::vna_name::hislip0'

# Create a connection (session) to the instrument

resourceManager = visa.ResourceManager()

session = resourceManager.open_resource(VISA_ADDRESS)

session.timeout = 10000 #Set timeout to 10 seconds

# Command to preset the instrument and deletes the default trace, measurement, and window

session.write("SYST:FPR")

# Create Modulation Distortion PIn measurement

session.write("disp:wind1:stat on")

catchErr()

session.write(f"CALC:MEAS:DEF 'PIn1:Modulation Distortion'")

catchErr()

session.write("DISP:MEAS1:FEED 1")

catchErr()

# Create flat top signal

session.write("sour:mod:file:type flat")

catchErr()

session.write("sour:mod:file:sign:srat 200e6")

catchErr()

session.write("sour:mod:file:sign:span 100e6")

catchErr()

session.write("sour:mod:file:sign:span:pri 1")

catchErr()

session.write("sour:mod:file:sign:tone:numb 1001")

catchErr()

session.write("sour:mod:file:sign:tone:numb:pri 1")

catchErr()

session.write("sour:mod:file:save 'C:\\Users\\Public\\Documents\\Network Analyzer\\flat.mdx'")

catchErr()

# Configure Modulation Distortion Measurement to use flat top signal

session.write("sens:DISTortion:MODulate:SOURce 'Port 1'") # Use built in XSB modulation of DDS Source

catchErr()

session.write("SOURce:MODulation:LOAD 'C:\\Users\\Public\\Documents\\Network Analyzer\\flat.mdx'")

catchErr()

session.write("SOUR:MOD:STAT ON")

catchErr()

# Calibrate flattop signal using input reference receiver

session.write("SOUR:MOD:CORR:COLL:POW:REC 'DUTIn1'")

catchErr()

session.write("SOUR:MOD:CORR:COLL:POW:ENAB ON")

catchErr()

session.write("SOUR:MOD:CORR:COLL:FLAT:ENAB ON")

catchErr()

session.write("SOUR:MOD:CORR:COLL:ACQ ASYN")

catchErr()

session.write("*OPC")

catchErr()

res = int(session.query("*STB?"))

# Poll until the calibration is complete

while (res == 0):

        res = int(session.query("*STB?"))

        time.sleep(0.1) # Only check every 100 ms

# Turn on correction

session.write("SOUR:MOD:CORR:STAT ON")

catchErr()

# Output detailed status of the correction

print(session.query("SOUR:MOD:CORR:COLL:ACQ:DET?"))