|
@@ -172,7 +172,8 @@ uint16_t MC_LimitSpeed_Cal_K_BySOC(FunctionalState Flag, uint16_t SOC)
|
|
|
//随温度计算助力衰减系数
|
|
|
uint16_t MC_Cal_K_ByTemperature(uint16_t CoilTemp, uint16_t AlarmTempTH)
|
|
|
{
|
|
|
- uint32_t CalTemp;
|
|
|
+ #if 0
|
|
|
+ uint32_t CalTemp;
|
|
|
uint16_t Result = 1024;
|
|
|
|
|
|
if(CoilTemp > AlarmTempTH)
|
|
@@ -186,6 +187,26 @@ uint16_t MC_Cal_K_ByTemperature(uint16_t CoilTemp, uint16_t AlarmTempTH)
|
|
|
}
|
|
|
|
|
|
return(Result);
|
|
|
+
|
|
|
+ #else
|
|
|
+ uint32_t CalTemp;
|
|
|
+ uint16_t Result = 1024;
|
|
|
+
|
|
|
+ if(CoilTemp > AlarmTempTH + 20)
|
|
|
+ {
|
|
|
+ Result = 256;
|
|
|
+ }
|
|
|
+ else if(CoilTemp > AlarmTempTH)
|
|
|
+ {
|
|
|
+ Result = 1024 - (CoilTemp - AlarmTempTH) * 38;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Result = 1024;
|
|
|
+ }
|
|
|
+
|
|
|
+ return(Result);
|
|
|
+ #endif
|
|
|
}
|
|
|
|
|
|
//随车速调节启动最大力矩
|
|
@@ -465,7 +486,7 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasSpeed_Process(MC_GasMode_Struct_t GasMo
|
|
|
static uint16_t K_ByVoltage_Set_Old = 1024;
|
|
|
uint16_t K_ByVoltage_Set;
|
|
|
static uint16_t K_ByVoltage_Result;
|
|
|
- uint32_t K_ByTemperature_Set, K_ByTemperature_Set1, K_ByTemperature_Set2;
|
|
|
+ uint16_t K_ByTemperature_Set, K_ByTemperature_SetTemp[3];
|
|
|
static uint16_t K_ByTemperature_Result;
|
|
|
|
|
|
//根据电压调节输出
|
|
@@ -474,9 +495,10 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasSpeed_Process(MC_GasMode_Struct_t GasMo
|
|
|
K_ByVoltage_Result = MC_DataSet_Linear_Process(K_ByVoltage_Set, K_ByVoltage_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
//根据温度调节输出
|
|
|
- K_ByTemperature_Set1 = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, MC_ConfigParam1.TempTH_Alarm); //根据温度计算衰减比例
|
|
|
- K_ByTemperature_Set2 = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm - 15)); //根据温度计算衰减比例
|
|
|
- K_ByTemperature_Set = (K_ByTemperature_Set1 * K_ByTemperature_Set2) >> 10;
|
|
|
+ K_ByTemperature_SetTemp[0] = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm - 10)); //根据PCB温度衰减系数,85℃到105℃
|
|
|
+ K_ByTemperature_SetTemp[1] = MC_Cal_K_ByTemperature(MC_RunInfo.T_MCU, (MC_ConfigParam1.TempTH_Alarm + 5)); //根据MOS温度衰减系数,100℃到120℃
|
|
|
+ K_ByTemperature_SetTemp[2] = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, (MC_ConfigParam1.TempTH_Alarm + 15)); //根据电机温度衰减系数,110℃到130℃
|
|
|
+ K_ByTemperature_Set = GetMinData(K_ByTemperature_SetTemp, 3);
|
|
|
K_ByTemperature_Result = MC_DataSet_Linear_Process(K_ByTemperature_Set, K_ByTemperature_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
#else
|
|
@@ -751,39 +773,42 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasTorque_Process(MC_GasMode_Struct_t GasM
|
|
|
}
|
|
|
else if(GasMode_Param.Mode_bit.PowerLimitFlag == 0) //不根据挡位限制功率,按照Turbo参数
|
|
|
{
|
|
|
- #if 0 //限制最大力矩
|
|
|
- //控制输入给定加速斜率
|
|
|
- TorqueAccStep = (MC_AssisParam.Gear_SMART.AccCnt <= 0) ? 1 : MC_AssisParam.Gear_SMART.AccCnt;
|
|
|
+ #if 1 //根据车速限制最大力矩
|
|
|
+ #define LimitVal (uint16_t)1575
|
|
|
+ #define SpeedBegin (uint16_t)50
|
|
|
+ #define SpeedEnd (uint16_t)100
|
|
|
+ //控制输入给定加速斜率
|
|
|
+ TorqueAccStep = 2;
|
|
|
//控制输入给定减速斜率
|
|
|
- TorqueDecStep = MC_AssisParam.Gear_TURBO.DecCnt;
|
|
|
+ TorqueDecStep = 2;
|
|
|
//根据输入调节力矩环给定
|
|
|
- Torque_Temp = (uint32_t)(MC_TorqueProcess_Param.TorqueApp * MC_AssisParam.Gear_TURBO.Upper_Iq) >> 11;
|
|
|
+ Torque_Temp = (uint32_t)(MC_TorqueProcess_Param.TorqueApp * MC_Cal_MaxIq_BySpeed(SpeedBegin, SpeedEnd, 2100, LimitVal, MC_SpeedSensorData.Speed_Data)) >> 11;
|
|
|
//给定上限
|
|
|
- Torque_Temp = (Torque_Temp > MC_AssisParam.Gear_TURBO.Upper_Iq) ? MC_AssisParam.Gear_TURBO.Upper_Iq : Torque_Temp;
|
|
|
+ Torque_Temp = (Torque_Temp > MC_Cal_MaxIq_BySpeed(SpeedBegin, SpeedEnd, 2100, LimitVal, MC_SpeedSensorData.Speed_Data)) ? MC_Cal_MaxIq_BySpeed(SpeedBegin, SpeedEnd, 2100, LimitVal, MC_SpeedSensorData.Speed_Data) : Torque_Temp;
|
|
|
//限流参数设置
|
|
|
- CurrentLimitSet = (uint32_t)(MC_AssisParam.Gear_TURBO.CurrentMax_K * MC_ConfigParam1.CurrentLimit * 1000 >> 17) * 100;
|
|
|
+ CurrentLimitSet = (uint32_t)(1024 * MC_ConfigParam1.CurrentLimit * 1000 >> 17) * 100;
|
|
|
CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
|
|
|
- PID_IMax.hLower_Limit_Output = -(MC_AssisParam.Gear_TURBO.Upper_Iq); //Lower Limit for Output limitation
|
|
|
+ PID_IMax.hLower_Limit_Output = -(MC_Cal_MaxIq_BySpeed(SpeedBegin, SpeedEnd, 2100, LimitVal, MC_SpeedSensorData.Speed_Data)); //Lower Limit for Output limitation
|
|
|
PID_IMax.hUpper_Limit_Output = 0; //Upper Limit for Output limitation
|
|
|
- PID_IMax.wLower_Limit_Integral = -(MC_AssisParam.Gear_TURBO.Upper_Iq << 10); // 放大1024
|
|
|
- PID_IMax.wUpper_Limit_Integral = 0; // 放大1024
|
|
|
-
|
|
|
- #else //根据车速限制最大力矩
|
|
|
+ PID_IMax.wLower_Limit_Integral = -(MC_Cal_MaxIq_BySpeed(SpeedBegin, SpeedEnd, 2100, LimitVal, MC_SpeedSensorData.Speed_Data) << 10); // 放大1024
|
|
|
+ PID_IMax.wUpper_Limit_Integral = 0; // 放大1024
|
|
|
+
|
|
|
+ #else
|
|
|
//控制输入给定加速斜率
|
|
|
TorqueAccStep = 2;
|
|
|
//控制输入给定减速斜率
|
|
|
TorqueDecStep = 2;
|
|
|
//根据输入调节力矩环给定
|
|
|
- Torque_Temp = (uint32_t)(MC_TorqueProcess_Param.TorqueApp * MC_Cal_MaxIq_BySpeed(50, 100, 2100, 1365, MC_SpeedSensorData.Speed_Data)) >> 11;
|
|
|
+ Torque_Temp = (uint32_t)(MC_TorqueProcess_Param.TorqueApp * 2100) >> 11;
|
|
|
//给定上限
|
|
|
- Torque_Temp = (Torque_Temp > MC_Cal_MaxIq_BySpeed(50, 100, 2100, 1365, MC_SpeedSensorData.Speed_Data)) ? MC_Cal_MaxIq_BySpeed(50, 100, 2100, 1365, MC_SpeedSensorData.Speed_Data) : Torque_Temp;
|
|
|
+ Torque_Temp = (Torque_Temp > 2100) ? 2100 : Torque_Temp;
|
|
|
//限流参数设置
|
|
|
CurrentLimitSet = (uint32_t)(1024 * MC_ConfigParam1.CurrentLimit * 1000 >> 17) * 100;
|
|
|
CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
|
|
|
- PID_IMax.hLower_Limit_Output = -(MC_Cal_MaxIq_BySpeed(50, 100, 2100, 1365, MC_SpeedSensorData.Speed_Data)); //Lower Limit for Output limitation
|
|
|
+ PID_IMax.hLower_Limit_Output = -(2100); //Lower Limit for Output limitation
|
|
|
PID_IMax.hUpper_Limit_Output = 0; //Upper Limit for Output limitation
|
|
|
- PID_IMax.wLower_Limit_Integral = -(MC_Cal_MaxIq_BySpeed(50, 100, 2100, 1365, MC_SpeedSensorData.Speed_Data) << 10); // 放大1024
|
|
|
- PID_IMax.wUpper_Limit_Integral = 0; // 放大1024
|
|
|
+ PID_IMax.wLower_Limit_Integral = -(2100 << 10); // 放大1024
|
|
|
+ PID_IMax.wUpper_Limit_Integral = 0; // 放大1024
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -878,7 +903,7 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasTorque_Process(MC_GasMode_Struct_t GasM
|
|
|
static uint16_t K_ByVoltage_Set_Old = 1024;
|
|
|
uint16_t K_ByVoltage_Set;
|
|
|
static uint16_t K_ByVoltage_Result;
|
|
|
- uint32_t K_ByTemperature_Set, K_ByTemperature_Set1, K_ByTemperature_Set2;
|
|
|
+ uint16_t K_ByTemperature_Set, K_ByTemperature_SetTemp[3];
|
|
|
static uint16_t K_ByTemperature_Result;
|
|
|
|
|
|
//根据电压调节输出
|
|
@@ -887,9 +912,10 @@ MC_CalParam_Struct_t MC_AssistRunMode_GasTorque_Process(MC_GasMode_Struct_t GasM
|
|
|
K_ByVoltage_Result = MC_DataSet_Linear_Process(K_ByVoltage_Set, K_ByVoltage_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
//根据温度调节输出
|
|
|
- K_ByTemperature_Set1 = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, MC_ConfigParam1.TempTH_Alarm); //根据温度计算衰减比例
|
|
|
- K_ByTemperature_Set2 = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm-15)); //根据温度计算衰减比例
|
|
|
- K_ByTemperature_Set = (K_ByTemperature_Set1 * K_ByTemperature_Set2)>>10;
|
|
|
+ K_ByTemperature_SetTemp[0] = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm - 10)); //根据PCB温度衰减系数,85℃到105℃
|
|
|
+ K_ByTemperature_SetTemp[1] = MC_Cal_K_ByTemperature(MC_RunInfo.T_MCU, (MC_ConfigParam1.TempTH_Alarm + 5)); //根据MOS温度衰减系数,100℃到120℃
|
|
|
+ K_ByTemperature_SetTemp[2] = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, (MC_ConfigParam1.TempTH_Alarm + 15)); //根据电机温度衰减系数,110℃到130℃
|
|
|
+ K_ByTemperature_Set = GetMinData(K_ByTemperature_SetTemp, 3);
|
|
|
K_ByTemperature_Result = MC_DataSet_Linear_Process(K_ByTemperature_Set, K_ByTemperature_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
#else
|
|
@@ -1008,7 +1034,7 @@ MC_CalParam_Struct_t MC_AssistRunMode_Walk_Process(MC_WorkMode_Struct_t p_MC_Wor
|
|
|
static uint16_t K_ByVoltage_Set_Old = 1024;
|
|
|
uint16_t K_ByVoltage_Set;
|
|
|
static uint16_t K_ByVoltage_Result;
|
|
|
- uint16_t K_ByTemperature_Set;
|
|
|
+ uint16_t K_ByTemperature_Set, K_ByTemperature_SetTemp[3];
|
|
|
static uint16_t K_ByTemperature_Result;
|
|
|
|
|
|
//根据电压调节输出
|
|
@@ -1017,7 +1043,10 @@ MC_CalParam_Struct_t MC_AssistRunMode_Walk_Process(MC_WorkMode_Struct_t p_MC_Wor
|
|
|
K_ByVoltage_Result = MC_DataSet_Linear_Process(K_ByVoltage_Set, K_ByVoltage_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
//根据温度调节输出
|
|
|
- K_ByTemperature_Set = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, MC_ConfigParam1.TempTH_Alarm); //根据温度计算衰减比例
|
|
|
+ K_ByTemperature_SetTemp[0] = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm - 10)); //根据PCB温度衰减系数,85℃到105℃
|
|
|
+ K_ByTemperature_SetTemp[1] = MC_Cal_K_ByTemperature(MC_RunInfo.T_MCU, (MC_ConfigParam1.TempTH_Alarm + 5)); //根据MOS温度衰减系数,100℃到120℃
|
|
|
+ K_ByTemperature_SetTemp[2] = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, (MC_ConfigParam1.TempTH_Alarm + 15)); //根据电机温度衰减系数,110℃到130℃
|
|
|
+ K_ByTemperature_Set = GetMinData(K_ByTemperature_SetTemp, 3);
|
|
|
K_ByTemperature_Result = MC_DataSet_Linear_Process(K_ByTemperature_Set, K_ByTemperature_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
#else
|
|
@@ -1495,7 +1524,7 @@ MC_CalParam_Struct_t MC_AssistRunMode_Torque_Process(uint16_t SenorData, MC_Gear
|
|
|
static uint16_t K_ByVoltage_Set_Old = 1024;
|
|
|
uint16_t K_ByVoltage_Set;
|
|
|
static uint16_t K_ByVoltage_Result;
|
|
|
- uint32_t K_ByTemperature_Set, K_ByTemperature_Set1, K_ByTemperature_Set2;
|
|
|
+ uint16_t K_ByTemperature_Set, K_ByTemperature_SetTemp[3];
|
|
|
static uint16_t K_ByTemperature_Result;
|
|
|
|
|
|
//根据电压调节输出
|
|
@@ -1504,9 +1533,10 @@ MC_CalParam_Struct_t MC_AssistRunMode_Torque_Process(uint16_t SenorData, MC_Gear
|
|
|
K_ByVoltage_Result = MC_DataSet_Linear_Process(K_ByVoltage_Set, K_ByVoltage_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
//根据温度调节输出
|
|
|
- K_ByTemperature_Set1 = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, MC_ConfigParam1.TempTH_Alarm); //根据温度计算衰减比例
|
|
|
- K_ByTemperature_Set2 = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm-15)); //根据温度计算衰减比例
|
|
|
- K_ByTemperature_Set = (K_ByTemperature_Set1 * K_ByTemperature_Set2)>>10;
|
|
|
+ K_ByTemperature_SetTemp[0] = MC_Cal_K_ByTemperature(MC_RunInfo.T_PCB, (MC_ConfigParam1.TempTH_Alarm - 10)); //根据PCB温度衰减系数,85℃到105℃
|
|
|
+ K_ByTemperature_SetTemp[1] = MC_Cal_K_ByTemperature(MC_RunInfo.T_MCU, (MC_ConfigParam1.TempTH_Alarm + 5)); //根据MOS温度衰减系数,100℃到120℃
|
|
|
+ K_ByTemperature_SetTemp[2] = MC_Cal_K_ByTemperature(MC_RunInfo.T_Coil, (MC_ConfigParam1.TempTH_Alarm + 15)); //根据电机温度衰减系数,110℃到130℃
|
|
|
+ K_ByTemperature_Set = GetMinData(K_ByTemperature_SetTemp, 3);
|
|
|
K_ByTemperature_Result = MC_DataSet_Linear_Process(K_ByTemperature_Set, K_ByTemperature_Result, 1, 1); //设定值与给定值线性处理
|
|
|
|
|
|
#else
|