Files

90 lines
3.1 KiB
Python
Executable File

#!/usr/bin/python3
from device_interaction import *
from time import sleep
INITIAL_TEMPERATURE_1 = 28 # Set initial temperature for Laser 1 in Celsius: from -1 to 45 C ??
INITIAL_TEMPERATURE_2 = 28.9 # Set initial temperature for Laser 2 in Celsius: from -1 to 45 C ??
INITIAL_CURRENT_1 = 33 # 64.0879 max # Set initial current for Laser 1, in mA
INITIAL_CURRENT_2 = 35 # 64.0879 max # Set initial current for Laser 2, in mA
def set_initial_params():
params = {}
params['Temp_1'] = INITIAL_TEMPERATURE_1 # Initial temperature for Laser 1
params['Temp_2'] = INITIAL_TEMPERATURE_2 # Initial temperature for Laser 2
params['ProportionalCoeff_1'] = int(10*256) # Proportional coefficient for temperature stabilizatoin for Laser 1 <-- ToDo (why int?)
params['ProportionalCoeff_2'] = int(10*256) # Proportional coefficient for temperature stabilizatoin for Laser 2 <-- ToDo (why int?)
params['IntegralCoeff_1'] = int(0.5*256) # Integral coefficient for temperature stabilizatoin for Laser 1 <-- ToDo (why int?)
params['IntegralCoeff_2'] = int(0.5*256) # Integral coefficient for temperature stabilizatoin for Laser 2 <-- ToDo (why int?)
params['Message_ID'] = "00FF" # Send Message ID (hex format)
params['Iset_1'] = INITIAL_CURRENT_1 # Currency value array for Laser 1, in mA
params['Iset_2'] = INITIAL_CURRENT_2 # Currency value array for Laser 2, in mA
params['Min_Temp_1'] = INITIAL_TEMPERATURE_1
params['Max_Temp_1'] = 28
params['Min_Current_1'] = INITIAL_CURRENT_1
params['Max_Current_1'] = 70.0 #50
params['Delta_Temp_1'] = 0.05
params['Delta_Current_1'] = 0.05
params['Min_Temp_2'] = INITIAL_TEMPERATURE_2
params['Max_Temp_2'] = 28
params['Min_Current_2'] = INITIAL_CURRENT_2
params['Max_Current_2'] = 60 # 50
params['Delta_Temp_2'] = 0.05
params['Delta_Current_2'] = 0.05
params['Delta_Time'] = 50
params['Tau'] = 10
return params
def set_task_params():
task_params = {}
task_params["ProportionalCoeff_1"] = 2560 #
task_params["IntegralCoeff_1"] = 128#
task_params["ProportionalCoeff_2"] = 2560#
task_params["IntegralCoeff_2"] = 128#
task_params["TaskType"] = "TT_CHANGE_CURR_1" # TT_CHANGE_CURR_1, TT_CHANGE_CURR_2, TT_CHANGE_TEMP_1, TT_CHANGE_TEMP_2
task_params["MinC1"] = 33.0#
task_params["MaxC1"] = 70.0#
task_params["DeltaC1"] = 0.05#
task_params["T1"] = 28.0#
task_params["T2"] = 28.9#
task_params["I2"] = 35.0#
task_params["Dt"] = 50#
task_params["Tau"] = 10.0#
return task_params
if __name__ == "__main__":
port = create_port_connection()
reset_port_settings(port)
# rcvd_data = request_data(port)
# print_data(rcvd_data)
print(request_data(port))
ctrl_params = set_initial_params()
#start lasers
send_control_parameters(port, ctrl_params)
print(request_data(port))
sleep(2)
#start current variation
task_params = set_task_params()
#switch to laser_current sweep mode
send_task_command(port, task_params)
print(request_data(port))
sleep(2)
#stop current variation (goto steady current)
send_control_parameters(port, ctrl_params)
print(request_data(port))
sleep(2)