Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcerf authored and terrorfisch committed Jun 8, 2018
1 parent 69729c3 commit 69ed1db
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
16 changes: 13 additions & 3 deletions MATLAB/+qc/awg_program.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
fprintf('Program ''%s'' is now being instantiated...', a.program_name);
tic;
end
instantiated_pulse = qc.instantiate_pulse(a.pulse_template, 'parameters', qc.join_params_and_dicts(program.parameters_and_dicts), 'channel_mapping', program.channel_mapping, 'window_mapping', program.window_mapping);
instantiated_pulse = qc.instantiate_pulse(a.pulse_template, 'parameters', qc.join_params_and_dicts(program.parameters_and_dicts), 'channel_mapping', program.channel_mapping, 'window_mapping', program.window_mapping);

if a.verbosity > 9
fprintf('took %.0fs\n', toc);
Expand Down Expand Up @@ -72,8 +72,18 @@
% Call directly before trigger comes, otherwise you might encounter a
% trigger timeout. Also, call after daq_operations('add')!
[~, bool, msg] = qc.awg_program('present', qc.change_field(a, 'verbosity', 0));
if bool
% qc.workaround_alazar_single_buffer_acquisition();
if bool
% Wait for AWG to stop playing pulse, otherwise this might lead to a
% trigger timeout since the DAQ is not necessarily configured for the
% whole pulse time and can return data before the AWG stops playing
% the pulse.
if ~isempty(plsdata.awg.currentProgam)
waitingTime = min(max(plsdata.awg.registeredPrograms.(plsdata.awg.currentProgam).pulse_duration - (now() - plsdata.awg.triggerStartTime)*24*60*60, 0), plsdata.awg.maxPulseWait);
if waitingTime == plsdata.awg.maxPulseWait
warning('Maximum waiting time ''plsdata.awg.maxPulseWait'' = %g s reached.\nIncrease if you experience problems with the data acquistion.', plsdata.awg.maxPulseWait);
end
pause(waitingTime);
end

hws.arm_program(a.program_name);
plsdata.awg.currentProgam = a.program_name;
Expand Down
7 changes: 6 additions & 1 deletion MATLAB/+qc/conf_seq.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'force_update', false, ...
'add_custom_pulse', false, ... % Automatically add a custom pulse in sequence
'add_custom_pulse_fn', @tune.add_dbz_fid, ... % Can specify a custom function here which modifies the variable a below
'save_custom_var_fn', @tune.get_global_opts,...% Can specify a function which returns data to be saved in the scan
...
... Measurements
'operations', {plsdata.daq.defaultOperations}, ...
Expand All @@ -65,7 +66,7 @@
);
a = util.parse_varargin(varargin, defaultArgs);

if args.add_dbz_fid
if a.add_custom_pulse
try
a = feval(a.add_custom_pulse_fn, a); % Add any proprietary function here
catch err
Expand Down Expand Up @@ -174,6 +175,10 @@
% -> already done by qc.cleanupfn_rf_sources called above
end

% Add custom variables for documentation purposes
scan.configfn(end+1).fn = @smaconfigwrap_save_data;
scan.configfn(end).args = {'custom_var', a.save_custom_var_fn};

% Delete unnecessary data
scan.cleanupfn(end+1).fn = @qc.cleanupfn_delete_getchans;
scan.cleanupfn(end).args = {a.delete_getchans};
Expand Down
3 changes: 2 additions & 1 deletion MATLAB/+qc/daq_operations.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
msg = sprintf('Operations from last armed program ''%s'' reused.\n If an error occurs, try executing another program\n first to update the operations.', plsdata.awg.currentProgam);
else
daq.register_operations(a.program_name, qc.operations_to_python(a.operations));
msg = sprintf('Operations for program ''%s'' added', a.program_name);
msg = sprintf('Operations for program ''%s'' added', a.program_name);
qc.workaround_alazar_single_buffer_acquisition();
end
bool = true;

Expand Down
3 changes: 2 additions & 1 deletion MATLAB/+qc/program_to_struct.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
'parameters_and_dicts', {parameters_and_dicts}, ...
'channel_mapping', channel_mapping, ...
'window_mapping', window_mapping ...
);
);
program.pulse_duration = qc.get_pulse_duration(pulse_template, qc.join_params_and_dicts(program.parameters_and_dicts));

for name = fieldnames(program.channel_mapping)'
if strcmp(class(program.channel_mapping.(name{1})), 'py.NoneType')
Expand Down
3 changes: 3 additions & 0 deletions MATLAB/+qc/setup_tabor_awg.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ function setup_tabor_awg(varargin)
'taborName', 'TaborAWG2184C', ...
'ip', '169.254.40.2', ...
'dcMode', false, ...
'maxPulseWait', 60, ... % Maximum waiting time in s in qc.awg_program before arming DAQ again
'taborDriverPath', 'C:\Users\lablocal\Documents\PYTHON\TaborDriver\' ...
);
args = util.parse_varargin(varargin, defaultArgs);
plsdata.awg.sampleVoltPerAwgVolt = args.sampleVoltPerAwgVolt;
plsdata.awg.dcMode = args.dcMode;
plsdata.awg.triggerStartTime = 0;
plsdata.awg.maxPulseWait = args.maxPulseWait;

for smChannels = args.smChannels
if ~(smdata.channels(smchanlookup(smChannels{1})).instchan(1) == sminstlookup(args.taborName))
Expand Down
4 changes: 3 additions & 1 deletion MATLAB/+qc/workaround_alazar_single_buffer_acquisition.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ function workaround_alazar_single_buffer_acquisition()
plsdata.daq.inst.config.totalRecordSize = int64(0);
plsdata.daq.inst.config.aimedBufferSize = int64(2^24);
plsdata.daq.inst.card.reset
plsdata.daq.inst.update_settings = py.True;
plsdata.daq.inst.update_settings = py.True;

fprintf('qc.workaround_alazar_single_buffer_acquisition executed\n');

0 comments on commit 69ed1db

Please sign in to comment.