소스 검색

车速传感器信号个数为0时,根据电机转速或踏频估算车速。

dd 2 달 전
부모
커밋
ad6bbedd83
1개의 변경된 파일23개의 추가작업 그리고 2개의 파일을 삭제
  1. 23 2
      3.BasicFunction/Source/canAppl.c

+ 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)