Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023 tim johann cleanup #136

Merged
merged 3 commits into from
May 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 86 additions & 130 deletions Required/Scans.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function ScanFastDAC(instrID, start, fin, channels, [numptsx, sweeprate, delay,
if (use_awg)
Set_AWG_state(S, AWG, mod(j, S.interlaced_num_setpoints))
endif
Ramp_interlaced_channels(S, S.instrIDy, mod(j, S.interlaced_num_setpoints))
Ramp_interlaced_channels(S, mod(j, S.interlaced_num_setpoints))
endif

// Ramp to start of fast axis
Expand Down Expand Up @@ -574,6 +574,7 @@ function ScanFastDacSlow2D(instrID, startx, finx, channelsx, numptsx, delayx, st
endif
end


//////////////////////
///// DEPRECATED /////
//////////////////////
Expand All @@ -598,33 +599,30 @@ end
// variable use_second_fd = paramisdefault(fdyID) ? 0 : 1 // Whether using a second FD for the y axis gates
//
//
//
// // Reconnect instruments
// sc_openinstrconnections(0)
//
// // Put info into scanVars struct (to more easily pass around later)
// struct ScanVars S
// if (use_bd == 0 && use_second_fd == 0)
// if (use_bd == 0)
// initScanVarsFD(S, fdID, startx, finx, channelsx=channelsx, rampratex=rampratex, numptsx=numpts, sweeprate=sweeprate, numptsy=numptsy, delayy=delayy, \
// starty=starty, finy=finy, channelsy=channelsy, rampratey=rampratey, startxs=startxs, finxs=finxs, startys=startys, finys=finys, comments=comments)
//
// if (use_second_fd)
// S.instrIDy = fdyID
// endif
// else // Using BabyDAC for Y axis so init x in FD_ScanVars, and init y in BD_ScanVars
// initScanVarsFD(S, fdID, startx, finx, channelsx=channelsx, rampratex=rampratex, numptsx=numpts, sweeprate=sweeprate, numptsy=numptsy, delayy=delayy, \
// rampratey=rampratey, startxs=startxs, finxs=finxs, comments=comments)
// s.is2d = 1
// S.starty = starty
// S.finy = finy
// if (use_bd)
// S.instrIDy = bdID
// S.channelsy = scu_getChannelNumbers(channelsy, fastdac=0)
// S.y_label = scu_getDacLabel(S.channelsy, fastdac=0)
// scv_setSetpoints(S, S.channelsx, S.startx, S.finx, S.channelsy, S.starty, S.finy, S.startxs, S.finxs, S.startys, S.finys)
// else // use_second_fd
// S.instrIDy = fdyID
// S.channelsy = scu_getChannelNumbers(channelsy, fastdac=1)
// S.y_label = scu_getDacLabel(S.channelsy, fastdac=1)
// scv_setSetpoints(S, S.channelsx, S.startx, S.finx, S.channelsy, S.starty, S.finy, S.startxs, S.finxs, S.startys, S.finys)
// endif
// S.instrIDy = bdID
// S.channelsy = scu_getChannelNumbers(channelsy, fastdac=0)
// S.y_label = scu_getDacLabel(S.channelsy, fastdac=0)
// scv_setSetpoints(S, S.channelsx, S.startx, S.finx, S.channelsy, starty, finy, S.startxs, S.finxs, startys, finys)
// endif
//
//
// // Check software limits and ramprate limits and that ADCs/DACs are on same FastDAC
//
Expand Down Expand Up @@ -662,7 +660,11 @@ end
// variable i=0, j=0
// variable setpointy, sy, fy
// string chy
// variable interlace_value
// for(i=0; i<S.numptsy; i++)
//
//
// ///// DO NORMAL SCANFASTDAC2D /////
// // Ramp fast axis to start
// rampToNextSetpoint(S, 0, fastdac=1, ignore_lims=1)
//
Expand All @@ -674,6 +676,9 @@ end
//
// // Record fast axis
// scfd_RecordValues(S, i, AWG_list=AWG)
//
//
//
// endfor
//
// // Save by default
Expand All @@ -685,120 +690,10 @@ end
//
//end

function ScanFastDAC2D(fdID, startx, finx, channelsx, starty, finy, channelsy, numptsy, [numpts, sweeprate, bdID, fdyID, rampratex, rampratey, delayy, startxs, finxs, startys, finys, comments, nosave, use_AWG])
// 2D Scan for FastDAC only OR FastDAC on fast axis and BabyDAC on slow axis
// Note: Must provide numptsx OR sweeprate in optional parameters instead
// Note: To ramp with babyDAC on slow axis provide the BabyDAC variable in bdID
// Note: channels should be a comma-separated string ex: "0,4,5"
variable fdID, startx, finx, starty, finy, numptsy, numpts, sweeprate, bdID, fdyID, rampratex, rampratey, delayy, nosave, use_AWG
string channelsx, channelsy, comments, startxs, finxs, startys, finys

// Set defaults
delayy = ParamIsDefault(delayy) ? 0.01 : delayy
comments = selectstring(paramisdefault(comments), comments, "")
startxs = selectstring(paramisdefault(startxs), startxs, "")
finxs = selectstring(paramisdefault(finxs), finxs, "")
startys = selectstring(paramisdefault(startys), startys, "")
finys = selectstring(paramisdefault(finys), finys, "")
variable use_bd = paramisdefault(bdid) ? 0 : 1 // Whether using both FD and BD or just FD
variable use_second_fd = paramisdefault(fdyID) ? 0 : 1 // Whether using a second FD for the y axis gates



// Reconnect instruments
sc_openinstrconnections(0)

// Put info into scanVars struct (to more easily pass around later)
struct ScanVars S
if (use_bd == 0)
initScanVarsFD(S, fdID, startx, finx, channelsx=channelsx, rampratex=rampratex, numptsx=numpts, sweeprate=sweeprate, numptsy=numptsy, delayy=delayy, \
starty=starty, finy=finy, channelsy=channelsy, rampratey=rampratey, startxs=startxs, finxs=finxs, startys=startys, finys=finys, comments=comments)
if (use_second_fd)
S.instrIDy = fdyID
endif
else // Using BabyDAC for Y axis so init x in FD_ScanVars, and init y in BD_ScanVars
initScanVarsFD(S, fdID, startx, finx, channelsx=channelsx, rampratex=rampratex, numptsx=numpts, sweeprate=sweeprate, numptsy=numptsy, delayy=delayy, \
rampratey=rampratey, startxs=startxs, finxs=finxs, comments=comments)
s.is2d = 1
S.starty = starty
S.finy = finy
S.instrIDy = bdID
S.channelsy = scu_getChannelNumbers(channelsy, fastdac=0)
S.y_label = scu_getDacLabel(S.channelsy, fastdac=0)
scv_setSetpoints(S, S.channelsx, S.startx, S.finx, S.channelsy, starty, finy, S.startxs, S.finxs, startys, finys)
endif


// Check software limits and ramprate limits and that ADCs/DACs are on same FastDAC

if(use_bd == 1)
// PreScanChecksBD(Bsv)
PreScanChecksFD(S, x_only=1)
PreScanChecksBD(S, y_only=1)
else // Should work for 1 or 2 FDs
PreScanChecksFD(S)
endif

// If using AWG then get that now and check it
struct AWGVars AWG
if(use_AWG)
fd_getGlobalAWG(AWG)
CheckAWG(AWG, S) // Note: sets S.numptsx here and AWG.lims_checked = 1
endif
SetAWG(AWG, use_AWG)

// Ramp to start without checks
if(use_bd == 1)
RampStartFD(S, x_only=1, ignore_lims=1)
RampStartBD(S, y_only=1, ignore_lims=1)
else // Should work for 1 or 2 FDs
RampStartFD(S, ignore_lims=1)
endif

// Let gates settle
sc_sleep(S.delayy)

// Initialize waves and graphs
initializeScan(S)

// Main measurement loop
variable i=0, j=0
variable setpointy, sy, fy
string chy
variable interlace_value
for(i=0; i<S.numptsy; i++)


///// DO NORMAL SCANFASTDAC2D /////
// Ramp fast axis to start
rampToNextSetpoint(S, 0, fastdac=1, ignore_lims=1)

// Ramp slow axis
rampToNextSetpoint(S, 0, outer_index=i, y_only=1, fastdac=!use_bd, ignore_lims=1)

// Let gates settle
sc_sleep(S.delayy)

// Record fast axis
scfd_RecordValues(S, i, AWG_list=AWG)



endfor

// Save by default
if (nosave == 0)
EndScan(S=S)
else
dowindow /k SweepControl
endif

end




function ScanFastDAC2DInterlaced(fdID, startx, finx, channelsx, starty, finy, channelsy, numptsy, [numpts, sweeprate, bdID, fdyID, rampratex, rampratey, delayy, startxs, finxs, startys, finys, comments, nosave, use_AWG, interlaced_channels, interlaced_setpoints])
function ScanFastDAC2D(fdID, startx, finx, channelsx, starty, finy, channelsy, numptsy, [numpts, sweeprate, bdID, fdyID, rampratex, rampratey, delayy, startxs, finxs, startys, finys, comments, nosave, use_AWG, interlaced_channels, interlaced_setpoints])
// 2D Scan for FastDAC only OR FastDAC on fast axis and BabyDAC on slow axis
// Note: Must provide numptsx OR sweeprate in optional parameters instead
// Note: To ramp with babyDAC on slow axis provide the BabyDAC variable in bdID
Expand Down Expand Up @@ -899,7 +794,7 @@ function ScanFastDAC2DInterlaced(fdID, startx, finx, channelsx, starty, finy, ch

///// LOOP FOR INTERLACE SCANS /////
if (S.interlaced_y_flag)
Ramp_interlaced_channels(S, fdID, mod(i, S.interlaced_num_setpoints))
Ramp_interlaced_channels(S, mod(i, S.interlaced_num_setpoints))
Set_AWG_state(S, AWG, mod(i, S.interlaced_num_setpoints))
if (mod(i, S.interlaced_num_setpoints) == 0) // Ramp slow axis only for first of interlaced setpoints
rampToNextSetpoint(S, 0, outer_index=i, y_only=1, fastdac=!use_bd, ignore_lims=1)
Expand Down Expand Up @@ -952,10 +847,10 @@ function Set_AWG_State(S, AWG, index)
end


function Ramp_interlaced_channels(S, fdID, i)
function Ramp_interlaced_channels(S, i)
// TODO: Should this live in Scans.ipf? If so, is there a better location for it?
struct ScanVars &S
variable fdID, i
variable i

string interlace_channel, interlaced_setpoints_for_channel

Expand All @@ -975,10 +870,8 @@ function Ramp_interlaced_channels(S, fdID, i)
interlace_channel = StringFromList(k, S.interlaced_channels, ",") // return one of the channels in interlaced_channels
interlaced_setpoints_for_channel = StringFromList(k, S.interlaced_setpoints, ";") // return string of values to interlace between for one of the channels in interlaced_channels
interlace_value = str2num(StringFromList(mod(i, ItemsInList(interlaced_setpoints_for_channel, ",")), interlaced_setpoints_for_channel, ",")) // return the interlace value for specific channel, changes per 1d sweep
// rampmultiplefDAC(fdID, interlace_channel, interlace_value)

//////////////////////// Additions to determine instrID from channel name //////////////
// TODO: If this works, then remove the requirement of fdID being passed in....
// Check if channel actually exists on a FastDAC, if not skip
if(numtype(str2num(interlace_channel)) != 0) // If possible channel is a name (not a number)
duplicate/o/free/t/r=[][3] fdacvalstr fdacnames
Expand Down Expand Up @@ -1883,3 +1776,66 @@ end



Function protoFunc_StepTempScan()
// I.e. Function passed to StepTempScanFunc must take no arguments
End


function StepTempScanFunc(sFunc, targettemps, [mag_fields])
String sFunc // string form of function you want to run
wave targettemps
wave mag_fields
// Master function for running scans at multiple temps and magnetic fields. Assumes the function has no input parameters.
// Will run function at set targettemps (including base) and mag_fields
// EXAMPLE USAGE:: stepTempScanFunc("feb17_Scan0to1Peaks_paper", {500, 300, 100}, mag_fields={70, 2000})
FUNCREF protoFunc_StepTempScan func_to_run = $sFunc
svar ls
nvar fd, magz

variable use_mag_field = 0
if (paramisDefault(mag_fields))
make/o/free mag_fields = {0}
use_mag_field = 0
else
use_mag_field = 1
endif


variable j = 0
for (j=0;j<numpnts(mag_fields);j++)
if (use_mag_field) // Only consider ramping field if using mag_fields
if (abs(getls625field(magz) - mag_fields[j]) > 1) // Only ramp and wait if change in field necessary
setls625fieldWait(magz, mag_fields[j])
asleep(5*60)
endif
endif

// Do Low T scan first (if already at low T)
variable low_t_scanned = 0
if (getls370temp(ls, "MC")*1000 < 20)
func_to_run() //run the function
low_t_scanned = 1
endif
setLS370exclusivereader(ls,"mc")

// Scan at current temp
variable i=0
for(i=0;i<numpnts(targettemps);i++)
setLS370temp(ls,targettemps[i])
asleep(2.0)
WaitTillTempStable(ls, targettemps[i], 5, 30, 0.05)
asleep(5*60)
print "MEASURE AT: "+num2str(targettemps[i])+"mK"

func_to_run() //run the function
endfor
setls370heaterOff(ls)
resetls370exclusivereader(ls)

if (!low_t_scanned)
asleep(60*60)
func_to_run() //run the function
endif
endfor

end