Channels, Windows, and Measurements using SCPI


This Python program does the following:

The following notes explain the basic structure of the SCPI tree on the analyzer:

See Also

Python Basics

Traces, Channels, and Windows on the Analyzer

See Other SCPI Example Programs

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)

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

# Create measurements in two different channels
session.write("CALC1:MEAS1:DEF 'S11'")
session.write("CALC2:MEAS2:DEF 'S21'")

# Turn on 2 windows
session.write("DISP:WIND1:STAT ON")
session.write("DISP:WIND2:STAT ON")

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

# Change each channel's frequency span
session.write("SENS1:FREQ:SPAN 1e9")
session.write("SENS2:FREQ:SPAN 2e9")

# Turn marker 1 ON for measurement 1 and measurement 2
session.write("CALC1:MEAS1:MARK1:STAT ON")
session.write("CALC2:MEAS2:MARK1:STAT ON")

# Select second measurement as active measurement
session.write("CALC2:PAR:MNUM 2")