channel = 1 ports_string = "1,2,3,4" touchstone_filename = "ch1_data.s4p" # For trace data: trace_name = "Trc1" trace_filename = "Trc1.csv" # Indicate which ports you want to # capture data for before starting sweep # Note: This must be done for each channel # Using channel 1 for illustrative purposes: channel = 1 scpi = ":CALC{0}:PAR:DEF:SGR {1}" scpi = scpi.format(channel, ports_string) vna.write(scpi) # Enable manual sweep mode # (i.e. control timing) vna.write("INIT:CONT:ALL 0") # Start all sweeps vna.write("INIT:SCOP ALL") vna.write("INIT") # Wait for sweeps to finish # Note: Make sure timeout is long # enough for sweeps to complete vna.query("*OPC?") # Save touchstone file to vna
import os # Connect vna = Vna() vna.open_tcp() channel = 1 ports = range(1, 5) # Ports 1-4 filename = "test.s2p" # s2p file must exist locally on VNA for port in ports: # Set deembed model to touchstone file scpi = "CALC{0}:TRAN:VNET:SEND:DEEM{1}:TND FIMP" scpi = scpi.format(channel, port) vna.write(scpi) ## Option a: ## Set via touchstone file on VNA # scpi = "MMEM:LOAD:VNET{0}:SEND:DEEM{1} '{2}'" # scpi = scpi.format(channel, port, filename) # vna.write(scpi) # Option b: # Set via data transfer data = open(filename, 'rb').read() size_str = str(len(data)) header = "#{0}{1}".format(len(size_str), size_str) scpi = "CALC{0}:TRAN:VNET:SEND:DEEM{1}:PAR:DATA FPOR,{2}{3}" scpi = scpi.format(channel, port, header, data) vna.write(scpi)
from rohdeschwarz.instruments.vna import Vna # Connect vna = Vna() vna.open_tcp() temp_filename = 'temp.png' local_filename = 'screenshot.png' # Set temporary file name to # save to (on vna) scpi = ":MMEM:NAME '{0}'" scpi = scpi.format(temp_filename) vna.write(scpi) # Set format # Options include: # - BMP # - PNG # - JPG # - PDF # - SVG vna.write(":HCOP:DEV:LANG PNG") # Set contents of screenshot # to entire screen vna.write(":HCOP:PAGE:WIND HARD") # - OR ------------------------- # Set active diagram # Unfortunately there isn't an
# Provide this information: ip_address = '127.0.0.1' timeout_ms = 5 * 60 * 1000 # 5 mins ports = range(1, 21) # VNA Ports 1-20 cal_size = 8 # Cal unit is 8 ports # Assuming channel 1 ('SENS1') # for simplicity's sake # Connect to VNA vna = Vna() vna.open_tcp(ip_address) # Delete any previously defined cal steps vna.write("SENS1:CORR:COLL:AUTO:ASS:DEL:ALL") # 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)
#!/usr/bin/env python from rohdeschwarz.instruments.vna import Vna # Connect vna = Vna() vna.open_tcp() # Applying example in channel 1 channel = 1 # Load cal group # Assuming cal group called "my_cal_group" # cal group files have .cal extension cal_group = "my_cal_group.cal"; scpi = ":MMEM:LOAD:CORR {0}, '{1}'" scpi = scpi.format(channel, cal_group) vna.write(scpi); vna.pause() # Saving a calibration to a cal group new_cal_group = "my_new_cal.cal" scpi = ":MMEM:STOR:CORR {0}, '{1}'" scpi = scpi.format(channel, new_cal_group) vna.write(scpi); vna.pause() vna.close()