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
@@ -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;