Compare commits

2 Commits

Author SHA1 Message Date
ecdad1b583 some fixes 2026-03-10 15:48:57 +03:00
32fb12a2c2 ? 2026-02-18 16:43:34 +03:00
4 changed files with 15 additions and 26 deletions

Binary file not shown.

View File

@ -20,20 +20,20 @@ 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 = 28 # 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 = 28.9 # Set initial temperature for Laser 2 in Celsius: from -1 to 45 C ?? INITIAL_TEMPERATURE_2 = 29.2 # 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_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 INITIAL_CURRENT_2 = 60 # 64.0879 max # Set initial current for Laser 2, in mA
AD9833_FREQ_DEFAULT_KHZ = 125.0 AD9833_FREQ_DEFAULT_KHZ = 1000
AD9833_MCLK_DEFAULT_MHZ = 20.0 AD9833_MCLK_DEFAULT_MHZ = 20.0
DS1809_MAX_STEP = 63 DS1809_MAX_STEP = 63
DS1809_DEFAULT_STEP = 3 DS1809_DEFAULT_STEP = 39
DS1809_INIT_HOME_PULSES = 64 DS1809_INIT_HOME_PULSES = 64
DS1809_INIT_PULSE_MS = 2 DS1809_INIT_PULSE_MS = 2
DS1809_INIT_STARTUP_DELAY_S = 0.35 DS1809_INIT_STARTUP_DELAY_S = 0.35
STM32_DAC_VREF = 2.5 STM32_DAC_VREF = 2.5
STM32_DAC_MAX_CODE = 4095 STM32_DAC_MAX_CODE = 4095
PA4_DAC_DEFAULT_VOLT = 0.0 PA4_DAC_DEFAULT_VOLT = 0.52
#### ---- Functions #### ---- Functions

View File

@ -13,31 +13,16 @@ WAIT_AFTER_SEND = 0.15 # Wait after sending command before requesting input (s)
def create_port_connection(): def create_port_connection():
prt = None prt = None
print() for port, _, _ in sorted(cmd.list_ports.comports()):
ports = [port for port, _, _ in sorted(cmd.list_ports.comports())]
# Linux-only preference: use USB UART ports first.
usb_ports = [port for port in ports if "USB" in port]
if usb_ports:
ports = usb_ports
for port in ports:
try: try:
print("PORT:", port)
prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1) prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1)
cmd.open_port(prt) cmd.open_port(prt)
reset_port_settings(prt) reset_port_settings(prt)
return prt except:
except Exception:
if prt is not None:
try:
prt.close() prt.close()
except Exception:
pass
continue continue
break
return None return prt
def _print_state_reply(state_bytes): def _print_state_reply(state_bytes):
@ -51,9 +36,13 @@ def _print_state_reply(state_bytes):
def reset_port_settings(prt): def reset_port_settings(prt):
# Reset port settings and check status
cmd.send_DEFAULT_ENABLE(prt) cmd.send_DEFAULT_ENABLE(prt)
time.sleep(WAIT_AFTER_SEND) time.sleep(WAIT_AFTER_SEND)
return _print_state_reply(cmd.get_STATE(prt)) status = cmd.get_STATE(prt).hex()
if status is not None:
print("Received: STATE. State status:", cmd.decode_STATE(status), "(" + cmd.flipfour(status) + ")")
print("")
def request_state(prt): def request_state(prt):