Ejemplo n.º 1
0
 def __init__(self, a_min, a_max, a_step, a_unit, a_label=None):
     Frequency_Range.__init__(self, a_min, a_max, a_step, a_unit)
     if a_label is None:
         self.label = None
     elif a_label == "":
         self.label = None
     else:
         self.label = a_label
Ejemplo n.º 2
0
def measure_LNA_spurius(SMB_LO, SMB_RF, FSV, VSCD,
                        synthetizer_LO_state=synthetizer_LO_state,
                        synthetizer_LO_frequency=synthetizer_LO_frequency,
                        synthetizer_LO_level=synthetizer_LO_level,  # dBm
                        synthetizer_RF_state=synthetizer_RF_state,
                        synthetizer_RF_frequency=synthetizer_RF_frequency,
                        synthetizer_RF_level=synthetizer_RF_level,  # dBm
                        downconverter_state=vscd_state,
                        downconverter_frequency=vscd_frequency,
                        downconverter_level=vscd_level,  # dBm
                        spectrum_analyzer_state=spectrum_analyzer_state,
                        spectrum_analyzer_sweep_points=spectrum_analyzer_sweep_points,
                        spectrum_analyzer_resolution_bandwidth=spectrum_analyzer_resolution_bandwidth,
                        spectrum_analyzer_resolution_bandwidth_unit=spectrum_analyzer_resolution_bandwidth_unit,
                        spectrum_analyzer_video_bandwidth=spectrum_analyzer_video_bandwidth,
                        spectrum_analyzer_video_bandwidth_unit=spectrum_analyzer_video_bandwidth_unit,
                        spectrum_analyzer_frequency_span=spectrum_analyzer_frequency_span,
                        spectrum_analyzer_frequency_span_unit=spectrum_analyzer_frequency_span_unit,
                        # spectrum_analyzer_attenuation = spectrum_analyzer_attenuation,
                        gainAmplifier=gainAmplifier,  # dB
                        spectrum_analyzer_IF_atten_enable=spectrum_analyzer_IF_atten_enable,
                        spectrum_analyzer_IF_atten=spectrum_analyzer_IF_atten,
                        spectrum_analyzer_IF_relative_level=spectrum_analyzer_IF_relative_level_enable,
                        spectrum_analyzer_IF_relative_level_enable=spectrum_analyzer_IF_relative_level_enable,
                        threshold_power=0,  # dB
                        spectrum_analyzer_frequency_marker_unit=spectrum_analyzer_frequency_marker_unit,
                        FSV_delay=FSV_delay,
                        m_RF=m_RF,
                        n_LO=n_LO,
                        IF_low=IF_low,
                        IF_low_unit=IF_low_unit,
                        IF_high=IF_high,
                        IF_high_unit=IF_high_unit,
                        spurius_IF_unit=spurius_IF_unit,
                        calibration_file_LO=calibration_file_LO,
                        calibration_file_LO_enable=calibration_file_LO_enable,
                        calibration_file_RF=calibration_file_RF,
                        calibration_file_RF_enable=calibration_file_RF_enable,
                        calibration_file_IF=calibration_file_IF,
                        calibration_file_IF_enable=calibration_file_IF_enable,
                        result_file_name=result_file_name,
                        createprogressdialog=False):
    #dialog = createprogressdialog
    if createprogressdialog:
       import wx

       app = wx.App()
       dialog = wx.ProgressDialog("Progress", "Time remaining", maximum = 100,
               style=wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_AUTO_HIDE)


    values = []  # variable for results

    # reset the synthetizer SMB100A
    SMB_LO.write("*rst")
    SMB_RF.write("*rst")

    # reset spectrum analyzer
    # imposta la modalit� di funzionamento dei due SMB
    SMB_LO.write("FREQ:MODE FIX")
    SMB_LO.write("POW:MODE FIX")
    SMB_RF.write("FREQ:MODE FIX")
    SMB_RF.write("POW:MODE FIX")

    FSV_reset_setup(FSV, spectrum_analyzer_sweep_points,
                    spectrum_analyzer_resolution_bandwidth,
                    spectrum_analyzer_resolution_bandwidth_unit,
                    spectrum_analyzer_video_bandwidth,
                    spectrum_analyzer_video_bandwidth_unit,
                    spectrum_analyzer_frequency_span,
                    spectrum_analyzer_frequency_span_unit,
                    spectrum_analyzer_IF_atten_enable,
                    spectrum_analyzer_IF_atten,
                    spectrum_analyzer_IF_relative_level_enable,
                    spectrum_analyzer_IF_relative_level)

    FSV.write("CALC:MARKER ON")  # enable marker mode

    # load data for cables from calibration files
    if calibration_file_LO_enable:
        calibration_LO = readcalibrationfile(calibration_file_LO)
        calibration_function_LO, calibration_function_LO_unit = calibrationfilefunction(calibration_LO)
    else:
        calibration_LO = []
        calibration_function_LO = None
        calibration_function_LO_unit = unit.Hz
    if calibration_file_IF_enable:
        calibration_IF = readcalibrationfile(calibration_file_IF)
        calibration_function_IF, calibration_function_IF_unit = calibrationfilefunction(calibration_IF)
    else:
        calibration_IF = []
        calibration_function_IF = None
        calibration_function_IF_unit = unit.Hz
    if calibration_file_RF_enable:
        calibration_RF = readcalibrationfile(calibration_file_RF)
        calibration_function_RF, calibration_function_RF_unit = calibrationfilefunction(calibration_RF)
    else:
        calibration_RF = []
        calibration_function_RF = None
        calibration_function_RF_unit = unit.Hz
    totale_values = []
    if not synthetizer_LO_state:
        # set default parameter to skeep syntetizer loop
        synthetizer_LO_frequency = Frequency_Range(3000, 3000, 50, unit.MHz)  # same value of min for fixed value
        synthetizer_LO_frequency.to_base()
        synthetizer_LO_level = Generic_Range(-10, -10, 0.5)  # same value of min for fixed value

    if (not synthetizer_RF_state) or (m_RF.min == 0 and m_RF.max == 0 and m_RF.step == 1):
        # set default parameter to skeep syntetizer loop
        # By this mode is possibile calculate harmonic for LO frequency LO power
        synthetizer_RF_frequency = Frequency_Range(3000, 3000, 50, unit.MHz)  # same value of min for fixed value
        synthetizer_RF_frequency.to_base()
        synthetizer_RF_level = Generic_Range(-10, -10, 0.5)  # same value of min for fixed value

        m_step_RF = 0

    p = unicode("_".join(["PartialResults", return_now_postfix()]))
    partial_file_path = os.path.join(result_file_name, p)
    if not os.path.exists(partial_file_path):
        try:
            os.makedirs(partial_file_path)
        except:
            print("Error creating " + partial_file_path)
            return 0
    frequency_LO_range = synthetizer_LO_frequency.return_range()
    level_LO_range = synthetizer_LO_level.return_arange()
    level_RF_range = synthetizer_RF_level.return_arange()
    frequency_RF_range = synthetizer_RF_frequency.return_range()
    IF_high = unit.convertion_to_base(IF_high, IF_high_unit)
    IF_low = unit.convertion_to_base(IF_low, IF_low_unit)

    maxcount = float(len(frequency_LO_range) * len(level_LO_range) * len(level_RF_range) * len(frequency_RF_range))
    count = 0
    continue_progress = (True, True)

    for f_LO in frequency_LO_range:  # frequency loop
        # set SMB100A frequency for LO
        f_LO_value = str(f_LO)
        current_lo_frequency = f_LO_value + unit.return_unit_str(unit.Hz)
        current_lo_frequency_human_readable = unit.return_human_readable_str(f_LO)
        command = "FREQ " + current_lo_frequency  # Ex. FREQ 500kHz
        if synthetizer_LO_state:
            SMB_LO.write(command)

        for l_LO in level_LO_range:  # power level loop
            # set SMB100A level for LO
            # calculate calibrated value of level for LO
            current_LO_level, calibration_LO_result = calibrate(l_LO, f_LO, unit.Hz, calibration_LO,
                                                                calibration_function=calibration_function_LO,
                                                                calibration_function_unit=calibration_function_LO_unit)
            if threshold_power is not None:
                if current_LO_level > threshold_power:
                    # Power over the limit
                    count += 1
                    continue
            command = "POW " + str(current_LO_level)
            if synthetizer_LO_state:
                SMB_LO.write(command)
                # turn on LO
                SMB_LO.write("OUTP ON")

            for l_RF in level_RF_range:  # power level loop

                for f_RF in frequency_RF_range:  # frequency loop
                    values = []
                    # calculate calibrated value of level for RF
                    current_RF_level, calibration_RF_result = calibrate(l_RF, f_RF, unit.Hz, calibration_RF,
                                                                        calibration_function=calibration_function_RF,
                                                                        calibration_function_unit=calibration_function_RF_unit)
                    if threshold_power is not None:
                        if current_RF_level > threshold_power:
                            # Power over the limit
                            count += 1
                            continue
                    command = "POW " + str(current_RF_level)
                    if synthetizer_RF_state:
                        SMB_RF.write(command)  # set level for RF
                    # set SMB100A frequency for RF
                    f_RF_value = str(f_RF)
                    current_rf_frequency = f_RF_value + unit.return_unit_str(unit.Hz)
                    current_rf_frequency_human_readable = unit.return_human_readable_str(f_RF)
                    command = "FREQ " + current_rf_frequency  # Ex. FREQ 500kHz
                    if synthetizer_RF_state:
                        SMB_RF.write(command)

                    # Set the downconverter frequency and attenuation
                    if downconverter_state:
                        VSCD.set_freq(f_RF_value)
                        VSCD.set_rf_on()

                    # calculate spurius frequency
                    spurius_tmp = return_spurius_list(f_LO, f_RF, n_LO, m_RF, IF_low, IF_high)
                    if synthetizer_RF_state:
                        # turn on RF
                        SMB_RF.write("OUTP ON")
                    spurius_markers = readFSV_marker_spurius(FSV,
                                                             FSV_delay,
                                                             spurius_tmp,
                                                             unit.Hz,
                                                             calibration_IF,
                                                             calibration_IF_function=calibration_function_IF,
                                                             calibration_IF_function_unit=calibration_function_IF_unit)
                    count += 1

                    # if not createprogressdialog is None:
                    #     import wx
                    #     wx.MicroSleep(500)
                    #     message = "LO {lo_freq} {lo_pow}dB - RF  {rf_freq} {rf_pow}dB".format(
                    #         lo_freq=current_lo_frequency_human_readable, lo_pow=str(current_LO_level),
                    #         rf_freq=current_rf_frequency_human_readable, rf_pow=str(current_RF_level))
                    #     newvalue = min([int(count / maxcount * 100), 100])
                    #     if newvalue == 100:
                    #         createprogressdialog = False
                    #         dialog.Update(newvalue, message)
                    #         wx.MicroSleep(500)
                    #         dialog.Close()
                    #     else:
                    #         continue_progress = dialog.Update(newvalue, message)

                    # load value for each spurius frequency
                    for s in spurius_markers:
                        # value = [LO frequency, unit, LO level, CAL/NOCAL, RF frequency, unit, RF level, CAL/NOCAL, Spurius Frequency, Spurius level]
                        # values.append([f_LO_value, unit.return_unit_str(synthetizer_LO_frequency_unit), str(current_LO_level), calibration_LO_result, f_RF_value, unit.return_unit_str(synthetizer_RF_frequency_unit), str(current_RF_level), calibration_RF_result] + s)
                        values.append(
                            [f_LO_value, unit.return_unit_str(unit.Hz), str(l_LO), calibration_LO_result, f_RF_value,
                             unit.return_unit_str(unit.Hz), str(l_RF), calibration_RF_result] + s)
                        totale_values.append(values[-1])
                        print(totale_values[-1])
                    # build filename - result_file_name_LOfrequency_unit_LOlevel_CAL/NOCAL_RFfrequency_unit_RFlevel_CAL/NOCAL_datetime
                    if len(spurius_markers) > 0:
                        spurius_filename = os.path.join(partial_file_path, "_".join(["R"] + values[0][0:-2]))
                        save_spurius(spurius_filename, values)

                    # if not continue_progress[0]:
                    #     dialog.Destroy()
                    #     break
                    # if f_LO == frequency_LO_range[-1] and l_LO == level_LO_range[-1] and l_RF == level_RF_range[
                    #     -1] and f_RF == frequency_RF_range[-1]:
                    #     # safety turn Off
                    #     # dialog.Update(100, "Measure completed)
                    #     dialog.Destroy()
                    #     # SMB_LO.write("OUTP OFF")
                    #     # SMB_RF.write("OUTP OFF")
                if not continue_progress[0]:
                    break
            if not continue_progress[0]:
                break
        if not continue_progress[0]:
            break

    # turn off LO and RF
    if downconverter_state:
        VSCD.set_rf_off()
    if synthetizer_LO_state:
        SMB_LO.write("OUTP OFF")
    if synthetizer_RF_state:
        SMB_RF.write("OUTP OFF")

    if m_RF.step == 0:
        harmonic_filename = result_file_name + "_TOTAL_HARMONIC_" + return_now_postfix()
        save_harmonic(harmonic_filename, totale_values)
        spurius_filename = result_file_name + "_TOTAL_" + return_now_postfix()
        save_spurius(spurius_filename, totale_values)
    else:
        spurius_filename = result_file_name + "_TOTAL_" + return_now_postfix()
        save_spurius(spurius_filename, totale_values)

    print("Misure completed\n")
    return spurius_filename
Ejemplo n.º 3
0
VERSION = 8.0

unit = unit_class()

calibration_file_LO = "C:\\Users\\sabah\\Documents\\Aptana Studio 3 Workspace\\ArduinoStepAttenuator\\v04\\RF_cal.csv"
calibration_file_LO_enable = True
calibration_file_RF = "C:\\Users\\sabah\\Documents\\Aptana Studio 3 Workspace\\ArduinoStepAttenuator\\v04\\RF_cal.csv"
calibration_file_RF_enable = True
calibration_file_IF = "C:\\Users\\sabah\\Documents\\Aptana Studio 3 Workspace\\ArduinoStepAttenuator\\v04\\RF_cal.csv"
calibration_file_IF_enable = False
# D:\Users\Andrea\Desktop
result_file_name = "C:\\Users\\sabah\\Documents\\Aptana Studio 3 Workspace\\ArduinoStepAttenuator\\v04\\misuraSpuri_TEST_HARMONIC"  # without extension

synthetizer_LO_state = "ON"
synthetizer_LO_frequency = Frequency_Range(4600, 5000, 500, unit.MHz)
synthetizer_LO_frequency.to_base()
synthetizer_LO_level = Generic_Range(10, 15, 5)

synthetizer_RF_state = "ON"
synthetizer_RF_frequency = Frequency_Range(3000, 4500, 500, unit.MHz)
synthetizer_RF_frequency.to_base()
synthetizer_RF_level = Generic_Range(-50, -25, 20)

vscd_state = "ON"
vscd_frequency = Frequency_Range(3000, 4500, 500, unit.MHz)
vscd_frequency.to_base()
vscd_level = Generic_Range(-50, -25, 20)

FSV_delay = 1
Ejemplo n.º 4
0
        def ask(self, command):
            return ["1.1"]


    SAB = SAB_class()
    SAB_delay = 0
else:
    SAB_delay = 1

synthetizer_state = "ON"
# synthetizer_frequency_min = 5000
# synthetizer_frequency_max = 6000
# synthetizer_frequency_step = 100
# synthetizer_frequency_unit = unit.MHz
synthetizer_frequency = Frequency_Range(5000, 6000, 100, unit.MHz)
synthetizer_frequency.to_base()
synthetizer_fix_power = 0  # dBm
synthetizer_level = Generic_Range(0, 10, 1)
# synthetizer_level_max = 10 #dBm
# synthetizer_level_step = 1 #dBm
power_meter_make_zero = True
power_meter_make_zero_delay = 1  # seconds
power_meter_misure_number = 1
power_meter_misure_delay = 1000  # milliseconds
SAB_state = "ON"
SAB_attenuation_level = Generic_Range(0, 5, 1)
# SAB_attenuation_level_max = 5
# SAB_attenuation_level_step = 1
SAB_attenuation_delay = 1
SAB_switch_01_delay = 1  # seconds
Ejemplo n.º 5
0
else:
    PM5_delay = 1

VERSION = 1.0

unit = unit_class()

# imposta i valori del sintetizzatore
# 0 dbm per la potenza fissa
synthetizer_fix_power = 0  # dBm

# synthetizer_frequency_min = 4600
# synthetizer_frequency_max = 4700
# synthetizer_frequency_step = 100
# synthetizer_frequency_unit = unit.MHz
synthetizer_frequency = Frequency_Range(4600, 4700, 100, unit.MHz)
synthetizer_level = Generic_Range(0, 10, 1)
# synthetizer_level_min = 0 #dBm
# synthetizer_level_max = 10 #dBm
# synthetizer_level_step = 1 #dBm
pm5_misure_number = 1
pm5_misure_delay = 1

result_file_name = "C:\\Users\\Labele\\Desktop\\Spurius\\LO_cal"
calibration_cable_file_name = "C:\\Users\\Labele\\Desktop\\IP1\\misure calibrate\\CableLO_20160505122636.csv"

# result_file_name = "D:\\Users\\Andrea\\Documents\\Lavoro\\2015\\INAF\\MisureLNA\\test_cable"
# Freqeunza strat , stop step


def measure_100GHz_cal(SMB=SMB_RF,