Exemple #1
0
 def init_vna(self):
     # Abkürzung
     settings = self.config["VNA"]
     
     # Serial-Config
     port = settings["Port"]
     baudrate = int(settings["Baudrate"])
     
     self.vna = VNA(port, baudrate)
     
     # VNA-Settings
     points = int(settings["Points"])
     power = int(settings["Power"])
     average = int(settings["Average"])
     
     self.vna.set_points(points)
     self.vna.set_power(power)
     self.vna.set_avg(average)
     
     self.vna.measurecycles()
Exemple #2
0
def init_vna():
    ref_freq = 40e6

    vna = VNA()

    source_freq = 6.0e9
    lo_freq = source_freq - 2e6

    vna.set_tx_mux('iq', sample_input='adc')

    vna.lo.freq_to_regs(lo_freq, ref_freq, apwr=0)
    vna.source.freq_to_regs(source_freq, ref_freq, apwr=0)

    #vna.dither_en(1)
    #vna.set_tx_mux('samples', sample_input='adc')

    vna.write_sample_time(int(40e6 / 1000 + 100))
    #vna.write_sample_time(110000)
    vna.write_io(pwdn=0, mixer_enable=0, led=1, adc_oe=0, adc_shdn=0)
    vna.write_pll_io(lo_ce=1, source_ce=1, lo_rf=1, source_rf=1)
    vna.write_att(0.0)
    vna.write_switches(tx_filter=source_freq,
                       port=2,
                       rx_sw='rx2',
                       rx_sw_force=False)
    vna.write_pll(vna.source)
    vna.write_pll(vna.lo)
    vna.write_pll(vna.source)
    vna.write_pll(vna.lo)

    vna.read_iq()
    vna.read_iq()
    return vna
def sw_terms(iqs, freqs):
    """Switch terms from IQ"""
    sparams = []

    for f in xrange(len(freqs)):
        sw_f = iqs[f][('rx2',1)]/iqs[f][('b',1)]
        sw_r = iqs[f][('rx1',2)]/iqs[f][('a',2)]
        sparams.append( [[sw_f, 0], [0, sw_r]] )

    return skrf.Network(s=sparams, f=freqs, f_unit='Hz')


ref_freq = 40e6

vna = VNA()

ports = [1, 2]
sw_correction = True

freqs = np.linspace(30e6, 6e9, 801)

vna.set_tx_mux('iq', sample_input='adc')
vna.write_att(7.0)
vna.write_sample_time(int(40e6/1000+100))
vna.write_io(pwdn=0, mixer_enable=0, led=1, adc_oe=0, adc_shdn=0)
vna.write_pll_io(lo_ce=1, source_ce=1, lo_rf=1, source_rf=1)
iqs = [{} for i in xrange(len(freqs))]

time.sleep(0.5)
Exemple #4
0
class Stoerkoerpermessung:
    def __init__(self, config, filename):
        # Config auslesen
        self.config_filename = config
        self.config = ConfigParser()
        self.config.read(config)
        
        self.out_filename = filename
        
        self.init_motor()
        self.init_vna()
        
    def init_motor(self):
        # Abkürzung
        settings = self.config["MOTOR"]
        
        # Serial-Config
        port = settings["Port"]
        baudrate = int(settings["Baudrate"])
        serial_timeout = float(settings["SerialTimeout"])
        
        self.motor_serial = Serial(port, baudrate, timeout=serial_timeout)
        
        # Motor-Config
        motor_name = settings["Name"]
        motor_config = settings["Config"]
        
        self.motor = Motor(self.motor_serial, motor_name)
        self.motor.load_motor_config(motor_config)
        self.motor.scaling = float(settings["Scaling"])
    
    def init_vna(self):
        # Abkürzung
        settings = self.config["VNA"]
        
        # Serial-Config
        port = settings["Port"]
        baudrate = int(settings["Baudrate"])
        
        self.vna = VNA(port, baudrate)
        
        # VNA-Settings
        points = int(settings["Points"])
        power = int(settings["Power"])
        average = int(settings["Average"])
        
        self.vna.set_points(points)
        self.vna.set_power(power)
        self.vna.set_avg(average)
        
        self.vna.measurecycles()
    
    def measure(self):
        #Abkürzung
        settings = self.config["MEASUREMENT"]
        
        start = float(settings["Start"])
        stop = float(settings["Stop"])
        
        # Checkmode Settings
        checkmode = settings.getboolean("Checkmode")
        cm_reference = float(settings["ReferencePoint"])
        
        if start > stop:
            start, stop = stop, start
        
        # Überprüfung welche Methode der Berechnung der stepsize gewählt wurde.
        # Entweder aus der Anzahl der Schritte oder mit fester angegebener step-
        # size
        if not (("StepSize" in settings) ^ ("Steps" in settings)):
            raise RuntimeError("StepSize and Steps in configuration file are"
                               "mutually exclusive")
        elif "StepSize" in settings:
            stepsize = float(settings["StepSize"])
        else:
            steps = int(settings["Steps"])
            stepsize = (stop - start) / steps
        
        
        with open(self.out_filename, "w") as outf:
            # Tabellenkopf
            print("# Config: {}".format(self.config_filename), file=outf)
            print("# Date: {}".format(asctime()), file=outf)
            print("# Center: {}".format(self.vna.get_center()), file=outf)
            print("# Span: {}".format(self.vna.get_span()), file=outf)
            print("# Points: {}".format(self.vna.get_points()), file=outf)
            
            if checkmode:
                print("# P\tf\tf_ref\tfreq-t_ref", file=outf)
            else:
                print("# P\tf", file=outf)
            
            pos = start
            while stop - pos > -1E-6:
                print("Measuring: d = {} mm".format(pos))
                
                if checkmode:
                    f_ref = self.get_freq_at(cm_reference)
                freq = self.get_freq_at(pos)
                
                if checkmode:
                    print("{0:.3f}\t{1}\t{2}\t{3}".format(pos, freq, f_ref, freq - f_ref),
                          file=outf)
                else:
                    print("{0:.3f}\t{1}".format(pos, freq), file=outf)
                
                pos += stepsize
                outf.flush()
        self.motor.move_to(start)
        
        
    def get_freq_at(self, pos):
        delay = float(self.config["MEASUREMENT"]["Delay"])
        average = int(self.config["VNA"]["Average"])
        
        self.motor.move_to(pos)
        while self.motor.is_moving():
            sleep(0.1)
        sleep(delay)
        self.vna.measurecycles()
        freq, refl = self.vna.mark[1].search_min()
        
        return freq