def rf_switches_test(vna, sgen, rffe, rfsw_1, ip_sw1, sw1_port_1, sw1_port_2, rfsw_2, ip_sw2, sw2_port_1, sw2_port_2, center_freq, freq_span, pow_value, att_value, switch_ref, switch_tol, tela_leds, percentual, rf_switch_test_log, s_parameter_test_selection, s_parameter_data_chA, s_parameter_data_chB, freq_central_position): print("\nRunning RF switches test - Ports: " + str(sw2_port_1) + " - " + str(sw2_port_2) + "\n") tela_leds.ui.progressBar.setValue(5 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) #Configuração Inicial de Segurança - Atenuador do RFFE no máximo, e VNA setado para pow_value dB rffe.set_attenuator_value(att_value) sgen.set_signal_DC() sgen.set_pos("direct") vna.send_command(b":SOUR1:POW " + format(pow_value).encode('utf-8') + b"\n") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw_1.sw1_pos(ip_sw1, 3, 3) #coloca o switch 1 na chave 3-3 = 0dBm rfsw_2.sw2_pos(ip_sw2, 0, 0) leds_rf_switch(3, 3, 0, 0, tela_leds) #vna.send_command(b":SENSE1:AVER:COUN "+ format(10).encode('utf-8') + b"\n") vna.send_command(b":SENSE1:AVER OFF\n") #Data Acquisition if (s_parameter_test_selection == True): #Neste teste utilizamos o parâmetro S21 com medição na freq central #s_parameter_data_chA=[s11,s12,s21,s22] #Canal A: 1-1 ou 3-3 #Canal B: 2-2 ou 4-4 print("Using S-Parameters data for direct position") #Nível DC: ALTO data_chA_ctr_freq_direct = s_parameter_data_chA[2][ freq_central_position] data_chB_ctr_freq_direct = s_parameter_data_chB[2][ freq_central_position] #Atualiza barra de progresso tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) #Nível DC: BAIXO sgen.set_pos("inverted") print("Channel " + str(sw2_port_1) + "-" + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2, sw2_port_1, sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) s21_test = float(test_lib.marker_value(0, center_freq, "s21", vna)) data_chA_ctr_freq_inverted = s21_test print("Channel " + str(sw2_port_2) + " - " + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2, sw2_port_2, sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) s21_test = float(test_lib.marker_value(0, center_freq, "s21", vna)) data_chB_ctr_freq_inverted = s21_test #Atualiza barra de progresso tela_leds.ui.progressBar.setValue(50 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) else: print("Acquiring data...") #Canal A (1-1 ou 3-3) print("Channel " + str(sw2_port_1) + "-" + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2, sw2_port_1, sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) #NÍVEL DC: ALTO sgen.set_pos("direct") s21_test = float(test_lib.marker_value(0, center_freq, "s21", vna)) data_chA_ctr_freq_direct = s21_test #Nível DC: BAIXO sgen.set_pos("inverted") s21_test = float(test_lib.marker_value(0, center_freq, "s21", vna)) data_chA_ctr_freq_inverted = s21_test #Atualiza barra de progresso tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) #Canal B (2-2 ou 4-4) print("Channel " + str(sw2_port_2) + " - " + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2, sw2_port_2, sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) #Nível DC: ALTO sgen.set_pos("direct") s21_test = float(test_lib.marker_value(0, center_freq, "s21", vna)) data_chB_ctr_freq_direct = s21_test #Nível DC: BAIXO sgen.set_pos("inverted") s21_test = float(test_lib.marker_value(0, center_freq, "s21", vna)) data_chB_ctr_freq_inverted = s21_test #Atualiza barra de progresso tela_leds.ui.progressBar.setValue(50 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) #Tolerance print("Lower Boundary: ", abs(switch_ref + switch_tol)) #Calculations and Results of Channel A (1-1 ou 3-3) rf_sw_result_valuesA = abs( round((abs( float(data_chA_ctr_freq_direct) - float(data_chA_ctr_freq_inverted))), 2)) if rf_sw_result_valuesA < abs(switch_ref + switch_tol): rf_sw_resultA = "RF Switches Test Channel " + str( sw2_port_1) + "-" + str(sw2_port_1) + ": FAILED" print("Result: ", rf_sw_result_valuesA) print("RF Switches Test Channel " + str(sw2_port_1) + "-" + str(sw2_port_1) + ": FAILED") rf_sw_fail_A = 1 else: rf_sw_resultA = "RF Switches Test Channel " + str( sw2_port_1) + "-" + str(sw2_port_1) + ": OK" print("Result: ", rf_sw_result_valuesA) print("RF Switches Test Channel " + str(sw2_port_1) + "-" + str(sw2_port_1) + ": OK") rf_sw_fail_A = 0 #Calculations and Results of Channel B (2-2 ou 4-4) rf_sw_result_valuesB = abs( round((abs( float(data_chB_ctr_freq_direct) - float(data_chB_ctr_freq_inverted))), 2)) if rf_sw_result_valuesB < abs(switch_ref + switch_tol): rf_sw_resultB = "RF Switches Test Channel " + str( sw2_port_2) + "-" + str(sw2_port_2) + ": FAILED" print("Result: ", rf_sw_result_valuesB) print("RF Switches Test Channel " + str(sw2_port_2) + "-" + str(sw2_port_2) + ": FAILED") rf_sw_fail_B = 1 else: rf_sw_resultB = "RF Switches Test Channel " + str( sw2_port_2) + "-" + str(sw2_port_2) + ": OK" print("Result: ", rf_sw_result_valuesB) print("RF Switches Test Channel " + str(sw2_port_2) + "-" + str(sw2_port_2) + ": OK") rf_sw_fail_B = 0 #LOG INFO rf_switch_test_log.append("Channel " + str(sw2_port_1) + " - " + str(sw2_port_1)) rf_switch_test_log.append("Waveform Generator - DC Offset [V]: " + str(3.0)) rf_switch_test_log.append("Measurement [dB]:" + str(round(data_chA_ctr_freq_direct, 2))) rf_switch_test_log.append("Waveform Generator - DC Offset [V]: " + str(0.0)) rf_switch_test_log.append("Measurement [dB]:" + str(round(data_chA_ctr_freq_inverted, 2))) rf_switch_test_log.append("Result Value [dB]:" + str(rf_sw_result_valuesA)) rf_switch_test_log.append(rf_sw_resultA + "\n") rf_switch_test_log.append("Channel " + str(sw2_port_2) + " - " + str(sw2_port_2)) rf_switch_test_log.append("Waveform Generator - DC Offset [V]: " + str(3.0)) rf_switch_test_log.append("Measurement [dB]:" + str(round(data_chB_ctr_freq_direct, 2))) rf_switch_test_log.append("Waveform Generator - DC Offset [V]: " + str(0.0)) rf_switch_test_log.append("Measurement [dB]:" + str(round(data_chB_ctr_freq_inverted, 2))) rf_switch_test_log.append("Result Value [dB]:" + str(rf_sw_result_valuesB)) rf_switch_test_log.append(rf_sw_resultB + "\n") #volta a condição original por segurança sgen.set_pos("direct") return (rf_sw_resultA, rf_sw_result_valuesA, rf_sw_resultB, rf_sw_result_valuesB, rf_switch_test_log, rf_sw_fail_A, rf_sw_fail_B)
s22_ref=float(metadata_param['s22_ref']) s11_tol=float(metadata_param['s11_tolerance']) s12_tol=float(metadata_param['s12_tolerance']) s21_tol=float(metadata_param['s21_tolerance']) s22_tol=float(metadata_param['s22_tolerance']) linearity_tol=float(metadata_param['linearity_tol']) print("Test parameters loaded from metadata - ok!\n...\n") #Data measurement from the Network Analyzer for different switches positions sgen.set_pos("direct") vna.send_command(b":SOUR1:POW:GPP "+format(pow_value).encode('utf-8')+b"\n") #-->for python3 print("Starting tests. Measuring S-parameters ...\n") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw.sw1_pos(1) rfsw.sw2_pos(1) s11_pos1=vna.get_s11_data() s12_pos1=vna.get_s12_data() s21_pos1=vna.get_s21_data() s22_pos1=vna.get_s22_data() s11_pos1=np.array([[s11_pos1]]).T s12_pos1=np.array([[s12_pos1]]).T s21_pos1=np.array([[s21_pos1]]).T s22_pos1=np.array([[s22_pos1]]).T sparam_pos1 = np.c_[s11_pos1, s12_pos1, s21_pos1, s22_pos1] print("...\n")
def return_loss_test_s22(vna, sgen, rffe, rfsw_1, ip_sw1, sw1_port_1, sw1_port_2, rfsw_2, ip_sw2, sw2_port_1, sw2_port_2, center_freq, freq_span, pow_value, att_value, ret_loss_s22_ref, ret_loss_s22_ref_tol, start_bandwidth, stop_bandwidth, step_bandwidth, ret_loss_test_log, percentual, s_parameter_test_selection, s_parameter_data_chA, s_parameter_data_chB, freq_data, tela_leds): print("\nRunning return loss test s22 - Ports: " + str(sw2_port_1) + " - " + str(sw2_port_2) + "\n") tela_leds.ui.progressBar.setValue(5 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra ret loss", tela_leds.repaint()) print("barra ret loss", QApplication.processEvents()) #Configuração Inicial de Segurança - Atenuador do RFFE no máximo, e VNA setado para pow_value dB rffe.set_attenuator_value(att_value) sgen.set_signal_DC() sgen.set_pos("direct") vna.send_command(b":SOUR1:POW " + format(pow_value).encode('utf-8') + b"\n") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw_1.sw1_pos(ip_sw1, 3, 3) #coloca o switch 1 na chave 3-3 = 0dBm rfsw_2.sw2_pos(ip_sw2, 0, 0) leds_rf_switch(3, 3, 0, 0, tela_leds) #vna.send_command(b":SENSE1:AVER:COUN "+ format(10).encode('utf-8') + b"\n") vna.send_command(b":SENSE1:AVER OFF\n") #Variables data_chA_filter = [] data_chB_filter = [] #Data Acquisition if (s_parameter_test_selection == True): print("Utilizando os dados adquiridos no teste do S-Parameters") #Neste teste utilizamos o parâmetro S21 #s_parameter_data_chA=[s11,s12,s21,s22] data_chA = s_parameter_data_chA[3] data_chB = s_parameter_data_chB[3] #start_bandwidth_position for i in range(0, len(freq_data)): if (freq_data[i] >= start_bandwidth): start_bandwidth_position = i break print("Frequencia Detectada: ", freq_data[start_bandwidth_position], "Frequencia Esperada: ", start_bandwidth) #stop_bandwith_position for i in range(0, len(freq_data)): if (freq_data[i] > stop_bandwidth): stop_bandwidth_position = i - 1 break print(freq_data[stop_bandwidth_position], stop_bandwidth) for i in range(start_bandwidth_position, stop_bandwidth_position): data_chA_filter.append(data_chA[i]) data_chB_filter.append(data_chB[i]) print("Aquisição de dados completa...") print(data_chA_filter) print(data_chB_filter) tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra ret loss", tela_leds.repaint()) print("barra ret loss", QApplication.processEvents()) else: print("Aquisição de dados necessária...Iniciando aquisição...") #Data acquisition for channel A 1-1 or 3-3 print("Channel " + str(sw2_port_1) + "-" + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2, sw2_port_1, sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) data_chA = vna.get_s22_data() #Data acquisition for channel B 2-2 or 4-4 print("Channel " + str(sw2_port_2) + "-" + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2, sw2_port_2, sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) data_chB = vna.get_s22_data() #Frequency Data Acquisition freq_data = vna.get_frequency_data() #start_bandwidth_position for i in range(0, len(freq_data)): if (freq_data[i] >= start_bandwidth): start_bandwidth_position = i break print("Frquencia Detectada: ", freq_data[start_bandwidth_position], "Frequencia Esperada: ", start_bandwidth) #stop_bandwith_position for i in range(0, len(freq_data)): if (freq_data[i] > stop_bandwidth): stop_bandwidth_position = i - 1 break print("Frequencia Detectada:", freq_data[stop_bandwidth_position], "Frequencia Esperada: ", stop_bandwidth) for i in range(start_bandwidth_position, stop_bandwidth_position): data_chA_filter.append(data_chA[i]) data_chB_filter.append(data_chB[i]) print("Aquisição de dados completa...") tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra ret loss", tela_leds.repaint()) print("barra ret loss", QApplication.processEvents()) #Tolerance print("Lower Boundary: ", abs(ret_loss_s22_ref + ret_loss_s22_ref_tol)) print("Upper Boundary: ", str(0)) #Calculations and Results of Channel A: 1-1 or 3-3 #Determinar a maior amplitude, e a menor amplitude para comparação: maximum_valueA = -1000 minimum_valueA = 1000 for i in range(0, len(data_chA_filter)): if (data_chA_filter[i] > maximum_valueA): maximum_valueA = data_chA_filter[i] freq_maximum_position_A = i if (data_chA_filter[i] < minimum_valueA): minimum_valueA = data_chA_filter[i] freq_minimum_position_A = i freq_maximum_A = freq_data[freq_maximum_position_A + start_bandwidth_position] freq_minimum_A = freq_data[freq_minimum_position_A + start_bandwidth_position] print("Valor Máximo: ", maximum_valueA, " Frequência: ", freq_maximum_A) print("Valor Mínimo: ", minimum_valueA, " Frequência: ", freq_minimum_A) #Verifica se o valor dentro da varredutra não ficou maior do que a tolerância máxima (ou seja, ponto máximo em relação com o ponto mínimo) #Verifica se o valor do ganho no filtro atingiu o valor mínimo especificado #deltaA=maximum_valueA-minimum_valueA #ret_loss_resultA_value = abs(deltaA) #str1_A="Result Delta Varredura (abs) [dB]: " +str(round(ret_loss_resultA_value,2)) str2_A = "Result Maximum (abs) [dB]: " + str(round(maximum_valueA, 2)) str3_A = "Result Minimum (abs) [dB]: " + str(round(minimum_valueA, 2)) str4_A = "Result Maximum - Frequency [Hz]: " + str(freq_maximum_A) str5_A = "Result Minimum - Frequency [Hz]: " + str(freq_minimum_A) if (abs(maximum_valueA) < abs(ret_loss_s22_ref + ret_loss_s22_ref_tol) or maximum_valueA > 0): ret_loss_resultA = "Return Loss Channel " + str( sw2_port_1) + "-" + str(sw2_port_1) + ": FAILED" fail_A = 1 else: ret_loss_resultA = "Return Loss Channel " + str( sw2_port_1) + "-" + str(sw2_port_1) + ": OK" fail_A = 0 print(ret_loss_resultA) #Calculations and Results of Channel B: 2-2 or 4-4 #Determinar a maior amplitude, e a menor amplitude para comparação: maximum_valueB = -1000 minimum_valueB = 1000 for i in range(0, len(data_chB_filter)): if (data_chB_filter[i] > maximum_valueB): maximum_valueB = data_chB_filter[i] freq_maximum_position_B = i if (data_chB_filter[i] < minimum_valueB): minimum_valueB = data_chB_filter[i] freq_minimum_position_B = i if (s_parameter_test_selection == True): freq_maximum_B = freq_data[freq_maximum_position_B + start_bandwidth_position] freq_minimum_B = freq_data[freq_minimum_position_B + start_bandwidth_position] else: freq_maximum_B = freq_maximum_position_B * step_bandwidth + start_bandwidth freq_minimum_B = freq_minimum_position_B * step_bandwidth + start_bandwidth print("Valor Máximo: ", maximum_valueB, " Frequência: ", freq_maximum_B) print("Valor Mínimo: ", minimum_valueB, " Frequência: ", freq_minimum_B) #Verifica se o valor dentro da varredutra não ficou maior do que a tolerância máxima (ou seja, ponto máximo em relação com o ponto mínimo) #Verifica se o valor do ganho no filtro atingiu o valor mínimo especificado #deltaB=maximum_valueB-minimum_valueB #ret_loss_resultB_value = abs(deltaB) #str1_B="Result Delta Varredura (abs) [dB]: " +str(round(ret_loss_resultB_value,2)) str2_B = "Result Maximum (abs) [dB]: " + str(round(maximum_valueB, 2)) str3_B = "Result Minimum (abs) [dB]: " + str(round(minimum_valueB, 2)) str4_B = "Result Maximum - Frequency [Hz]: " + str(freq_maximum_B) str5_B = "Result Minimum - Frequency [Hz]: " + str(freq_minimum_B) if (abs(maximum_valueB) < abs(ret_loss_s22_ref + ret_loss_s22_ref_tol) or maximum_valueB > 0): ret_loss_resultB = "Return Loss Channel " + str( sw2_port_2) + "-" + str(sw2_port_2) + ": FAILED" fail_B = 1 else: ret_loss_resultB = "Return Loss Channel " + str( sw2_port_2) + "-" + str(sw2_port_2) + ": OK" fail_B = 0 print(ret_loss_resultB) #LOG INFO ret_loss_test_log.append("Channel " + str(sw2_port_1) + "-" + str(sw2_port_1)) #ret_loss_test_log.append(str1_A) ret_loss_test_log.append(str2_A) #ret_loss_test_log.append(str3_A) ret_loss_test_log.append(str4_A) #ret_loss_test_log.append(str5_A) ret_loss_test_log.append(ret_loss_resultA + "\n") ret_loss_test_log.append("Channel " + str(sw2_port_2) + " - " + str(sw2_port_2)) #ret_loss_test_log.append(str1_B) ret_loss_test_log.append(str2_B) #ret_loss_test_log.append(str3_B) ret_loss_test_log.append(str4_B) #ret_loss_test_log.append(str5_B) ret_loss_test_log.append(ret_loss_resultB + "\n") tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra ret loss", tela_leds.repaint()) print("barra ret loss", QApplication.processEvents()) maximum_valueA = abs(maximum_valueA) maximum_valueB = abs(maximum_valueB) return (ret_loss_resultA, ret_loss_resultB, maximum_valueA, maximum_valueB, minimum_valueA, minimum_valueB, ret_loss_test_log, fail_A, fail_B)
def s_parameters_test(vna, sgen, rffe, rfsw_1, ip_sw1, sw1_port_1, sw1_port_2, rfsw_2, ip_sw2, sw2_port_1, sw2_port_2, center_freq, freq_span, pow_value, att_value, serial_number, metadata_path, datapath_save, tela_leds, percentual, curva_s_parameter, datapath_save_figure): print("\nStarting tests. Measuring S-parameters - Ports: " + str(sw2_port_1) + " - " + str(sw2_port_2) + "\n") tela_leds.ui.progressBar.setValue(5 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra s parameter", tela_leds.repaint()) print("barra s parameter", QApplication.processEvents()) #Configuração Inicial de Segurança - Atenuador do RFFE no máximo, e VNA setado para pow_value dB rffe.set_attenuator_value(att_value) sgen.set_signal_DC() sgen.set_pos("direct") vna.send_command(b":SOUR1:POW " + format(pow_value).encode('utf-8') + b"\n") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw_1.sw1_pos(ip_sw1, 3, 3) #coloca o switch 1 na chave 3-3 = 0dBm rfsw_2.sw2_pos(ip_sw2, 0, 0) leds_rf_switch(3, 3, 0, 0, tela_leds) #Data acquisition for channel 1-1 or 3-3 #Frequency Data Acquisition freq_data = vna.get_frequency_data() #This one's purpose in exclusive to plot the data freq_data_mhz = [] for i in range(0, len(freq_data)): freq_data_mhz.append(freq_data[i] / 1000000) print("Porta " + str(sw2_port_1) + " - " + str(sw2_port_1) + " do Switch") rfsw_2.sw2_pos(ip_sw2, sw2_port_1, sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) s11_pos1 = vna.get_s11_data() s12_pos1 = vna.get_s12_data() s21_pos1 = vna.get_s21_data() s22_pos1 = vna.get_s22_data() s_pos_a = [s11_pos1, s12_pos1, s21_pos1, s22_pos1] s_pos_a_ch = [sw2_port_1, sw2_port_1] if (curva_s_parameter == True): fig = plt.figure() plt.plot(freq_data_mhz, s11_pos1) plt.title('Parâmetro S11 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_1) + '_s11.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s12_pos1) plt.title('Parâmetro S12 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_1) + '_s12.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s21_pos1) plt.title('Parâmetro S21 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_1) + '_s21.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s22_pos1) plt.title('Parâmetro S22 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_1) + '_s22.png', dpi=fig.dpi) plt.close(fig) s11_pos1 = np.array([[s11_pos1]]).T s12_pos1 = np.array([[s12_pos1]]).T s21_pos1 = np.array([[s21_pos1]]).T s22_pos1 = np.array([[s22_pos1]]).T sparam_pos1 = np.c_[s11_pos1, s12_pos1, s21_pos1, s22_pos1] tela_leds.ui.progressBar.setValue(12.5 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra s parameter", tela_leds.repaint()) print("barra s parameter", QApplication.processEvents()) #Data acquisition for channel 1-2 or 3-4 print("Porta " + str(sw2_port_1) + " - " + str(sw2_port_2) + " do Switch") rfsw_2.sw2_pos(ip_sw2, sw2_port_1, sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_2, tela_leds) s11_pos2 = vna.get_s11_data() s12_pos2 = vna.get_s12_data() s21_pos2 = vna.get_s21_data() s22_pos2 = vna.get_s22_data() s_pos_b = [s11_pos2, s12_pos2, s21_pos2, s22_pos2] s_pos_b_ch = [sw2_port_1, sw2_port_2] if (curva_s_parameter == True): fig = plt.figure() plt.plot(freq_data_mhz, s11_pos2) plt.title('Parâmetro S11 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_2) + '_s11.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s12_pos2) plt.title('Parâmetro S12 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_2) + '_s12.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s21_pos2) plt.title('Parâmetro S21 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_2) + '_s21.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s22_pos2) plt.title('Parâmetro S22 [Ch:' + str(sw2_port_1) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_1) + str(sw2_port_2) + '_s22.png', dpi=fig.dpi) plt.close(fig) s11_pos2 = np.array([[s11_pos2]]).T s12_pos2 = np.array([[s12_pos2]]).T s21_pos2 = np.array([[s21_pos2]]).T s22_pos2 = np.array([[s22_pos2]]).T sparam_pos2 = np.c_[s11_pos2, s12_pos2, s21_pos2, s22_pos2] tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra s parameter", tela_leds.repaint()) print("barra s parameter", QApplication.processEvents()) #Data acquisition for channel 2-1 or 4-3 print("Porta " + str(sw2_port_2) + " - " + str(sw2_port_1) + " do Switch") rfsw_2.sw2_pos(ip_sw2, sw2_port_2, sw2_port_1) #(4,3) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_1, tela_leds) s11_pos3 = vna.get_s11_data() s12_pos3 = vna.get_s12_data() s21_pos3 = vna.get_s21_data() s22_pos3 = vna.get_s22_data() s_pos_c = [s11_pos3, s12_pos3, s21_pos3, s22_pos3] s_pos_c_ch = [sw2_port_2, sw2_port_1] if (curva_s_parameter == True): fig = plt.figure() plt.plot(freq_data_mhz, s11_pos3) plt.title('Parâmetro S11 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_1) + '_s11.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s12_pos3) plt.title('Parâmetro S12 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_1) + '_s12.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s21_pos3) plt.title('Parâmetro S21 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_1) + '_s21.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s22_pos3) plt.title('Parâmetro S22 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_1) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_1) + '_s22.png', dpi=fig.dpi) plt.close(fig) s11_pos3 = np.array([[s11_pos3]]).T s12_pos3 = np.array([[s12_pos3]]).T s21_pos3 = np.array([[s21_pos3]]).T s22_pos3 = np.array([[s22_pos3]]).T sparam_pos3 = np.c_[s11_pos3, s12_pos3, s21_pos3, s22_pos3] tela_leds.ui.progressBar.setValue(37.5 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra s parameter", tela_leds.repaint()) print("barra s parameter", QApplication.processEvents()) #Data acquisition for channel 2-2 or 4-4 print("Porta " + str(sw2_port_2) + " - " + str(sw2_port_2) + " do Switch") rfsw_2.sw2_pos(ip_sw2, sw2_port_2, sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) s11_pos4 = vna.get_s11_data() s12_pos4 = vna.get_s12_data() s21_pos4 = vna.get_s21_data() s22_pos4 = vna.get_s22_data() s_pos_d = [s11_pos4, s12_pos4, s21_pos4, s22_pos4] s_pos_d_ch = [sw2_port_2, sw2_port_2] if (curva_s_parameter == True): fig = plt.figure() plt.plot(freq_data_mhz, s11_pos4) plt.title('Parâmetro S11 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_2) + '_s11.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s12_pos4) plt.title('Parâmetro S12 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_2) + '_s12.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s21_pos4) plt.title('Parâmetro S21 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_2) + '_s21.png', dpi=fig.dpi) plt.close(fig) fig = plt.figure() plt.plot(freq_data_mhz, s22_pos4) plt.title('Parâmetro S22 [Ch:' + str(sw2_port_2) + '-' + str(sw2_port_2) + ']') plt.xlabel('FREQUENCY [MHz]') plt.ylabel('AMPLITUDE [dB]') plt.grid() #plt.show() fig.savefig(datapath_save_figure + 'ch_' + str(sw2_port_2) + str(sw2_port_2) + '_s22.png', dpi=fig.dpi) plt.close(fig) s11_pos4 = np.array([[s11_pos4]]).T s12_pos4 = np.array([[s12_pos4]]).T s21_pos4 = np.array([[s21_pos4]]).T s22_pos4 = np.array([[s22_pos4]]).T sparam_pos4 = np.c_[s11_pos4, s12_pos4, s21_pos4, s22_pos4] tela_leds.ui.progressBar.setValue(50 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra s parameter", tela_leds.repaint()) print("barra s parameter", QApplication.processEvents()) freq_data = vna.get_frequency_data() freq_data_file = np.array([[freq_data]]).T sparam = np.c_[freq_data_file, sparam_pos1, sparam_pos2, sparam_pos3, sparam_pos4] print("\nSaving test data...") #test_lib.list_to_file(0,sparam,datapath_save + serial_number + "_data_ch_"+str(sw2_port_1)+ "_" + str(sw2_port_2)+".txt") return (sparam, s_pos_a, s_pos_a_ch, s_pos_b, s_pos_b_ch, s_pos_c, s_pos_c_ch, s_pos_d, s_pos_d_ch, freq_data, freq_data_mhz)
def power_sweep_test(vna,sgen,rffe, rfsw_1,ip_sw1,sw1_port_1,sw1_port_2, rfsw_2,ip_sw2,sw2_port_1,sw2_port_2, center_freq, freq_span, pow_value, att_value, pow_sweep_ini,pow_sweep_end,pow_sweep_step, linearity_ref, linearity_tol,pow_sweep_correction_factor, att_fail_A,att_fail_B, tela_leds,percentual,linearity_test_log, freq_central_position): print("\nRunning Power Sweep (Linearity) test - Ports: "+str(sw2_port_1)+ " - " + str(sw2_port_2)) tela_leds.ui.progressBar.setValue(5+percentual) tela_leds.repaint() QApplication.processEvents() print("barra linearity",tela_leds.repaint()) print("barra linearity",QApplication.processEvents()) #Configuração Inicial de Segurança - Atenuador do RFFE no máximo, e VNA setado para pow_value dB vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") rffe.set_attenuator_value(att_value) sgen.set_signal_DC() sgen.set_pos("direct") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw_1.sw1_pos(ip_sw1,3,3) #coloca o switch 1 na chave 3-3 = 0dBm rfsw_2.sw2_pos(ip_sw2,0,0) leds_rf_switch(3, 3, 0, 0, tela_leds) #Aquisição de dados pow_sweep_resultA_1db=[] pow_sweep_resultA_5db=[] pow_sweep_resultB_1db=[] pow_sweep_resultB_5db=[] pow_sweep_resultA=[] pow_sweep_resultB=[] aver_value = 20 aver_feedback =0 vna.send_command(b":SENSE1:AVER:COUN "+ format(aver_value).encode('utf-8') + b"\n") vna.send_command(b":SENSE1:AVER ON\n") '''while(aver_feedback!=aver_value): aver_feedback=vna.check_avarage() print("valor no loop",aver_feedback) print("Average Factor: OK")''' espacamento=20 #Aquisição de dados para o Canal A: 1-1 ou 3-3 para 1 dB no SWITCH 1 #Configuração deste teste #TESTE 1: Atenuação do Switch 1 configurado para 1 dB (Porta 2-2) print("falha em A: ",att_fail_A) if (att_fail_A==0): #só realiza este teste se o teste de atenuação for aprovado #Nível de 1 dB no Switch 1 #Inicialização de Segurança vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") sw1_port_1=2 print("Running power sweep test: 1dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1)) rfsw_1.sw1_pos(ip_sw1,sw1_port_1,sw1_port_1) #porta 2-2 do switch 1 #Canal A: 1-1 ou 3-3 do Switch 2 strA_1="Running power sweep test: 1dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1) strA_2="Switch 2 - Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1) print("Switch 2 - Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2,sw2_port_1,sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) power_values=np.arange(float(pow_sweep_ini),float(pow_sweep_end),float(pow_sweep_step)) print(pow_sweep_ini,pow_sweep_end,pow_sweep_step) print(power_values) for i in range (0,len(power_values)): vna.set_power_range(power_values[i]) vna.send_command(b":SOUR1:POW "+format(power_values[i]).encode('utf-8')+b"\n") if (i==0): time.sleep(SLEEP_TIME) data_chA=vna.get_s21_data() data_chA_center_freq=data_chA[freq_central_position] pow_sweep_resultA_1db.append(data_chA_center_freq) print("Data acquired!") print("Canal A 1dB:",pow_sweep_resultA_1db) strA_3="Data Acquired:" strA_4="Input Power [dB]".ljust(espacamento)+"Measurement [dB]".ljust(espacamento) #Nível de 5 dB no Switch 1 #Inicialização de Segurança vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") sw1_port_1=1 print("Running power sweep test: 5dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1)) rfsw_1.sw1_pos(ip_sw1,sw1_port_1,sw1_port_1) #porta 1-1 do switch 1 #Canal A: 1-1 ou 3-3 do Switch 2 print("Switch 2 - Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1)) strA_5="Running power sweep test: 5dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1) strA_6="Switch 2 - Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1) rfsw_2.sw2_pos(ip_sw2,sw2_port_1,sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) for i in range (0,len(power_values)): vna.set_power_range(power_values[i]) vna.send_command(b":SOUR1:POW "+format(power_values[i]).encode('utf-8')+b"\n") if (i==0): time.sleep(SLEEP_TIME) data_chA=vna.get_s21_data() data_chA_center_freq=data_chA[freq_central_position] pow_sweep_resultA_5db.append(data_chA_center_freq) strA_7="Data Acquired:" strA_8="Input Power [dB]".ljust(espacamento)+"Measurement [dB]".ljust(espacamento) print("Data acquired!") print("Canal A 5dB:",pow_sweep_resultA_5db) else: strA_1="Data for Channel: Switch 2 - Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1)+" was not acquired due to safety reasons" strA_2="Attenuator test for this channel was not performed or attenuator test for this channel has failed" print("This test was not performed due to safety reasons") tela_leds.ui.progressBar.setValue(25+percentual) tela_leds.repaint() QApplication.processEvents() print("barra linearity",tela_leds.repaint()) print("barra linearity",QApplication.processEvents()) #Aquisição de dados para o Canal B: 2-2 ou 4-4 para 1 dB no SWITCH 1 #Configuração deste teste #TESTE 1: Atenuação do Switch 1 configurado para 1 dB (Porta 2-2) print("falha em B: ",att_fail_B) if (att_fail_B==0): #só realiza este teste se o teste de atenuação for aprovado #Nível de 1 dB no Switch 1 #Inicialização de Segurança vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") sw1_port_1=2 print("Running power sweep test: 1dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1)) rfsw_1.sw1_pos(ip_sw1,sw1_port_1,sw1_port_1) #porta 2-2 do switch 1 #Canal B: 2-2 ou 4-4 do Switch 2 print("Switch 2 - Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2)) strB_1="Running power sweep test: 1dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1) strB_2="Switch 2 - Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2) rfsw_2.sw2_pos(ip_sw2,sw2_port_2,sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) power_values=np.arange(float(pow_sweep_ini),float(pow_sweep_end),float(pow_sweep_step)) for i in range (0,len(power_values)): vna.set_power_range(power_values[i]) vna.send_command(b":SOUR1:POW "+format(power_values[i]).encode('utf-8')+b"\n") data_chB=vna.get_s21_data() data_chB_center_freq=data_chB[freq_central_position] pow_sweep_resultB_1db.append(data_chB_center_freq) print("Data acquired!") print("Canal B 1dB:",pow_sweep_resultB_1db) strB_3="Data Acquired:" strB_4="Input Power [dB]".ljust(espacamento)+"Measurement [dB]".ljust(espacamento) #Nível de 5 dB no Switch 1 #Inicialização de Segurança vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") sw1_port_1=1 print("Running power sweep test: 5dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1)) rfsw_1.sw1_pos(ip_sw1,sw1_port_1,sw1_port_1) #porta 1-1 do switch 1 #Canal A: 2-2 ou 4-4 do Switch 2 print("Switch 2 - Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2,sw2_port_2,sw2_port_2) strB_5="Running power sweep test: 5dB of Attenuation - Switch 1 - Channel: "+str(sw1_port_1)+ "-" + str(sw1_port_1) strB_6="Switch 2 - Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) for i in range (0,len(power_values)): vna.set_power_range(power_values[i]) vna.send_command(b":SOUR1:POW "+format(power_values[i]).encode('utf-8')+b"\n") data_chB=vna.get_s21_data() data_chB_center_freq=data_chB[freq_central_position] pow_sweep_resultB_5db.append(data_chB_center_freq) print("Canal B 5dB:",pow_sweep_resultB_5db) print("Data acquired!") strB_7="Data Acquired:" strB_8="Input Power [dB]".ljust(espacamento)+"Measurement [dB]".ljust(espacamento) else: strB_1="Data for Channel: Switch 2 - Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2)+" was not acquired due to safety reasons" strB_2="Attenuator test for this channel was not performed or attenuator test for this channel has failed" print("This test was not performed due to safety reasons") tela_leds.ui.progressBar.setValue(45+percentual) tela_leds.repaint() QApplication.processEvents() print("barra linearity",tela_leds.repaint()) print("barra linearity",QApplication.processEvents()) #Tolerance print("Upper Boundary: ", linearity_ref+linearity_tol) print("Lower Boundary: ", linearity_ref-linearity_tol) #Calculations Channel A if (att_fail_A==0): fail_A=0 for i in range(0,len(power_values)): pow_sweep_resultA.append(pow_sweep_resultA_1db[i]-pow_sweep_resultA_5db[i]) pow_sweep_resultA[i]=round(abs(abs(pow_sweep_resultA[i])-pow_sweep_correction_factor),2) if (pow_sweep_resultA[i]>(linearity_ref+linearity_tol)): fail_A=fail_A+1 if fail_A!=0: lin_resultA="Linearity Test Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1)+": FAILED" print("Result: ", pow_sweep_resultA) else: lin_resultA="Linearity Test Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1)+": OK" print("Result: ", pow_sweep_resultA) else: lin_resultA = "Linearity Test for Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1) + ": FAILED" pow_sweep_resultA = "-" print(lin_resultA) #Calculations Channel B if (att_fail_B==0): fail_B=0 for i in range(0,len(power_values)): pow_sweep_resultB.append(pow_sweep_resultB_1db[i]-pow_sweep_resultB_5db[i]) pow_sweep_resultB[i]=round(abs(abs(pow_sweep_resultB[i])-pow_sweep_correction_factor),2) if (pow_sweep_resultB[i]>(linearity_ref+linearity_tol)): fail_B=fail_B+1 if fail_B!=0: lin_resultB="Linearity Test Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2)+": FAILED" print("Result: ", pow_sweep_resultB) else: lin_resultB="Linearity Test Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2)+": OK" print("Result: ", pow_sweep_resultB) else: lin_resultB = "Linearity Test for Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2) + ": FAILED" pow_sweep_resultB = "-" print(lin_resultB) if(att_fail_A==0): linearity_test_log.append("\n"+strA_2) linearity_test_log.append(strA_1) linearity_test_log.append(strA_3) linearity_test_log.append(strA_4) for i in range (0,len(power_values)): linearity_test_log.append(str(power_values[i]).ljust(espacamento)+str(pow_sweep_resultA_1db[i]).ljust(espacamento)) linearity_test_log.append(strA_5) #linearity_test_log.append(strA_6) linearity_test_log.append(strA_7) linearity_test_log.append(strA_8) for i in range (0,len(power_values)): linearity_test_log.append(str(power_values[i]).ljust(espacamento)+str(pow_sweep_resultA_5db[i]).ljust(espacamento)) linearity_test_log.append("Final Result:") #linearity_test_log.append(strA_6) linearity_test_log.append("Measurement".ljust(espacamento)+"Result [dB]".ljust(espacamento)) for i in range (0,len(pow_sweep_resultA)): linearity_test_log.append(str((i+1)).ljust(espacamento)+str(pow_sweep_resultA[i]).ljust(espacamento)) linearity_test_log.append(lin_resultA+"\n") else: fail_A=1 linearity_test_log.append(strA_1) linearity_test_log.append(strA_2) linearity_test_log.append(lin_resultA) if(att_fail_B==0): linearity_test_log.append("\n"+strB_2) linearity_test_log.append(strB_1) linearity_test_log.append(strB_3) linearity_test_log.append(strB_4) for i in range (0,len(power_values)): linearity_test_log.append(str(power_values[i]).ljust(espacamento)+str(pow_sweep_resultB_1db[i]).ljust(espacamento)) linearity_test_log.append(strB_5) #linearity_test_log.append(strB_6) linearity_test_log.append(strB_7) linearity_test_log.append(strB_8) for i in range (0,len(power_values)): linearity_test_log.append(str(power_values[i]).ljust(espacamento)+str(pow_sweep_resultB_5db[i]).ljust(espacamento)) linearity_test_log.append("Final Result:") #linearity_test_log.append(strB_6) linearity_test_log.append("Measurement".ljust(espacamento)+"Result [dB]".ljust(espacamento)) for i in range (0,len(pow_sweep_resultA)): linearity_test_log.append(str((i+1)).ljust(espacamento)+str(pow_sweep_resultB[i]).ljust(espacamento)) linearity_test_log.append(lin_resultB+"\n") else: fail_B=1 linearity_test_log.append(strB_1) linearity_test_log.append(strB_2) linearity_test_log.append(lin_resultB) #Coloca o equipamento para operar na potência de referência vna.set_power_range(pow_value) vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") #Coloca o switch 1 no valor de referência de 0 dB sw1_port_1=3 rfsw_1.sw1_pos(ip_sw1,sw1_port_1,sw1_port_1) #porta 1-1 do switch 1 leds_rf_switch(sw1_port_1, sw1_port_2, 0, 0, tela_leds) vna.send_command(b":SENSE1:AVER OFF\n") tela_leds.ui.progressBar.setValue(50+percentual) tela_leds.repaint() QApplication.processEvents() print("barra linearity",tela_leds.repaint()) print("barra linearity",QApplication.processEvents()) return (pow_sweep_resultA,pow_sweep_resultB,fail_A,fail_B)
def crosstalk_test(vna,sgen,rffe, rfsw_1,ip_sw1,sw1_port_1,sw1_port_2, rfsw_2,ip_sw2,sw2_port_1,sw2_port_2, center_freq, freq_span, pow_value, att_value, xtalk_ref,xtalk_tol_ref, start_bandwidth,stop_bandwidth, crosstalk_test_log,percentual,tela_leds, s_parameter_test_selection, s_parameter_data_chAA,s_parameter_data_chBB, s_parameter_data_chAB,s_parameter_data_chBA, freq_data): print("Running Crosstalk test - Ports: "+str(sw2_port_1)+ " - " + str(sw2_port_2)) tela_leds.ui.progressBar.setValue(5+percentual) tela_leds.repaint() QApplication.processEvents() print("barra xtalk",tela_leds.repaint()) print("barra xtalk",QApplication.processEvents()) #Configuração Inicial de Segurança - Atenuador do RFFE no máximo, e VNA setado para pow_value dB rffe.set_attenuator_value(att_value) sgen.set_signal_DC() sgen.set_pos("direct") vna.send_command(b":SOUR1:POW "+format(pow_value).encode('utf-8')+b"\n") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw_1.sw1_pos(ip_sw1,3,3) #coloca o switch 1 na chave 3-3 = 0dBm rfsw_2.sw2_pos(ip_sw2,0,0) leds_rf_switch(3, 3, 0, 0, tela_leds) #vna.send_command(b":SENSE1:AVER:COUN "+ format(10).encode('utf-8') + b"\n") vna.send_command(b":SENSE1:AVER OFF\n") #Variables data_chAA_filter=[] data_chBB_filter=[] data_chAB_filter=[] data_chBA_filter=[] #Data Acquisition if(s_parameter_test_selection==True): print("Utilizando os dados adquiridos no teste do S-Parameters") #Neste teste utilizamos o parâmetro S21 #s_parameter_data_chA=[s11,s12,s21,s22] data_chAB=s_parameter_data_chAB[2] data_chBA=s_parameter_data_chBA[2] #start_bandwidth_position for i in range (0,len(freq_data)): if(freq_data[i]>=start_bandwidth): start_bandwidth_position=i break print("Frquencia Detectada: ",freq_data[start_bandwidth_position],"Frequencia Esperada: ",start_bandwidth) #stop_bandwith_position for i in range (0,len(freq_data)): if(freq_data[i]>stop_bandwidth): stop_bandwidth_position=i-1 break print("Frequencia Detectada:",freq_data[stop_bandwidth_position],"Frequencia Esperada: ",stop_bandwidth) for i in range (start_bandwidth_position,stop_bandwidth_position): data_chAB_filter.append(data_chAB[i]) data_chBA_filter.append(data_chBA[i]) print("Aquisição de dados completa...") tela_leds.ui.progressBar.setValue(45+percentual) tela_leds.repaint() QApplication.processEvents() print("barra xtalk",tela_leds.repaint()) print("barra xtalk",QApplication.processEvents()) else: print("Aquisição de dados necessária...Iniciando aquisição...") #Data acquisition for channel A 1-2 or 3-4 print("Channel "+str(sw2_port_1)+ "-" + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2,sw2_port_1,sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_2, tela_leds) data_chAB=vna.get_s21_data() #Data acquisition for channel B 2-1 or 4-3 print("Channel "+str(sw2_port_2)+ "-" + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2,sw2_port_2,sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_1, tela_leds) data_chBA=vna.get_s21_data() #Data acquisition for channel A 1-1 or 3-3 print("Channel "+str(sw2_port_1)+ "-" + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2,sw2_port_1,sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) s_parameter_data_chAA=vna.get_s21_data() #Data acquisition for channel B 2-2 or 4-4 print("Channel "+str(sw2_port_2)+ "-" + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2,sw2_port_2,sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) s_parameter_data_chBB=vna.get_s21_data() #start_bandwidth_position for i in range (0,len(freq_data)): if(freq_data[i]>=start_bandwidth): start_bandwidth_position=i break print("Frquencia Detectada: ",freq_data[start_bandwidth_position],"Frequencia Esperada: ",start_bandwidth) #stop_bandwith_position for i in range (0,len(freq_data)): if(freq_data[i]>stop_bandwidth): stop_bandwidth_position=i-1 break print("Frequencia Detectada:",freq_data[stop_bandwidth_position],"Frequencia Esperada: ",stop_bandwidth) for i in range (start_bandwidth_position,stop_bandwidth_position): data_chAB_filter.append(data_chAB[i]) data_chBA_filter.append(data_chBA[i]) print("Aquisição de dados completa...") tela_leds.ui.progressBar.setValue(45+percentual) tela_leds.repaint() QApplication.processEvents() print("barra xtalk",tela_leds.repaint()) print("barra xtalk",QApplication.processEvents()) #Tolerance print("Lower Boundary: ",xtalk_ref+xtalk_tol_ref) #Calculations and Results of Channel A: 1-2 or 3-4 #Determinar a maior amplitude, e a menor amplitude para comparação: maximum_valueAB= -1000 minimum_valueAB= 1000 for i in range (0,len(data_chAB_filter)): if(data_chAB_filter[i]>maximum_valueAB): maximum_valueAB=data_chAB_filter[i] freq_maximum_position_AB=i if(data_chAB_filter[i]<minimum_valueAB): minimum_valueAB=data_chAB_filter[i] freq_minimum_position_AB=i freq_maximum_AB=freq_data[freq_maximum_position_AB+start_bandwidth_position] freq_minimum_AB=freq_data[freq_minimum_position_AB+start_bandwidth_position] print("Valor Máximo: ",maximum_valueAB, " Frequência: ",freq_maximum_AB) print("Valor Mínimo: ",minimum_valueAB, " Frequência: ",freq_minimum_AB) #calculo aqui if(s_parameter_test_selection==True): xtalk_valueAB=abs(maximum_valueAB-s_parameter_data_chAA[2][freq_maximum_position_AB+start_bandwidth_position]) else: xtalk_valueAB=abs(maximum_valueAB-s_parameter_data_chAA[freq_maximum_position_AB+start_bandwidth_position]) if (xtalk_valueAB<abs((xtalk_ref+xtalk_tol_ref))): xtalk_resultA="Crosstalk Channel "+str(sw2_port_1)+ "-" + str(sw2_port_2)+": FAILED" fail_A=1 else: xtalk_resultA="Crosstalk Channel "+str(sw2_port_1)+ "-" + str(sw2_port_2)+": OK" fail_A=0 print(xtalk_resultA) #Calculations and Results of Channel B: 2-1 or 4-3 #Determinar a maior amplitude, e a menor amplitude para comparação: maximum_valueBA= -1000 minimum_valueBA= 1000 for i in range (0,len(data_chBA_filter)): if(data_chBA_filter[i]>maximum_valueBA): maximum_valueBA=data_chBA_filter[i] freq_maximum_position_BA=i if(data_chBA_filter[i]<minimum_valueBA): minimum_valueBA=data_chBA_filter[i] freq_minimum_position_BA=i freq_maximum_BA=freq_data[freq_maximum_position_BA+start_bandwidth_position] freq_minimum_BA=freq_data[freq_minimum_position_BA+start_bandwidth_position] print("Valor Máximo: ",maximum_valueBA, " Frequência: ",freq_maximum_BA) print("Valor Mínimo: ",minimum_valueBA, " Frequência: ",freq_minimum_BA) #calculo aqui if(s_parameter_test_selection==True): xtalk_valueBA=abs(maximum_valueBA-s_parameter_data_chBB[2][freq_maximum_position_BA+start_bandwidth_position]) else: xtalk_valueBA=abs(maximum_valueBA-s_parameter_data_chBB[freq_maximum_position_BA+start_bandwidth_position]) #calculation if (xtalk_valueBA<abs((xtalk_ref+xtalk_tol_ref))): xtalk_resultB="Crosstalk Channel "+str(sw2_port_2)+ "-" + str(sw2_port_1)+": FAILED" fail_B=1 print(xtalk_resultB) else: xtalk_resultB="Crosstalk Channel "+str(sw2_port_2)+ "-" + str(sw2_port_1)+": OK" fail_B=0 print(xtalk_resultB) #LOG INFO xtalk_valueAB=round(xtalk_valueAB,2) strA_1="Channel "+str(sw2_port_1)+ "-" + str(sw2_port_2) strA_2="Crosstalk [dB]: "+str(xtalk_valueAB) #strA_3="Frequency at Maximum Value [Hz]: "+str(freq_maximum_A) crosstalk_test_log.append(strA_1) crosstalk_test_log.append(strA_2) #crosstalk_test_log.append(strA_3) crosstalk_test_log.append(xtalk_resultA+"\n") xtalk_valueBA=round(xtalk_valueBA,2) strB_1="Channel "+str(sw2_port_2)+ "-" + str(sw2_port_1) strB_2="Crosstalk [dB]: "+str(xtalk_valueBA) #strB_3="Frequency at Maximum Value [Hz]: "+str(freq_maximum_B) crosstalk_test_log.append(strB_1) crosstalk_test_log.append(strB_2) #crosstalk_test_log.append(strB_3) crosstalk_test_log.append(xtalk_resultB+"\n") tela_leds.ui.progressBar.setValue(50+percentual) tela_leds.repaint() QApplication.processEvents() print("barra xtalk",tela_leds.repaint()) print("barra xtalk",QApplication.processEvents()) return (xtalk_valueAB,xtalk_valueBA,fail_A,fail_B)
def attenuators_sweep_test(vna, sgen, rffe, rfsw_1, ip_sw1, sw1_port_1, sw1_port_2, rfsw_2, ip_sw2, sw2_port_1, sw2_port_2, center_freq, freq_span, pow_value, att_value, att_sweep_low, att_sweep_high, att_step, att_step_tol, tela_leds, percentual, attenuator_test_log): print("\nRunning attenuators sweep test - Ports: " + str(sw2_port_1) + " - " + str(sw2_port_2) + "... ") tela_leds.ui.progressBar.setValue(5 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra attenuator", tela_leds.repaint()) print("barra attenuator", QApplication.processEvents()) #Configuração Inicial de Segurança - Atenuador do RFFE no máximo, e VNA setado para pow_value dB rffe.set_attenuator_value(att_value) sgen.set_signal_DC() sgen.set_pos("direct") vna.send_command(b":SOUR1:POW " + format(pow_value).encode('utf-8') + b"\n") test_lib.set_vna(0, center_freq, freq_span, 0, vna) rfsw_1.sw1_pos(ip_sw1, 3, 3) #coloca o switch 1 na chave 3-3 = 0dBm rfsw_2.sw2_pos(ip_sw2, 0, 0) leds_rf_switch(3, 3, 0, 0, tela_leds) #vna.send_command(b":SENSE1:AVER:COUN "+ format(10).encode('utf-8') + b"\n") vna.send_command(b":SENSE1:AVER OFF\n") #Variáveis do tipo lista que serão utilizadas s21_testA = [] step_sizeA = [] s21_testB = [] step_sizeB = [] nivel_attenuation_A = [] nivel_attenuation_B = [] #Data acquisition for channel 1-1 or 3-3 print("\nRunning attenuators sweep test, Channel " + str(sw2_port_1) + " - " + str(sw2_port_1)) rfsw_2.sw2_pos(ip_sw2, sw2_port_1, sw2_port_1) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_1, sw2_port_1, tela_leds) """Sets the attenuation value of both front-ends. The argument should be a floating-point number representing the attenuation (in dB) between 0 dB and 31.5 dB, with a 0.5 dB step size. Argument values other than these will be disconsidered.""" for att in range(int(att_sweep_low * 2), int(att_sweep_high + 1) * 2, int(att_step * 2)): rffe.set_attenuator_value(att / 2) s21 = float(test_lib.marker_value(0, center_freq, "s21", vna)) s21_testA.append(round(s21, 2)) nivel_attenuation_A.append(att / 2) fail = 0 #Tolerance print("Upper Boundary: ", abs(att_step + att_step_tol)) print("Lower Boundary: ", abs(att_step - att_step_tol)) #Calculations of Channel 1-1 or 3-3 for i in range(0, len(s21_testA) - 1): step_sizeA.append(round(s21_testA[i + 1] - s21_testA[i], 2)) if abs(float(step_sizeA[i])) > abs(att_step + att_step_tol) or abs( float(step_sizeA[i])) < abs(att_step - att_step_tol): fail = 1 #Results of Channel 1-1 or 3-3 if fail == 1: att_sweep_resultA = "Attenuator Sweep Test Result Channel " + str( sw2_port_1) + "-" + str(sw2_port_1) + ": FAILED" print("Result: ", step_sizeA) print("Result: Attenuator Sweep Test Result Channel " + str(sw2_port_1) + "-" + str(sw2_port_1) + ": FAILED") fail_A = 1 else: att_sweep_resultA = "Attenuator Sweep Test Result Channel " + str( sw2_port_1) + "-" + str(sw2_port_1) + ": OK" print("Result: ", step_sizeA) print("Result: Attenuator Sweep Test Result Channel " + str(sw2_port_1) + "-" + str(sw2_port_1) + ": OK") fail_A = 0 fail = 0 tela_leds.ui.progressBar.setValue(25 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) #Data acquisition for Channel 2-2 or 4-4 print("Running attenuators sweep test, Channel " + str(sw2_port_2) + " - " + str(sw2_port_2)) rfsw_2.sw2_pos(ip_sw2, sw2_port_2, sw2_port_2) leds_rf_switch(sw1_port_1, sw1_port_2, sw2_port_2, sw2_port_2, tela_leds) """Sets the attenuation value of both front-ends. The argument should be a floating-point number representing the attenuation (in dB) between 0 dB and 31.5 dB, with a 0.5 dB step size. Argument values other than these will be disconsidered.""" for att in range(int(att_sweep_low * 2), int(att_sweep_high + 1) * 2, int(att_step * 2)): rffe.set_attenuator_value(att / 2) s21 = float(test_lib.marker_value(0, center_freq, "s21", vna)) s21_testB.append(round(s21, 2)) nivel_attenuation_B.append(att / 2) #Calculations of Channel 2-2 or 4-4 for i in range(0, len(s21_testB) - 1): step_sizeB.append(round(s21_testB[i + 1] - s21_testB[i], 2)) print(step_sizeB[i]) if abs(float(step_sizeB[i])) > abs(att_step + att_step_tol) or abs( float(step_sizeB[i])) < abs(att_step - att_step_tol): fail = 1 #Results of Channel 2-2 or 4-4 if fail == 1: att_sweep_resultB = "Attenuator Sweep Test Result Channel " + str( sw2_port_2) + "-" + str(sw2_port_2) + ": FAILED" print("Result: ", step_sizeB) print("Result: Attenuator Sweep Test Result Channel " + str(sw2_port_2) + "-" + str(sw2_port_2) + ": FAILED") fail_B = 1 else: att_sweep_resultB = "Attenuator Sweep Test Result Channel " + str( sw2_port_2) + "-" + str(sw2_port_2) + ": OK" print("Result: ", step_sizeB) print("Result: Attenuator Sweep Test Result Channel " + str(sw2_port_2) + "-" + str(sw2_port_2) + ": OK") fail_B = 0 tela_leds.ui.progressBar.setValue(50 + percentual) tela_leds.repaint() QApplication.processEvents() print("barra rf switch", tela_leds.repaint()) print("barra rf switch", QApplication.processEvents()) #LOG INFO espacamento = 25 attenuator_test_log.append("Attenuators sweep test - RFFE Channel: " + str(sw2_port_1) + " - " + str(sw2_port_1)) attenuator_test_log.append("RFFE Attenuation [dB]".ljust(espacamento) + "Result Values [dB]".ljust(espacamento)) for i in range(0, len(step_sizeA)): step_sizeA[i] = abs(step_sizeA[i]) attenuator_test_log.append( str(nivel_attenuation_A[i]).ljust(espacamento) + str(step_sizeA[i]).ljust(espacamento)) attenuator_test_log.append(att_sweep_resultA + "\n") attenuator_test_log.append("Attenuators sweep test - RFFE Channel: " + str(sw2_port_2) + " - " + str(sw2_port_2)) attenuator_test_log.append("RFFE Attenuation [dB]".ljust(espacamento) + "Result Values [dB]".ljust(espacamento)) for i in range(0, len(step_sizeB)): step_sizeB[i] = abs(step_sizeB[i]) attenuator_test_log.append( str(nivel_attenuation_B[i]).ljust(espacamento) + str(step_sizeB[i]).ljust(espacamento)) attenuator_test_log.append(att_sweep_resultB + "\n") return (att_sweep_resultA, step_sizeA, att_sweep_resultB, step_sizeB, fail_A, fail_B, attenuator_test_log)