From 3c243ea79211272647ff68edc123ff6b97c4b8f2 Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 3 Jul 2026 09:36:28 +0800 Subject: [PATCH] =?UTF-8?q?change:=20=E6=97=B6=E9=97=B4=E9=87=8F=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E5=8D=95=E4=BD=8D=205ms=E2=86=9210ms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 进场车间距 / 离场通过时间: misc_value = (差值)/2 - 内部时间戳保持 5ms 精度, 仅上报值转为 10ms - 更新注释和 devlog (V2.6) --- vd960Loop/docs/devlog.md | 30 +++++++++++++++++++ .../at32f421_freertos_demo/inc/TaskLoop.h | 6 ++-- .../at32f421_freertos_demo/src/TaskLoop.c | 8 ++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/vd960Loop/docs/devlog.md b/vd960Loop/docs/devlog.md index 5e1e02b..03bba79 100644 --- a/vd960Loop/docs/devlog.md +++ b/vd960Loop/docs/devlog.md @@ -116,10 +116,40 @@ ALFA_CAP1 = 79 // α = 79/256 ≈ 0.31, @10ms → τ ≈ 32ms --- +## 2026-07-03 — 时间量上报单位改为 10ms + +### 背景 + +`MISC_TYPE_TIME` 上报的通过时间 / 车间距原来以 5ms 为单位(直接 `report_counter - 时间戳`),与外部协议期望的 10ms 单位不一致。 + +### 方案 + +内部时间戳 `report_counter` / `passtime_start` / `last_exit_tick` 保持 5ms 精度不动,仅在上报 `misc_value` 时 `/2` 转为 10ms: + +```c +// 进场 — 车间距 (10ms) +misc_value = (report_counter - last_exit_tick) / 2; + +// 离场 — 通过时间 (10ms) +misc_value = (report_counter - passtime_start) / 2; +``` + +### 影响范围 + +| 位置 | 变更 | +|------|------| +| `TaskLoop.c` 进场路径 | `misc_value` /2 | +| `TaskLoop.c` 离场 flatness | `misc_value` /2 | +| `TaskLoop.c` 离场 cnt_release | `misc_value` /2 | +| `TaskLoop.h` 注释 | 标注 `/2→10ms` | + +--- + ## 修订记录 | 版本 | 时间 | 说明 | |------|------|------| +| V2.6 | 2026-07-03 | misc_value 时间量单位 5ms→10ms | | V2.5 | 2026-06-29 | 稳定期窗口 100 快速收敛 | | V2.4 | 2026-06-29 | 去掉快速 IIR,ALFA_CAP1=79 @10ms | | V2.3 | 2026-06-29 | 基线冻结超时 + 稳定性检查 | diff --git a/vd960Loop/utilities/at32f421_freertos_demo/inc/TaskLoop.h b/vd960Loop/utilities/at32f421_freertos_demo/inc/TaskLoop.h index f11facf..da4119d 100644 --- a/vd960Loop/utilities/at32f421_freertos_demo/inc/TaskLoop.h +++ b/vd960Loop/utilities/at32f421_freertos_demo/inc/TaskLoop.h @@ -79,7 +79,7 @@ #define MISC_TYPE_COUNT 4 // 总类型数 /*=========================================================================== - * 主动上报 — 间隔 (5ms tick) + * 主动上报 — 间隔 (5ms tick, misc_value 上报时 /2 转 10ms) *===========================================================================*/ #define REPORT_IDLE_TICKS 120 // 空闲稳定: 120×5ms = 600ms #define REPORT_EVENT_TICKS 30 // 事件/变化: 30×5ms = 150ms @@ -181,8 +181,8 @@ typedef struct { /*--- 主动上报杂项计数 ---*/ uint32_t flow_count; // 车流量累计 uint32_t relay_count; // 继电器动作次数 - uint32_t passtime_start; // 进场 时间戳(5ms tick) - uint32_t last_exit_tick; // 上次离场 时间戳(5ms tick), 用于车间距计算 + uint32_t passtime_start; // 进场 时间戳(5ms tick, 上报/2→10ms) + uint32_t last_exit_tick; // 上次离场 时间戳(5ms tick, 上报/2→10ms) uint32_t misc_value; // 当前要上报的杂项值 } Loop154_Unit; diff --git a/vd960Loop/utilities/at32f421_freertos_demo/src/TaskLoop.c b/vd960Loop/utilities/at32f421_freertos_demo/src/TaskLoop.c index 1d26040..dce408b 100644 --- a/vd960Loop/utilities/at32f421_freertos_demo/src/TaskLoop.c +++ b/vd960Loop/utilities/at32f421_freertos_demo/src/TaskLoop.c @@ -523,7 +523,7 @@ void vd1_task_per_channel(Loop154_Unit *unit) unit->flow_count++; unit->relay_count++; if (unit->last_exit_tick > 0) { - unit->misc_value = g_loop_states.report_counter - unit->last_exit_tick; + unit->misc_value = (g_loop_states.report_counter - unit->last_exit_tick) / 2; } else { unit->misc_value = 0; // 首次检测, 车间距为0 } @@ -608,8 +608,8 @@ void vd1_task_per_channel(Loop154_Unit *unit) unit->flat_ok_cnt = 0; unit->exit_state = 0; - /* 主动上报: 计算通过时间 = 当前-进场时间戳 (5ms单位) */ - unit->misc_value = g_loop_states.report_counter - unit->passtime_start; + /* 主动上报: 计算通过时间 = (当前-进场)/2 (10ms单位) */ + unit->misc_value = (g_loop_states.report_counter - unit->passtime_start) / 2; unit->last_exit_tick = g_loop_states.report_counter; unit->relay_count++; // 离开时继电器翻转 } @@ -641,7 +641,7 @@ void vd1_task_per_channel(Loop154_Unit *unit) unit->loop_cnt_release = 0; /* 主动上报: 通过时间 + 继电器 */ - unit->misc_value = g_loop_states.report_counter - unit->passtime_start; + unit->misc_value = (g_loop_states.report_counter - unit->passtime_start) / 2; unit->last_exit_tick = g_loop_states.report_counter; unit->relay_count++; }