Bladeren bron

调整传动比计算。

dd 4 maanden geleden
bovenliggende
commit
b149489e7e

+ 8 - 8
3.BasicFunction/Include/CadAssist.h

@@ -240,17 +240,17 @@
 #define ASS_CMD_SPEED_LPF_TIME  5000L                           /**< Cmd Low Pass Filter Time. Unit 1ms */
    
 #if(THROTTLEGEAR !=0)
-#define ASS_ONE_SPEED_PERCENT           48
-#define ASS_TWO_SPEED_PERCENT           64
-#define ASS_THREE_SPEED_PERCENT         80
+#define ASS_ONE_SPEED_PERCENT           60
+#define ASS_TWO_SPEED_PERCENT           72
+#define ASS_THREE_SPEED_PERCENT         84
 #define ASS_FOUR_SPEED_PERCENT          100
 #define ASS_FIVE_SPEED_PERCENT          100
 #endif
 
 #if(CADASSISTGEAR !=0)
-#define CAD_ONE_SPEED_PERCENT           48
-#define CAD_TWO_SPEED_PERCENT           64
-#define CAD_THREE_SPEED_PERCENT         80
+#define CAD_ONE_SPEED_PERCENT           60
+#define CAD_TWO_SPEED_PERCENT           72
+#define CAD_THREE_SPEED_PERCENT         84
 #define CAD_FOUR_SPEED_PERCENT          100
 #define CAD_FIVE_SPEED_PERCENT          100
 #endif
@@ -280,8 +280,8 @@ typedef enum
 {
     //coef
     UWORD uwPidKp;                      /**助力kp< Q8. PID Kp */
-    UWORD uwThrittlePidKp;                      /**< Q8. PID Kp */
-    UWORD uwACTPidKp;                      /**< Q8. PID Kp */
+    UWORD uwThrittlePidKp;              /**< Q8. PID Kp */
+    UWORD uwACTPidKp;                   /**< Q8. PID Kp */
     //input
     SWORD swIqRef;                      /**< Q14. PID Input q axis current reference */
     SWORD swIqFbk;                      /**< Q14. PID Input q axis current feedback */

+ 24 - 22
3.BasicFunction/Source/BikeRatioCal.c

@@ -11,7 +11,7 @@ Bike_RatioCal_Struct_t Bike_RatioCalParam = {0,0,0,0,0};
 //参数初始化
 void BikeRatioCal_Init(UWORD Teeth_F, UWORD Teeth_B)
 {
-    Bike_RatioCalParam.RatioDefault = (Teeth_F << 10) / Teeth_B;
+    Bike_RatioCalParam.RatioDefault = 1 << 10;
     Bike_RatioCalParam.RatioResult = Bike_RatioCalParam.RatioDefault;
 }
 
@@ -19,44 +19,46 @@ void BikeRatioCal_Init(UWORD Teeth_F, UWORD Teeth_B)
 void BikeRatioCal_Process(UWORD MotorSpeed, UWORD Cadence, UWORD BikeSpeedRpm, UWORD PedalTorqueNm, UWORD Current, Bike_RatioCal_Struct_t* p_Bike_RatioCal)
 {
     ULONG Speed_F, Speed_B; //前后牙盘转速 rpm Q8
-    UBYTE Coasted_Flag = 1; //滑行或静止标志,1-滑行或静止
+    UBYTE Coasted_Flag = 0xFF; //滑行或静止标志,1-滑行,2-静止
 
     //有效判断
     if(BikeSpeedRpm > 20) //20rpm*60*2.19m/1000≈2.6km/h
     {
-        if((PedalTorqueNm > 50) && (Cadence > 10)) //5Nm 10rpm
+        if((PedalTorqueNm > 100) && (Cadence > 10)) //10Nm 10rpm
             Coasted_Flag = 0;
         else
         {
             if((MotorSpeed > 100) && (Current > 10)) //100rpm 0.1A
-            {
                 Coasted_Flag = 0;
-            }
+            else
+                Coasted_Flag = 1;
         }
     }
+    else
+        Coasted_Flag = 2;
 
     //计算传动比
-    if(Coasted_Flag == 0)
+    if(Coasted_Flag == 2) //静止更新为默认值
     {
-        //转速计算
-        Speed_F = ((((ULONG)MotorSpeed * 56) > ((ULONG)Cadence * 614)) ? ((ULONG)MotorSpeed * 56) : ((ULONG)Cadence * 614)) >> 8; //max(电机转速/4.55*256,踏频*2.4*256)
-        Speed_B = BikeSpeedRpm;
-        //计算传动比 Q10
-        p_Bike_RatioCal->RatioPer = (Speed_B << 10) / Speed_F;
-        //限制计算结果
-        p_Bike_RatioCal->RatioPer = (p_Bike_RatioCal->RatioPer < 200) ? 200 : ((p_Bike_RatioCal->RatioPer > 5000) ? 5000 : p_Bike_RatioCal->RatioPer);
+        p_Bike_RatioCal->RatioResult = p_Bike_RatioCal->RatioDefault;
+        p_Bike_RatioCal->RatioFltSum = 0;
+    }
+    else
+    {
+        if(Coasted_Flag == 0) //骑行或转把时计算
+        {
+            //转速计算
+            Speed_F = ((((ULONG)MotorSpeed * 56) > ((ULONG)Cadence * 614)) ? ((ULONG)MotorSpeed * 56) : ((ULONG)Cadence * 614)) >> 8; //max(电机转速/4.55*256,踏频*2.4*256)
+            Speed_B = BikeSpeedRpm;
+            //计算传动比 Q10
+            p_Bike_RatioCal->RatioPer = (Speed_B << 10) / Speed_F;
+            //限制计算结果
+            p_Bike_RatioCal->RatioPer = (p_Bike_RatioCal->RatioPer < 400) ? 400 : ((p_Bike_RatioCal->RatioPer > 1500) ? 1500 : p_Bike_RatioCal->RatioPer);
+        }
         //计算结果滤波
-        p_Bike_RatioCal->RatioFltSum += ((p_Bike_RatioCal->RatioPer << 10) - p_Bike_RatioCal->RatioFltSum) >> 4;
+        p_Bike_RatioCal->RatioFltSum += ((p_Bike_RatioCal->RatioPer << 10) - p_Bike_RatioCal->RatioFltSum) >> 8;
         p_Bike_RatioCal->RatioFlt = p_Bike_RatioCal->RatioFltSum >> 10;
         //目标值计算
         p_Bike_RatioCal->RatioResult = p_Bike_RatioCal->RatioFlt;
     }
-    else
-    {
-        p_Bike_RatioCal->RatioPer = p_Bike_RatioCal->RatioDefault;
-        p_Bike_RatioCal->RatioResult = p_Bike_RatioCal->RatioDefault;
-        p_Bike_RatioCal->RatioFlt = p_Bike_RatioCal->RatioDefault;
-        p_Bike_RatioCal->RatioFltSum = 0;
-    }
-
 }

+ 9 - 9
3.BasicFunction/Source/CadAssist.c

@@ -535,15 +535,15 @@ void ass_voAssistCmdDeal(void)
     {
         ass_stCadAssParaPro.uwAssitMode = 6;
         /** Q15 * Q4 / Q4 = Q15 */
-         if(MC_WorkMode == 1)
-         {
-           tmp_slAssistSpdCmd = (SLONG)ass_stCadAssCoef.swKmhToMSpdPu*(SLONG)ass_stCadAssCoef.uwThrottleMaxBikeSpeed >> 4;
-           tmp_slAssistSpdCmd= ((SLONG)MC_MotorSPD_rpm_Percent * tmp_slAssistSpdCmd) / 100;
-         }
-         else
-         {
-        tmp_slAssistSpdCmd = (SLONG)ass_stCadAssCoef.swKmhToMSpdPu*(SLONG)ass_stCadAssCoef.uwCartMaxBikeSpeed  >> 4;    
-    }
+        if(MC_WorkMode == 1)
+        {
+            tmp_slAssistSpdCmd = (SLONG)ass_stCadAssCoef.swKmhToMSpdPu*(SLONG)ass_stCadAssCoef.uwThrottleMaxBikeSpeed >> 4;
+            tmp_slAssistSpdCmd = ((SLONG)MC_MotorSPD_rpm_Percent * tmp_slAssistSpdCmd) / 100;
+        }
+        else
+        {
+            tmp_slAssistSpdCmd = (SLONG)ass_stCadAssCoef.swKmhToMSpdPu*(SLONG)ass_stCadAssCoef.uwCartMaxBikeSpeed  >> 4;
+        }
     }
     else if((ass_stCadAssParaIn.uwGearSt > 0)&&(ass_stCadAssParaIn.uwGearSt <= 5))
     {

+ 2 - 2
4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Include/syspar.h

@@ -43,7 +43,7 @@ Update Time
 
 #define IPM_VOLTAGE_36V         0x0
 #define IPM_VOLTAGE_48V         0x1
-#define IPM_VOLTAGE_SEL         IPM_VOLTAGE_48V
+#define IPM_VOLTAGE_SEL         IPM_VOLTAGE_36V
 
 #define BIKE_TYPE_R219          0x0
 #define BIKE_TYPE_R168          0x01
@@ -299,7 +299,7 @@ Update Time
 #define IPM_TURN_ON_TM_NS           300  // 86      // unit:ns
 #define IPM_TURN_OFF_TM_NS          300  // 105      // unit:ns
 #define IPM_DEAD_TM_NS              1000 // unit:ns
-#define IPM_HVIC_CHRG_TM            20 // unit: ms,Bootstrap capacitor charge time
+#define IPM_HVIC_CHRG_TM            20   // unit: ms,Bootstrap capacitor charge time
 
 #define ADC_UABC_MAX_VT             495
 #define ADC_DISPLAY_MAX_VT          188

+ 3 - 3
4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Include/user.h

@@ -706,7 +706,7 @@ Update Time
 #elif ((MOTOR_ID_SEL == MOTOR_LUNGU_WELLING_HAL_POLE8_350W)||(MOTOR_ID_SEL == MOTOR_LUNGU_WELLING_HAL_POLE8_350W_958Ratio)||(MOTOR_ID_SEL ==MOTOR_LUNGU_WELLING_HAL_POLE8_250W_958Ratio) ||(MOTOR_ID_SEL ==MOTOR_LUNGU_WELLING_HAL_POLE8_500W_958Ratio))
 #define ALM_ROTOR_LOCK_SPD 40 // unit: rpm, Threshold value
 #else
-#define ALM_ROTOR_LOCK_SPD 100 // unit: rpm, Threshold value
+#define ALM_ROTOR_LOCK_SPD 40 // unit: rpm, Threshold value
 #endif
 
 #if (IPM_VOLTAGE_SEL == IPM_VOLTAGE_48V)
@@ -792,7 +792,7 @@ Update Time
 #define ALM_REC_ALL_TM 200 // unit: ms, Time of duration(TBC)
 
 /* Recover time of IPM OC */
-#define ALM_IPM_OC_REC_TM  1000//100 // unit: ms, Time of duration(TBC)
+#define ALM_IPM_OC_REC_TM  1000 //100 // unit: ms, Time of duration(TBC)
 
 /* Recover time & value of IPM over heat */
 #define ALM_IPM_OVR_HEAT_REC_VAL 105  // unit: Ce, Threshold value
@@ -889,7 +889,7 @@ Update Time
    PWM generation
 *=======================================================================*/
 #define PWM_MAX_DUTY_CYLE_IPM   900// 900// 900                        // 938      // unit: 0.1%,Max duty cyle for compare value
-#define PWM_7SVM_TO_5SVM_DUTY_IPM 700                        // unit: 0.1%, Switch ratio from 7 to 5 svpwm
+#define PWM_7SVM_TO_5SVM_DUTY_IPM 1000                        // unit: 0.1%, Switch ratio from 7 to 5 svpwm
 #define PWM_MIN_SAMPLE_DUTY1_IPM  5 * 10000 / PWM_PERIOD_US  // unit: 0.1%, 5us TWO MIN ZERO VECTOR = two sample current steady time
 #define PWM_MIN_SAMPLE_DUTY2_IPM  10 * 10000 / PWM_PERIOD_US // unit: 0.1%, 10us TWO (one sample current steady time + one sample time)
 #define PWM_MIN_SAMPLE_DUTY3_IPM \