4 S- Parameter Measurement

The following Python program demonstrates how to set up 4 S-Parameter measurement and display it on the VNA screen.

See Also

Python Basics

 

import pyvisa as visa

# Change this variable to the address of your instrument
VISA_ADDRESS = 'TCPIP0::localhost::inst0::INSTR'

# Create a connection (session) to the instrument
resourceManager = visa.ResourceManager()
session = resourceManager.open_resource(VISA_ADDRESS)


session.timeout = 25000

# Command to preset the instrument and deletes the default trace, measurement, and window
session.write("SYST:FPR")

# Create and turn on window 1
session.write("DISP:WIND1:STAT ON")

# ======================== Set up 4 S-Parameters ========================
# Create a S11 measurement
session.write("CALC1:MEAS1:DEF 'S11'")

# Displays measurement 1 in window 1 and assigns the next available trace number to the measurement
session.write("DISP:MEAS1:FEED 1")

# Create a S21 measurement
session.write("CALC1:MEAS2:DEF 'S21'")

# Displays measurement 2 in window 1 and assigns the next available trace number to the measurement
session.write("DISP:MEAS2:FEED 1")

# Create a S12 measurement
session.write("CALC1:MEAS3:DEF 'S12'")

# Displays measurement 3 in window 1 and assigns the next available trace number to the measurement
session.write("DISP:MEAS3:FEED 1")

# Create a S22 measurement
session.write("CALC1:MEAS4:DEF 'S22'")

# Displays measurement 4 in window 1 and assigns the next available trace number to the measurement
session.write("DISP:MEAS4:FEED 1")

# ======================== Set start and stop ========================
session.write("SENS1:FREQ:START 1e9")

session.write("SENS1:FREQ:STOP 2e9")

# ======================== Change the number of points ========================
session.write("SENS1:SWE:POIN 51")

# ======================== Set IFBW ========================
# Set IF Bandwidth to 700 Hz
session.write("SENS1:BAND 700")

# ======================== Take a sweep and read back data ========================
# Perfoms a single sweep
session.write("SENS1:SWE:MODE SING")
opcCode = session.query(
"*OPC?")
results1 = session.query_ascii_values("CALC1:MEAS1:DATA:FDATA?")
results2 = session.query_ascii_values(
"CALC1:MEAS2:DATA:FDATA?")
results3 = session.query_ascii_values(
"CALC1:MEAS3:DATA:FDATA?")
results4 = session.query_ascii_values("CALC1:MEAS4:DATA:FDATA?")