Skip to content
Snippets Groups Projects
Commit fe244235 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

Fix VNA readings

- Load VNA config (and calibration) from file.
  The *.znxml file has to be prepared in advance and saved on the VNA.
  It needs to set the VNA to CW mode and single sweep.
- Trigger single sweep and wait for it to complete
- Fix trace definitions
parent d27e1c8d
No related branches found
No related tags found
No related merge requests found
...@@ -196,6 +196,40 @@ class Vna: ...@@ -196,6 +196,40 @@ class Vna:
self.vna.write("SYST:PRES; *OPC?") self.vna.write("SYST:PRES; *OPC?")
self.vna.read() self.vna.read()
#Hack: put in the frequency which is configured in the config file to guess if loading was
#successful. FIXME: Do proper error checking here
def load_config(self, config_file, frequency):
"""
Load the config from the VNA's internal drive. It must be in the folder
C:\\Users\\Public\\Documents\\Rohde-Schwarz\\ZNA\\RecallSets\\
Parameters
----------
config_file : str
znxml file with VNA config and calibration. Only the file name without folder.
"""
#Backslashes are escaped. Default path on the ZNA.
directory = 'C:\\Users\\Public\\Documents\\Rohde-Schwarz\\ZNA\\RecallSets\\'
full_path = directory+config_file
#The string has to have single quotes, so we use double quotes to define the string.
self.vna.write("MMEM:LOAD:STAT 1,'"+full_path+"'")
self.vna.query('*OPC?')
#FIXME: raise exception if loading not successful
def do_single_sweep(self):
"""
Start a single sweep and wait until it is done.
Notice: Due to the hard coded timeout of 5 seconds, the sweep must not take longer!
"""
#start measurement
self.vna.write('INIT1')
#wait until finished
self.vna.query('*OPC?')
def close(self): def close(self):
self.vna.close() self.vna.close()
......
...@@ -116,9 +116,10 @@ class VnaDummy: ...@@ -116,9 +116,10 @@ class VnaDummy:
result.append(float(x)) result.append(float(x))
return result return result
def load_config(self, config_file, frequency):
pass
def do_single_sweep(self):
pass
...@@ -42,6 +42,7 @@ class Measurements: ...@@ -42,6 +42,7 @@ class Measurements:
self.max_delta_phase = config_data['delta_phase'] self.max_delta_phase = config_data['delta_phase']
self.sleep_time = config_data["sleep_time"] self.sleep_time = config_data["sleep_time"]
self.frequency = config_data["frequency"] self.frequency = config_data["frequency"]
self.vna_config_file = config_data["vna_config_file"]
target_accuracy = [self.max_delta_temp, self.max_delta_hum] target_accuracy = [self.max_delta_temp, self.max_delta_hum]
self.chamber = climate_chamber.create_chamber(chamber_address, target_accuracy) self.chamber = climate_chamber.create_chamber(chamber_address, target_accuracy)
self.vna = VNA.create_vna(vna_address, target_accuracy) self.vna = VNA.create_vna(vna_address, target_accuracy)
...@@ -54,16 +55,11 @@ class Measurements: ...@@ -54,16 +55,11 @@ class Measurements:
self.magnitude_stable = False self.magnitude_stable = False
self.phase_stable = False self.phase_stable = False
self.vna.load_config(self.vna_config_file, self.frequency)
self.vna.create_new_trace("Trace1", "S11") self.vna.create_new_trace("Trace1", "S11")
self.vna.create_new_trace("Trace2", "S11") self.vna.create_new_trace("Trace2", "S12")
self.vna.create_new_trace("Trace3", "S21") self.vna.create_new_trace("Trace3", "S21")
self.vna.create_new_trace("Trace4", "S21") self.vna.create_new_trace("Trace4", "S22")
self.vna.create_new_trace("Trace5", "A1")
self.vna.create_new_trace("Trace6", "B1")
self.vna.create_new_trace("Trace7", "A2")
self.vna.create_new_trace("Trace8", "B2")
self.vna.set_cw_frequency(self.frequency)
self.vna.set_sweep_mode('CW')
def perform_measurements(self): def perform_measurements(self):
with open(self.output, mode='w', newline='') as csv_file: with open(self.output, mode='w', newline='') as csv_file:
...@@ -194,9 +190,10 @@ class Measurements: ...@@ -194,9 +190,10 @@ class Measurements:
[temp, hum, mode, alarms] = self.chamber.read_monitor().split(',') [temp, hum, mode, alarms] = self.chamber.read_monitor().split(',')
power = self.vna.get_current_power() power = self.vna.get_current_power()
frequency = self.vna.get_current_cw_frequency() frequency = self.vna.get_current_cw_frequency()
self.vna.do_single_sweep()
s11 = self.get_trace_data("Trace1") s11 = self.get_trace_data("Trace1")
s21 = self.get_trace_data("Trace2") s12 = self.get_trace_data("Trace2")
s12 = self.get_trace_data("Trace3") s21 = self.get_trace_data("Trace3")
s22 = self.get_trace_data("Trace4") s22 = self.get_trace_data("Trace4")
return MeasurementData(int(self.clock.time()), temp, hum, power, frequency, s11, s21, s12, s22) return MeasurementData(int(self.clock.time()), temp, hum, power, frequency, s11, s21, s12, s22)
......
{"delta_temp": 1, "delta_hum": 2, "delta_mag": 0.1 , "delta_phase": 5, "sleep_time": 1.0, "frequency": 1300000000} {"delta_temp": 0.1, "delta_hum": 1, "delta_mag": 0.1 , "delta_phase": 0.02, "sleep_time": 1.0, "frequency": 1300000000, "vna_config_file": "climate-lab.znxml"}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment