fix: update ADC calibration offset limits from relative to absolute range, add Force_charging_phase_max

This commit is contained in:
2026-07-29 09:39:43 +08:00
parent f1f6b44d99
commit 7eee5f7881
+19 -24
View File
@@ -167,12 +167,10 @@ RPU_TESTS = [
# Written via FC16 (write multiple registers).
#
# Calibration gain (A): limits = [nominal × 0.9, nominal × 1.1]
# Calibration offset (B) with positive nominal: limits = [nominal × 0.8, nominal × 1.2]
# Calibration offset (B) with negative nominal: limits are inverted in firmware
# (lo_limit = nominal×0.8, up_limit = nominal×1.2 where lo > up numerically).
# min_val = lo_limit (expected clamp when src too negative),
# max_val = up_limit (expected clamp when src too positive/less negative).
# PFC_current_rms_cali_B excluded (nominal = 0.0).
# Calibration offset (B): limits = [nominal delta, nominal + delta]
# PFC/INV current: delta = 5.0
# DC bus voltage, AC in voltage, coil voltage: delta = 10.0
# PFC current rms: delta = 5.0 (nominal = 0.0 → limits = [5.0, 5.0])
TPU_TESTS = [
# ----- PFC power (uint16) -----
@@ -200,8 +198,9 @@ TPU_TESTS = [
('OVP_phase_threshold', 76, 'uint16', 0, 500, None, 501),
('OVP_count_threshold', 77, 'uint16', 0, 10, None, 11),
# ----- Phase command min (uint16) -----
# ----- Phase command / force charging phase (uint16) -----
('Phase_cmd_min', 101, 'uint16', 0, 750, None, 751),
('Force_charging_phase_max', 100, 'uint16', 0, 750, None, 751),
# ----- No-batt coupling ramp (uint16) -----
('No_batt_coupling_ramp_phase', 109, 'uint16', 0, 300, None, 301),
@@ -283,24 +282,20 @@ TPU_TESTS = [
('PFC_current_rms_cali_A', 110, 'float32', 0.9, 1.1, 0.85, 1.15),
# ----- ADC calibration offset (B) registers (float32) -----
# Limits = [nominal × 0.8, nominal × 1.2]
# Limits = [nominal delta, nominal + delta]
# Nominal values from global_variables.h:
# ANA_PFC_CURRENT_OFFSET = -0.469129801 (negative → inverted range in firmware)
# ANA_INV_CURRENT_OFFSET = -51.38759228 (negative → inverted range in firmware)
# ANA_DC_BUS_VOLTAGE_OFFSET = 0.391120149 (positive)
# ANA_AC_IN_VOLTAGE_OFFSET = 0.639814597 (positive)
# ANA_COIL_VOLTAGE_OFFSET = -7.280746292 (negative → inverted range in firmware)
# ANA_PFC_CURRENT_RMS_OFFSET = 0.0 (excluded: trivial limits)
#
# For negative nominals: min_val = lo_limit = nominal×0.8 (less negative),
# max_val = up_limit = nominal×1.2 (more negative).
# Phase 1 writes a more-negative value (<min_val) → expect clamp to min_val.
# Phase 2 writes a less-negative value (>max_val) → expect clamp to max_val.
('PFC_current_cali_B', 14, 'float32', -0.375304, -0.562956, -0.65, -0.30),
('INV_current_cali_B', 18, 'float32', -41.11007, -61.66511, -70.0, -30.0),
('DC_bus_voltage_cali_B', 22, 'float32', 0.312896, 0.469344, 0.293, 0.490),
('AC_in_voltage_cali_B', 26, 'float32', 0.511852, 0.767778, 0.480, 0.800),
('Coil_voltage_cali_B', 82, 'float32', -5.824597, -8.736896, -10.0, -4.0),
# ANA_PFC_CURRENT_OFFSET = -0.469129801 delta=5.0 → [-5.469130, 4.530870]
# ANA_INV_CURRENT_OFFSET = -51.38759228 delta=5.0 → [-56.387592, -46.387592]
# ANA_DC_BUS_VOLTAGE_OFFSET = 0.391120149 delta=10.0 → [-9.608880, 10.391120]
# ANA_AC_IN_VOLTAGE_OFFSET = 0.639814597 delta=10.0 → [-9.360185, 10.639815]
# ANA_COIL_VOLTAGE_OFFSET = -7.280746292 delta=10.0 → [-17.280746, 2.719254]
# ANA_PFC_CURRENT_RMS_OFFSET = 0.0 delta=5.0 → [-5.0, 5.0]
('PFC_current_cali_B', 14, 'float32', -5.469130, 4.530870, -5.5, 4.6),
('INV_current_cali_B', 18, 'float32', -56.387592, -46.387592, -57.0, -46.0),
('DC_bus_voltage_cali_B', 22, 'float32', -9.608880, 10.391120, -9.7, 10.5),
('AC_in_voltage_cali_B', 26, 'float32', -9.360185, 10.639815, -9.4, 10.7),
('Coil_voltage_cali_B', 82, 'float32', -17.280746, 2.719254, -17.5, 2.8),
('PFC_current_rms_cali_B', 112, 'float32', -5.0, 5.0, -5.1, 5.1),
]