void bms_temp_rise_diag(void) { INT8U flag = 0; INT16U slave_index = 0, cell_index = 0, total_temp = 0, index = 0, now_temp = 0, gx_flag = FALSE; INT16U max_temp_now, max_temp_index_now; static INT8U temp_flag = FALSE; // static INT16U old_temp[MAX_TEMP_NUM] = {0}; static INT16U old_temp = 0; static INT32U tick = 0, tick2 = 0; if(temp_flag == FALSE) { tick = OSTimeGet(); tick2 = OSTimeGet(); } if((bms_get_time_interval(tick2, OSTimeGet()) > 9000) || (temp_flag == FALSE)) { if(bms_get_time_interval(tick, OSTimeGet()) > 3000) { gx_flag = TRUE; tick = OSTimeGet(); } tick2 = OSTimeGet(); now_temp = bms_get_max_temp(); if((old_temp == 0xFF) || (old_temp == 0) || (now_temp == 0xFF) || (now_temp == 0) ) { old_temp = now_temp; } if((old_temp != 0xFF) && (old_temp != 0) && (now_temp != 0xFF) && (now_temp != 0) && (now_temp - old_temp > 1) ) { flag = TRUE; bms_save_tr_pos(index); } if(gx_flag == TRUE) { old_temp = now_temp;//bmu_get_cell_temp(slave_index, cell_index); } temp_flag = TRUE; } if(flag == TRUE) { if(AlarmLevel2 != bms_get_tr()) { save_event_log(TR_ALARM_TYPE, 0xFF); } bms_set_tr(AlarmLevel2); } else if(gx_flag == TRUE) { bms_set_tr(AlarmNone); } if(bms_get_rel_flag() == TRUE) { bms_set_tr(AlarmNone); // flag = FALSE; temp_flag = FALSE; } }
时间: 2024-04-21 17:26:52 浏览: 82
ATMEGA16HVBBMS.zip_BMS SOC_SOC_bms_soc bms_wearvl2
这段代码是用来检测电池温度是否过高,并触发相应的警报。它会记录电池的最高温度,并与之前记录的最高温度进行比较。如果两者之间的差值超过1度,则会触发警报,并将当前的位置信息保存。如果连续9秒内没有触发警报,则会更新记录的最高温度,并且每隔3秒会将记录的最高温度上传到服务器。如果接收到释放电池的信号,则会取消警报。
阅读全文