Selaa lähdekoodia

防止转把信号采集异常时飞车问题

Ye Jin 1 vuosi sitten
vanhempi
sitoutus
140802db09

+ 3 - 4
User project/3.BasicFunction/Include/bikethrottle.h

@@ -20,7 +20,7 @@
  *          Definitions & Macros
  *
  ****************************************/
-#define BIKETHROTTLE_VOLTAGE_MAX_RANGE   5000        // MAX voltage of throttle sensor, mV
+#define BIKETHROTTLE_VOLTAGE_MAX_RANGE   4500        // MAX voltage of throttle sensor, mV
 #define BIKETHROTTLE_VOLTAGE_MIN_RANGE   0           // MIN voltage of throttle sensor, mV
 #define BIKETHROTTLE_VOLTAGE_SEN2MCUGAIN 100 * 3 / 5 // gain of sensor output to Mcu ADC   0.01
 #define BIKETHROTTLE_LPF_FRQ             10          // Hz  bandwidth of LPF
@@ -31,11 +31,11 @@
 
 #define BIKETHROTTLE_OUT_DEFAULT    \
     {                               \
-        0, 0, 0, 0, 0, FALSE, FALSE \
+        0, 0, 0, 0, 0, 0, FALSE \
     } // Default value of CADENCE_OUT
 #define BIKETHROTTLE_COF_DEFAULT \
     {                            \
-        0, 0, 0, 0, 0, 0, 0      \
+        0, 0, 0, 0, 0, 0, 0, 0, 0      \
     } // Default value of CADENCE_OUT
 
 /***************************************
@@ -81,7 +81,6 @@ typedef struct
  *           Exported variable
  *
  ****************************************/
-extern UWORD            Bikethrottle_uwDMAReg;
 extern BIKETHROTTLE_OUT bikethrottle_stBikeThrottleOut;
 /***************************************
  *

+ 5 - 4
User project/3.BasicFunction/Source/bikethrottle.c

@@ -33,7 +33,6 @@ BIKETHROTTLE_OUT        bikethrottle_stBikeThrottleOut = BIKETHROTTLE_OUT_DEFAUL
  * extern Parameter
  *
  ******************************/
-UWORD Bikethrottle_uwDMAReg = 0;
 
 /***************************************************************
  Function: bikethrottle_voBikeThrottleCof;
@@ -81,9 +80,10 @@ void bikethrottle_voBikeThrottleInit(void)
     bikethrottle_stBikeThrottleOut.uwThrottleVolReg = 0;
     bikethrottle_stBikeThrottleOut.uwThrottleVolPu = 0;
     bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = 0;
-    bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = FALSE;
+    bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
     bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
     bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt = 0;
+    bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = FALSE;
 }
 
 /***************************************************************
@@ -101,6 +101,7 @@ void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(A
     {
         bikethrottle_stBikeThrottleOut.uwThrottleVolPu = 0;
         bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = 0;
+        bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
         bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt++;
         if (bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt == bikethrottle_stBikeThrottleCof.uwThrottleRecoverCnt)
         {
@@ -116,7 +117,7 @@ void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(A
         mth_voLPFilter((SWORD)bikethrottle_stBikeThrottleOut.uwThrottleVolPu, &scm_stBikeThrottleLpf);
         bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = scm_stBikeThrottleLpf.slY.sw.hi;
 
-        if (bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu < bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu)
+        if (bikethrottle_stBikeThrottleOut.uwThrottleVolPu < bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu)
         {
             bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu;
             bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt++;
@@ -126,7 +127,7 @@ void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(A
                 bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
             }
         }
-        else if (bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu > bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu)
+        else if (bikethrottle_stBikeThrottleOut.uwThrottleVolPu > bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu)
         {
             bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu;
             bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt++;