Add RFG UDP source to rph_radar

This commit is contained in:
Ayzen
2026-10-06 19:36:00 +03:00
parent a185e61495
commit cfe81f782b
29 changed files with 817 additions and 279 deletions
@@ -39,6 +39,18 @@ def current_ma_to_n(current_ma: float) -> int:
Returns:
Integer in [0, 65535] for the DAC.
"""
n = int(ADC_BITS_16 / 2000 * RREF * current_ma)
n = max(0, min(ADC_BITS_16, n))
return n
# Rounded like the lab GUI (_device_main.py), so both send identical DAC codes.
return max(0, min(ADC_BITS_16, round(ADC_BITS_16 / 2000 * RREF * current_ma)))
def variation_codes(min_value: float, max_value: float, step: float) -> tuple[int, int, int]:
low, high, delta = (current_ma_to_n(value) for value in (min_value, max_value, step))
if delta == 0 or low >= high:
raise ValueError("Current variation range and step must be representable by the DAC")
return low, high, delta
def variation_step_count(min_value: float, max_value: float, step: float) -> int:
"""SWEEP_STEP edges per sweep: firmware loops ``while (current < max) current += delta`` on these codes."""
low, high, delta = variation_codes(min_value, max_value, step)
return math.ceil((high - low) / delta)