Преглед на файлове

增加转把模式功率限制。

dd преди 4 месеца
родител
ревизия
e1a8452598

+ 8 - 2
.cproject

@@ -30,7 +30,7 @@
 							</option>
 							<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.667530017" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="TICLANG_3.2.2.LTS" valueType="string"/>
 							<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.targetPlatformDebug.42360861" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.targetPlatformDebug"/>
-							<builder buildPath="${BuildDirectory}" enableAutoBuild="false" id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.builderDebug.1137809730" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.builderDebug"/>
+							<builder autoBuildTarget="all" buildPath="${BuildDirectory}" cleanBuildTarget="clean" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.builderDebug.1137809730" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU Make" parallelBuildOn="false" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.builderDebug"/>
 							<tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.compilerDebug.1794514536" name="Arm Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.exe.compilerDebug">
 								<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.compilerID.GENERATE_DWARF_DEBUG.628486153" name="Generate DWARF debug" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.compilerID.GENERATE_DWARF_DEBUG" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.compilerID.GENERATE_DWARF_DEBUG.GDWARF_3" valueType="enumerated"/>
 								<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.compilerID.ENDIAN_NESS__BIG_LITTLE.1915348719" name="Endian-ness (big/little) [See 'General' page to edit]" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.compilerID.ENDIAN_NESS__BIG_LITTLE" useByScannerDiscovery="false" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_3.2.compilerID.ENDIAN_NESS__BIG_LITTLE.MLITTLE_ENDIAN" valueType="enumerated"/>
@@ -121,6 +121,12 @@
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
 		<project id="empty_LP_MSPM0G3507_nortos_ticlang.com.ti.ccstudio.buildDefinitions.TMS470.ProjectType.1665106300" name="TMS470" projectType="com.ti.ccstudio.buildDefinitions.TMS470.ProjectType"/>
 	</storageModule>
-	<storageModule moduleId="scannerConfiguration"/>
 	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
+	<storageModule moduleId="refreshScope" versionNumber="2">
+		<configuration configurationName="Debug">
+			<resource resourceType="PROJECT" workspacePath="/empty_LP_MSPM0G3507_APP_Normal_20250107"/>
+		</configuration>
+	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+	<storageModule moduleId="scannerConfiguration"/>
 </cproject>

+ 7 - 1
1.FrameLayer/Source/TimeTask_Event.c

@@ -103,12 +103,16 @@ void  Event_1ms(void)
     // Brake detection 
     bikebrake_voBikeBrakeDetect();
 
+    /* 转把根据车速限制功率 */
+    ThrottlePowerLimitCal((ass_stCadAssParaPro.uwAssitMode == 7), MC_RunInfo.BikeSpeed, ass_ParaCong.uwThrottleMaxSpdKmH * 10,
+                          scm_stMotoPwrInLpf.sY.sw.hi, pwr_stPwrLimOut2.swMotorPwrLimitActualPu, &Throttle_PowerLimit_K);
+
     /* 电池电量限电流 */
     AssistCurrentLimitAccordingBMS(MC_RunInfo.SOC);
 
     /* 限制母线电流 */
     AssCurLimAccordIdc(adc_stUpOut.uwIbusAvgLpfPu);
-#if(BIKE_OXFORD_EN==0)
+#if(BIKE_OXFORD_EN==0)cd
     if(power_stPowStateOut.powerstate != POWER_ON_END)
     {
        cp_stBikeRunInfoPara.uwBikeGear = 0;
@@ -406,6 +410,8 @@ void  Event_200ms(void)
     {
          SendData(&UART_TxBuff_Struct_OBC, ID_MC_BC, MODE_REPORT, 0x1104, (uint8_t *)&MC_ErrorCode.Code);
     }
+
+    //功率限制
     GearLimitCurHandle();
 }
 

+ 2 - 1
2.MotorDrive/Include/pwrlim.h

@@ -89,6 +89,7 @@ typedef struct // Input of " pwr_voPwrLim "
     SWORD swPCBTemp;    /**< PCB温度,单位:摄氏度 */
     SWORD swMotorTemp;  /**< MOTOR温度,单位:摄氏度 */
     UWORD uwBatCap;     /**< 电池电量 */
+    UWORD uwThrottleLimit_K; /* 转把模式功率限制系数 */
 } PWRLIM_IN;
 
 typedef struct // Output of " pwr_voPwrLim "
@@ -150,4 +151,4 @@ _PWRLIM_EXT void       pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT
 *************************************************************************
  End of this File (EOF):
  Do not put anything after this part!
-************************************************************************/
+************************************************************************/

+ 1 - 1
2.MotorDrive/Source/pwrlim.c

@@ -294,7 +294,7 @@ void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out)
         swIqlimPu1 = (swMotorTempCurLimitPu < swPCBTempCurLimitPu) ? swMotorTempCurLimitPu : swPCBTempCurLimitPu;
     }
     /* 功率限制PI调节:根据功率限制电流 */
-    slERROR = out->swMotorPwrLimitActualPu - in->swMotorPwrPu;
+    slERROR = ((out->swMotorPwrLimitActualPu * in->uwThrottleLimit_K) >> 14) - in->swMotorPwrPu;
 //    slERROR = cof->swMotorPwrLimitPu - in->swMotorPwrPu;
     if (slERROR >= 32768)
     {

+ 1 - 0
2.MotorDrive/Source/spdctrFSM.c

@@ -166,6 +166,7 @@ void ClzLoop_TbcupHook(void)
     pwr_stPwrLimIn.swPCBTemp = scm_stPCBTempLpf.slY.sw.hi;  
     pwr_stPwrLimIn.swMotorTemp = scm_stMotorTempLpf.slY.sw.hi;  
     pwr_stPwrLimIn.uwBatCap = MC_RunInfo.SOC;
+    pwr_stPwrLimIn.uwThrottleLimit_K = Throttle_PowerLimit_K.K_Result;
     pwr_voPwrLimPI(&pwr_stPwrLimIn, &pwr_stPwrLimCof, &pwr_stPwrLimOut2); // Q14
 }
 

+ 2 - 2
3.BasicFunction/Include/AssistCurve.h

@@ -85,8 +85,8 @@
     } // Q12
 
 #if 1
-#define TORQUR_ASSIST_BASE       4200 // 250W Maximum Current
-#define TORQUR_CP(x)             ((ULONG)(x)*M_IS_PEAK_MAX_AP /TORQUR_ASSIST_BASE)
+#define TORQUR_ASSIST_BASE       M_IS_PEAK_MAX_AP
+#define TORQUR_CP(x)             ((ULONG)(x)*M_IS_PEAK_MAX_AP / TORQUR_ASSIST_BASE)
 
 #define TORQUE_ASSIST_DEFAULT             \
     {                                     \

+ 12 - 1
3.BasicFunction/Include/CadAssist.h

@@ -441,6 +441,15 @@ typedef struct
 
 }GEAR_CUR_TRUCT;
 
+typedef struct
+{
+    UBYTE State;       //0-Stop,1-加速,2-恒功率
+    UWORD K_Init;      //初始系数
+    UWORD K_AccStep;   //递增斜率
+    UWORD K_DecStep;   //递减斜率
+    UWORD K_Result;    //功率限制衰减系数
+}THROTTLE_POWER_LIMIT_STRUCT;
+
 extern MaTCHCAD_TRUCT CadSmart;
 extern GEAR_CUR_TRUCT GearCur;
 /****************************************
@@ -455,6 +464,7 @@ extern CADASS_PER_OUT  ass_stCadAssCalOut;
 extern CADASS_PID      ass_stCadAssSpdCtl;
 extern CADASS_PER_PRO  ass_stCadAssParaPro;
 extern CAD_ASS_FSM_STATUS      ass_enCadAssStatus;
+extern THROTTLE_POWER_LIMIT_STRUCT Throttle_PowerLimit_K;
 /************************************************************************
  Ram Allocation
 *************************************************************************/
@@ -480,7 +490,6 @@ extern void ass_voParameterInit(void);
 extern void ass_voAssistCoefCal(void);
 
 
-
 extern void CadSpedLinitPowerInit(void);
 /**
  * @brief  Assist Function
@@ -493,4 +502,6 @@ extern void ass_voAssistFunc(void);
 extern void CadSmartDisting(void);
 
 extern void GearLimitCurHandle(void);
+
+extern void ThrottlePowerLimitCal(BOOL ThrottleModeFlag, UWORD BikeSpeed, UWORD BikeSpeedLimit, SWORD PowerCur, SWORD PowerMax, THROTTLE_POWER_LIMIT_STRUCT* ThrottlePowerLimit);
 #endif

+ 59 - 1
3.BasicFunction/Source/CadAssist.c

@@ -54,6 +54,8 @@ GEAR_COEF CadAssistSped;
 CADPOWER_STRUCT CadSpdPower;
 GEAR_CUR_TRUCT GearCur;
 
+THROTTLE_POWER_LIMIT_STRUCT Throttle_PowerLimit_K={0, 16384, 10, 10, 16384};
+
 /******************************
  *
  *  Function Statement
@@ -939,7 +941,9 @@ void ass_voAssistCmdDeal(void)
             {
                 tmp_slAssistSpdCmd = (SLONG)ass_stCadAssCoef.swKmhToMSpdPu*(SLONG)ass_MaxSpeed.MaxBikeSpeed>> 4;
             }
+            #if 0
             tmp_slAssistSpdCmd = (tmp_slAssistSpdCmd << 10) / Bike_RatioCalParam.RatioResult; //前后飞轮传动比
+            #endif
         #else
             if(ass_stCadAssParaIn.uwThrottlePercent < 650) //850
             {
@@ -950,7 +954,9 @@ void ass_voAssistCmdDeal(void)
             {
                 tmp_slAssistSpdCmd = (SLONG)ass_stCadAssCoef.swKmhToMSpdPu*(SLONG)ass_stCadAssCoef.uwThrottleMaxBikeSpeed >> 4;
             }
+            #if 0
             tmp_slAssistSpdCmd = (tmp_slAssistSpdCmd << 10) / Bike_RatioCalParam.RatioResult; //前后飞轮传动比
+            #endif
          #endif
         }
         else
@@ -1849,4 +1855,56 @@ void GearLimitCurHandle(void)
 
 }
 
-
+void ThrottlePowerLimitCal(BOOL ThrottleModeFlag, UWORD BikeSpeed, UWORD BikeSpeedLimit, SWORD PowerCur, SWORD PowerMax, THROTTLE_POWER_LIMIT_STRUCT* ThrottlePowerLimit)
+{
+    if(ThrottleModeFlag == FALSE) //未进入转把模式,不限制功率
+    {
+        ThrottlePowerLimit->State = 0; //停止
+        ThrottlePowerLimit->K_Init = 16384;
+        ThrottlePowerLimit->K_Result = ThrottlePowerLimit->K_Init;
+        return;
+    }
+    else
+    {
+        switch(ThrottlePowerLimit->State)
+        {
+            case 0: //停止阶段
+            {
+                ThrottlePowerLimit->State = 1;
+                ThrottlePowerLimit->K_Init = 16384;
+                ThrottlePowerLimit->K_Result = ThrottlePowerLimit->K_Init;
+                break;
+            }
+            case 1: //加速阶段
+            {
+                if(BikeSpeed > BikeSpeedLimit)
+                {
+                    ThrottlePowerLimit->State = 2;
+                    ThrottlePowerLimit->K_Init = (SLONG)(PowerCur << 14) / PowerMax;
+                    ThrottlePowerLimit->K_Result = ThrottlePowerLimit->K_Init;
+                }
+                break;
+            }
+            case 2: //恒功率阶段
+            {
+                if(BikeSpeed < 100)
+                    ThrottlePowerLimit->State = 0;
+                else
+                {
+                    if(BikeSpeed > (BikeSpeedLimit + 10))
+                    {
+                        //if(ThrottlePowerLimit->K_Result > ThrottlePowerLimit->K_DecStep)
+                        //    ThrottlePowerLimit->K_Result -= ThrottlePowerLimit->K_DecStep;
+                    }
+                    else if(BikeSpeed < (BikeSpeedLimit - 10))
+                    {
+                        //if(ThrottlePowerLimit->K_Result < 16384)
+                        //    ThrottlePowerLimit->K_Result += ThrottlePowerLimit->K_AccStep;
+                    }
+                }
+                break;
+            }
+            default:break;
+        }
+    }
+}