diff --git a/Dasha_LCRCode.py b/Dasha_LCRCode.py index bb7d69c..285c047 100644 --- a/Dasha_LCRCode.py +++ b/Dasha_LCRCode.py @@ -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! # NOTE: helper function for the scanning loop - def helper_scan_func(idx, voltage_val, instr=handle, sleep=2): - - # TODO: edit code block below for the LCR controller - # read the actual voltage and print it out - # actual_voltage_val = sep_num_from_units(query_no_echo(instr, 'IMAG?'))[0]*0.1 # convert kG to T + 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 + klcSetChannelEnable(handle, 1) + # initialise actual_voltage_val variable 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') - - while abs(actual_voltage_val - voltage_val) > 0.0001: # if the actual voltage is not reached, keep + # 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 time.sleep(sleep) # little break actual_bval = sep_num_from_units(query_no_echo(instr, 'IMAG?'))[0]*0.1 # 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 for i, bval in enumerate(voltage_lst):