# Create measurement boundaries and number of points
# I found these commands in the integration tests, so they should fit
# reminder: explicit is better than implicit
vna.cmd(":DEV:MODE VNA") # other modes are possible!
vna.cmd(":VNA:SWEEP FREQUENCY") # other valid value: POWER is possible!
vna.cmd(":VNA:STIM:LVL -10") # -10 dBm is default, more or less, see manual
vna.cmd(":VNA:ACQ:IFBW 10000") # IFBW wtf is that=
vna.cmd(":VNA:ACQ:AVG 1") # more than 1 measurement possible for every value
vna.cmd(":VNA:ACQ:POINTS 501") # maximum is 4501 !
# 500000000 == 500.000.000 just to find the size ;-)
vna.cmd(":VNA:FREQuency:START 500000000") # always in Hertz, here 0.5 GHz
vna.cmd(":VNA:FREQuency:STOP 1500000000") # always in Hertz, here 1.5 GHz
#vna.cmd(":VNA:FREQuency:ZERO 1500000000") ???
#
# Create the calibrations measurements.
# This is necessary because the GUI starts with no calibration measurements by default.
# In case the GUI was already running, we clear the calibration measurements first.
vna.cmd("VNA:CAL:RESET")
vna.cmd("VNA:CAL:ADD OPEN")
vna.cmd("VNA:CAL:ADD SHORT")
vna.cmd("VNA:CAL:ADD LOAD")
vna.cmd("VNA:CAL:ADD OPEN")
vna.cmd("VNA:CAL:ADD SHORT")
vna.cmd("VNA:CAL:ADD LOAD")
vna.cmd("VNA:CAL:ADD THROUGH")
# Set all three measurements to port 1 (just for clarity, 1 is already the default value)
vna.cmd("VNA:CAL:PORT 0 1")
vna.cmd("VNA:CAL:PORT 1 1")
vna.cmd("VNA:CAL:PORT 2 1")
vna.cmd("VNA:CAL:PORT 3 2")
vna.cmd("VNA:CAL:PORT 4 2")
vna.cmd("VNA:CAL:PORT 5 2")
vna.cmd("VNA:CAL:PORT 6 1 2")
def take_measurement(vna, cal_num):
# start the measurement
vna.cmd("VNA:CAL:MEAS "+str(cal_num))
# wait for the measurement to complete
while vna.query(":VNA:CAL:BUSY?") == "TRUE":
time.sleep(0.1)