From 16090a48fae530510d176edeeafd721145a2d9da Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 26 Jun 2026 16:23:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A8=B3=E5=AE=9A=E6=9C=9F=E5=86=85?= =?UTF-8?q?=E7=BB=95=E8=BF=87=E6=96=9C=E7=8E=87=E9=99=90=E5=B9=85=E5=92=8C?= =?UTF-8?q?=20IIR=EF=BC=8C=E7=9B=B4=E6=8E=A5=E7=94=A8=20Value=20=E5=BB=BA?= =?UTF-8?q?=E7=AB=8B=E5=9F=BA=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: 首测 CAPVD=177406 是瞬态高值 (~38% 偏高), 5% 斜率限幅让 CAPVD 在 128 tick 稳定期内无法充分收敛, 100 窗口滑动平均被前半段高值污染: Origin=149755 vs 真实值~128688, 差值 21067 >> dlt_ORG=82 修复: 稳定期内直接将 CAPVD/CAPVD_fast 设为 raw Value, 不做斜率限幅和 IIR, 使基线 100 窗口快速收敛到真实值。 稳定期结束后恢复正常 IIR+斜率限幅用于检测。 --- utilities/at32f421_freertos_demo/src/TaskLoop.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utilities/at32f421_freertos_demo/src/TaskLoop.c b/utilities/at32f421_freertos_demo/src/TaskLoop.c index 7a977e5..2cb90a0 100644 --- a/utilities/at32f421_freertos_demo/src/TaskLoop.c +++ b/utilities/at32f421_freertos_demo/src/TaskLoop.c @@ -673,12 +673,16 @@ void vd1_task(void) /*--- 2. 稳定期:只跟踪基线,不检测车辆 ---*/ if (!g_loop_stable) { + /* 稳定期内不做斜率限幅和 IIR — 直接用 Value 快速收敛到真实基线 */ + loop1_CAPVD = loop1_Value; + loop1_CAPVD_fast = loop1_Value; + update_moving_average(&loop1_ORG_SUM, &loop1_ORG_CNT, &loop1_Origin, loop1_CAPVD, 100); _stable_cnt++; if (_stable_cnt >= STABLE_SAMPLES) { g_loop_stable = 1; - PRINT("Loop stable, Origin:%d\n", loop1_Origin); + PRINT("Loop stable, Origin:%d\\n", loop1_Origin); } return; }