helper_scan_func: only need to modify while loop functionality; TODO after: modify for loop
This commit is contained in:
parent
450c0d3924
commit
8ccf19b5cd
@ -414,20 +414,21 @@ def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
|
|||||||
|
|
||||||
# TODO: edit the helper_scan_func and scanning loop below, after this, the code should be complete!
|
# TODO: edit the helper_scan_func and scanning loop below, after this, the code should be complete!
|
||||||
# NOTE: helper function for the scanning loop
|
# NOTE: helper function for the scanning loop
|
||||||
def helper_scan_func(idx, voltage_val, instr=handle, sleep=2):
|
def helper_scan_func(idx, voltage_val, instr=handle, sleep=2): # TODO: idx argument possibly redundant for Dasha's code
|
||||||
|
# => enable V1 preset => set voltage for V1 preset
|
||||||
# TODO: edit code block below for the LCR controller
|
klcSetChannelEnable(handle, 1)
|
||||||
# read the actual voltage and print it out
|
# initialise actual_voltage_val variable
|
||||||
# actual_voltage_val = sep_num_from_units(query_no_echo(instr, 'IMAG?'))[0]*0.1 # convert kG to T
|
|
||||||
actual_voltage_val = [0]
|
actual_voltage_val = [0]
|
||||||
|
klcGetVoltage1(handle, actual_voltage_val)
|
||||||
|
print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V')
|
||||||
|
klcSetVoltage1(handle, voltage_val)
|
||||||
|
|
||||||
print(f'Actual magnet strength: {actual_voltage_val} T,', f'Target magnet strength: {voltage_val} T')
|
# TODO: change the while loop for Dasha's code!!
|
||||||
|
while abs(actual_voltage_val[0] - voltage_val) > 0.0005: # check if target voltage is reached, if not, wait
|
||||||
while abs(actual_voltage_val - voltage_val) > 0.0001: # if the actual voltage is not reached, keep
|
|
||||||
time.sleep(sleep) # little break
|
time.sleep(sleep) # little break
|
||||||
actual_bval = sep_num_from_units(query_no_echo(instr, 'IMAG?'))[0]*0.1
|
actual_bval = sep_num_from_units(query_no_echo(instr, 'IMAG?'))[0]*0.1
|
||||||
# update the actual bval
|
# update the actual bval
|
||||||
print(f'Actual magnet strength: {actual_voltage_val} T,', f'Target magnet strength: {voltage_val} T')
|
print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V')
|
||||||
|
|
||||||
#scanning loop
|
#scanning loop
|
||||||
for i, bval in enumerate(voltage_lst):
|
for i, bval in enumerate(voltage_lst):
|
||||||
|
Loading…
Reference in New Issue
Block a user