change: 时间量上报单位 10ms→50ms, report_counter 入 50ms tick

- report_counter++ 从 5ms ISR 外层移入 if(TM1cnt>=10) 50ms 块
- 3处 misc_value 去掉 /2, 直接差值即可
- REPORT_IDLE_TICKS 120→12, REPORT_EVENT_TICKS 30→3
- 更新 TaskLoop.h/main.c/devlog 注释
This commit is contained in:
wangfq
2026-07-03 10:01:30 +08:00
parent 3c243ea792
commit 85a4fa7910
4 changed files with 41 additions and 17 deletions
@@ -78,11 +78,11 @@
#define MISC_TYPE_RELAY 3 // 继电器输出次数
#define MISC_TYPE_COUNT 4 // 总类型数
/*===========================================================================
* 主动上报 — 间隔 (5ms tick, misc_value 上报时 /2 转 10ms)
/*
* 主动上报 — 间隔 (50ms tick)
*===========================================================================*/
#define REPORT_IDLE_TICKS 120 // 空闲稳定: 120×5ms = 600ms
#define REPORT_EVENT_TICKS 30 // 事件/变化: 30×5ms = 150ms
#define REPORT_IDLE_TICKS 12 // 空闲稳定: 12×50ms = 600ms
#define REPORT_EVENT_TICKS 3 // 事件/变化: 3×50ms = 150ms
/*===========================================================================
* 灵敏度表(4级: 0=低, 3=高)
@@ -181,8 +181,8 @@ typedef struct {
/*--- 主动上报杂项计数 ---*/
uint32_t flow_count; // 车流量累计
uint32_t relay_count; // 继电器动作次数
uint32_t passtime_start; // 进场 时间戳(5ms tick, 上报/2→10ms)
uint32_t last_exit_tick; // 上次离场 时间戳(5ms tick, 上报/2→10ms)
uint32_t passtime_start; // 进场 时间戳(50ms tick)
uint32_t last_exit_tick; // 上次离场 时间戳(50ms tick)
uint32_t misc_value; // 当前要上报的杂项值
} Loop154_Unit;
@@ -190,7 +190,7 @@ typedef struct {
* 全局状态
*===========================================================================*/
typedef struct {
uint32_t report_counter; // 上报间隔计数器 (5ms tick)
uint32_t report_counter; // 上报间隔计数器 (50ms tick)
uint8_t report_misc_round; // 空闲轮转: 0=MISC_TYPE_TIME, 1=CUT, 2=FLOW, 3=RELAY
Loop154_Unit loop_unit[LOOP_CAPTURE_MAX];
} Loop154_States;
@@ -250,14 +250,14 @@ void TMR15_GLOBAL_IRQHandler(void)
if (tmr_interrupt_flag_get(TMR15, TMR_OVF_FLAG) != RESET) {
/*--- 上报计数器 ---*/
g_loop_states.report_counter++;
/*--- 50ms tick 分频 ---*/
TM1cnt++;
if (TM1cnt >= 10) {
TM1cnt = 0;
/*--- 上报计数器 (50ms tick) ---*/
g_loop_states.report_counter++;
for (i = 0; i < LOOP_CAPTURE_MAX; i++) {
Loop154_Unit *unit = &g_loop_states.loop_unit[i];
@@ -523,11 +523,11 @@ 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) / 2;
unit->misc_value = g_loop_states.report_counter - unit->last_exit_tick;
} else {
unit->misc_value = 0; // 首次检测, 车间距为0
}
unit->passtime_start = g_loop_states.report_counter; // 5ms tick
unit->passtime_start = g_loop_states.report_counter; // 50ms tick
if (unit->hold_time > 0) {
unit->loop_VD_HOLD = 1;
}
@@ -608,8 +608,8 @@ void vd1_task_per_channel(Loop154_Unit *unit)
unit->flat_ok_cnt = 0;
unit->exit_state = 0;
/* 主动上报: 计算通过时间 = (当前-进场)/2 (10ms单位) */
unit->misc_value = (g_loop_states.report_counter - unit->passtime_start) / 2;
/* 主动上报: 计算通过时间 = 当前-进场 (50ms单位) */
unit->misc_value = g_loop_states.report_counter - unit->passtime_start;
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) / 2;
unit->misc_value = g_loop_states.report_counter - unit->passtime_start;
unit->last_exit_tick = g_loop_states.report_counter;
unit->relay_count++;
}
@@ -425,9 +425,9 @@ void uart_report_packet_loop_acs(uint8_t flag)
/*--- 2. 确定上报间隔 ---*/
if (_flag_event) {
_interval = REPORT_EVENT_TICKS; // 150ms
_interval = REPORT_EVENT_TICKS; // 3×50ms = 150ms
} else {
_interval = REPORT_IDLE_TICKS; // 600ms
_interval = REPORT_IDLE_TICKS; // 12×50ms = 600ms
}
if (g_loop_states.report_counter < _interval) return;