Przeglądaj źródła

华耀定制,HUAYAO_ENABLE、THOTTLECRUISE_EN、THOTTLE_STARTRUNATSPEED宏定义需要定制

Ye Jin 5 miesięcy temu
rodzic
commit
84bce2d4a7

+ 1 - 1
User project/1.FrameLayer/Source/TimeTask_Event.c

@@ -401,7 +401,7 @@ void Event_100ms(void)
             }
             
             {
-                Event_pvt_uwBikeSpdRefTarget = (UWORD)((((ULONG)25 - (ULONG)4) *(uwThrottlePercent - 200)/690 + 4) * BIKESPEED_KMPERH2FREQPU); // Q20   
+                Event_pvt_uwBikeSpdRefTarget = (UWORD)((((ULONG)ass_stParaCong.uwAssistMaxSpdKmH - (ULONG)4) *(uwThrottlePercent - 200)/690 + 4) * bikespeed_stFreGetCof.uwBikespeedKmh2Pu); // Q20   
             }
             
             /* Bike Speed Ref Ramp */

+ 2 - 1
User project/3.BasicFunction/Include/Customization.h

@@ -21,6 +21,7 @@
  *
  ****************************************/
 #define GIANT_ENABLE                     0   //0-标准程序,1-giant定制
-
+/*华耀定制需求:1、转把》6km/h 启动,2、转把定速巡航功能,稳住8S 时 可定速度,3.转把限速不超过25km/h,4、仪表自动关机10分钟,5、电机转矩配置  75Nm  功率500w*/
+#define HUAYAO_ENABLE                    0   //0-标准程序,1-华耀定制
 
 #endif /* 3_BASICFUNCTION_INCLUDE_CUSTOMIZATION_H_ */

+ 1 - 0
User project/3.BasicFunction/Include/bikespeed.h

@@ -90,6 +90,7 @@ typedef struct
 
     UWORD uwWheelPerimeter;   // the back wheel Diameter 0.1 cm
     UWORD uwMinTriptoUpdate; // the minimum trip to update m
+    UWORD uwBikespeedKmh2Pu;
 } BIKESPEED_COF;
 
 /**

+ 28 - 2
User project/3.BasicFunction/Include/bikethrottle.h

@@ -22,13 +22,17 @@
  ****************************************/
 #define BIKETHROTTLE_VOLTAGE_MAX_RANGE   4500        // MAX voltage of throttle sensor, mV
 #define BIKETHROTTLE_VOLTAGE_MIN_RANGE   0    //100  // MIN voltage of throttle sensor, mV
-#define BIKETHROTTLE_VOLTAGE_SEN2MCUGAIN 100 * 3 / 5 // gain of sensor output to Mcu ADC   0.01
+#define BIKETHROTTLE_VOLTAGE_FAULT_RANGE 1200           // 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
 #define BIKETHROTTLE_LPF_DISCRETEHZ      100         // Hz   T=1/f,T is used in discreting LPF s function
 #define BIKETHROTTLE_ERROR_TIME          2000        // ms
 #define BIKETHROTTLE_RECOVER_TIME        2000        // ms
 #define BIKETHROTTLE_ERROE_TIMEUNIT      5           // ms
 
+#define BIKETHROTTLE_STARTRUNSPEED       60//6km/h
+#define BIKETHROTTLE_RESETTRUNSPEEDPU    190//190-1km/h
+
 #define BIKETHROTTLE_OUT_DEFAULT    \
     {                               \
         0, 0, 0, 0, 0, 0, FALSE \
@@ -67,6 +71,7 @@ typedef struct
 {
     UWORD uwMaxThrottleVolOutputPu; // mV,the max voltage of Throttle sensor output
     UWORD uwMinThrottleVolOutputPu; // mV,the min voltage of Throttle sensor output
+    UWORD uwThrottleVoFaultlPu;
     UWORD uwThrottleVolLPFFrq;      // Hz,LPF bandwidth
     UWORD uwThrottleVolLPFDisFrq;   // Hz,used in discreting LPF s function
     UWORD uwThrottleVolSen2McuGain; // gain of sensor output to Mcu ADC
@@ -76,6 +81,26 @@ typedef struct
     UWORD uwThrottleRecoverCnt;
 } BIKETHROTTLE_COF;
 
+/**
+ * @brief Throttlecruise
+ *
+ */
+
+#define BIKECRUISE_OUT_DEFAULT    \
+    {                               \
+        0, 0, 0, 0 \
+    } // Default value
+
+#define   CRUISESETINGTIME      8000
+typedef struct
+{
+    UWORD ThrottlekeepVault ;
+    UWORD CruiseMode;
+    ULONG KeepInTime;
+    UWORD CruisePercent ;
+    UWORD ThrottleResetCruiseFlag  ;
+} BIKECRUISE_COF;
+
 /****************************************
  *
  *           Exported variable
@@ -90,7 +115,8 @@ extern BIKETHROTTLE_OUT bikethrottle_stBikeThrottleOut;
 void bikethrottle_voBikeThrottleInit(void);
 void bikethrottle_voBikeThrottleCof(void);
 void bikethrottle_voBikeThrottleADC(void);
-
+void bikethrottle_voThrottlecruise(void);
+void bikethrottle_voStartAllow(void);
 /************************************************************************/
 
 #endif

+ 9 - 4
User project/3.BasicFunction/Source/bikespeed.c

@@ -64,6 +64,7 @@ void bikespeed_voBikeSpeedCof(void)
     bikespeed_stFreGetCof.uwBikespeedPwrErrorVoltagePuUp = ((ULONG)BIKESPEED_POWER_ERROR_VOLTAGE_UP << 14) / VBASE;
     bikespeed_stFreGetCof.uwWheelPerimeter = 600;
     bikespeed_stFreGetCof.uwMinTriptoUpdate = 100; // 100m
+    bikespeed_stFreGetCof.uwBikespeedKmh2Pu = (1000 << 20)/(FBASE * (ass_stParaCong.uwWheelPerimeter + ass_stParaCong.swDeltPerimeter) * 36);
     
     if(0 == ass_stParaCong.uwAssistMaxSpdKmH)
     {
@@ -73,8 +74,12 @@ void bikespeed_voBikeSpeedCof(void)
     {
         bikespeed_stSpdLimCoef.blThrottleExist = TRUE;
     }
-    bikespeed_stSpdLimCoef.uwBikeSpdThresHold1 = (ass_stParaCong.uwAssistMaxSpdKmH-2)*BIKESPEED_KMPERH2FREQPU;
-    bikespeed_stSpdLimCoef.uwBikeSpdThresHold2 = ass_stParaCong.uwAssistMaxSpdKmH*BIKESPEED_KMPERH2FREQPU;
+    bikespeed_stSpdLimCoef.uwBikeSpdThresHold1 = (ass_stParaCong.uwAssistMaxSpdKmH-2)*bikespeed_stFreGetCof.uwBikespeedKmh2Pu;
+#if(HUAYAO_ENABLE == 1)
+    bikespeed_stSpdLimCoef.uwBikeSpdThresHold2 = ass_stParaCong.uwAssistMaxSpdKmH*bikespeed_stFreGetCof.uwBikespeedKmh2Pu + bikespeed_stFreGetCof.uwBikespeedKmh2Pu/5;
+#else
+    bikespeed_stSpdLimCoef.uwBikeSpdThresHold2 = ass_stParaCong.uwAssistMaxSpdKmH*bikespeed_stFreGetCof.uwBikespeedKmh2Pu;
+#endif
     bikespeed_stSpdLimCoef.ulBikeSpdDeltInv = ((SQWORD)1 << 20) / (bikespeed_stSpdLimCoef.uwBikeSpdThresHold2 - bikespeed_stSpdLimCoef.uwBikeSpdThresHold1); // Q20;
     bikespeed_stSpdLimCoef.uwBikeSpdRefIncrease = (ass_stParaCong.uwThrottleSmooth>>8)*10;
     bikespeed_stSpdLimCoef.uwBikeSpdRefDecrease = (ass_stParaCong.uwThrottleSmooth&0xFF)*10;
@@ -115,7 +120,7 @@ static void bikespeed_voBikeSpeedIdle(UWORD source)
 //            bikespeed_stFreGetOut.uwCaputureNumCnt = 0;
             bikespeed_stFreGetOut.uwCaputureNumCnt = 1;
             bikespeed_stFreGetOut.bikespeed_fsm = BIKESPEED_WORK;
-            bikespeed_pvt_FreqPu = 1 * BIKESPEED_KMPERH2FREQPU ;
+            bikespeed_pvt_FreqPu = 1 * bikespeed_stFreGetCof.uwBikespeedKmh2Pu ;
             bikespeed_stFreGetOut.uwFrequencyPu =  (UWORD)bikespeed_pvt_FreqPu;  
             bikespeed_stFreGetOut.uwCaputure1Cnt = (UWORD)iCap_GetCaptureValue(0, CAP_CH(3));
         }
@@ -548,7 +553,7 @@ void bikespeed_voPI(const BIKESPDPI_IN *in, BIKESPDPI_OUT *out)
 //    mth_voLPFilter(uwBikeSpeedGain, &bike_pvt_stCurLpf); 
  
 //    out->swIqRefPu = (SWORD)(out->slIqRefPu >> 16); // Q30-Q16=Q14
-    out->swIqRefPu = ((SLONG)cp_stMotorPara.swIpeakMaxA * in->slSpdRefPu /4750 << 14) / IBASE ;
+    out->swIqRefPu = ((SLONG)(cp_stMotorPara.swIpeakMaxA * in->slSpdRefPu / ass_stParaCong.uwAssistMaxSpdKmH /bikespeed_stFreGetCof.uwBikespeedKmh2Pu) << 14) / IBASE ;
     out->slErrorZ1 = slSpdErrPu;
 }
 /*************************************************************************

+ 105 - 1
User project/3.BasicFunction/Source/bikethrottle.c

@@ -14,12 +14,14 @@
  Compiler Directives:
 *************************************************************************/
 #include "syspar.h"
+#include "user.h"
 #include "typedefine.h"
 #include "mathtool.h"
 #include "bikethrottle.h"
 #include "api.h"
 #include "board_config.h"
 #include "bikespeed.h"
+#include "bikebrake.h"
 /******************************
  *
  * static Parameter
@@ -28,7 +30,7 @@
 static BIKETHROTTLE_COF bikethrottle_stBikeThrottleCof = BIKETHROTTLE_COF_DEFAULT;
 static LPF_OUT          scm_stBikeThrottleLpf;
 BIKETHROTTLE_OUT        bikethrottle_stBikeThrottleOut = BIKETHROTTLE_OUT_DEFAULT;
-
+BIKECRUISE_COF          bikeCruise = BIKECRUISE_OUT_DEFAULT;
 /******************************
  *
  * extern Parameter
@@ -50,6 +52,7 @@ void bikethrottle_voBikeThrottleCof(void)
 
     bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu = ((ULONG)BIKETHROTTLE_VOLTAGE_MAX_RANGE << 14) / (VBASE * 100); // Q15
     bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu = ((ULONG)BIKETHROTTLE_VOLTAGE_MIN_RANGE << 14) / (VBASE * 100); // Q15
+    bikethrottle_stBikeThrottleCof.uwThrottleVoFaultlPu     = ((ULONG)BIKETHROTTLE_VOLTAGE_FAULT_RANGE << 14) / (VBASE * 100);
     bikethrottle_stBikeThrottleCof.uwThrottleVolSen2McuGain = BIKETHROTTLE_VOLTAGE_SEN2MCUGAIN;
     bikethrottle_stBikeThrottleCof.uwThrottleVolLPFFrq = BIKETHROTTLE_LPF_FRQ;
     bikethrottle_stBikeThrottleCof.uwThrottleVolLPFDisFrq = BIKETHROTTLE_LPF_DISCRETEHZ;
@@ -148,6 +151,8 @@ void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(A
                     (bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu - bikethrottle_stBikeThrottleCof.uwThrottleOffsetPu) * 1000 /
                     (bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu - bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu);
             }
+            bikethrottle_voThrottlecruise();
+            bikethrottle_voStartAllow();
         }
     }
     else
@@ -155,7 +160,106 @@ void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(A
         bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
     }
 }
+/***************************************************************
+ Function: Throttlecruise;
+ Description:  
+ Call by: functions in 100ms TimeTask;
+ Input Variables: N/A
+ Output/Return Variables: N/A
+ Subroutine Call: N/A;
+ Reference: N/A
+****************************************************************/
+void bikethrottle_voThrottlecruise(void)
+{
+#if(THOTTLECRUISE_EN == 0xAA)
+   if((bikethrottle_stBikeThrottleOut.uwThrottleVolPu < (bikeCruise.ThrottlekeepVault+180)) && (bikethrottle_stBikeThrottleOut.uwThrottleVolPu > (bikeCruise.ThrottlekeepVault-180)))
+   {
+       if((BikeBrake_blGetstate() == FALSE)
+          &&(alm_blAlmOccrFlg == FALSE)
+          &&(cp_stBikeRunInfoPara.uwBikeGear > 0)
+          &&(cp_stBikeRunInfoPara.uwBikeGear <= 5)
+          &&(bikethrottle_stBikeThrottleOut.uwThrottlePercent > 200)
+          &&(bikeCruise.CruiseMode == 0))
+       {
+           if((cp_ulSystickCnt - bikeCruise.KeepInTime) >= CRUISESETINGTIME) //8秒指拨不动进入巡航
+           {
+               bikeCruise.CruiseMode = 1;
+               bikeCruise.CruisePercent = bikethrottle_stBikeThrottleOut.uwThrottlePercent;
+               bikeCruise.ThrottleResetCruiseFlag = 1;
+           }
+       }
+       if(bikethrottle_stBikeThrottleOut.uwThrottlePercent < 200)
+       {
+          bikeCruise.KeepInTime = cp_ulSystickCnt;
+       }
+   }
+   else
+   {
+       bikeCruise.ThrottlekeepVault = bikethrottle_stBikeThrottleOut.uwThrottleVolPu;
+       bikeCruise.KeepInTime = cp_ulSystickCnt;
+      // bikeCruise.ThrottleResetCruiseFlag = 0;
+   }
 
+   //有故障退出,刹车退出,0档退出
+   if((alm_blAlmOccrFlg == TRUE)
+       ||(BikeBrake_blGetstate() == TRUE)
+       ||(cp_stBikeRunInfoPara.uwBikeGear == 0)
+       ||(bikeCruise.ThrottleResetCruiseFlag == 3))
+   {
+       bikeCruise.CruiseMode = 0;
+       bikeCruise.KeepInTime = cp_ulSystickCnt;
+       bikeCruise.ThrottleResetCruiseFlag = 0;
+   }
+   //指拨重新调速退出
+  if(bikethrottle_stBikeThrottleOut.uwThrottlePercent > 350)
+  {
+      if(bikeCruise.ThrottleResetCruiseFlag == 2)
+      {
+          bikeCruise.ThrottleResetCruiseFlag = 3;
+      }
+  }
+  else
+  {
+      if((bikeCruise.CruiseMode) && (bikeCruise.ThrottleResetCruiseFlag == 1) && (bikethrottle_stBikeThrottleOut.uwThrottlePercent < 200))
+      {
+          bikeCruise.ThrottleResetCruiseFlag = 2;
+      }
+  }
+  
+  if(bikeCruise.CruiseMode != 0)
+  {
+     bikethrottle_stBikeThrottleOut.uwThrottlePercent = bikeCruise.CruisePercent;
+  }
+#endif
+}
+/***************************************************************
+ Function: Throttlecruise;
+ Description:  
+ Call by: functions in 100ms TimeTask;
+ Input Variables: N/A
+ Output/Return Variables: N/A
+ Subroutine Call: N/A;
+ Reference: N/A
+****************************************************************/
+void bikethrottle_voStartAllow(void)
+{
+#if(THOTTLE_STARTRUNATSPEED == 0xAA)
+    static UBYTE SetZeroRunMode = 0;
+    
+    if((bikespeed_stFreGetOut.uwLPFFrequencyPu < bikespeed_stFreGetCof.uwBikespeedKmh2Pu) && (bikethrottle_stBikeThrottleOut.uwThrottlePercent <= 200))
+    {
+        SetZeroRunMode = 0;
+    }
+    else if(cp_stBikeRunInfoPara.BikeSpeedKmH >= BIKETHROTTLE_STARTRUNSPEED)
+    {
+        SetZeroRunMode = 1;
+    }
+    if(SetZeroRunMode == 0)
+    {
+        bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
+    }
+#endif
+}
 /*************************************************************************
  End of this File (EOF)!
  Do not put anything after this part!

+ 12 - 0
User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Include/user.h

@@ -72,6 +72,18 @@ Update Time
 #define ADC_IPHASE_CUR_MAX_AP 16500
 #define ADC_IPHASE_CUR_OVER_K 1024
 #endif
+  
+/*======================================================================*
+巡航Bike Cruise
+ //指拨巡航功能   0xAA-指拨维持不动维持8秒,进入巡航功能,仪表出线巡航图标,刹车,0档,有助力踏频,重新调速,有故障会退出,else-无巡航功能
+*=======================================================================*/
+#define  THOTTLECRUISE_EN             0xAA
+/*======================================================================*
+  NOT ZERO Ssart
+   //0xAA-速度非零起动,速度大于3KM/H,转把才有效 ;else-车速为零可以转把启动
+*=======================================================================*/
+#define  THOTTLE_STARTRUNATSPEED      0xAA      //0xAA-enable,else-disable
+ 
 /*======================================================================*
     Motor Parameters
 *=======================================================================*/

+ 4 - 1
User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Source/CodePara.c

@@ -200,8 +200,11 @@ void CodeParaInit(void)
 
     cp_stControlPara.swCvbConstantVolBrakeV = CVB_CONSTANT_VOL_BRAKE_V;
     cp_stControlPara.swCvbConstantSpdLowRpm = CVB_CONSTANT_SPD_LOW_RPM;
-
+#if(HUAYAO_ENABLE == 1)
+    cp_stControlPara.swPwrLimitValWt = 5000;//500W
+#else
     cp_stControlPara.swPwrLimitValWt = PWRLIM_VAL;
+#endif
     cp_stControlPara.swPwrLimitErrWt = PWRLIM_ERR;
     cp_stControlPara.swPwrLimitLPFFre = PWRLIM_LPF_FRQ;
     cp_stControlPara.swPwrLimitKpPu = PWR_IQ_LIMIT_KP_PU;