changed while loop cond, updated README

This commit is contained in:
ryantan 2024-11-13 12:52:00 +01:00
parent 79765dd0e3
commit 73025984e6
3 changed files with 5 additions and 4 deletions

View File

@ -295,7 +295,7 @@ def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V') print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V')
klcSetVoltage1(instr, voltage_val) klcSetVoltage1(instr, voltage_val)
while abs(actual_voltage_val[0] - voltage_val) > 0.0005: # check if target voltage is reached, if not, wait while abs(actual_voltage_val[0] - voltage_val) > 0.0011: # check if target voltage is reached, if not, wait
time.sleep(sleep) # little break time.sleep(sleep) # little break
klcGetVoltage1(instr, actual_voltage_val) # update the actual voltage klcGetVoltage1(instr, actual_voltage_val) # update the actual voltage
print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V') print(f'Actual output voltage: {actual_voltage_val[0]} V,', f'Target output voltage: {voltage_val} V')
@ -341,7 +341,7 @@ def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
klcSetChannelEnable(handle, 0) # disables channel output klcSetChannelEnable(handle, 0) # disables channel output
#save intensity & WL data as .txt #save intensity & WL data as .txt
os.chdir('C:/Users/localadmin/Desktop/Users/Dasha') os.chdir('C:/Users/localadmin/Desktop/Users/Dasha/241112_LCR_code_test')
# creates new folder for MAP data # creates new folder for MAP data
if folder_name == '': if folder_name == '':
folder_name = f"{datetime.datetime.now().strftime('%Y_%m_%d_%H.%M')}" folder_name = f"{datetime.datetime.now().strftime('%Y_%m_%d_%H.%M')}"
@ -351,7 +351,7 @@ def LCR_scan_func(handle:int, init_voltage:float, final_voltage:float,
os.mkdir(folder_name) os.mkdir(folder_name)
# Here the things will be saved in a new folder under user Lukas ! # Here the things will be saved in a new folder under user Lukas !
# IMPORTANT last / has to be there, otherwise data cannot be saved and will be lost!!!!!!!!!!!!!!!! # IMPORTANT last / has to be there, otherwise data cannot be saved and will be lost!!!!!!!!!!!!!!!!
os.chdir('C:/Users/localadmin/Desktop/Users/Dasha/'+ folder_name) os.chdir('C:/Users/localadmin/Desktop/Users/Dasha/241112_LCR_code_test'+ folder_name)
intensity_data = np.array(intensity_data) intensity_data = np.array(intensity_data)
np.savetxt(base_file_name + '.txt', intensity_data) np.savetxt(base_file_name + '.txt', intensity_data)

View File

@ -4,7 +4,7 @@ import os,sys
# TODO: change the file path below for the offline computer, maybe direct to the KLC programm # TODO: change the file path below for the offline computer, maybe direct to the KLC programm
# folder path (under C++) # folder path (under C++)
#region import dll functions; NOTE: ENTER ABSOLUTE PATH BELOW #region import dll functions; NOTE: ENTER ABSOLUTE PATH BELOW
klcLib=cdll.LoadLibrary(r"C:\Users\rtan\Documents\RyanWork2024\Dasha-LCR_Code\Thorlabs_KLC_PythonSDK\"KLCCommandLib_x64.dll") klcLib=cdll.LoadLibrary(r"C:\Users\localadmin\Desktop\Users\Dasha\LCRControllerCode-master\lcrcontrollercode\KLCCommandLib_x64.dll")
cmdList = klcLib.List cmdList = klcLib.List
cmdList.argtypes=[c_char_p, c_int] cmdList.argtypes=[c_char_p, c_int]

View File

@ -12,6 +12,7 @@ The user of the script must enter the given start- and end voltages, as well as
In the next step, enter the name of the file, under the variable `experiment_settings`. The main functionality to perform the rotation script is located in the `LCR_scan_func`, for which there are additional input parameters to modify measurement: `reversescan_bool` allows the user to perform the rotation in the opposite direction, and is set to `False` on default. `zerowhenfin_bool` sets the voltage of preset 1 (V1, as called in the SDK from Thorlabs) to 0 V **and** disables the output of the device, and is set to `True` per defaut. `loopscan_bool` allows for a measurement series starting voltage -> final voltage -> starting voltage loop, and is set to `False` per default. These parameters and editable in the function head, right at th bottom of the script. In the next step, enter the name of the file, under the variable `experiment_settings`. The main functionality to perform the rotation script is located in the `LCR_scan_func`, for which there are additional input parameters to modify measurement: `reversescan_bool` allows the user to perform the rotation in the opposite direction, and is set to `False` on default. `zerowhenfin_bool` sets the voltage of preset 1 (V1, as called in the SDK from Thorlabs) to 0 V **and** disables the output of the device, and is set to `True` per defaut. `loopscan_bool` allows for a measurement series starting voltage -> final voltage -> starting voltage loop, and is set to `False` per default. These parameters and editable in the function head, right at th bottom of the script.
**IMPORTANT:** Ensure that the saved data path in the LightField experiment settings (the pop-up GUI from LightField) is the path to the **temporary dump folder in the code**!
## Notes/ Possible Issues ## Notes/ Possible Issues
1. For the code to work, change the directory to load the KLCCommandLib_x64.dll file, located in 'KLCCommandLib64.py', line 5, to your specific directory, in which the .dll file is stored. 1. For the code to work, change the directory to load the KLCCommandLib_x64.dll file, located in 'KLCCommandLib64.py', line 5, to your specific directory, in which the .dll file is stored.