def H3344_script(vip): print 40 * "#" sk = 'H3344_1' vip.set(sk, {'B_connect': 'TRY'}) se.bn_connect_to_lab(vip) ########## ########## ########## ########## vip.instruments[sk].query_ID() print "trigger" vip.instruments[sk].set_trigger(0) #vip.instruments[sk].test_fg1_square(0, 1, 100000) #time.sleep(1.5) settings = { 'F_use_channel': '0', 'R_amplitude': '1.0', 'FILE_PATH_waveform': "C:/Users/Public/Documents/Signadyne/Examples/Waveforms/Gaussian.csv" # Square.csv } vip.instruments[sk].waveform_from_file(settings) #time.sleep(1.5) #vip.instruments[sk].test_fg1_square(0, 1, 200000) #time.sleep(1.5) #for _ in range(2): # a = 1 # f = 10000 # vip.instruments[sk].test_fg1_square(0, a, f) # time.sleep(0.5) # a = 0.5 # f = 20000 # vip.instruments[sk].test_fg1_square(0, a, f) # time.sleep(1) # vip.instruments[sk].offset_sinusoids() # time.sleep(1.5) # a = 0.75 # f = 5000 # vip.instruments[sk].test_fg1_square(0, a, f) # time.sleep(0.5) #vip.instruments[sk].set_dc_offset(0) #time.sleep(2) #vip.instruments[sk]._clear_channels() #time.sleep(2) ########## ########## ########## ########## print "\n/(H3344_script)\n"
def fitting_test(vip): se.bn_load_session_to_vip(vip) sk = 'ZNB_1' vip.set(sk, {'B_connect': 'TRY'}) se.bn_connect_to_lab(vip) vip.Bpy_redo_sweep = True im.bn_do_sweep(vip) print "/(fitting_test)"
def phase_test(vip): sk = 'SGS_32' vip.set(sk, {'B_connect': 'TRY'}) se.bn_connect_to_lab(vip) vip.instruments[sk].set_phase(77) vip.instruments[sk].get_info() vip.instruments[sk].set_power(-50) vip.instruments[sk].set_phase(33) vip.instruments[sk].get_info() print "/(phase_test)"
def set_instrument_test(vip): sk = 'ZNB_1' settings = {'B_connect': 'TRY', 'N_sweep_points': '4001'} vip.set(sk, settings) se.bn_connect_to_lab(vip) vip.instruments[sk].get_info() R_bandwidth = float(vip.get('ZNB_1', 'R_bandwidth')) print "\nBandwidth of {0}: {1}".format(sk, R_bandwidth) print "/(set_instrument_test)"
def set_osci_test(vip): sk = 'RTE1054_1' settings = { 'B_connect': 'TRY' #,'N_sweep_points' : '4001' } vip.set(sk, settings) se.bn_connect_to_lab(vip) vip.instruments[sk].get_info() data_x, data_y = vip.instruments[sk].get_data(1) print data_x[3:9] print data_y[3:9] print "/(set_instrument_test)"
def _build_Instrument_buttons(vip): qw_ref = '_Instruments' tab_ws = ['le', 'dm', 'cb', 'bn', 'lb'] for k in tab_ws: vip._qWidgets[k][qw_ref] = {} for k in ['captions', 'events']: vip.content[k][qw_ref] = {} ########## ########## content vip.content['captions'][qw_ref]['lb'] = {'_lb_instr' : "Instruments"} vip.content['captions'][qw_ref]['bn'] = {'_bn_feedback' : "Feedback" ,'_bn_connect' : "Connect" ,'_bn_adopt' : "Adopt settings" } vip.content['captions'][qw_ref]['cb'] = {} vip.content['events'][qw_ref]['le'] = {} vip.content['events'][qw_ref]['cb'] = {} vip.content['events'][qw_ref]['dm'] = {} vip.content['events'][qw_ref]['bn'] = {'_bn_feedback' : lambda: se.bn_open_GUI_feedback(vip) ,'_bn_connect' : lambda: se.bn_connect_to_lab(vip) ,'_bn_adopt' : lambda: se.bn_adopt_settings(vip) } sw.__fill_widgets(vip, qw_ref) #### ---------- vip._qWidgets['bn'][qw_ref]['_bn_connect'].setFont(QtGui.QFont(cs.FONT, cs.FONTSIZE+4)) vip._qWidgets['bn'][qw_ref]['_bn_connect'].adjustSize() vip._qWidgets['lb'][qw_ref]['_lb_instr'].setAlignment(QtCore.Qt.AlignCenter) ########## ########## hBoxs hBox_ks = ['__instr', '__connect'] hBoxs = {k : QtGui.QHBoxLayout() for k in hBox_ks} hBoxs['__instr'].addWidget(vip._qWidgets['lb'][qw_ref]['_lb_instr']) hBoxs['__instr'].addWidget(vip._qWidgets['bn'][qw_ref]['_bn_feedback']) hBoxs['__connect'].addWidget(vip._qWidgets['bn'][qw_ref]['_bn_connect']) hBoxs['__connect'].addWidget(vip._qWidgets['bn'][qw_ref]['_bn_adopt']) ########## ########## vBox vip._instrument_qw_box = QtGui.QWidget() vBox = QtGui.QVBoxLayout(vip._instrument_qw_box) for k in hBox_ks: vBox.addLayout(hBoxs[k])
def H3344_script(vip): print 40 * "#" sk = 'H3344_1' vip.set(sk, {'B_connect': 'TRY'}) events.bn_connect_to_lab(vip) ########## ########## ########## ########## vip.instruments[sk].query_ID() #vip.instruments[sk].test_fg1_square(0, 1, 100000) #time.sleep(1.5) #settings = {'F_use_channel' : 0 ###n <-- it's saver to pass a string, sis # ,'R_amplitude' : '1.0' # ,'FILE_PATH_waveform' : "E:\Measurement_Software\VIP_all\VIP_170107\Data\Waveforms\Generated_waveforms/nikolaj_gaussian.csv" # Square.csv # } vip.set(sk, {'B_channel_0': 'ON', 'B_channel_1': 'ON'}) #settings = {} #vip.instruments[sk].waveform_from_file(settings) vip.instruments[sk].sin(0, 0.01 * 10**9, 0.5, offset=0, phase=0) # # # time.sleep(3) # #print "trigger" #vip.instruments[sk]._set_trigger(0) #vip.instruments[sk].test_output_on_two_AWG_extTrig_2(settings) #vip.instruments[sk].test_fg1_square(0, 1, 200000) #time.sleep(1.5) #for _ in range(2): # a = 1 # f = 10000 # vip.instruments[sk].test_fg1_square(0, a, f) # time.sleep(0.5) # a = 0.5 # f = 20000 # vip.instruments[sk].test_fg1_square(0, a, f) # time.sleep(1) # vip.instruments[sk].offset_sinusoids() # time.sleep(1.5) # a = 0.75 # f = 5000 # vip.instruments[sk].test_fg1_square(0, a, f) # time.sleep(0.5) #vip.instruments[sk].set_dc_offset(0) #time.sleep(2) #vip.instruments[sk]._clear_channels() #time.sleep(2) ########## ########## ########## ########## print "\n/(H3344_script)\n"
def main(vip): sk = 'Mixer calib.' TIC = time_now() # center_freq = float(input('input your desired LO frequency in GHz: ')) # int_freq = float(input('input your desired intermediate frequency in MHz: ')) # res_band = float(input('input your desired resolution bandwidth in kHz: ')) # LO_pow = float(input('input your desired LO power in dBm: ')) # amp = float(input('input your desired sinusoidal amplitude in V: ')) center_freq = float(vip.get(sk, 'center_freq')) int_freq = float(vip.get(sk, 'int_freq')) res_band = float(vip.get(sk, 'res_band')) SPEC_pow = float(vip.get(sk, 'LO_pow')) amp = float(vip.get(sk, 'R_amplitude')) dig = 'ATS9870_1' spec = 'SGS_31' lo = 'SGS_31' awg = 'H3344_1' ni = 'NI_pulse_1' cal_settings = { 'LO': lo, 'Spec': spec, 'AWG': awg, 'Dig': dig, 'center_freq': center_freq, 'wanted_sideband': center_freq - int_freq, 'int_freq': int_freq, 'R_amplitude': amp } #CONNECT TO INSTRUMENTS vip.set(dig, {'B_connect': 'TRY'}) vip.set(spec, {'B_connect': 'TRY'}) vip.set(lo, {'B_connect': 'TRY'}) vip.set(awg, {'B_connect': 'TRY'}) vip.set(ni, {'B_connect': 'TRY'}) dig_settings = vip.get(dig) meas_type = vip.get('Meas_main', 'meas_type') meas_instr = vip.get(meas_type, 'F_instr_name') old_settings = dict(vip._session[meas_type]) print old_settings print '^' * 50 print dig_settings ni_mode = vip.get(ni, 'F_use_config') print ni_mode vip.set(ni, {'F_use_config': '6: Spec - UpC - DIG'}) print vip.get(ni, 'F_use_config') from interface.session_events import load_config_NI_pulse, safe_NI_pulse load_config_NI_pulse(vip, ni) safe_NI_pulse(vip, ni, False, False) from interface.session_events import bn_connect_to_lab bn_connect_to_lab(vip) #SET PARAMETERS #ideally it now reads off the session and saves it for later #then loads a pre-defined session for calibration vip.set(dig, {'F_channelA_coupling': 'DC'}) vip.set(dig, {'F_channelB_coupling': 'DC'}) vip.set(dig, {'R_intermediate_frequency': '0'}) # vip.set(dig, {'N_records_per_buffer':'50'}) # vip.set(dig, {'N_buffers_per_acquisition':'50'}) sweep_setting = {'sweep_title_1': 'From trace'} vip.set('Sweep', sweep_setting) vip.set('Meas_main', {'meas_type': 'Dig. sample'}) lo_freq = vip.get(lo, 'R_freq_source') center_freq = vip.get(spec, 'R_freq_source') vip.set(lo, {'R_freq_source': str(center_freq)}) sweep_setting = { 'sweep_title_1': 'From trace', 'B_is_max_1': 'ON', 'B_is_max_2': 'OFF' } vip.set('Sweep', sweep_setting) vip.set('Meas_main', {'meas_type': 'Dig. sample'}) vip.set('Dig. sample', { 'N_records_per_buffer': '20', 'N_buffers_per_acquisition': '20' }) vip.set('Dig. sample', {'N_samples_factor': '1'}) vip.set(spec, {'R_freq_source': str(center_freq)}) vip.set(spec, {'R_power_source': str(15)}) vip.set(spec, {'B_output': 'ON'}) vip.set(lo, {'R_freq_source': str(center_freq)}) vip.set(lo, {'R_power_source': str(15)}) vip.set(lo, {'B_output': 'ON'}) settings = vip._session['Dig. sample'] vip.set(dig, settings) from interface.session_events import bn_adopt_settings bn_adopt_settings(vip) reset_awg(vip, awg) if int_freq == 0: offset_sinusoids(vip, awg, int_freq, 0) else: offset_sinusoids(vip, awg, int_freq, amp) wanted_freq = float(center_freq) unwanted_freq = float(center_freq) + 2. * float(int_freq) leak_freq = float(center_freq) + float(int_freq) lo_pow, channel_0_offset, channel_1_offset, phase_diff, amp_imbalance = total_callibration( vip, cal_settings) #span = 1/10*int_freq*100 #rbw = 10*span #suppressed_freq = (center_freq*(10**3)) - int_freq #wanted_freq = (center_freq*(10**3)) + int_freq #inp_pow = 10*log10(1000*((amp)**2)/100) #axes = get_freq_spectrum_trace(sa, 'Freq Spectrum Script-SB-Callibrated Vector Source') #vip.set(awg,{'R_offset_0':str(channel_0_offset)}) #vip.set(awg,{'R_offset_1':str(channel_1_offset)}) vip.instruments[awg].sin(0, int_freq, amp * amp_imbalance, offset=channel_0_offset, phase=phase_diff) vip.instruments[awg].sin(1, int_freq, amp, offset=channel_1_offset, phase=0) #awg_settings = vip.get(awg) #vip.instruments[awg].waveform_from_file(awg_settings) #vip.set(ni,{'F_use_config':ni_mode}) try: load_config_NI_pulse(vip, ni) safe_NI_pulse(vip, ni, False, False) except KeyError: pass print '@' * 50 print phase_diff print amp_imbalance print channel_0_offset print channel_1_offset print 'SUPPRESSED FREQ' print suppressed_freq vip.set(lo, {'R_freq_source': str(lo_freq)}) vip.set(dig, dig_settings) vip.set('Meas_main', {'meas_type': meas_type}) vip.set(meas_type, {'F_instr_name': meas_instr}) print old_settings vip.set(meas_type, old_settings) bn_adopt_settings(vip) print '@' * 50 TOC = time_now() print str(TOC - TIC) + " sec (demo_main)" print "/// Script completed.(demo_main)"