252 lines
7.9 KiB
C
252 lines
7.9 KiB
C
#include "CDZ_DATA.h"
|
|
|
|
bool Set_VCU_Charging_Allowed(enum VCU_ChrgAllowed setting_up);
|
|
bool Set_BMS_Working_Mode(enum VCU_Mode setting_up);
|
|
bool Set_BMS_Working_Status(enum BMS_WorkStatus setting_up);
|
|
bool Set_DCU_Charging_Allowed(enum BMS_ChrgAllow setting_up);
|
|
bool Set_BMS_OncConSt_Status(enum BMS_OncConSt setting_up);
|
|
|
|
bool Get_VCU_Charging_Allowed(struct Car_message* self);
|
|
enum VCU_Mode Get_BMS_Working_Mode(struct Car_message* self);
|
|
bool Get_BMS_Working_Status(struct Car_message* self);
|
|
bool Get_DCU_Charging_Allowed(struct Car_message* self);
|
|
uint8_t Get_BMS_OncConSt_Status(struct Car_message* self);
|
|
|
|
struct Car_message Car_Message = {
|
|
.Set_BMS_Charging_allowance = Set_DCU_Charging_Allowed,
|
|
.Get_BMS_Charging_allowance = Get_DCU_Charging_Allowed,
|
|
|
|
.Set_Car_Charging_allowance = Set_VCU_Charging_Allowed,
|
|
.Get_Car_Charging_allowance = Get_VCU_Charging_Allowed,
|
|
|
|
.Set_Car_Working_Mode = Set_BMS_Working_Mode,
|
|
.Get_Car_Working_Mode = Get_BMS_Working_Mode,
|
|
|
|
.Set_Car_Working_Status = Set_BMS_Working_Status,
|
|
.Get_Car_Working_Status = Get_BMS_Working_Status,
|
|
|
|
.Set_Car_OncConSt_Status = Set_BMS_OncConSt_Status,
|
|
.Get_Car_OncConSt_Status = Get_BMS_OncConSt_Status,
|
|
};
|
|
|
|
struct BMD_TO_CDZ BMSDefaultParameters = {
|
|
|
|
.parenr = &Car_Message,
|
|
|
|
};
|
|
|
|
//传输值转物理值
|
|
uint16_t ValueData__to_physical(uint16_t Data,float factor,int16_t offset)
|
|
{
|
|
return (uint16_t)(Data*factor + offset);
|
|
}
|
|
//物理值转传输值
|
|
uint16_t ValuePhysical_to_Data(uint16_t Physical,float factor,int16_t offset)
|
|
{
|
|
return (uint16_t)((Physical - offset)/factor);
|
|
|
|
}
|
|
|
|
//传输值转物理值
|
|
int16_t Int_ValueData__to_physical(uint16_t Data,float factor,int16_t offset)
|
|
{
|
|
return (int16_t)(Data*factor + offset);
|
|
}
|
|
|
|
//物理值转传输值
|
|
int16_t IntValuePhysical_to_Data(uint16_t Physical,float factor,int16_t offset)
|
|
{
|
|
return (int16_t)((Physical - offset)/factor);
|
|
|
|
}
|
|
|
|
//设置VCU充电状态
|
|
bool Set_VCU_Charging_Allowed(enum VCU_ChrgAllowed setting_up)
|
|
{
|
|
Car_Message.VCU_ChrgAllowed = setting_up;
|
|
return true;
|
|
}
|
|
//获取VCU充电状态
|
|
bool Get_VCU_Charging_Allowed(struct Car_message* self)
|
|
{
|
|
if(self->VCU_ChrgAllowed == ALLOWED)
|
|
{
|
|
return true;
|
|
}
|
|
else if(self->VCU_ChrgAllowed == NOT_ALLOWED)
|
|
{
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//设置BMS工作模式
|
|
bool Set_BMS_Working_Mode(enum VCU_Mode setting_up)
|
|
{
|
|
Car_Message.VCU_Mode = setting_up;
|
|
return true;
|
|
}
|
|
//获取BMS工作模式
|
|
enum VCU_Mode Get_BMS_Working_Mode(struct Car_message* self)
|
|
{
|
|
return self->VCU_Mode;
|
|
}
|
|
|
|
//设置BMS工作状态
|
|
bool Set_BMS_Working_Status(enum BMS_WorkStatus setting_up)
|
|
{
|
|
if( (setting_up != HV_finished) && (setting_up != HV_shutdown) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Car_Message.BMS_WorkStatus = setting_up;
|
|
return true;
|
|
}
|
|
//获取BMS工作状态
|
|
bool Get_BMS_Working_Status(struct Car_message* self)
|
|
{
|
|
if(self->BMS_WorkStatus == HV_finished)
|
|
{
|
|
return true;
|
|
}
|
|
else if(self->BMS_WorkStatus == HV_shutdown)
|
|
{
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//设置BMS充电允许
|
|
bool Set_DCU_Charging_Allowed(enum BMS_ChrgAllow setting_up)
|
|
{
|
|
if( (setting_up !=allow) && (setting_up != refuse) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Car_Message.BMS_ChrgAllowed = setting_up;
|
|
return true;
|
|
}
|
|
//获取BMS充电允许
|
|
bool Get_DCU_Charging_Allowed(struct Car_message* self)
|
|
{
|
|
if(self->BMS_ChrgAllowed == allow)
|
|
{
|
|
return true;
|
|
}
|
|
else if(self->BMS_ChrgAllowed == refuse)
|
|
{
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
//BMS插枪连接状态
|
|
bool Set_BMS_OncConSt_Status(enum BMS_OncConSt setting_up)
|
|
{
|
|
Car_Message.BMS_OncConSt = setting_up;
|
|
return true;
|
|
}
|
|
|
|
uint8_t Get_BMS_OncConSt_Status(struct Car_message* self)
|
|
{
|
|
return self->BMS_OncConSt;
|
|
}
|
|
|
|
void initializeBMS_default_parameters(void)
|
|
{
|
|
BMSDefaultParameters.uBatCurSOC = 20;
|
|
//BHM
|
|
BMSDefaultParameters.BHM.Maximum_allowable_total_charging_voltage = 5000;//精度0.1
|
|
|
|
//BRM
|
|
BMSDefaultParameters.BRM.VersionNumber.fields.VersionArr[0] = 0x01;
|
|
BMSDefaultParameters.BRM.VersionNumber.fields.VersionArr[1] = 0x01;
|
|
BMSDefaultParameters.BRM.VersionNumber.fields.VersionArr[2] = 0x00;
|
|
BMSDefaultParameters.BRM.BatteryType = LFP_battery;
|
|
BMSDefaultParameters.BRM.RatedCapacity = 1000;//精度0.1
|
|
BMSDefaultParameters.BRM.RatedTotalVoltage = 4200;//精度0.1需要做默认参数
|
|
|
|
//厂家编号
|
|
BMSDefaultParameters.BRM.Battery_manufacturer[0] = 'B';
|
|
BMSDefaultParameters.BRM.Battery_manufacturer[1] = 'Y';
|
|
BMSDefaultParameters.BRM.Battery_manufacturer[2] = 'D';
|
|
BMSDefaultParameters.BRM.Battery_manufacturer[3] = 'T';
|
|
//电池组序号
|
|
BMSDefaultParameters.BRM.BatterySerialNumber[0] = 0X00;
|
|
BMSDefaultParameters.BRM.BatterySerialNumber[1] = 0X00;
|
|
BMSDefaultParameters.BRM.BatterySerialNumber[2] = 0X01;
|
|
BMSDefaultParameters.BRM.BatterySerialNumber[3] = 0X02;
|
|
|
|
BMSDefaultParameters.BRM.Batteryack_production_dateYesr = 25;
|
|
BMSDefaultParameters.BRM.Batteryack_production_dateMouth = 0x0B;
|
|
BMSDefaultParameters.BRM.Batteryack_production_dateData = 0X0A;
|
|
|
|
BMSDefaultParameters.BRM.Battery_pack_charge_count.fields.ChargeCount[0] = 0x00;
|
|
BMSDefaultParameters.BRM.Battery_pack_charge_count.fields.ChargeCount[1] = 0x00;
|
|
BMSDefaultParameters.BRM.Battery_pack_charge_count.fields.ChargeCount[2] = 0x10;
|
|
|
|
BMSDefaultParameters.BRM.Battery_pack_property_right_identification = 0;
|
|
BMSDefaultParameters.BRM.reserve = 0;
|
|
memcpy(BMSDefaultParameters.BRM.ucCarVin,"LVPC5279XND013818",17);
|
|
memcpy(BMSDefaultParameters.BRM.BMS_Software_version_number,"S001H001",8);
|
|
|
|
//BCP
|
|
BMSDefaultParameters.BCP.MaxChargingVoltageSingle = 420;//精度0.01
|
|
// BMSDefaultParameters.BCP.MaxChargingCurrent = ValuePhysical_to_Data(-400,0.1,-400);//精度0.1 偏移-400
|
|
BMSDefaultParameters.BCP.MaxChargingCurrent = 500;
|
|
//BMSDefaultParameters.BCP.NominalTotalEnergy = 310;//31度电
|
|
BMSDefaultParameters.BCP.MaxTotalChargingVoltage = 4900;//最高允许充电电压
|
|
|
|
BMSDefaultParameters.BCP.MaxTemperature = 110;//最高允许温度
|
|
BMSDefaultParameters.BCP.ChargeState = 200;//整车SOC状态
|
|
BMSDefaultParameters.BCP.CurrentVoltage = 4000;//当前电池电压
|
|
|
|
//BRO
|
|
BMSDefaultParameters.BRO.Whether_the_BMS_is_ready = 0;//00或者AA
|
|
|
|
//BCL
|
|
BMSDefaultParameters.BCL.VoltageDemand = 4000;//精度0.1
|
|
// BMSDefaultParameters.BCL.CurrentDemand = ValuePhysical_to_Data(-5,0.1,-400);//精度0.1 偏移-400
|
|
BMSDefaultParameters.BCL.CurrentDemand = 600;
|
|
BMSDefaultParameters.BCL.Mode = ConstantCurrent;
|
|
|
|
//BCS
|
|
BMSDefaultParameters.BCS.ChargingVoltage = 0;
|
|
BMSDefaultParameters.BCS.ChargingCurrent = 0;
|
|
BMSDefaultParameters.BCS.MaxSingleCellVoltage.fields.voltage = 324;
|
|
BMSDefaultParameters.BCS.MaxSingleCellVoltage.fields.group = 1;
|
|
|
|
BMSDefaultParameters.BCS.RemainingChargeTime = 60;
|
|
|
|
//BSM
|
|
BMSDefaultParameters.BSM.highest_cell_voltage_number = 1;
|
|
BMSDefaultParameters.BSM.highest_battery_temperature = ValuePhysical_to_Data(10,0.1,-50);
|
|
BMSDefaultParameters.BSM.highest_temperature_detection_point = 3;
|
|
BMSDefaultParameters.BSM.lowest_battery_temperature = ValuePhysical_to_Data(5,0.1,-50);
|
|
BMSDefaultParameters.BSM.lowest_temperature_detection_point = 4;
|
|
|
|
BMSDefaultParameters.BSM.high_low_voltage_status = Normal;
|
|
BMSDefaultParameters.BSM.high_low_SOC_status = Normal;
|
|
BMSDefaultParameters.BSM.charging_overcurrent_status = Normal;
|
|
BMSDefaultParameters.BSM.high_temperature_status = Normal;
|
|
|
|
BMSDefaultParameters.BSM.insulation_status = Normal;
|
|
BMSDefaultParameters.BSM.output_connector_status = Normal;
|
|
BMSDefaultParameters.BSM.charging_permission = Normal;
|
|
|
|
//BST
|
|
BMSDefaultParameters.BST.charge_abort_reason = 01;
|
|
BMSDefaultParameters.BST.charge_abort_faults = 00;
|
|
BMSDefaultParameters.BST.charge_abort_errors = 00;
|
|
//BSD
|
|
BMSDefaultParameters.BSD.soc_abort = 100;
|
|
BMSDefaultParameters.BSD.min_cell_voltage = 345;
|
|
BMSDefaultParameters.BSD.max_cell_voltage = 355;
|
|
BMSDefaultParameters.BSD.min_battery_temperature = ValuePhysical_to_Data(25,0.1,-50);
|
|
BMSDefaultParameters.BSD.max_battery_temperature = ValuePhysical_to_Data(28,0.1,-50);
|
|
|
|
}
|
|
|
|
|