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

Raysu 2023 0519 #162

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Required/ScanController.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ function scg_open1Dgraph(wn, x_label, [y_label, append_wn])

if (cmpstr(append_wn, ""))
appendtograph /r $append_wn
makecolorful()
// makecolorful()
legend
endif

Expand Down
124 changes: 99 additions & 25 deletions Required/Scans.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function ScanFastDacSlow(instrID, start, fin, channels, numpts, delay, ramprate,
RampStartFD(S, ignore_lims=1)

// Let gates settle
sc_sleep(S.delayy)
sc_sleep(15)

// Make Waves and Display etc
InitializeScan(S)
Expand All @@ -487,6 +487,7 @@ function ScanFastDacSlow(instrID, start, fin, channels, numpts, delay, ramprate,
sc_sleep(S.delayy)
i = 0
do

rampToNextSetpoint(S, i, fastdac=1, ignore_lims=1) // Ramp x to next setpoint
sc_sleep(S.delayx)
if (s.is2d)
Expand All @@ -507,7 +508,7 @@ function ScanFastDacSlow(instrID, start, fin, channels, numpts, delay, ramprate,
endif
endfor


// Save by default
if (nosave == 0)
EndScan(S=S)
Expand Down Expand Up @@ -900,8 +901,8 @@ end



function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex, [y_label, comments, nosave]) //Units: mV
variable instrID, startx, finx, numptsx, delayx, rampratex, nosave
function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex, [y_label, comments, nosave, ramp]) //Units: mV
variable instrID, startx, finx, numptsx, delayx, rampratex, nosave, ramp
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!"

Expand All @@ -921,10 +922,10 @@ function Scank2400(instrID, startx, finx, channelsx, numptsx, delayx, rampratex,
// PreScanChecksKeithley(S)

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

// Let gates settle
sc_sleep(S.delayy*20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably better to keep delayy instead of hard coding a 2 second sleep. It would be better to add an optional parameter to Scank2400 that allows you to set delayy and if not set will use default of 2.

sc_sleep(5)

// Make waves and graphs etc
initializeScan(S)
Expand All @@ -933,9 +934,14 @@ 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)
setK2400Voltage(S.instrIDx, setpointx)
sc_sleep(S.delayx)
if (ramp ==1)
rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
asleep(S.delayx)
else
setK2400Voltage(S.instrIDx, setpointx)
sc_sleep(S.delayx)
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not essential, but nice to keep orderly indenting.


RecordValues(S, i, i)
i+=1
while (i<S.numptsx)
Expand Down Expand Up @@ -971,11 +977,11 @@ function Scank24002D(instrIDx, startx, finx, numptsx, delayx, rampratex, instrID
// PreScanChecksKeithley(S)

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

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

// Make waves and graphs etc
initializeScan(S)
Expand All @@ -987,7 +993,6 @@ function Scank24002D(instrIDx, startx, finx, numptsx, delayx, rampratex, instrID
setpointy = S.starty + (i*(S.finy-S.starty)/(S.numptsy-1))
rampK2400Voltage(S.instrIDy, setpointy, ramprate=S.rampratey)
rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)

sc_sleep(S.delayy)
j=0
do
Expand Down Expand Up @@ -1371,10 +1376,10 @@ function ScanLS625Magnet(instrID, startx, finx, numptsx, delayx, [y_label, comme
setpointx = S.startx + (i*(S.finx-S.startx)/(S.numptsx-1))
if(fast==1)
setlS625field(S.instrIDx, setpointx)
sc_sleep(max(S.delayx, (0.05+60*abs(finx-startx)/numptsx/ramprate)))
sc_sleep(max(S.delayx, (S.delayx+60*abs(finx-startx)/numptsx/ramprate)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this math do? Looks like you have the time in minutes for a ramp to complete divided by the number of points in x. So if you take 1 data point this is the same as setlS625fieldwait(S.instrIDx, setpointx) but if you take 1e6 data points then you will start collecting data immediately??

else
setlS625fieldwait(S.instrIDx, setpointx)
sc_sleep(S.delayx)
// sc_sleep(S.delayx)
endif
RecordValues(S, i, i)
i+=1
Expand All @@ -1388,7 +1393,6 @@ function ScanLS625Magnet(instrID, startx, finx, numptsx, delayx, [y_label, comme
endif
end


function ScanBabyDACLS625Magnet2D(bdID, startx, finx, channelsx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, rampratey, [startxs, finxs, y_label, comments, nosave]) //Units: mV
// Sweeps BabyDAC on x-axis and Keithley on y-axis
variable bdID, startx, finx, numptsx, delayx, rampratex, magnetID, starty, finy, numptsy, delayy, rampratey, nosave
Expand Down Expand Up @@ -1519,6 +1523,74 @@ function ScanFastDACLS625Magnet2D(fdID, startx, finx, channelsx, magnetID, start
end


function ScanFastDACIPS120Magnet2D(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 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!"

// Set defaults
delayy = ParamIsDefault(delayy) ? 0.01 : delayy
comments = selectstring(paramisdefault(comments), comments, "")
startxs = selectstring(paramisdefault(startxs), startxs, "")
finxs = selectstring(paramisdefault(finxs), finxs, "")

// Reconnect instruments
sc_openinstrconnections(0)

// Put info into scanVars struct (to more easily pass around later)
struct ScanVars S
// Init FastDAC part like usual, then manually set the rest
initScanVarsFD(S, fdID, startx, finx, channelsx=channelsx, rampratex=rampratex, numptsx=numpts, sweeprate=sweeprate, numptsy=numptsy, delayy=delayy, \
startxs=startxs, finxs=finxs, comments=comments)
S.instrIDy = magnetID
s.is2d = 1
S.starty = starty
S.finy = finy
S.y_label = selectString(paramIsDefault(y_label), y_label, "Magnet /mT")

// Check software limits and ramprate limits and that ADCs/DACs are on same FastDAC
PreScanChecksFD(S, x_only=1)
// PreScanChecksMagnet(S, y_only=1)

// Ramp to start without checks
RampStartFD(S, x_only=1, ignore_lims=1)
setips120fieldWait(S.instrIDy, S.starty) // Ramprate should be set beforehand for magnets

// Let gates settle
sc_sleep(S.delayy*3)

// Initialize waves and graphs
initializeScan(S)

// Main measurement loop
variable setpointy
variable i=0, j=0
string chy
for(i=0; i<S.numptsy; i++)
// Ramp slow axis
setpointy = S.starty + (i*(S.finy-S.starty)/(S.numptsy-1))
setips120fieldWait(S.instrIDy, setpointy) // Ramprate should be set beforehand for magnets

// Ramp to start of fast axis
RampStartFD(S, ignore_lims=1, x_only=1)
sc_sleep(S.delayy)

// Record fast axis
scfd_RecordValues(S, i)
endfor

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


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"
Expand All @@ -1531,6 +1603,7 @@ function ScanFastDacSlowLS625Magnet2D(instrIDx, startx, finx, channelsx, numptsx
// Set defaults
comments = selectstring(paramisdefault(comments), comments, "")
y_label = selectstring(paramisdefault(y_label), y_label, "")

// Initialize ScanVars
struct ScanVars S

Expand All @@ -1551,7 +1624,7 @@ function ScanFastDacSlowLS625Magnet2D(instrIDx, startx, finx, channelsx, numptsx
setlS625fieldWait(S.instrIDy, starty )

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

// Make Waves and Display etc
InitializeScan(S)
Expand All @@ -1562,15 +1635,17 @@ function ScanFastDacSlowLS625Magnet2D(instrIDx, startx, finx, channelsx, numptsx
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)
rampMultipleFDAC(S.instrIDx,channelsx, setpointx, ramprate=S.rampratex, ignore_lims=1)
setlS625fieldwait(S.instrIDy, setpointy)
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)
// if (mod(j, 100) == 0)
// sc_sleep(S.delayx)
// endif
RecordValues(S, i, j)
j+=1
while (j<S.numptsx)
Expand Down Expand Up @@ -1626,15 +1701,14 @@ function ScanK2400LS625Magnet2D(keithleyID, startx, finx, numptsx, delayx, rampr
do
setpointx = S.startx
setpointy = S.starty + (i*(S.finy-S.starty)/(S.numptsy-1))
setlS625fieldWait(S.instrIDy, setpointy)
setlS625field(S.instrIDy, setpointy)
rampK2400Voltage(S.instrIDx, setpointx, ramprate=S.rampratex)
// setK2400Voltage(S.instrIDy, setpointy)

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))
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 @@ -1669,7 +1743,7 @@ function ScanSRSFrequency(instrID, startx, finx, numptsx, delayx, nosave)
SetSRSFrequency(S.instrIDx,startx)

// Let gates settle
sc_sleep(S.delayy*10)
sc_sleep(2)

// Make waves and graphs etc
initializeScan(S)
Expand Down
30 changes: 24 additions & 6 deletions Required/fastdac.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function getFADCchannel(fdid, channel, [len_avg])
// Instead of just grabbing one single datapoint which is susceptible to high f noise, this averages data over len_avg and returns a single value
variable fdid, channel, len_avg

len_avg = paramisdefault(len_avg) ? 0.05 : len_avg
len_avg = paramisdefault(len_avg) ? 0.03 : len_avg

variable numpts = ceil(getFADCspeed(fdid)*len_avg)
if(numpts <= 0)
Expand All @@ -139,7 +139,7 @@ function getFADCvalue(fdid, channel, [len_avg])
// Note: Min read time is ~60ms because of having to check SamplingFreq a couple of times -- Could potentially be optimized further if necessary
variable fdid, channel, len_avg

len_avg = paramisdefault(len_avg) ? 0.05 : len_avg
len_avg = paramisdefault(len_avg) ? 0.02 : len_avg

variable/g scfd_val_mv = getFADCchannel(fdid, channel, len_avg=len_avg) // Must be global so can use execute
variable/g scfd_val_real
Expand All @@ -154,8 +154,8 @@ function getFADCvalue(fdid, channel, [len_avg])
end


function getFADCChannelSingle(instrID,channel) // Units: mV
// channel must be the channel number given by the GUI!
function getFADCChannelSingle(instrID, channel) // Units: mV
//cleachannel must be the channel number given by the GUI!
// Gets a single FADC reading only, likely to be very noisy because no filtering of high f noise
// Use getFADCchannelAVG for averaged value

Expand Down Expand Up @@ -504,7 +504,27 @@ function stopPID(instrID)
string cmd=""
sprintf cmd, "STOP_PID"
writeInstr(instrID, cmd+"\r")

end

function stopPIDClearBuffer(instrID)
// stops the PID algorithm on DAC and ADC channels 0
variable instrID

string cmd=""
sprintf cmd, "STOP_PID"
writeInstr(instrID, cmd+"\r")

asleep(1)
clearfdacBuffer(instrID)

writeInstr(instrID, cmd+"\r")

asleep(1)
clearfdacBuffer(instrID)

end


function setPIDTune(instrID, kp, ki, kd)
// sets the PID tuning parameters
Expand Down Expand Up @@ -1766,8 +1786,6 @@ end
/////////////////////////////////// FastDAC Sweeps /////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////



function/s fd_start_sweep(S, [AWG_list])
// Starts one of:
// regular sweep (INT_RAMP in arduino)
Expand Down
Loading