def wx_set_and_amplitude_and_offset(amp=[1.5, 1.5, 1.5, 1.5], offset=[0., 0., 0.057, -0.061]): # [0., 0., 0.0105, -0.083] ''' DESCRIPTION: sets the amplitudes and offsets of each WX channel ''' instr_addr = get_wx_address() # Initializing the instrument inst = tewx.TEWXAwg(instr_addr, paranoia_level=1) # Setting up amplitudes and offsets # amp = [amp12, amp12, 1.5, 1.5] # for ch_index in range(4): inst.send_cmd(':INST:SEL {0}'.format(ch_index + 1)) inst.send_cmd(':VOLT {}'.format(amp[ch_index])) inst.send_cmd(':VOLT:OFFS {}'.format(offset[ch_index])) # query system error syst_err = inst.send_query(':SYST:ERR?') print(syst_err) inst.close() # set_marker_level(which_channel='ch1ch2', which_marker=2, marker_voltage_level=1.2)
def wx_initialize(): instr_addr = '128.252.134.119' # Initializing the instrument inst = tewx.TEWXAwg(instr_addr, paranoia_level=1) inst.send_cmd('*CLS') # Clear errors #inst.send_cmd('*RST') # Reset the device inst.send_cmd(":FREQ:RAST 1000000001.000000", paranoia_level=1) inst.send_cmd(":FREQ:RAST 1000000000.000000", paranoia_level=1) inst.close()
def set_run_mode_continuous(): instr_addr = get_wx_address() # Initializing the instrument inst = tewx.TEWXAwg(instr_addr, paranoia_level=1) # inst.send_cmd('INIT:CONT:STAT ON') # query system error syst_err = inst.send_query(':SYST:ERR?') print(syst_err) inst.close()
def wx_initialize(): instr_addr = get_wx_address() # Initializing the instrument inst = tewx.TEWXAwg(instr_addr, paranoia_level=1) inst.send_cmd('*CLS') # Clear errors #inst.send_cmd('*RST') # Reset the device inst.send_cmd(":FREQ:RAST 1000000001.000000", paranoia_level=1) inst.send_cmd(":FREQ:RAST 1000000000.000000", paranoia_level=1) # syst_err = inst.send_query(':SYST:ERR?') print(syst_err) inst.close()
def set_marker_level(which_channel='ch1ch2', which_marker=2, marker_voltage_level=1.2): # instr_addr = get_wx_address() # Initializing the instrument inst = tewx.TEWXAwg(instr_addr, paranoia_level=1) if which_channel == 'ch1ch2': inst.send_cmd(':INST:SEL {0}'.format(0 + 1)) elif which_channel == 'ch3ch4': inst.send_cmd(':INST:SEL {0}'.format(2 + 1)) inst.send_cmd('MARK:SEL {}'.format(which_marker)) inst.send_cmd('MARK:VOLT:LEV:HIGH {}'.format(marker_voltage_level)) # query system error syst_err = inst.send_query(':SYST:ERR?') print(syst_err) inst.close()
def load_sequence_CSV(self, instr_addr, base_name='foo', file_path=os.getcwd(), num_offset=0): ''' DESCRIPTION: loads multi channel INPUT: OUTPUT: TODO: ''' file_length = self.sequence_length num_steps = self.num_steps if not file_path.endswith("\\"): file_path += "\\" print("loading {}".format(file_path)) # Reading the wave data from .npy file waveforms = [[ None, ] * num_steps for _ in self.channel_list] for ch_index, _ in enumerate(self.channel_list): ch_name = "ch" + str(ch_index + 1) print("loading " + ch_name) for step_index in range(num_steps): file_name = file_path + base_name + "_" + ch_name + "_{:d}.csv".format( step_index + num_offset) waveforms[ch_index][step_index] = np.loadtxt(file_name, dtype=int, delimiter=', ', usecols=(1, )) # Initializing the instrument inst = tewx.TEWXAwg(instr_addr, paranoia_level=1) inst.send_cmd('*CLS') # Clear errors inst.send_cmd( '*RST' ) # Reset the device #need to add several commands to set up device to use markers and other configurations inst.send_cmd(':OUTP:ALL 0') seg_quantum = inst.get_dev_property('seg_quantum', 16) # Setting up the markers # Downloading the wave data seg_len = np.ones(num_steps, dtype=np.uint32) * file_length pseudo_seg_len = num_steps * file_length + (num_steps - 1) * seg_quantum wav_dat = np.zeros(2 * pseudo_seg_len, 'uint16') for ch_index, _ in enumerate(self.channel_list): if ch_index % 2: continue offs = 0 for step_index in range(self.num_steps): wav1 = waveforms[ch_index][step_index] wav2 = waveforms[ch_index + 1][step_index] offs = inst.make_combined_wave(wav1, wav2, wav_dat, dest_array_offset=offs, add_idle_pts=(0 != offs)) # select channel: inst.send_cmd(':INST:SEL {0}'.format(ch_index + 1)) inst.send_cmd('MARK:SEL 1') inst.send_cmd('MARK:SOUR USER') inst.send_cmd('MARK:STAT ON') inst.send_cmd('MARK:SEL 2') inst.send_cmd('MARK:SOUR USER') inst.send_cmd('MARK:STAT ON') # select user-mode (arbitrary-wave): inst.send_cmd(':FUNC:MODE FIX') # delete all segments (just to be sure): inst.send_cmd(':TRAC:DEL:ALL') inst.send_cmd('SEQ:DEL:ALL') # set combined wave-downloading-mode: inst.send_cmd(':TRAC:MODE COMB') # define the pseudo segment: inst.send_cmd(':TRAC:DEF 1,{0}'.format(np.uint32(pseudo_seg_len))) # select segment 1: inst.send_cmd(':TRAC:SEL 1') # download binary data: inst.send_binary_data(':TRAC:DATA', wav_dat) # --------------------------------------------------------------------- # Write the *appropriate* segment-table # (array of 'uint32' values holding the segments lengths) # --------------------------------------------------------------------- inst.send_binary_data(':SEGM:DATA', seg_len) # Setting up sequence mode for step in range(1, num_steps + 1): inst.send_cmd(':SEQ:DEF {},{},1,0'.format(step, step)) inst.send_cmd(':FUNC:MODE SEQ') inst.send_cmd(':SEQ:ADV STEP') # Setting up the triggers inst.send_cmd(':TRIG:SOUR EVEN') inst.send_cmd(':TRIG:COUN 1') # Turn channels on: inst.send_cmd(':INIT:CONT 0') # Setting up amplitudes and offsets amp = [1., 1., 1., 1.] offset = [0., 0., 0., 0.] for ch_index, _ in enumerate(self.channel_list): inst.send_cmd(':INST:SEL {0}'.format(ch_index + 1)) inst.send_cmd(':VOLT {}'.format(amp[ch_index])) inst.send_cmd(':VOLT:OFFS {}'.format(offset[ch_index])) inst.send_cmd(':INST:COUP:STAT ON') inst.send_cmd(':OUTP:ALL 1') # query system error syst_err = inst.send_query(':SYST:ERR?') print(syst_err) inst.close()