Exemplo n.º 1
0
vna = Vna()

# log
vna.open_log(log_file)
vna.print_info()

# connect to instrument (no visa)
vna.open_tcp(address)

# alternatively, using pyvisa:
# vna.open('gpib', 20)

# preset and clear errors
vna.clear_status()
vna.preset()
vna.pause()

# create an interesting setup
# to save
ch1 = vna.channel(1)
ch1.start_frequency_Hz = 1.0e9
ch1.stop_frequency_Hz  = 2.0e9
ch1.points             = 401

trc1 = vna.trace('Trc1')
trc1.parameter = 'S11'

index = vna.create_diagram()

name = vna.create_trace()
trc2 = vna.trace(name)
Exemplo n.º 2
0
# Setup for full N-Port calibration with cal unit
vna.write("SENS1:CORR:COLL:AUTO:CONF FNPort,''")

# get cal steps
steps = get_cal_steps(ports, cal_size)
num_steps = len(steps)

# Define each cal step via SCPI
for i in range(1, num_steps + 1):
    step = [str(n) for n in steps[i]]
    step = ",".join(step)
    scpi = "SENS1:CORR:COLL:AUTO:ASS{0}:TPOR {1}".format(i, step)
    vna.write(scpi)

# For each cal step:
# - Make sure vna ports are connected
# - Start measurement
# - Wait until it completes
for i in range(1, num_steps + 1):
    while connections(vna) != steps[i]:
        input('Connect ports {0}'.format(step))
    vna.write("SENS1:CORR:COLL:AUTO:ASS{0}:ACQ".format(i))
    vna.pause(timeout_ms)

# Apply calibration
vna.write("SENS1:CORR:COLL:AUTO:SAVE")

# Close connection
vna.local()
vna.close()
Exemplo n.º 3
0
from rohdeschwarz.instruments.vna import SweepType
import matplotlib.pyplot as plt
import numpy             as np

# Open instrument connection
vna = Vna()
vna.open('TCPIP', '127.0.0.1')

# SCPI command log
vna.open_log("SCPI Command Log.txt")
print_header(vna.log, "Measure with a1", "0.0.1")
vna.print_info()

# Preset
vna.preset()
vna.pause()
vna.clear_status()

# Setup channel 1
ch1                 = vna.channel(1)
ch1.sweep_type      = SweepType.power
ch1.start_power_dBm = -20.0
ch1.stop_power_dBm  = 0
ch1.points          = 201
ch1.if_bw_Hz        = 1, 'kilo'
ch1.cal_group       = 'example'
ch1.manual_sweep    = True

# Setup Trc1: S21
s21_trace           = vna.trace('Trc1')
s21_trace.parameter = 'S21'
Exemplo n.º 4
0
# Temp dir for cal data
vna.file.cd(Directory.default)
temp_dir = PureWindowsPath(vna.file.directory()) / 'CAL_UNIT_DATA'
if vna.file.is_directory(temp_dir):
    vna.file.delete_all(temp_dir)
else:
    vna.file.mkdir(temp_dir)
vna.file.cd(str(temp_dir))

# Export factory cal data files
# from cal unit to VNA,
# download to local computer
dest_dir = Path('.') / 'data'
vna.cal_unit().export_factory_cal(str(temp_dir))
vna.pause(10000)
for i in vna.file.files():
    src = str(temp_dir / i)
    dest = str(dest_dir / i)
    vna.file.download_file(src, dest)

# Read data.
# Data file naming convention:
open_filename = 'CalibrationUnit Open (P{0}).s1p'
short_filename = 'CalibrationUnit Short (P{0}).s1p'
match_filename = 'CalibrationUnit Match (P{0}).s1p'
thru_filename = 'CalibrationUnit Through (P{0}P{1}).s2p'

# Read port 1
# open, short, match
# format is complex (re + j*im)
scpi = "SENS{0}:CORR:COLL:FIXT:LMP {1}";
scpi = scpi.format(channel, direct_comp)
vna.write(scpi)

# include loss compensation
#   This setting is overridden if direct compensation
#   is on
scpi = "SENS{0}:CORR:COLL:FIXT:LMP:LOSS {1}";
scpi = scpi.format(channel, include_loss)
vna.write(scpi)

# Measure a standard (short) at all ports
scpi = "SENS{0}:CORR:COLL:FIXT:ACQ {1},{2}"
scpi = scpi.format(channel, standard, ports_string)
vna.write(scpi)
vna.pause(10000) # wait for 10 s

# Optional:
#   Can also measure another standard.
#   The VNA will use the average of both
#   results
standard = "OPEN"
scpi = "SENS{0}:CORR:COLL:FIXT:ACQ {1},{2}"
scpi = scpi.format(channel, standard, ports_string)
vna.write(scpi)
vna.pause(10000) # wait for 10 s

# Apply corrections
scpi = "SENS{0}:CORR:COLL:FIXT:SAVE"
scpi = scpi.format(channel)
vna.write(scpi)