added tec modulation

This commit is contained in:
Ayzen
2026-04-27 17:49:52 +03:00
parent 6b6689fa5f
commit 31fd8ab111
7 changed files with 185 additions and 0 deletions

View File

@ -50,6 +50,10 @@ from .constants import (
STM32_DAC_CODE_MIN,
STATUS_RESPONSE_LENGTH,
WAIT_AFTER_SEND_SEC,
TEC_MODULATION_AMPLITUDE_CODE_MAX,
TEC_MODULATION_AMPLITUDE_CODE_MIN,
TEC_MODULATION_FREQUENCY_MAX_HZ,
TEC_MODULATION_FREQUENCY_MIN_HZ,
)
from .exceptions import (
CommunicationError,
@ -429,6 +433,44 @@ class LaserController:
)
logger.info("STM32 DAC configured: enabled=%s code=%d", enabled, dac_code)
def configure_tec_modulation(
self,
*,
enabled: bool,
laser: int,
frequency_hz: int,
amplitude_code: int,
) -> None:
"""Configure fast zero-mean TEC drive modulation around the PID output."""
laser = self._validate_int_range(laser, "laser", 1, 2)
frequency_hz = self._validate_int_range(
frequency_hz,
"frequency_hz",
TEC_MODULATION_FREQUENCY_MIN_HZ,
TEC_MODULATION_FREQUENCY_MAX_HZ,
)
amplitude_code = self._validate_int_range(
amplitude_code,
"amplitude_code",
TEC_MODULATION_AMPLITUDE_CODE_MIN,
TEC_MODULATION_AMPLITUDE_CODE_MAX,
)
self._send_and_expect_ok(
Protocol.encode_tec_modulation_control(
enabled=enabled,
laser=laser,
frequency_hz=frequency_hz,
amplitude_code=amplitude_code,
)
)
logger.info(
"TEC modulation configured: enabled=%s laser=%d frequency_hz=%d amplitude_code=%d",
enabled,
laser,
frequency_hz,
amplitude_code,
)
def save_profile_to_sd(self, request: ProfileSaveRequest) -> None:
"""Stream a rendered profile INI and optional waveform CSV to the device SD card."""
if not isinstance(request, ProfileSaveRequest):