Skip to content

Commit

Permalink
Raysu 202207 (#132)
Browse files Browse the repository at this point in the history
Co-authored-by: FolkLab <[email protected]>
Co-authored-by: Ruiheng Su <[email protected]>
  • Loading branch information
3 people authored Apr 14, 2023
1 parent 42217c7 commit dfe9d43
Show file tree
Hide file tree
Showing 7 changed files with 1,732 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Required/ScanController.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ function EndScan([S, save_experiment, aborting, additional_wavenames])
endif

if(sc_checkBackup()) // check if a path is defined to backup data
sc_copyNewFiles(S_.filenum, save_experiment=save_experiment) // copy data to server mount point (nvar filenum gets incremented after HDF is opened)
sc_copyNewFiles(S_.filenum, save_experiment=save_experiment) // copy data to server mount point (nvar filenum gets incremented after HDF is opened)
endif

// add info about scan to the scan history file in /config
Expand Down
2 changes: 1 addition & 1 deletion Required/ScanController_INSTR.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ threadsafe function/s readInstr(instrID, [read_term, read_bytes, binary])
string buffer, err
variable return_count
variable status = viRead(instrID, buffer, read_bytes, return_count)
if(status != 0 && status != 0x3fff0006) // 0x3fff0006 means read_bytes = return_count (NOT AN ERROR).
if(status != 0 && status != 0x3fff0006 && status != 0x3fff0005) // 0x3fff0006 means read_bytes = return_count (NOT AN ERROR).
VISAerrormsg("readInstr() -- viRead", instrID, status)
return "NaN" // abort not supported in threads (v7)
endif
Expand Down
117 changes: 93 additions & 24 deletions Required/Scans.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,10 @@ function ScanFastDAC2D(fdID, startx, finx, channelsx, starty, finy, channelsy, n

end




function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex, [y_label, comments, nosave]) //Units: mV
variable instrID, startx, finx, numptsx, delayx, rampratex, nosave
string channelsx, y_label, comments
abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"
//abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"

// Reconnect instruments
sc_openinstrconnections(0)
Expand All @@ -681,7 +678,7 @@ function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex,
// Initialize ScanVars
struct ScanVars S
initScanVars(S, instrIDx=instrID, startx=startx, finx=finx, channelsx=channelsx, numptsx=numptsx, delayx=delayx, rampratex=rampratex, \
y_label=y_label, comments=comments)
y_label=y_label, x_label = "k2400", comments=comments)

// Check software limits and ramprate limits
// PreScanChecksKeithley(S)
Expand All @@ -690,7 +687,7 @@ function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex,
rampK2400Voltage(S.instrIDx, startx)

// Let gates settle
sc_sleep(S.delayy*5)
sc_sleep(S.delayy*20)

// Make waves and graphs etc
initializeScan(S)
Expand All @@ -699,7 +696,8 @@ function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex,
variable i=0, setpointx
do
setpointx = S.startx + (i*(S.finx-S.startx)/(S.numptsx-1))
rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
// rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
setK2400Voltage(S.instrIDx, setpointx)
sc_sleep(S.delayx)
RecordValues(S, i, i)
i+=1
Expand All @@ -713,25 +711,24 @@ function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex,
endif
end


function Scank24002D(instrIDx, startx, finx, numptsx, delayx, rampratex, instrIDy, starty, finy, numptsy, delayy, rampratey, [y_label, comments, nosave]) //Units: mV
variable instrIDx, startx, finx, numptsx, delayx, rampratex, instrIDy, starty, finy, numptsy, delayy, rampratey, nosave
string y_label, comments
abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"
//abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"

// Reconnect instruments
sc_openinstrconnections(0)

// Set defaults
comments = selectstring(paramisdefault(comments), comments, "")
y_label = selectstring(paramisdefault(y_label), y_label, "Keithley /mV")
y_label = selectstring(paramisdefault(y_label), y_label, "k2400 (mV)")


// Initialize ScanVars
struct ScanVars S
initScanVars(S, instrIDx=instrIDx, startx=startx, finx=finx, numptsx=numptsx, delayx=delayx, rampratex=rampratex, \
instrIDy=instrIDy, starty=starty, finy=finy, numptsy=numptsy, delayy=delayy, rampratey=rampratey, \
y_label=y_label, comments=comments)
y_label=y_label, x_label = "k2400 (mV)", comments=comments)

// Check software limits and ramprate limits
// PreScanChecksKeithley(S)
Expand All @@ -758,7 +755,8 @@ function Scank24002D(instrIDx, startx, finx, numptsx, delayx, rampratex, instrID
j=0
do
setpointx = S.startx + (j*(S.finx-S.startx)/(S.numptsx-1))
rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
// rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
setK2400Voltage(S.instrIDx, setpointx)
sc_sleep(S.delayx)
RecordValues(S, i, j)
j+=1
Expand Down Expand Up @@ -1092,19 +1090,19 @@ end
function ScanLS625Magnet(instrID, startx, finx, numptsx, delayx, [y_label, comments, nosave])
variable instrID, startx, finx, numptsx, delayx, nosave
string y_label, comments
abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"
//abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"

// Reconnect instruments
sc_openinstrconnections(0)

// Set defaults
comments = selectstring(paramisdefault(comments), comments, "")
y_label = selectstring(paramisdefault(y_label), y_label, "Field /mT")
y_label = selectstring(paramisdefault(y_label), y_label, "")

// Initialize ScanVars
struct ScanVars S
initScanVars(S, instrIDx=instrID, startx=startx, finx=finx, numptsx=numptsx, delayx=delayx, \
y_label=y_label, comments=comments)
y_label=y_label, x_label = "Field /mT", comments=comments)


// Check software limits and ramprate limits
Expand All @@ -1123,7 +1121,7 @@ function ScanLS625Magnet(instrID, startx, finx, numptsx, delayx, [y_label, comme
variable i=0, setpointx
do
setpointx = S.startx + (i*(S.finx-S.startx)/(S.numptsx-1))
setlS625fieldWait(S.instrIDx, setpointx)
setlS625fieldWait(S.instrIDx, setpointx, short_wait = 1) // Mr Ray changed this on August 04
sc_sleep(S.delayx)
RecordValues(S, i, i)
i+=1
Expand Down Expand Up @@ -1201,12 +1199,12 @@ end


function ScanFastDACLS625Magnet2D(fdID, startx, finx, channelsx, magnetID, starty, finy, numptsy, [numpts, sweeprate, rampratex, delayy, startxs, finxs, y_label, comments, nosave, use_AWG])
// 2D Scan with Fastdac on x-axis and keithley on y-axis
// 2D Scan with Fastdac on x-axis and magnet on y-axis
// Note: Must provide numptsx OR sweeprate in optional parameters instead
// Note: channels should be a comma-separated string ex: "0,4,5"
variable fdID, startx, finx, starty, finy, numptsy, numpts, sweeprate, magnetID, rampratex, delayy, nosave, use_AWG
string channelsx, y_label, comments, startxs, finxs
abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"
//abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"

// Set defaults
delayy = ParamIsDefault(delayy) ? 0.01 : delayy
Expand Down Expand Up @@ -1265,14 +1263,78 @@ function ScanFastDACLS625Magnet2D(fdID, startx, finx, channelsx, magnetID, start
else
dowindow /k SweepControl
endif

end


function ScanK2400LS625Magnet2D(keithleyID, startx, finx, channelsx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, rampratey, [y_label, comments, nosave]) //Units: mV
function ScanFastDacSlowLS625Magnet2D(instrIDx, startx, finx, channelsx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, [rampratey, y_label, comments, nosave])
// sweep one or more FastDAC channels but in the ScanController way (not ScanControllerFastdac). I.e. ramp, measure, ramp, measure...
// channels should be a comma-separated string ex: "0, 4, 5"
variable instrIDx, startx, finx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, nosave, rampratey
string channelsx, comments, y_label

// Reconnect instruments
sc_openinstrconnections(0)

// Set defaults
comments = selectstring(paramisdefault(comments), comments, "")
y_label = selectstring(paramisdefault(y_label), y_label, "")
// Initialize ScanVars
struct ScanVars S

initScanVars(S, instrIDx=instrIDx, startx=startx, finx=finx, channelsx=channelsx, numptsx=numptsx, delayx=delayx, rampratex=rampratex, \
instrIDy=magnetID, starty=starty, finy=finy, numptsy=numptsy, delayy=delayy, rampratey=rampratey, \
y_label=y_label, comments=comments)

// Check limits (not as much to check when using FastDAC slow)
scc_checkLimsFD(S)
S.lims_checked = 1

// Ramp to start without checks because checked above
rampMultipleFDAC(S.instrIDx,channelsx,S.startx,ramprate=S.rampratex, ignore_lims=1)

if (!paramIsDefault(rampratey))
setLS625rate(magnetID,rampratey)
endif
setlS625fieldWait(S.instrIDy, starty )

// Let gates settle
asleep(S.delayy*10)

// Make Waves and Display etc
InitializeScan(S)


// Main measurement loop
variable i=0, j=0, setpointx, setpointy
do
setpointx = S.startx
setpointy = S.starty + (i*(S.finy-S.starty)/(S.numptsy-1))
setlS625field(S.instrIDy, setpointy)
rampMultipleFDAC(S.instrIDx,channelsx,setpointx,ramprate=S.rampratex, ignore_lims=1)
setlS625fieldwait(S.instrIDy, setpointy, short_wait = 1)
sc_sleep(S.delayy)
j=0
do
setpointx = S.startx + (j*(S.finx-S.startx)/(S.numptsx-1))
rampMultipleFDAC(S.instrIDx,channelsx,setpointx,ramprate=S.rampratex, ignore_lims=1)
sc_sleep(S.delayx)
RecordValues(S, i, j)
j+=1
while (j<S.numptsx)
i+=1
while (i<S.numptsy)

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

function ScanK2400LS625Magnet2D(keithleyID, startx, finx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, [rampratey, y_label, comments, nosave]) //Units: mV
variable keithleyID, startx, finx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, rampratey, nosave
string channelsx, y_label, comments
abort "WARNING: This scan has not been tested with an instrument connected. Remove this abort and test the behavior of the scan before running on a device!"
string y_label, comments

// Reconnect instruments
sc_openinstrconnections(0)
Expand All @@ -1284,7 +1346,7 @@ function ScanK2400LS625Magnet2D(keithleyID, startx, finx, channelsx, numptsx, de

// Initialize ScanVars
struct ScanVars S
initScanVars(S, instrIDx=keithleyID, startx=startx, finx=finx, channelsx=channelsx, numptsx=numptsx, delayx=delayx, rampratex=rampratex, \
initScanVars(S, instrIDx=keithleyID, startx=startx, finx=finx, numptsx=numptsx, delayx=delayx, rampratex=rampratex, \
instrIDy=magnetID, starty=starty, finy=finy, numptsy=numptsy, delayy=delayy, rampratey=rampratey, \
y_label=y_label, comments=comments)

Expand All @@ -1294,7 +1356,11 @@ function ScanK2400LS625Magnet2D(keithleyID, startx, finx, channelsx, numptsx, de

// Ramp to start without checks because checked above
rampK2400Voltage(S.instrIDx, startx, ramprate=S.rampratex)
setlS625fieldWait(S.instrIDy, starty)

if (!paramIsDefault(rampratey))
setLS625rate(magnetID,rampratey)
endif
setlS625fieldWait(S.instrIDy, starty )

// Let gates settle
sc_sleep(S.delayy*5)
Expand All @@ -1309,6 +1375,7 @@ function ScanK2400LS625Magnet2D(keithleyID, startx, finx, channelsx, numptsx, de
setpointy = S.starty + (i*(S.finy-S.starty)/(S.numptsy-1))
setlS625fieldWait(S.instrIDy, setpointy)
rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
// setK2400Voltage(S.instrIDy, setpointy)

sc_sleep(S.delayy)
j=0
Expand Down Expand Up @@ -1377,6 +1444,8 @@ end





//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// Useful Templates //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 3 additions & 2 deletions Required/ls625_single_supply.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ end
function setLS625fieldWait(instrID,output, [short_wait])
// Set short_wait = 1 if you want the waiting to be a very tight loop (i.e. Useful if trying to ramp very short distances quickly)
variable instrID, output, short_wait

// print("Going to field")
// print(output)
setLS625field(instrID,output)
variable start_time = stopmsTimer(-2)
do
if (short_wait)
asleep(0.01)
asleep(0.1)
else
asleep(2.1) // Over 2s makes the waiting abortable
endif
Expand Down
2 changes: 1 addition & 1 deletion Required/srs830.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function GetSRSSensitivity(instrID,[integer]) // Units: mV or nA
response = str2num(queryInstr(instrID, "SENS?\n"))
if(integer)
return response
endif
endif
modulo = mod(response,3)
expo = (response-modulo)/3

Expand Down
Loading

0 comments on commit dfe9d43

Please sign in to comment.