completely working!

This commit is contained in:
2025-10-22 18:11:34 +03:00
parent 8b0c99ab96
commit aeb3d90aec
9 changed files with 42 additions and 23 deletions

Binary file not shown.

View File

@ -18,10 +18,10 @@ GUI_TIMEOUT_INTERVAL = 5#505 - dev.WAIT_AFTER_SEND*1000 # GUI refresh time in mi
SAVE_POINTS_NUMBER = 1000 # Number of most recent data points kept in memory SAVE_POINTS_NUMBER = 1000 # Number of most recent data points kept in memory
INITIAL_TEMPERATURE_1 = 22.40 # Set initial temperature for Laser 1 in Celsius: from -1 to 45 C ?? INITIAL_TEMPERATURE_1 = 28 # Set initial temperature for Laser 1 in Celsius: from -1 to 45 C ??
INITIAL_TEMPERATURE_2 = 16.70 # Set initial temperature for Laser 2 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 = 32.0 # 64.0879 max # Set initial current for Laser 1, in mA INITIAL_CURRENT_1 = 33 # 64.0879 max # Set initial current for Laser 1, in mA
INITIAL_CURRENT_2 = 32.0 # 64.0879 max # Set initial current for Laser 2, in mA INITIAL_CURRENT_2 = 35 # 64.0879 max # Set initial current for Laser 2, in mA
#### ---- Functions #### ---- Functions
@ -62,17 +62,17 @@ def set_initial_params():
params['Min_Temp_1'] = INITIAL_TEMPERATURE_1 params['Min_Temp_1'] = INITIAL_TEMPERATURE_1
params['Max_Temp_1'] = 28 params['Max_Temp_1'] = 28
params['Min_Current_1'] = INITIAL_CURRENT_1 params['Min_Current_1'] = INITIAL_CURRENT_1
params['Max_Current_1'] = 50.0 params['Max_Current_1'] = 70.0 #50
params['Delta_Temp_1'] = 0.05 params['Delta_Temp_1'] = 0.05
params['Delta_Current_1'] = 0.05 params['Delta_Current_1'] = 0.05
params['Min_Temp_2'] = INITIAL_TEMPERATURE_2 params['Min_Temp_2'] = INITIAL_TEMPERATURE_2
params['Max_Temp_2'] = 28 params['Max_Temp_2'] = 28
params['Min_Current_2'] = INITIAL_CURRENT_2 params['Min_Current_2'] = INITIAL_CURRENT_2
params['Max_Current_2'] = 50.0 params['Max_Current_2'] = 60 # 50
params['Delta_Temp_2'] = 0.05 params['Delta_Temp_2'] = 0.05
params['Delta_Current_2'] = 0.05 params['Delta_Current_2'] = 0.05
params['Delta_Time'] = 50 params['Delta_Time'] = 50
params['Tau'] = 3 params['Tau'] = 10
return params return params
def update_data_lists(): def update_data_lists():

View File

@ -173,6 +173,7 @@ def get_DATA(prt):
print("Received "+str(prt.inWaiting())+" bytes.\n") print("Received "+str(prt.inWaiting())+" bytes.\n")
if prt.inWaiting()!=GET_DATA_TOTAL_LENGTH: if prt.inWaiting()!=GET_DATA_TOTAL_LENGTH:
print("Error. Couldn't get DATA data.") print("Error. Couldn't get DATA data.")
print("receiven data len:", prt.inWaiting())
return None return None
out_bytes = prt.read(GET_DATA_TOTAL_LENGTH) out_bytes = prt.read(GET_DATA_TOTAL_LENGTH)
@ -324,18 +325,18 @@ def decode_DATA(dh):
data = {} data = {}
data['datetime'] = datetime.now() data['datetime'] = datetime.now()
data['Header'] = get_word(dh, 0) data['Header'] = get_word(dh, 0)
data['I1'] = cnv.conv_I_N_to_mA(get_int_word(dh, 1)) data['I1'] = cnv.conv_I_N_to_mA(get_int_word(dh, 1)) #LD1_param.POWER
data['I2'] = cnv.conv_I_N_to_mA(get_int_word(dh, 2)) data['I2'] = cnv.conv_I_N_to_mA(get_int_word(dh, 2)) #LD2_param.POWER
data['TO_LSB'] = get_int_word(dh, 3) data['TO_LSB'] = get_int_word(dh, 3) #TO6_counter_LSB
data['TO_MSB'] = get_int_word(dh, 4) data['TO_MSB'] = get_int_word(dh, 4) #TO6_counter_MSB
data['Temp_1'] = cnv.conv_T_N_to_C(get_int_word(dh, 5)) data['Temp_1'] = cnv.conv_T_N_to_C(get_int_word(dh, 5)) #LD1_param.LD_CURR_TEMP
data['Temp_2'] = cnv.conv_T_N_to_C(get_int_word(dh, 6)) data['Temp_2'] = cnv.conv_T_N_to_C(get_int_word(dh, 6)) #LD2_param.LD_CURR_TEMP
data['Temp_Ext_1'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 7)) data['Temp_Ext_1'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 7)) #U_Rt1_ext_Gain
data['Temp_Ext_2'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 8)) data['Temp_Ext_2'] = cnv.conv_TExt_N_to_C(get_int_word(dh, 8)) #U_Rt2_ext_Gain
data['MON_3V3'] = cnv.conv_U3V3_N_to_V(get_int_word(dh, 9)) data['MON_3V3'] = cnv.conv_U3V3_N_to_V(get_int_word(dh, 9)) #3V_monitor
data['MON_5V1'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 10)) data['MON_5V1'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 10)) #5V1_monitor
data['MON_5V2'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 11)) data['MON_5V2'] = cnv.conv_U5V_N_to_V(get_int_word(dh, 11)) #5V2_monitor
data['MON_7V0'] = cnv.conv_U7V_N_to_V(get_int_word(dh, 12)) data['MON_7V0'] = cnv.conv_U7V_N_to_V(get_int_word(dh, 12)) #7V_monitor
data['Message_ID'] = get_word(dh, 13) # Last received command data['Message_ID'] = get_word(dh, 13) # Last received command
data['CRC'] = get_word(dh, 14) data['CRC'] = get_word(dh, 14)

View File

@ -13,7 +13,7 @@ R4 = 30000 # Ohm
R5 = 27000 # Ohm R5 = 27000 # Ohm
R6 = 56000 # Ohm R6 = 56000 # Ohm
RREF = 28.7 # Ohm (current-setting resistor) @1550 nm - 28.7 Ohm; @840 nm - 10 Ohm RREF = 10 # Ohm (current-setting resistor) @1550 nm - 28.7 Ohm; @840 nm - 10 Ohm
R7 = 22000 # Ohm R7 = 22000 # Ohm
R8 = 22000 # Ohm R8 = 22000 # Ohm

View File

@ -12,7 +12,20 @@ WAIT_AFTER_SEND = 0.15 # Wait after sending command, before requesting input (in
#### ---- High-level port commands #### ---- High-level port commands
'''
def create_port_connection():
prt = None
for port, _, _ in sorted(cmd.list_ports.comports()):
try:
prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1)
cmd.open_port(prt)
reset_port_settings(prt)
except:
prt.close()
continue
break
return prt
'''
def create_port_connection(): def create_port_connection():
prt = None prt = None
print() print()
@ -44,6 +57,9 @@ def create_port_connection():
break break
return prt return prt
# def setup_connection(): # def setup_connection():
# prt = cmd.setup_port_connection() # prt = cmd.setup_port_connection()
# cmd.open_port(prt) # cmd.open_port(prt)

4
gui.py
View File

@ -1,4 +1,6 @@
#from Tools.scripts.highlight import default_html
#default_html
import FreeSimpleGUI as sg import FreeSimpleGUI as sg
#### ---- GUI Constants #### ---- GUI Constants
@ -28,7 +30,7 @@ SET_DELTA_TEMPERATURE_TEXT_2 = 'Шаг дискретизации темпера
SET_MIN_CURRENT_TEXT_2 = 'Мнимальный ток лазера 2 (мА):' SET_MIN_CURRENT_TEXT_2 = 'Мнимальный ток лазера 2 (мА):'
SET_MAX_CURRENT_TEXT_2 = 'Максимальный ток лазера 2 (мА):' SET_MAX_CURRENT_TEXT_2 = 'Максимальный ток лазера 2 (мА):'
SET_DELTA_CURRENT_TEXT_2 = 'Шаг дискретизации тока лазера 2 (0.002-0.5 мА):' SET_DELTA_CURRENT_TEXT_2 = 'Шаг дискретизации тока лазера 2 (0.002-0.5 мА):'
SET_DELTA_T_TEXT = 'Шаг дискретизации времени (1-100 мкс):' SET_DELTA_T_TEXT = 'Шаг дискретизации времени (20-100 мкс, шаг 10 мкс):'
SET_TAU_T_TEXT = 'Время задержки (3-10мс):' SET_TAU_T_TEXT = 'Время задержки (3-10мс):'
SET_TEXT_WIDTH_NEW = 40 SET_TEXT_WIDTH_NEW = 40