Exemplo n.º 1
0
def do_measure():
    channel = VnaChannel("","", 1)
    channel.reset()
    channel.set_sweep_type(SweepType.LINEAR)
    channel.set_center_span(1E9, 5E6)
    channel.set_points(21)
    channel.set_traces(2)
    channel.set_sparam(1, SParameters.S11)
    channel.activate_trace(1)
    channel.turn_on()
    channel.trigger()
Exemplo n.º 2
0
def VnaMeasure(ui, ip, port):
    # Disable button after click

    ui.measure_vna.setEnabled(False)
    ui.left_button.setEnabled(False)
    ui.right_button.setEnabled(False)

    channel = VnaChannel(ip, port, 1) # One channel
    # channel.reset()
    channel.set_four_channels()
    sdata = [] # Clean sdata for each measure
    for idx, spar in enumerate([SParameters.S11, SParameters.S12, SParameters.S21, SParameters.S22]):
        print "Now measuring: " + str(spar)
        channel.set_sweep_type(SweepType.LINEAR)
        channel.channel = idx + 1
        points = str(ui.points_field.text())
        fmat = DataFormat.LOG # By default we use MLOG
        fmat_index = ui.format_combobox.currentIndex()
        formats = [DataFormat.LOG, 
                   DataFormat.LIN, 
                   DataFormat.LIN_PHASE, 
                   DataFormat.PHASE, 
                   DataFormat.GDELAY, 
                   DataFormat.SMITH_LIN_PHASE, 
                   DataFormat.SMITH_LOG_PHASE, 
                   DataFormat.SMITH_RE_IM, 
                   DataFormat.SMITH_R_JX, 
                   DataFormat.SMITH_G_JB]

        fmat = formats[fmat_index]
        
        if ui.center_span_radio.isChecked():
            groupbox = ui.bottom_layout.itemAt(3).widget()
            center_freq = float(groupbox.findChild(QtGui.QLineEdit, "center_field").text())
            span_freq = float(groupbox.findChild(QtGui.QLineEdit, "span_field").text())
            channel.set_center_span(center_freq, span_freq)
            channel.set_traces(1)
            channel.set_points(points)
            channel.set_sparam(1, spar)
            channel.set_format(fmat) # set the selected format
            channel.activate_channel()
            channel.activate_trace(1)
            channel.set_continuous(True)
            
        elif ui.start_stop_radio.isChecked():
            groupbox = ui.bottom_layout.itemAt(3).widget()
            freq_start = float(groupbox.findChild(QtGui.QLineEdit, "freqstart_field").text())
            freq_stop = float(groupbox.findChild(QtGui.QLineEdit, "freqstop_field").text())
            channel.set_start_stop(freq_start, freq_stop)
            channel.set_traces(1)
            channel.set_points(points)
            channel.set_sparam(1, spar)
            channel.set_format(fmat) # set the selected format
            channel.activate_channel()
            channel.activate_trace(1)
            channel.set_continuous(True)

        if ui.autoscale_checkbox.isChecked():
            channel.auto_scale() # Autoscale

        f = str(ui.vna_file_field.text())
        
        retrieve_data(ip, port, f, fmat, channel.executor)
    
    for ch, sparam in zip([1,2,3,4], [SParameters.S11, SParameters.S12, SParameters.S21, SParameters.S22]):
        channel.channel = ch
        channel.set_sparam(1, sparam)

    channel.channel = 1
    channel.executor.close()
    
    # Reenable buttons once measure has finished

    ui.measure_vna.setEnabled(True)
    ui.left_button.setEnabled(True)
    ui.right_button.setEnabled(True)
Exemplo n.º 3
0
def VnaMeasureSingle(ui, ip, port):
    ui.measure_vna.setEnabled(False)
    ui.left_button.setEnabled(False)
    ui.right_button.setEnabled(False)

    channel = VnaChannel(ip, port, 1) # One channel
    # channel.reset()
    channel.set_sweep_type(SweepType.LINEAR)
    if ui.s11_radio.isChecked():
        spar = SParameters.S11
    elif ui.s12_radio.isChecked():
        spar = SParameters.S12
    elif ui.s21_radio.isChecked():
        spar = SParameters.S21
    elif ui.s22_radio.isChecked():
        spar = SParameters.S22
    points = str(ui.points_field.text())
    fmat = DataFormat.LOG # By default we use MLOG
    fmat_index = ui.format_combobox.currentIndex()
    formats = [DataFormat.LOG, 
               DataFormat.LIN, 
               DataFormat.LIN_PHASE, 
               DataFormat.PHASE, 
               DataFormat.GDELAY, 
               DataFormat.SMITH_LIN_PHASE, 
               DataFormat.SMITH_LOG_PHASE, 
               DataFormat.SMITH_RE_IM, 
               DataFormat.SMITH_R_JX, 
               DataFormat.SMITH_G_JB]

    fmat = formats[fmat_index]
    channel.set_one_channel()
    if ui.center_span_radio.isChecked():
        groupbox = ui.bottom_layout.itemAt(3).widget()
        center_freq = float(groupbox.findChild(QtGui.QLineEdit, "center_field").text())
        span_freq = float(groupbox.findChild(QtGui.QLineEdit, "span_field").text())
        channel.set_center_span(center_freq, span_freq)
        channel.set_traces(1)
        channel.set_points(points)
        channel.set_sparam(1, spar)
        channel.set_format(fmat) # set the selected format
        channel.activate_channel()
        channel.activate_trace(1)
        channel.set_continuous(True)
        
    elif ui.start_stop_radio.isChecked():
        groupbox = ui.bottom_layout.itemAt(3).widget()
        freq_start = float(groupbox.findChild(QtGui.QLineEdit, "freqstart_field").text())
        freq_stop = float(groupbox.findChild(QtGui.QLineEdit, "freqstop_field").text())
        channel.set_start_stop(freq_start, freq_stop)
        channel.set_traces(1)
        channel.set_points(points)
        channel.set_sparam(1, spar)
        channel.set_format(fmat) # set the selected format
        channel.activate_channel()
        channel.activate_trace(1)
        channel.set_continuous(True)

    if ui.autoscale_checkbox.isChecked():
        channel.auto_scale() # Autoscale

    f = str(ui.vna_file_field.text())
    channel.executor.close()
    # Reenable buttons once measure has finished
    ui.measure_vna.setEnabled(True)
    ui.left_button.setEnabled(True)
    ui.right_button.setEnabled(True)

    thread.start_new_thread(retrieve_data_single, (ip, port, f))
Exemplo n.º 4
0
def con_alt_measure(smu_params, vna_params, delay, conn_keithley, conn_vna):
    points = smu_params["steps"]
    sweep_time = delay*points
    # Prepare K4200 to measure 
    params.append(smu_params)
    params.append(vna_params)
    ch = smu_params["index"] + 1
    if smu_params["mode"] == "voltage":
        source_mode = SourceMode.VOLTAGE
        source_type = SourceType.VOLTAGE

    if smu_params["mode"] == "current":
        source_mode = SourceMode.CURRENT
        source_type = SourceType.CURRENT

    start = smu_params["start"]
    stop = smu_params["stop"]
    step = smu_params["step"]
    compliance = smu_params["compliance"]
    sweep_type = SweepType.LINEAR # Always linear.

    smu = SMUSweep(ch, source_mode, source_type, start, stop, step, 
            compliance, sweep_type, 'V%s' % ch, "I%s"%ch)
    
    device = K4200(conn_keithley[0], conn_keithley[1])
    device.attach(smu)
    device.configure()
    device.executor.execute_command("SS DT {time}".format(time=delay))
    # device.executor.execute_command("SS HT {time}".format(time=2.2))

    # Prepare VNA to measure

    vna = VnaChannel(conn_vna[0], conn_vna[1], 1)
    vna.set_four_channels()
    vna.set_bus_trigger()

    def measure_vna(vna):
        vlock.acquire()    
        vna.trigger()
        vlock.release()

    def measure_keithley(keithley):
        klock.acquire()
        keithley.measure()
        klock.release()

    for i in range(1,5): # Measure using four channels, once per S parameter
        vna.channel = i
        vna.set_continuous(False)
        vna.set_immediate()
        vna.activate_channel()
        vna.set_traces(1)
        vna.activate_trace(1)
        vna.set_points(points)
        vna.set_format(vna_params["format"])
        vna.set_sparam(1, i) # Assign S11 to ch1, S12 to ch2, S21 to ch3 and S22 to ch4
        vna.set_sweep_time(sweep_time)

        if vna_params["type"] == "center_span":
            vna.set_center_span(vna_params["freq_center"], vna_params["freq_span"])
        elif vna_params["type"] == "start_stop":
            vna.set_center_span(vna_params["freq_start"], vna_params["freq_stop"])

    # Run in different threads to ensure start at the same time
    start_new_thread(measure_vna, (vna,))
    start_new_thread(measure_keithley, (device,))
    start_new_thread(check_vna, (vna,vna_params))
    start_new_thread(check_keithley, (device,smu_params))