Skip to content
Snippets Groups Projects
Commit 82c840fc authored by Stephan Philips's avatar Stephan Philips
Browse files

update upload waveforms

parent 5f3f76a8
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
......@@ -19,9 +19,8 @@ class pulselib:
def __init__(self):
# awg channels and locations need to be input parameters.
self.awg_channels = ['P1','P2','P3','P4','P5','B0','B1','B2','B3','B4','B5','G1','I_MW', 'Q_MW', 'M1', 'M2']
# channel type ? - default, IQpair,
# virtual gates
self.awg_channels_to_physical_locations = dict({'B0':('AWG1', 1),
'P1':('AWG1', 2),
'B1':('AWG1', 3),
......@@ -224,10 +223,10 @@ p.start_sequence('mysequence')
SEQ2 = [['INIT', 1, 0], ['Manip', 1, 0], ['Readout', 1, 0] ]
p.add_sequence('mysequence2', SEQ2)
# p.add_sequence('mysequence2', SEQ2)
p.start_sequence('mysequence2')
# p.start_sequence('mysequence2')
# insert in the begining of a segment
# seg.insert_mode()
# seg.clear()
......
......@@ -24,7 +24,7 @@ class keysight_awg():
# Note that this might change when inplementing advanved looping.
self.segmentdata = dict()
for i in self.channels:
self.segmentdata[i] = dict() #name segment + location
self.segmentdata[i] = dict() #name segment + location and date of construction of segment
self.vpp_data = dict()
for i in self.channels:
......@@ -82,8 +82,7 @@ class keysight_awg():
# Check if stuff in the memory, if present, needs to be updated.
if segment_name in self.segmentdata[chan] and unique == False:
if self.segment_bin.get_segment(segment_name).last_mod > self.segmentdata(segment_name):
print('Reusing {} for channel {} '.format(segment_name, chan) )
if self.segment_bin.get_segment(segment_name).last_mod <= self.segmentdata[chan][segment_name]['last_edit']:
continue
if unique == True:
......@@ -108,10 +107,9 @@ class keysight_awg():
segment_name = my_segment['segment']
repetitions= my_segment['ntimes']
unique = my_segment['unique']
# Check if we need to skip the upload.
if segment_name in self.segmentdata[chan] and unique == False:
if self.segment_bin.get_segment(segment_name).last_mod > self.segmentdata(segment_name):
if self.segment_bin.get_segment(segment_name).last_mod <= self.segmentdata[chan][segment_name]['last_edit']:
continue
if unique == False:
......@@ -122,8 +120,9 @@ class keysight_awg():
points = self.get_and_upload_waveform(chan,segment_name, time, my_segment['identifier'][uuid])
time += points
# step 5 make the queue
# step 5 make the queue in the AWG.
print(sequence_data_processed)
def get_and_upload_waveform(self, channel, segment_name, time, uuid=None):
'''
......@@ -132,12 +131,17 @@ class keysight_awg():
This function also adds the waveform to segmentdata variable
'''
seg_number = self.get_new_segment_number(channel)
segment_data = self.segment_bin.get_segment(segment_name).get_pulse(channel, time)
segment_data = self.segment_bin.get_segment(segment_name).get_waveform(channel, self.vpp_data, time)
last_mod = self.segment_bin.get_segment(segment_name).last_mod
# upload data
if uuid is None:
self.segmentdata[channel][segment_name] = seg_number
self.segmentdata[channel][segment_name] = dict()
self.segmentdata[channel][segment_name]['mem_pointer'] = seg_number
self.segmentdata[channel][segment_name]['last_edit'] = last_mod
else:
self.segmentdata[channel][uuid] = seg_number
self.segmentdata[channel][uuid] = dict()
self.segmentdata[channel][uuid]['mem_pointer'] = seg_number
self.segmentdata[channel][uuid]['last_edit'] = last_mod
return len(segment_data)
def adjust_vmin_vmax_data(self, Vmin_max_data):
......@@ -200,8 +204,10 @@ class keysight_awg():
vpp_test[i]['v_off']= (vmax + vmin)/2
# 2) if vpp fals not in old specs, clear memory and add new ranges.
if self.vpp_data[self.channels[0]]['v_pp'] is not None or voltage_range_reset_needed == True:
self.clear_mem()
if self.vpp_data[self.channels[0]]['v_pp'] is None or voltage_range_reset_needed == True:
if self.vpp_data[self.channels[0]]['v_pp'] is not None:
self.clear_mem()
for i in self.channels:
self.update_vpp_single(vpp_test[i],self.vpp_data[i])
......
......@@ -87,20 +87,29 @@ class segment_container():
def get_waveforms(self, channels, Vpp_data, return_type = np.int16):
def get_waveform(self, channel, Vpp_data, sequenc_time, return_type = np.int16):
# get waforms for required channels. For global Vpp, Voffset settings (per channel) and expected data type
self.prep4upload()
upload_data = np.empty([len(channels), self.totaltime], return_type)
upload_data = np.empty([int(self.total_time)], dtype = return_type)
chan_number = None
for i in range(len(self.channels)):
if self.channels[i] == channel:
chan_number = i
# do not devide by 0 (means channels is not used..)
if Vpp_data[channel]['v_pp'] == 0:
Vpp_data[channel]['v_pp'] = 1
# normalise according to the channel, put as
for i in range(len(channels)):
upload_data[i,:] =((self.waveform_cache[i,:] - V_off[self.channels[i]])/Vpp[self.channels[i]]).astype(return_type)
upload_data = ((self.waveform_cache[chan_number,:] - Vpp_data[channel]['v_off'])/Vpp_data[channel]['v_pp']).astype(return_type)
self.waveform_cache = None
return upload_data
def clear_chache():
return
def last_edited(f):
'''
just a simpe decoter used to say that a certain wavefrom is updaded and therefore a new upload needs to be made to the awg.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment