fix: 快速 IIR 输入改为限幅后原始值 (同步 DLD154V4B)

This commit is contained in:
wangfq
2026-06-29 17:27:11 +08:00
parent 918287d9da
commit 2aad8782a7

View File

@@ -450,9 +450,12 @@ void vd1_task_per_channel(Loop154_Unit *unit)
*================================================================*/ *================================================================*/
/* 1a. 慢速 IIR — 斜率限幅 */ /* 1a. 慢速 IIR — 斜率限幅 */
{
uint32_t fast_input; // 快速 IIR 的输入:限幅后的原始值,不经慢速 IIR 滞后
if (unit->loop_CAPVD == 0) { if (unit->loop_CAPVD == 0) {
unit->loop_CAPVD = unit->loop_Value; unit->loop_CAPVD = unit->loop_Value;
unit->loop_CAPVD_fast = unit->loop_Value; fast_input = unit->loop_Value;
} else { } else {
/* 斜率限幅: 物理车辆不可能让频率瞬间跳变 > MAX_SLOPE_RATE% */ /* 斜率限幅: 物理车辆不可能让频率瞬间跳变 > MAX_SLOPE_RATE% */
int32_t raw_delta = (int32_t)unit->loop_Value - (int32_t)unit->loop_CAPVD; int32_t raw_delta = (int32_t)unit->loop_Value - (int32_t)unit->loop_CAPVD;
@@ -462,16 +465,17 @@ void vd1_task_per_channel(Loop154_Unit *unit)
if (raw_delta < -max_step) raw_delta = -max_step; if (raw_delta < -max_step) raw_delta = -max_step;
uint32_t clamped_value = (uint32_t)((int32_t)unit->loop_CAPVD + raw_delta); uint32_t clamped_value = (uint32_t)((int32_t)unit->loop_CAPVD + raw_delta);
unit->loop_CAPVD = get_flt_value(clamped_value, unit->loop_CAPVD); unit->loop_CAPVD = get_flt_value(clamped_value, unit->loop_CAPVD);
fast_input = clamped_value;
} }
/* 1b. 快速 IIR — α=0.5: (old + new) / 2 */ /* 1b. 快速 IIR — α=0.5: (old + new) / 2
* 输入直接用限幅后的原始值,不经过慢速 IIR保持 τ≈28ms 的响应速度 */
if (unit->loop_CAPVD_fast == 0) { if (unit->loop_CAPVD_fast == 0) {
unit->loop_CAPVD_fast = unit->loop_CAPVD; // 首次直接锁定 unit->loop_CAPVD_fast = fast_input;
} else { } else {
unit->loop_CAPVD_fast = (unit->loop_CAPVD_fast + unit->loop_CAPVD) / 2; unit->loop_CAPVD_fast = (unit->loop_CAPVD_fast + fast_input) / 2;
}
} }
/*--- 2. 稳定期:绕过 IIR 和斜率限幅,直接用 Value 快速收敛 (V2.2) ---*/
if (!unit->loop_stable) { if (!unit->loop_stable) {
unit->loop_CAPVD = unit->loop_Value; unit->loop_CAPVD = unit->loop_Value;
unit->loop_CAPVD_fast = unit->loop_Value; unit->loop_CAPVD_fast = unit->loop_Value;