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

added some HVI stuff (in progress)

parent 4a72541e
No related branches found
No related tags found
No related merge requests found
"""
make a pulse object
"""
from example_init import return_pulse_lib
pulse = return_pulse_lib()
"""
define a function that loads the HVI file that will be used thoughout the experiments
"""
def load_HVI():
"""
load a HVI file on the AWG.
Args:
None
Returns:
HVI (SD_HVI) : keyisight HVI object.
"""
HVI = keysightSD1.SD_HVI()
HVI.open("C:/V2_code/HVI/For_loop_single_sequence.HVI")
HVI.assignHardwareWithUserNameAndSlot("Module 0",0,2)
HVI.assignHardwareWithUserNameAndSlot("Module 1",0,3)
HVI.assignHardwareWithUserNameAndSlot("Module 2",0,4)
HVI.assignHardwareWithUserNameAndSlot("Module 3",0,5)
return HVI
"""
define a function that applies the settings to a HVI file and then compiles it before the experiment.
"""
def set_and_compile_HVI(HVI, npt, n_rep, *args, **kwargs):
"""
Function that set values to the currently loaded HVI script and then performs a compile step.
Args:
HVI (SD_HVI) : HVI object that is already loaded in the memory. Will be loaded by default.
npt (int) : number of points of the sequence (assuming every point is one ns) (this is a default argument that will be provided by the pulse_lib library)
n_rep (int) : number of repertitions. This is the number of reperititons that you set in the pulselub object.
Returns:
None
"""
# Length of the sequence
HVI.writeIntegerConstantWithIndex(0, "length_sequence", int(npt/10 + 20))
HVI.writeIntegerConstantWithIndex(1, "length_sequence", int(npt/10 + 20))
HVI.writeIntegerConstantWithIndex(2, "length_sequence", int(npt/10 + 20))
HVI.writeIntegerConstantWithIndex(3, "length_sequence", int(npt/10 + 20))
# number of repetitions
nrep = n_rep
if nrep == 0:
nrep = 1
HVI.writeIntegerConstantWithIndex(0, "n_rep", nrep)
HVI.writeIntegerConstantWithIndex(1, "n_rep", nrep)
HVI.writeIntegerConstantWithIndex(2, "n_rep", nrep)
HVI.writeIntegerConstantWithIndex(3, "n_rep", nrep)
# Inifinite looping
step = 1
if n_rep == 0:
step = 0
HVI.writeIntegerConstantWithIndex(0, "step", step)
HVI.writeIntegerConstantWithIndex(1, "step", step)
HVI.writeIntegerConstantWithIndex(2, "step", step)
HVI.writeIntegerConstantWithIndex(3, "step", step)
HVI.compile()
"""
Function to load the HVI on the AWG. This will be the last function that is executed in the play function.
This function is optional, if not defined, there will be just two calls,
HVI.load()
HVI.start()
So only define if you want to set custom settings just before the experiment starts. Note that you can access most settings via HVI itselves, so it is better to do it via there.
"""
def load_HVI():
# TODO define AWGs..
for awg in awgs:
# set a certain filter on the FPGA
awg.setDigitalFilterMode(2)
HVI.load()
HVI.start()
"""
Let's now set these setting to the AWG, for this peculiar experiment.
"""
my_seq = p.mk_sequence(sequence)
# set number of repetitions (default is 1000)
my_seq.n_rep = 10000
my_seq.add_HVI(load_HVI, set_and_compile_HVI, load_HVI)
my_seq.upload(0)
my_seq.start(0)
# start upload after start.
my_seq.upload(0)
# upload is released shortly after called (~5ms, upload is without any gil.)
No preview for this file type
......@@ -78,10 +78,19 @@ class keysight_uploader():
return None
def __segment_AWG_memory(self):
def _segment_AWG_memory(self):
'''
Generates segments in the memory in the Keysight AWG.
'''
self.cpp_uploader.resegment_memory()
def play(self, id, index):
"""
start playback of a sequence that has been uploaded.
Args:
id
"""
@mk_thread
def uploader(self):
'''
......@@ -174,12 +183,13 @@ class keysight_uploader():
class upload_job(object):
"""docstring for upload_job"""
def __init__(self, sequence, index, seq_id, neutralize=True, priority=0):
def __init__(self, sequence, index, seq_id, n_rep, neutralize=True, priority=0):
'''
Args:
sequence (list of list): list with list of the sequence, number of repetitions and prescalor (// upload rate , see keysight manual)
index (tuple) : index that needs to be uploaded
seq_id (uuid) : if of the sequence
n_rep (int) : number of repetitions of this sequence.
neutralize (bool) : place a neutralizing segment at the end of the upload
priority (int) : priority of the job (the higher one will be excuted first)
'''
......@@ -187,13 +197,25 @@ class upload_job(object):
self.sequence = sequence
self.id = seq_id
self.index = index
self.n_rep = n_rep
self.neutralize = True
self.priority = priority
self.DSP = False
self.upload_data = None
self.HVI = None
def add_dsp_function(self, DSP):
self.DSP =True
self.DSP = True
self.DSP_func = DSP
def add_HVI(HVI, compile_function, start_function):
"""
Introduce HVI functionality to the upload.
args:
HVI (SD_HVI) : HVI object from the keysight libraries
compile_function (function) : function that compiles the HVI code. Default arguments that will be provided are (HVI, npt, n_rep) = (HVI object, number of points of the sequence, number of repetitions wanted)
start_function (function) :function to be executed to start the HVI (this can also be None)
"""
self.HVI = HVI
self.HVI_compile_function = compile_function
self.HVI_start_function = start_function
File added
......@@ -80,7 +80,7 @@ cdef class keysight_upload_module():
min_max_voltage = (channel_data.min_max_voltage.first, channel_data.min_max_voltage.second,)
upload_locations = list(channel_data.data_location_on_AWG)
AWG_init_data[dereference(it).first] = (min_max_voltage, upload_locations)
AWG_init_data[dereference(it).first] = (min_max_voltage, upload_locations, channel_data.npt)
postincrement(it)
......
No preview for this file type
......@@ -285,7 +285,8 @@ class segment_single():
Note that this are the units of this segment and not the sements around it.
Note2 : for a loopobject with a dimensions bigger than one, the setvals are not settable, as a 1D array for each of them is expected. As such, only the first row of the array will be kept... (though it is unlikely that this scenario will occur).
'''
units = ["a.u."]*self.ndim
names = ["undefined"]*self.ndim
setvals = []*self.ndim
......
......@@ -2,6 +2,8 @@ from pulse_lib.segments.segments import segment_container
from pulse_lib.segments.data_handling_functions import find_common_dimension
from pulse_lib.keysight.uploader import upload_job
import uuid
class sequencer():
"""
Class to make sequences for segments.
......@@ -16,22 +18,26 @@ class sequencer():
None
'''
# each segment had its own unique identifier.
self.id = None
self.units = None
self.setpoints = None
self.names = None
self.units = None
self.id = uuid.uuid4()
self._units = None
self._setpoints = None
self._names = None
self._shape = (1,)
self.sequence = list()
self.uploader = upload_module
self.correction_limits = correction_limits
# arguments of post processing the might be needed during rendering.
self.DSP = None
self.neutralize = True
self.priority = -1
# HVI if needed..
self.HVI = None
self.n_rep = 1000
@property
def shape(self):
......@@ -79,17 +85,19 @@ class sequencer():
'''
add a voltage compenstation at the end of the sequence
Args:
compenstate (bool) : compenstate yes or no (default if not set it yes)
compenstate (bool) : compenstate yes or no (default is True)
'''
self.neutralize = compenstate
def add_hvi(self, HVI):
def add_HVI(self, HVI_to_load, compile_function, start_function):
'''
Add HVI code to the AWG.
Args:
HVI (path) : location of the HVI file to upload, before doing the experiment.
HVI_to_load (function) : function that returns a HVI file.
compile_function (function) : function that compiles the HVI code. Default arguments that will be provided are (HVI, npt, n_rep) = (HVI object, number of points of the sequence, number of repetitions wanted)
start_function (function) :function to be executed to start the HVI (this can also be None)
'''
self.HVI = HVI
self.HVI = (HVI_to_load(), compile_function, start_function)
def upload(self, index):
'''
......@@ -104,6 +112,8 @@ class sequencer():
upload_object = upload_job(self.sequence, index, self.id, self.neutralize, self.priority)
upload_object.add_dsp_function(self.DSP)
if self.HVI is not None:
upload_job.add_HVI(*self.HVI)
self.uploader.add_upload_job(upload_object)
......@@ -117,9 +127,7 @@ class sequencer():
Note that the playback will not start until you have uploaded the waveforms.
'''
upload_data = self.uploader.get_upload_info(self.id, index)
self.uploader.play(self.id, index)
self._free_memory(index)
def _free_memory(self, index):
......
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