forked from gary/BCU
2
0
Fork 0

4000多地址增加连续可写的功能

This commit is contained in:
guzz 2025-02-25 10:24:49 +08:00
parent ed4c22e628
commit 091a70874e
10 changed files with 291 additions and 215968 deletions

View File

@ -253,7 +253,7 @@ void bmu_temp_breakline_check(int value, int bmuIdx, int tempIdx)
}
if(tempJudge_cnt[bmuIdx][tempIdx] > 1)
{
bms_set_bmu_fault_bit(kBmuFaultBit_TempCable, 1);
//bms_set_bmu_fault_bit(kBmuFaultBit_TempCable, 1);
}
}

View File

@ -195,7 +195,8 @@ void bms_force_crtl_do_status(uint8_t idx, DoCtrlStatus status)
if(status < kDoCtrlStatus_None)
{
do_item.tick[idx] = RELAY_CTRL_NO_DLY;
do_item.ctrl_status[idx] = (DoStatus)(status + 2);
//@wagnk2-17这里原本的status加了2取消了
do_item.ctrl_status[idx] = (DoStatus)(status);
}
else
{

View File

@ -15,6 +15,7 @@
#define CUR_FILTER_ENABLE (0u)
#define ADCIC_SAMPLE_CNT (20u)
#define MCP3208_SAMPLE_CNT (10u)
ADS8688_STATIC_INIT(ads8688, kSpiDev_2, kGpioType_ADC_Cs);
@ -83,7 +84,7 @@ void bms_init_current(void)
cur_item.shunt_volt = get_eeprom_data(kEep_ChgCurDir_ShuntRatedVolt, kEepromDataType_Low);
cur_item.prop[0].filter = cur_item.prop[1].filter = 0;
// 上位机下发时缩小10倍
// 上位机下发时缩小10倍,分流器量程 乘了 10
cur_item.prop[0].scale = get_eeprom_data(kEep_CurSensor2_1Range, kEepromDataType_Low) * 10;
cur_item.prop[1].scale = get_eeprom_data(kEep_CurSensor2_1Range, kEepromDataType_High) * 10;
@ -229,8 +230,8 @@ int16_t bms_caculate_current(uint32_t base_time)
break;
}
}
//测试用 SFJ 7.30
current = volval * 100 / 10;
//测试用 SFJ 7.30,2-18,注释
//current = volval * 100 / 10;
// 电流方向
current *= prop->dir;

View File

@ -17,6 +17,7 @@ DiParamItem di_param_item[kDiType_End];
//辅助触点1
//di_signal->di_item.status, di->di_iteml.type
void ord_di_do_feedback_func(uint32_t base_time, DiStatus di_signal, DiType di)
{
if(di < kDiType_End)

View File

@ -92,7 +92,7 @@ bool logic_adhesion_check(uint32_t base_time, DoType type)
void logic_open_check(uint32_t base_time)
{
uint16_t tv, hv, rate;
DoErrSrc do_err_src = bms_get_do_err_src(kDoType_Positive);
DoErrSrc do_err_src = bms_get_do_err_src(kDoType_Chg);
FaultLevel fault = kFaultLevel_Normal;
static uint16_t dly;
@ -161,8 +161,8 @@ void logic_same_circuit_ctrl(uint32_t base_time)
//kEep_IsSoftReset高低只能清楚一个否则断电下带无法保存0
if(((bms_get_run_status() != kRunStatus_Init) && (bms_get_circuit_cmd_status() == kCircuitStatus_On)) || (dly >= 10000))
{
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_On, 100);
bms_crtl_do_status(kDoType_Chg, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Dis, kDoCtrlStatus_On, 100);
dly = 0;
status = kDoLogicStatus_On;
}
@ -177,7 +177,7 @@ void logic_same_circuit_ctrl(uint32_t base_time)
//增加init状态防止预充中反复检测粘连 建议增加多次检测
//Gary 2024-07-25 连续粘连3秒才报粘连故障
dly += base_time;
if(logic_adhesion_check(base_time, kDoType_Positive) == true)
if(logic_adhesion_check(base_time, kDoType_Chg) == true)
{
dly = 0;
status = kDoLogicStatus_Off;
@ -189,22 +189,22 @@ void logic_same_circuit_ctrl(uint32_t base_time)
if (prechg_max_cnt == 0) //读取配置:不预充
{
status = kDoLogicStatus_On;
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, 100);
bms_crtl_do_status(kDoType_Dis, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Chg, kDoCtrlStatus_On, 100);
}
else //读取配置:预充
{
if (prechg_cnt++ < prechg_max_cnt) //判断预充次数
{
status = kDoLogicStatus_Prechg;
//bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY); //闭合总正继电器
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY);
//bms_crtl_do_status(kDoType_Chg, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY); //闭合总正继电器
bms_crtl_do_status(kDoType_Dis, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_PreChg, kDoCtrlStatus_On, 100);
}
else
{
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_Off, 100);
bms_crtl_do_status(kDoType_Dis, kDoCtrlStatus_Off, 100);
bms_set_fault_level(kFaultCode_PreChg, kFaultLevel_Third, kFaultHandle_CutNoRelIdx);
}
}
@ -217,7 +217,7 @@ void logic_same_circuit_ctrl(uint32_t base_time)
prechg_cnt = 0;
status = kDoLogicStatus_Off;
bms_crtl_do_status(kDoType_PreChg, kDoCtrlStatus_Off, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_Off, 100);
bms_crtl_do_status(kDoType_Dis, kDoCtrlStatus_Off, 100);
}
else if (dly >= prechg_time)//预充超时
{
@ -230,14 +230,14 @@ void logic_same_circuit_ctrl(uint32_t base_time)
prechg_volt = bms_get_high_volt(kHvType_Bat);//sfj 获取B+B-电压
if (prechg_volt >= 300)
{
prechg_type = 0;// (HvType)get_eeprom_data(kEep_PreChgVoltType_Rate,kEepromDataType_High);
prechg_volt = prechg_volt * 80 / 100 ;//get_eeprom_data(kEep_PreChgVoltType_Rate,kEepromDataType_Low) / 100;
prechg_type = (HvType)get_eeprom_data(kEep_PreChgVoltType_Rate,kEepromDataType_High);
prechg_volt = prechg_volt * get_eeprom_data(kEep_PreChgVoltType_Rate,kEepromDataType_Low) / 100;
if(bms_get_high_volt(prechg_type) >= prechg_volt)
{
dly = 0;
prechg_cnt = 0;
status = kDoLogicStatus_On;
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY); //闭合总正继电器
bms_crtl_do_status(kDoType_Chg, kDoCtrlStatus_On, RELAY_CTRL_NO_DLY); //闭合总正继电器
bms_crtl_do_status(kDoType_PreChg, kDoCtrlStatus_Off, 500); //延时500ms断开预充继电器
}
}
@ -271,8 +271,8 @@ void logic_same_circuit_ctrl(uint32_t base_time)
{
dly = 0;
status = kDoLogicStatus_WaitAdhesion;
bms_crtl_do_status(kDoType_Positive, kDoCtrlStatus_Off, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Negative, kDoCtrlStatus_Off, 100);
bms_crtl_do_status(kDoType_Chg, kDoCtrlStatus_Off, RELAY_CTRL_NO_DLY);
bms_crtl_do_status(kDoType_Dis, kDoCtrlStatus_Off, 100);
}
break;
case kDoLogicStatus_WaitAdhesion:
@ -296,8 +296,8 @@ void logic_same_circuit_poll(uint32_t base_time, uint8_t idx)
CircuitStatus circuit_st = kCircuitStatus_On;
logic_same_circuit_ctrl(base_time);
pos_rly_st = bms_get_do_status_by_type(kDoType_Positive);
neg_rly_st = (bms_is_do_config(kDoType_Negative) == true) ? bms_get_do_status_by_type(kDoType_Negative) : kDoStatus_On;
pos_rly_st = bms_get_do_status_by_type(kDoType_Chg);
neg_rly_st = (bms_is_do_config(kDoType_Dis) == true) ? bms_get_do_status_by_type(kDoType_Dis) : kDoStatus_On;
//neg_rly_st = kDoStatus_On;
if(((pos_rly_st != kDoStatus_On) && (pos_rly_st != kDoStatus_ForceOn))

View File

@ -146,8 +146,8 @@ uint16_t soh_init(uint16_t cycle, uint32_t dis_cap, uint32_t charge_cap)
{
uint16_t soh_loss1 = 0; //充放电次数计算出的SOH损耗百分比
uint16_t soh_loss2 = 0; //累计放电安时计算出的SOH损耗百分比
uint32_t rated_cap = get_eeprom_data(kEep_RatedCapacity, kEepromDataType_Full);
uint16_t cycle_70 = get_eeprom_data(kEep_SOHSeventyCycle, kEepromDataType_Full);
uint32_t rated_cap = get_eeprom_data(kEep_RatedCapacity, kEepromDataType_Full); //2800
uint16_t cycle_70 = get_eeprom_data(kEep_SOHSeventyCycle, kEepromDataType_Full);//3000
if(cycle <= 10)
{
@ -207,7 +207,7 @@ void cap_data_update(uint16_t base_time)
if (run_status == kRunStatus_Chg)
{
chg_dly += KIT_SECOND_CONVERT(1);
if(chg_dly >= KIT_MINUTE_CONVERT(6))
if(chg_dly >= KIT_MINUTE_CONVERT(6))//
{
chg_dly -= KIT_MINUTE_CONVERT(6);
@ -469,6 +469,7 @@ void bms_init_soc(void)
//soc = bms_check_pwr_on_ocv(soc);
sox_item.soc_kEep_99 = true;
sox_item.soc_kEep_1 = true;
if (soc == 0)
{
sox_item.soc_kEep_1 = false;
@ -504,6 +505,7 @@ void bms_init_soc(void)
sox_item.rated_cap = tmp_64u;
sox_item.soc_1_cap = (SOX_DIS_kEep_SOC * tmp_64u) / SOX_MAX_SOC_VALUE;
sox_item.soc_99_cap = (SOX_CHG_kEep_SOC * tmp_64u) / SOX_MAX_SOC_VALUE;
sox_item.calculate_cap = (soc * tmp_64u) / SOX_MAX_SOC_VALUE;
sox_item.cycle = get_eeprom_data(kEep_CycleTimes, kEepromDataType_Full);
@ -559,6 +561,10 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
if(sox_item.adjust_step != kSocAdjustStep_Wait)
return;
// /*soc test add 2-19
current = 168;
soc_run_calibrate(168, base_time);
// */
tmp_32u = kit_time_get_tick();
integral_time = kit_time_get_interval(sox_item.last_tick, tmp_32u);
sox_item.last_tick = tmp_32u;
@ -586,13 +592,15 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
{
//单位Ams
//公式 (current / 100 * integral_time) * (sox_item.chg_adjust_rate / 100)
tmp_32u = current * integral_time * sox_item.chg_adjust_rate / 10000;
//tmp_32u = current * integral_time * sox_item.chg_adjust_rate / 10000;
tmp_32u = current * integral_time * sox_item.chg_adjust_rate / 100;
if (tmp_32u > SOX_MAX_SIGNAL_INTEGRAL)
tmp_32u = SOX_MAX_SIGNAL_INTEGRAL;
sox_item.tmp_chg_cap += tmp_32u;
//单位 kWms
sox_item.tmp_chg_energy += tmp_32u * total_volt / 10000;
//tmp_32少除了100这里应该多除个100,2.20
sox_item.tmp_chg_energy += tmp_32u * total_volt / 1000000;
if(sox_item.calculate_cap < sox_item.rated_cap)
{
@ -632,7 +640,7 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
//放电积分
if(current < 0)
{
tmp_32u = KIT_ABS(current) * integral_time * sox_item.dis_adjust_rate / 10000;
tmp_32u = KIT_ABS(current) * integral_time * sox_item.dis_adjust_rate / 100;
if (tmp_32u > SOX_MAX_SIGNAL_INTEGRAL)
tmp_32u = SOX_MAX_SIGNAL_INTEGRAL;

View File

@ -53,7 +53,7 @@ typedef enum
void bms_analyse_chg_sop(uint32_t base_time)
{
static uint16_t dly = 0;
bool is_forbid_chg;
bool is_forbid_chg;// 充电禁止标志
uint16_t fault_cur, end_cur, fault_power, end_power, req_volt, total_volt;
uint16_t soc, min_temp, max_temp;
int32_t min_temp_cur, max_temp_cur;
@ -61,7 +61,7 @@ void bms_analyse_chg_sop(uint32_t base_time)
soc = bms_get_soc() / 100;
min_temp = (int32_t)bms_get_statistic_data(kStatisticData_MinTemp) /10 - 50;
max_temp = (int32_t)bms_get_statistic_data(kStatisticData_MaxTemp) /10 - 50;
total_volt = bms_get_statistic_data(kStatisticData_TotalVolt) > 300 ? bms_get_statistic_data(kStatisticData_TotalVolt):300;
total_volt = bms_get_statistic_data(kStatisticData_TotalVolt) > 300 ? bms_get_statistic_data(kStatisticData_TotalVolt):300;//534
if(get_eeprom_data(kEep_ChgDisMode_HighVoltStrategy, kEepromDataType_High) == kChgMode_CP)
{
@ -75,7 +75,7 @@ void bms_analyse_chg_sop(uint32_t base_time)
}
else
{
end_power = sop_item.rate_data[kSopData_ChgPower];
end_power = sop_item.rate_data[kSopData_ChgPower];//50
end_cur = (uint32_t)sop_item.rate_data[kSopData_ChgPower] * 10000/total_volt;
}
}

View File

@ -69,7 +69,7 @@ void task_100ms_handler(uint32_t base_time)
}
GLOBAL_TASK_VARS_CCM(poll_1ms_task, 4, 10, 5000, 400, poll_1ms_task_init, task_1ms_handler, NULL);
GLOBAL_TASK_VARS_CCM(poll_1ms_task, 4, 100, 5000, 400, poll_1ms_task_init, task_1ms_handler, NULL);
GLOBAL_TASK_VARS_CCM(poll_100ms_task, 1, 100, 2000, 400, NULL, task_100ms_handler, NULL);
GLOBAL_TASK_VARS_CCM(poll_10ms_task, 3, 100, 2000, 400, poll_10ms_task_init, task_10ms_handler, NULL);
@ -105,6 +105,10 @@ void poll_1ms_task_init(void)
bms_init_tag();
bms_init_run();
bms_init_comm();
//2-17 new add
//task_dido_ctrl_handle(1000);
bms_init_di_do(bmsCircuitCtrl, kDoCtrlStrategy_End, doLogicArray);
bsp_create_task(&poll_10ms_task, (uint8_t *)"10ms");

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff