Explorar el Código

Merge branch 'XiaoYaPan_NoSysConfig' into OBC_SetSpeed_New

dd hace 2 meses
padre
commit
5c417c3c79

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

@@ -30,7 +30,7 @@
 #define TORQUE_LF_MINFRE                25   // Min frequency of human foot in Low frequency method, 0.01Hz
 #define TORQUE_HF_MAXTIME_MS            150  // 3000             //Min time of valid pulses, ms
 #define TORQUE_ERROR_RESETTIME_MS       5000 // TIMER PERIOD,ms
-#define TORQUE_TIM_TIMERUNIT_US         ((SLONG)500000/FTBS_HZ)   //25   // TIMER PERIOD,ms    us
+#define TORQUE_TIM_TIMERUNIT_US         ((SLONG)100000/FTBS_HZ)   //25   // TIMER PERIOD,ms    us
 #define TORQUE_LPF_GAIN                 80   //%
 #define TORQUE_MAX_FREQUENCY            5    // Hz, human foot
 //#elif (ASSIST_MODE == CADENCE_ASSIST)
@@ -42,7 +42,7 @@
 #define CADENCE_LF_MINFRE                25   // Min frequency of human foot in Low frequency method, 0.01Hz
 #define CADENCE_HF_MAXTIME_MS            ((800*12)/CADENCE_NUMBERS_PULSES)  // 3000             //Min time of valid pulses, ms
 #define CADENCE_ERROR_RESETTIME_MS       5000 // TIMER PERIOD,ms
-#define CADENCE_TIM_TIMERUNIT_US         ((SLONG)500000/FTBS_HZ)   //25   // TIMER PERIOD,ms    us
+#define CADENCE_TIM_TIMERUNIT_US         ((SLONG)100000/FTBS_HZ)   //25   // TIMER PERIOD,ms    us
 #define CADENCE_LPF_GAIN                 80   //%
 #define CADENCE_MAX_FREQUENCY            5    // Hz, human foot
 //#endif

+ 1 - 1
3.BasicFunction/Include/bikespeed.h

@@ -27,7 +27,7 @@ typedef _Bool  BOOL;
 #define BIKESPEED_NUMBERS_VALIDPULSE2START 1  // numbers of valid pulses that needed to start
 #define BIKESPEED_HF_MINTIME_MS               5000  // Min time of valid pulses, ms
 #define BIKESPEED_ERROR_RESETTIME_MS          5000  // TIMER PERIOD,ms
-#define BIKESPEED_TIM_TIMERUNIT_US            ((SLONG)500000/FTBS_HZ)    // TIMER PERIOD,us
+#define BIKESPEED_TIM_TIMERUNIT_US            ((SLONG)1000000/FTBS_HZ)    // TIMER PERIOD,us
 #define BIKESPEED_LPF_GAIN                 80    //
 #define BIKESPEED_MAX_FREQUENCY            20    // Hz, ebike wheel
 

+ 23 - 2
3.BasicFunction/Source/canAppl.c

@@ -743,8 +743,29 @@ void Can_voMC_Run_1ms(void)
 
 void Can_voMC_Run_5ms(void)
 {
-    cp_stBikeRunInfoPara.BikeSpeedKmH =
-        (((SQWORD)bikespeed_stFreGetOut.uwFrequencyPu * FBASE * (ass_ParaCong.uwWheelPerimeter + ass_ParaCong.swDeltPerimeter) * 36 >> 20) * 1048 * 10) >>20; //    1048 = Q20(1/1000)    0.1 km/h
+    if(bikespeed_stFreGetCof.uwNumbersPulses == 0) //根据踏频估算和前后齿比
+    {
+        UWORD uwRpmByCadence = 0, uwRpmByMotor = 0, uwRpmWheel = 0;
+        uwRpmByCadence = (SLONG)((cadence_stFreGetOut.uwLPFFrequencyPu * cof_uwFbHz * 60 ) >> 20) * 24 / 10;
+        if(cp_stFlg.ThetaGetModelSelect == ANG_SWITCHHALL)
+        {
+            uwRpmByMotor = ((SLONG)abs(switchhall_stOut.swLowSpdLpfPu) * cof_uwVbRpm >> 15) * 1000 / ass_ParaCong.uwMechRationMotor; //减速比4.55
+        }
+        else
+        {
+            uwRpmByMotor = ((SLONG)abs(scm_stSpdFbkLpf.slY.sw.hi)* cof_uwVbRpm >> 15) * 1000 / ass_ParaCong.uwMechRationMotor; //减速比4.55
+        }
+        uwRpmWheel = (uwRpmByMotor > uwRpmByCadence) ? (uwRpmByMotor * ass_ParaCong.uwNmFrontChainring / ass_ParaCong.uwNmFrontChainring) :
+                     (uwRpmByCadence * ass_ParaCong.uwNmFrontChainring / ass_ParaCong.uwNmFrontChainring);
+        cp_stBikeRunInfoPara.BikeSpeedKmH =
+            ((ULONG)(uwRpmWheel * 6 * (ass_ParaCong.uwWheelPerimeter + ass_ParaCong.swDeltPerimeter)) * 1048) >> 20; //    1048 = Q20(1/1000)    0.1 km/h
+    }
+    else
+    {
+        cp_stBikeRunInfoPara.BikeSpeedKmH =
+            (((SQWORD)bikespeed_stFreGetOut.uwFrequencyPu * FBASE * (ass_ParaCong.uwWheelPerimeter + ass_ParaCong.swDeltPerimeter) * 36 >> 20) * 1048 * 10) >> 20; //    1048 = Q20(1/1000)    0.1 km/h
+    }
+
 }
 
 void Can_voMC_Run_200ms(void)

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

@@ -216,12 +216,12 @@ Update Time
 *=======================================================================*/
 #define FPWM_HZ        16000
 #define FTBC_HZ        8000
-#define FTBS_HZ        4000
+#define FTBS_HZ        8000
 #define FSYSTICK_HZ    1000
 #define PWM_PERIOD_CNT 4500
 #define PWM_PERIOD_US  625
 #define TBC_PERIOD_US  1250
-#define TBS_PERIOD_US  5000
+#define TBS_PERIOD_US  1250
 #define EVENT_1MS_HZ   1000
 
 /*======================================================================*