Эх сурвалжийг харах

转把信号采集去除滤波,转把调速增加平滑,转把加减速平滑值可通过上位机配置,配置转把限速为0禁止转把相关功能,调整转把限速默认值为25,调整转把故障码;使用峰值电流限幅值替换助力电流限幅值,并更改峰值电流限幅值为5000;增加生产信息、型号默认值写入;

Ye Jin 1 жил өмнө
parent
commit
a505cc14b2

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

@@ -205,6 +205,7 @@ void  Event_1ms(void) /* parasoft-suppress METRICS-28 "本项目圈复杂度无
             {
                 Event_pvt_swIqRef -= 40;
             }
+            else
             {
                 Event_pvt_swIqRef = Event_pvt_swIqRefTarget;
             }
@@ -394,23 +395,23 @@ void Event_100ms(void)
             }
             
             /* Bike Speed Ref Ramp */
-//            if(Event_pvt_uwBikeSpdRef < Event_pvt_uwBikeSpdRefTarget - 80)
-//            {   
-//                if(Event_pvt_uwBikeSpdRefTarget >= Event_pvt_uwBikeSpdRefTargetZ1)
-//                {
-//                    Event_pvt_uwBikeSpdRef += 80;
-//                }             
-//            }
-//            else if(Event_pvt_uwBikeSpdRef > Event_pvt_uwBikeSpdRefTarget + 160)
-//            {
-//                Event_pvt_uwBikeSpdRef -= 160;
-//            }               
-//            else
-//            {
-//                Event_pvt_uwBikeSpdRef = Event_pvt_uwBikeSpdRefTarget;
-//            }           
-//            Event_pvt_uwBikeSpdRefTargetZ1 = Event_pvt_uwBikeSpdRefTarget;
-            Event_pvt_uwBikeSpdRef = Event_pvt_uwBikeSpdRefTarget;
+            if(Event_pvt_uwBikeSpdRef < Event_pvt_uwBikeSpdRefTarget - bikespeed_stSpdLimCoef.uwBikeSpdRefIncrease)
+            {   
+                if(Event_pvt_uwBikeSpdRefTarget >= Event_pvt_uwBikeSpdRefTargetZ1)
+                {
+                    Event_pvt_uwBikeSpdRef += bikespeed_stSpdLimCoef.uwBikeSpdRefIncrease;
+                }             
+            }
+            else if(Event_pvt_uwBikeSpdRef > Event_pvt_uwBikeSpdRefTarget + bikespeed_stSpdLimCoef.uwBikeSpdRefDecrease)
+            {
+                Event_pvt_uwBikeSpdRef -= bikespeed_stSpdLimCoef.uwBikeSpdRefDecrease;
+            }               
+            else
+            {
+                Event_pvt_uwBikeSpdRef = Event_pvt_uwBikeSpdRefTarget;
+            }           
+            Event_pvt_uwBikeSpdRefTargetZ1 = Event_pvt_uwBikeSpdRefTarget;
+//            Event_pvt_uwBikeSpdRef = Event_pvt_uwBikeSpdRefTarget;
             
             /* Bike Speed Closed Loop */
             swIqLowerPu = (SWORD)((flx_stCtrlOut.swIqLimPu < ABS(pwr_stPwrLimOut2.swIqLimPu)) ? flx_stCtrlOut.swIqLimPu : ABS(pwr_stPwrLimOut2.swIqLimPu));  
@@ -467,7 +468,7 @@ void  Event_200ms(void)
             alm_stBikeIn.uwMotorNTCReg = adc_stUpOut.PCBTempReg;
             alm_stBikeIn.uwPCBNTCReg = adc_stUpOut.PCBTempReg;
             alm_stBikeIn.uwThrottleReg = adc_stUpOut.uwThrottleReg;
-            alm_stBikeIn.blThrottleExistFlg = FALSE;
+            alm_stBikeIn.blThrottleExistFlg = bikespeed_stSpdLimCoef.blThrottleExist;
             alm_stBikeIn.blMotorNTCExistFlg = FALSE;
             alm_voDetec200MS(&alm_stBikeIn, &alm_stDetect200MSCoef);   
         }

+ 3 - 0
User project/1.FrameLayer/Source/main.c

@@ -191,6 +191,7 @@ void mn_voParaSet(void)
                 ass_stParaCong.swDeltPerimeter = (SWORD)I2C_uwBikeParaRead[9];
                 ass_stParaCong.uwStartMode = I2C_uwBikeParaRead[10];
                 ass_stParaCong.uwAutoPowerOffTime = I2C_uwBikeParaRead[11];
+                ass_stParaCong.uwThrottleSmooth = I2C_uwBikeParaRead[12];
             }
             else
             {}
@@ -316,6 +317,7 @@ void mn_voParaUpdate(void)
         ass_stParaCong.swDeltPerimeter = MC_UpcInfo.stBikeInfo.swWheelSizeAdjust;
         ass_stParaCong.uwStartMode = MC_UpcInfo.stBikeInfo.uwStartMode;
         ass_stParaCong.uwAutoPowerOffTime = MC_UpcInfo.stBikeInfo.uwAutoPowerOffTime;
+        ass_stParaCong.uwThrottleSmooth = MC_UpcInfo.stBikeInfo.uwThrottleSmooth;
 
         cp_stFlg.ParaAssistUpdateFinishFlg = TRUE;
         cp_stFlg.ParaBikeInfoUpdateFlg = FALSE;
@@ -453,6 +455,7 @@ void mn_voEEUperParaUpdate(void)
         Syspara2.stBikePara.swDeltPerimeter.swReal = ass_stParaCong.swDeltPerimeter;
         Syspara2.stBikePara.uwStartMode.uwReal = ass_stParaCong.uwStartMode;
         Syspara2.stBikePara.uwAutoPowerOffTime.uwReal = ass_stParaCong.uwAutoPowerOffTime;
+        Syspara2.stBikePara.uwThrottleSmooth.uwReal = ass_stParaCong.uwThrottleSmooth;
     }
     if (MC_UpcInfo.stMContorlInfo.uwSaveFlg == TRUE)
     {

+ 6 - 4
User project/3.BasicFunction/Include/AssistCurve.h

@@ -33,7 +33,7 @@ extern "C" {
 #define BIKE_MECH_RATION              35
 #define BIKE_SPEED_IQLIMIT_THRESHOLD1 25                                // Km/h
 #define BIKE_SPEED_IQLIMIT_THRESHOLD2 (BIKE_SPEED_IQLIMIT_THRESHOLD1 + 2) // Km/h
-#define BIKE_SPEED_THROTTLE_MAX       34                                 // Km/h
+#define BIKE_SPEED_THROTTLE_MAX       25                                 // Km/h
 #define BIKE_SPEED_WALK_MAX            6                                 // Km/h
 #define BIKE_FRONTTEETH_NMB          38                                 // number
 #define BIKE_BACKTEETH_NMB            11                                 // number
@@ -46,8 +46,10 @@ extern "C" {
 #define BIKE_POWERSTART_DELAY_TIME    0     //0.2s
 #define BIKE_POWEROFF_DELAY_TIME      0     //0.2s
 #define BIKE_AUTO_POWER_OFF_TIME      15     //min
-#define BIKE_POWER_PARA               ((BIKE_POWERSTART_DELAY_TIME<<12)|(BIKE_POWEROFF_DELAY_TIME<<8)|BIKE_AUTO_POWER_OFF_TIME)     
-
+#define BIKE_POWER_PARA               ((BIKE_POWERSTART_DELAY_TIME<<12)|(BIKE_POWEROFF_DELAY_TIME<<8)|BIKE_AUTO_POWER_OFF_TIME)
+#define BIKE_THROTTLE_SMOOTH_INCREASE 15     //*10
+#define BIKE_THROTTLE_SMOOTH_DECREASE 30     //*10
+#define BIKE_THROTTLE_SMOOTH           ((BIKE_THROTTLE_SMOOTH_INCREASE<<8)|(BIKE_THROTTLE_SMOOTH_DECREASE))
 #define BIKE_ASSIST_MODE1              0x0155
 #define BIKE_ASSIST_MODE2              0x02AA
 #define TORQUE_START_THRESHOLD   50 // 0.1Nm
@@ -55,7 +57,6 @@ extern "C" {
 #define TORQUE_SWITCH2_THRESHOLD 120 // 0.1Nm
 #define TORQUE_SWITCH1_THRESHOLD 100 // 0.1Nm
 
-#define BIKE_ASS_MOTOR_CURRENT_MAX      5000 //5500 // 0.01A
 #define BIKE_ASS_MOTOR_TORQUE_MAX       30   // 0.1Nm
 #define BIKE_SPD_MOTOR_CURRENT_MAX      5  /* 电流系数初始值 */
 #define BIKE_SPD_MOTOR_CONSTANT_COMMAND 4096  /* 速度波动补偿系数初始值 */
@@ -190,6 +191,7 @@ typedef struct
     SWORD swDeltPerimeter;
     UWORD uwStartMode;
     UWORD uwAutoPowerOffTime;
+    UWORD uwThrottleSmooth;
 
     UWORD uwCadPulsePerCirc;
     UWORD uwBikeAssTorMaxPu;

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

@@ -148,6 +148,9 @@ typedef struct
     UWORD uwBikeSpdThresHold1; // Q15 the start bike speed to limit iqref
     UWORD uwBikeSpdThresHold2; // Q15 the end bike speed to limit iqref
     ULONG ulBikeSpdDeltInv;    // Q14
+    UWORD uwBikeSpdRefIncrease;
+    UWORD uwBikeSpdRefDecrease;
+    BOOL  blThrottleExist;
 } BIKESPDLIMIT_COEF;
 /****************************************
  *
@@ -159,6 +162,7 @@ extern BIKESPDPI_OUT bikespeed_stPIOut;
 extern BIKESPDPI_IN  bikespeed_stPIIn;
 extern BIKESPEED_OUT bikespeed_stFreGetOut;
 extern LPF_OUT bike_pvt_stCurLpf;
+extern BIKESPDLIMIT_COEF bikespeed_stSpdLimCoef;
 /***************************************
  *
  *          Function  Definations

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

@@ -21,10 +21,10 @@
  *
  ****************************************/
 #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_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_LPF_FRQ             10          // Hz  bandwidth of LPF
-#define BIKETHROTTLE_LPF_DISCRETEHZ      200         // Hz   T=1/f,T is used in discreting LPF s function
+#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

+ 2 - 2
User project/3.BasicFunction/Include/canAppl.h

@@ -122,7 +122,7 @@ typedef union MC_ERRORCODE
         ULONG Fault_TE_Circuit : 1;      ///>TE 电路故障
         ULONG Fault_MC_Check : 1;        ///>MC校验失败
         ULONG Fault_SpiPosSensor : 1;    ///>SPI位置故障
-        ULONG Fault_Throttle : 1;        ///>转把故障
+        ULONG RS0 : 1;        ///>转把故障
         ULONG RS1 : 1;
         ULONG RS2 : 1;
         ULONG RS3 : 1;
@@ -367,7 +367,7 @@ typedef struct
     SWORD swWheelSizeAdjust;     //周长微调  ±10cm
     UWORD uwStartMode;           //启动模式 1-柔和,2-正常,3-强劲
     UWORD uwAutoPowerOffTime;    //自动关机时间 1min,0-不自动关机
-    UWORD reserve1;
+    UWORD uwThrottleSmooth;      //转把加减速平滑值
 } UPC_BikeInfo_Struct_t;
 
 typedef struct

+ 6 - 2
User project/3.BasicFunction/Include/i2c_master.h

@@ -223,11 +223,15 @@
     {                                         \
         ((UWORD)BIKE_POWER_PARA), 0, 0, 0, 0 \
     }
+#define I2CuwThrottleSmooth                    \
+    {                                         \
+        ((UWORD)BIKE_THROTTLE_SMOOTH), 0, 0, 0, 0 \
+    }
 
 #define I2CBikePara                                                                                                                           \
     {                                                                                                                                         \
         I2CuwWheelPerimeter, I2CuwMechRationMotor, I2CuwAssistMaxSpdKmH, I2CuwThrottleMaxSpdKmH, I2CuwNmFrontChainring, I2CuwNmBackChainring,  \
-        I2CuwAssistSelect1, I2CuwAssistSelect2, I2CuwLightVoltage, I2CuwDeltDiameter, I2CuwStartMode, I2CuwAutoPowerOffTime, I2CReserve        \
+        I2CuwAssistSelect1, I2CuwAssistSelect2, I2CuwLightVoltage, I2CuwDeltDiameter, I2CuwStartMode, I2CuwAutoPowerOffTime, I2CuwThrottleSmooth        \
     }
 
 /* MControl Para */
@@ -813,7 +817,7 @@ typedef struct
     SWORD_VALUE swDeltPerimeter;
     UWORD_VALUE uwStartMode;
     UWORD_VALUE uwAutoPowerOffTime;
-    UWORD_VALUE reserve1;
+    UWORD_VALUE uwThrottleSmooth;
 } BIKE_PARAMETER;
 
 typedef struct

+ 2 - 1
User project/3.BasicFunction/Source/AssistCurve.c

@@ -208,6 +208,7 @@ void ass_voAssitEEInit(void)
     ass_stParaCong.swDeltPerimeter = BIKE_WHEEL_SIZE_ADJUST;
     ass_stParaCong.uwStartMode = BIKE_START_MODE;
     ass_stParaCong.uwAutoPowerOffTime = BIKE_POWER_PARA;
+    ass_stParaCong.uwThrottleSmooth = BIKE_THROTTLE_SMOOTH;
 
     ass_stParaSet.uwStartupCoef = 8194;       // Q12 percentage Min 1-4096  1.5-6144
     ass_stParaSet.uwStartupCruiseCoef = 4096; // Q12 percentage Min 1-4096  1-6144
@@ -258,7 +259,7 @@ void ass_voAssitCoef(void)
     /*状态机初始化*/
     Ass_FSM = StopAssit;
     /*电机限制初始化*/
-    ass_stParaCong.uwCofCurMaxPu = ((ULONG)BIKE_ASS_MOTOR_CURRENT_MAX << 14) / IBASE; // Q14
+    ass_stParaCong.uwCofCurMaxPu = ((ULONG)cp_stMotorPara.swIpeakMaxA << 14) / IBASE; // Q14
     ass_stParaCong.uwMotorPoles = cp_stMotorPara.swMotrPolePairs;
     ass_stParaCong.uwCofTorMaxPu = (UWORD)(((ULONG)cp_stMotorPara.swTorMax << 14) / TORQUEBASE);           // Q14
     ass_stParaCong.uwBikeAssTorMaxPu = ass_stParaCong.uwCofTorMaxPu * ass_stParaCong.uwMechRationMotor; // Q14;

+ 11 - 1
User project/3.BasicFunction/Source/bikespeed.c

@@ -65,9 +65,19 @@ void bikespeed_voBikeSpeedCof(void)
     bikespeed_stFreGetCof.uwWheelPerimeter = 600;
     bikespeed_stFreGetCof.uwMinTriptoUpdate = 100; // 100m
     
+    if(0 == ass_stParaCong.uwAssistMaxSpdKmH)
+    {
+        bikespeed_stSpdLimCoef.blThrottleExist = FALSE;
+    }
+    else
+    {
+        bikespeed_stSpdLimCoef.blThrottleExist = TRUE;
+    }
     bikespeed_stSpdLimCoef.uwBikeSpdThresHold1 = (ass_stParaCong.uwAssistMaxSpdKmH-2)*BIKESPEED_KMPERH2FREQPU;
     bikespeed_stSpdLimCoef.uwBikeSpdThresHold2 = ass_stParaCong.uwAssistMaxSpdKmH*BIKESPEED_KMPERH2FREQPU;
     bikespeed_stSpdLimCoef.ulBikeSpdDeltInv = ((SQWORD)1 << 20) / (bikespeed_stSpdLimCoef.uwBikeSpdThresHold2 - bikespeed_stSpdLimCoef.uwBikeSpdThresHold1); // Q20;
+    bikespeed_stSpdLimCoef.uwBikeSpdRefIncrease = (ass_stParaCong.uwThrottleSmooth>>8)*10;
+    bikespeed_stSpdLimCoef.uwBikeSpdRefIncrease = (ass_stParaCong.uwThrottleSmooth&0xFF)*10;
 }
 
 /***************************************************************
@@ -538,7 +548,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)BIKE_ASS_MOTOR_CURRENT_MAX * in->slSpdRefPu /4750 << 14) / IBASE ;
+    out->swIqRefPu = ((SLONG)cp_stMotorPara.swIpeakMaxA * in->slSpdRefPu /4750 << 14) / IBASE ;
     out->slErrorZ1 = slSpdErrPu;
 }
 /*************************************************************************

+ 46 - 37
User project/3.BasicFunction/Source/bikethrottle.c

@@ -19,6 +19,7 @@
 #include "bikethrottle.h"
 #include "api.h"
 #include "board_config.h"
+#include "bikespeed.h"
 /******************************
  *
  * static Parameter
@@ -97,53 +98,61 @@ void bikethrottle_voBikeThrottleInit(void)
 ****************************************************************/
 void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(ADC1);
 {
-    if (bikethrottle_stBikeThrottleOut.blThrottleErrorFlg == TRUE)
+    if(bikespeed_stSpdLimCoef.blThrottleExist)
     {
-        bikethrottle_stBikeThrottleOut.uwThrottleVolPu = 0;
-        bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = 0;
-        bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
-        bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt++;
-        if (bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt == bikethrottle_stBikeThrottleCof.uwThrottleRecoverCnt)
+        if (bikethrottle_stBikeThrottleOut.blThrottleErrorFlg == TRUE)
         {
-            bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = FALSE;
-            bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt = 0;
-        }
-    }
-    else
-    {
-        bikethrottle_stBikeThrottleOut.uwThrottleVolReg = iAdc_GetResultPointer(0)[HW_ADC_THRO_CH]; //hw_uwADC2[6]; 
-        bikethrottle_stBikeThrottleOut.uwThrottleVolPu =
-        		 (UWORD)(((ULONG)bikethrottle_stBikeThrottleOut.uwThrottleVolReg * bikethrottle_stBikeThrottleCof.uwThrottleVolReg2Pu) >> 10); // Q14
-        mth_voLPFilter((SWORD)bikethrottle_stBikeThrottleOut.uwThrottleVolPu, &scm_stBikeThrottleLpf);
-        bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = scm_stBikeThrottleLpf.slY.sw.hi;
-
-        if (bikethrottle_stBikeThrottleOut.uwThrottleVolPu < bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu)
-        {
-            bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu;
-            bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt++;
-            if (bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt == bikethrottle_stBikeThrottleCof.uwThrottleErrorCnt)
+            bikethrottle_stBikeThrottleOut.uwThrottleVolPu = 0;
+            bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = 0;
+            bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
+            bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt++;
+            if (bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt == bikethrottle_stBikeThrottleCof.uwThrottleRecoverCnt)
             {
-                bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = TRUE;
-                bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
+                bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = FALSE;
+                bikethrottle_stBikeThrottleOut.uwThrottleRecoverCnt = 0;
             }
         }
-        else if (bikethrottle_stBikeThrottleOut.uwThrottleVolPu > bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu)
+        else
         {
-            bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu;
-            bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt++;
-            if (bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt == bikethrottle_stBikeThrottleCof.uwThrottleErrorCnt)
+            bikethrottle_stBikeThrottleOut.uwThrottleVolReg = iAdc_GetResultPointer(0)[HW_ADC_THRO_CH]; //hw_uwADC2[6]; 
+            bikethrottle_stBikeThrottleOut.uwThrottleVolPu =
+                             (UWORD)(((ULONG)bikethrottle_stBikeThrottleOut.uwThrottleVolReg * bikethrottle_stBikeThrottleCof.uwThrottleVolReg2Pu) >> 10); // Q14
+            //mth_voLPFilter((SWORD)bikethrottle_stBikeThrottleOut.uwThrottleVolPu, &scm_stBikeThrottleLpf);
+            //bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = scm_stBikeThrottleLpf.slY.sw.hi;
+            bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleOut.uwThrottleVolPu;
+
+            if (bikethrottle_stBikeThrottleOut.uwThrottleVolPu < bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu)
+            {
+                bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu;
+                bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt++;
+                if (bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt == bikethrottle_stBikeThrottleCof.uwThrottleErrorCnt)
+                {
+                    bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = TRUE;
+                    bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
+                }
+            }
+            else if (bikethrottle_stBikeThrottleOut.uwThrottleVolPu > bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu)
+            {
+                bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu = bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu;
+                bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt++;
+                if (bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt == bikethrottle_stBikeThrottleCof.uwThrottleErrorCnt)
+                {
+                    bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = TRUE;
+                    bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
+                }
+            }
+            else
             {
-                bikethrottle_stBikeThrottleOut.blThrottleErrorFlg = TRUE;
                 bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
+                bikethrottle_stBikeThrottleOut.uwThrottlePercent =
+                    (bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu - bikethrottle_stBikeThrottleCof.uwThrottleOffsetPu) * 1000 /
+                    (bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu - bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu);
             }
         }
-        else
-        {
-            bikethrottle_stBikeThrottleOut.uwThrottleErrorCnt = 0;
-            bikethrottle_stBikeThrottleOut.uwThrottlePercent =
-                (bikethrottle_stBikeThrottleOut.uwThrottleVolLPFPu - bikethrottle_stBikeThrottleCof.uwThrottleOffsetPu) * 1000 /
-                (bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu - bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu);
-        }
+    }
+    else
+    {
+        bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
     }
 }
 

+ 4 - 3
User project/3.BasicFunction/Source/canAppl.c

@@ -90,6 +90,7 @@ void Can_voUpdateMC_UpcInfo(void)
     MC_UpcInfo.stBikeInfo.swWheelSizeAdjust = ass_stParaCong.swDeltPerimeter;
     MC_UpcInfo.stBikeInfo.uwStartMode = ass_stParaCong.uwStartMode;
     MC_UpcInfo.stBikeInfo.uwAutoPowerOffTime = ass_stParaCong.uwAutoPowerOffTime;
+    MC_UpcInfo.stBikeInfo.uwThrottleSmooth = ass_stParaCong.uwThrottleSmooth;
 
     MC_UpcInfo.stMContorlInfo.uwSPIPosOffsetOrigin = spi_stResolverOut.swSpiThetaOffsetOrignPu;
     MC_UpcInfo.stMContorlInfo.uwSPIPosOffsetNow = spi_stResolverOut.swSpiThetaOffsetPu;
@@ -423,7 +424,7 @@ void Can_voMC_Run_1ms(void) /* parasoft-suppress METRICS-28 "本项目圈复杂
             
             if (alm_unBikeCode.bit.Throttle == 1)
             {
-                MC_ErrorCode.ERROR_Bit.Fault_Throttle = 1;
+                MC_ErrorCode.ERROR_Bit.Fault_GasSensor = 1;
                 /*error log updata*/
                 ErrorLog_Updata();
                 que_ubPushIn(&que_stFlashErrorLog, &que_stErrorLog, 1);
@@ -536,11 +537,11 @@ void Can_voMC_Run_1ms(void) /* parasoft-suppress METRICS-28 "本项目圈复杂
         }
     }
 
-    if (MC_ErrorCode.ERROR_Bit.Fault_Throttle == 1)
+    if (MC_ErrorCode.ERROR_Bit.Fault_GasSensor == 1)
     {
         if (alm_unBikeCode.bit.Throttle != 1)
         {
-            MC_ErrorCode.ERROR_Bit.Fault_Throttle = 0;
+            MC_ErrorCode.ERROR_Bit.Fault_GasSensor = 0;
         }
     }
     

+ 9 - 0
User project/3.BasicFunction/Source/flash_master.c

@@ -123,6 +123,15 @@ void flash_voParaInit(void)
     SLONG Flash_CadAssGain[5][4] = CADENCE_ASSIST_DEFAULT;
     memcpy(&flash_stPara.slTorqAssGain[0], &Flash_TorqueAssGain[0], sizeof(Flash_TorqueAssGain));
     memcpy(&flash_stPara.slCadAssGain[0], &Flash_CadAssGain[0], sizeof(Flash_CadAssGain));
+#if ((MOTOR_ID_SEL == MOTOR_WELLING_MTB_36V) || (MOTOR_ID_SEL == MOTOR_WELLING_MTB_48V))
+    strncpy(flash_stPara.ubMotorVersion, (char *)"MIGIC_T1", 8);
+    strncpy(flash_stPara.ubProdInfo.MacBrand, (char *)"MM_MT1", 6);
+#elif ((MOTOR_ID_SEL == MOTOR_WELLING_CITY_36V) || (MOTOR_ID_SEL == MOTOR_WELLING_CITY_48V))
+    strncpy(MC_VerInfo.HW_Version, (char *)"MIGIC_C1", 8);
+    strncpy(flash_stPara.ubProdInfo.MacBrand, (char *)"MM_MC1", 6);
+#endif
+    strncpy(flash_stPara.ubProdInfo.Manufacturer, (char *)"TTIUM", 5);
+    strncpy(flash_stPara.ubProdInfo.MacAddr, (char *)"WUHAN", 5);
     flash_voWrite();
 }
 

+ 1 - 0
User project/3.BasicFunction/Source/i2c_master.c

@@ -610,6 +610,7 @@ void i2c_voGetValueFrmBuffer(const I2C_RXCRC_OUT *out)
     Syspara2.stBikePara.swDeltPerimeter.swReal = (SWORD)I2C_uwBikeParaRead[9];
     Syspara2.stBikePara.uwStartMode.uwReal = I2C_uwBikeParaRead[10];
     Syspara2.stBikePara.uwAutoPowerOffTime.uwReal = I2C_uwBikeParaRead[11];
+    Syspara2.stBikePara.uwThrottleSmooth.uwReal = I2C_uwBikeParaRead[12];
 
     Syspara2.stMControlPara.ParaFirstSetFlg.uwReal = I2C_uwMControlRead[0];
     Syspara2.stMControlPara.SpiOffsetFirstSetFlg.uwReal = I2C_uwMControlRead[1];

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

@@ -87,7 +87,7 @@ Update Time
 #define M_FLUX_WB           5360    // unit: 0.001mWb, Flux linkage
 #define M_ID_MAX_AP         0       //-25      // unit: 0.01A, Max d axis current
 #define M_ID_MIN_AP         -300    // unit: 0.01A, Min d axis current
-#define M_IS_PEAK_MAX_AP    5500    // unit: 0.01A, Max phase current(below base speed)
+#define M_IS_PEAK_MAX_AP    5000        //5500    // unit: 0.01A, Max phase current(below base speed)
 #define M_POWER_MAX_WT      600     // unit: W, Max power
 #define M_R_SPD_RPM         5000    // unit: r/min, rate spd
 #define M_R_PWR_WT          250     // unit: W, rate power
@@ -285,7 +285,7 @@ Update Time
 #define ALM_TORQ_MIN_VOL     1  // unit: 0.1V
 #define ALM_TORQ_FLT_TS      1  // unit: s
 #define ALM_THROTTLE_MAX_VOL 30 // unit: 0.1V
-#define ALM_THROTTLE_MIN_VOL 1  // unit: 0.1V
+#define ALM_THROTTLE_MIN_VOL 0  //1  // unit: 0.1V
 #define ALM_THROTTLE_FLT_TS  1  // unit: s
 #define ALM_NTC_MAX_VOL      32 // unit: 0.1V
 #define ALM_NTC_MIN_VOL      3  // unit: 0.1V