Преглед на файлове

1.新思维定制,通过宏定义可更改转把限速;2.塔基传感器宏定义优化;3.锂电2号限速调整为仅支持向下修改限速(以骑行限速为基准)

Ye Jin преди 5 месеца
родител
ревизия
a205b2297b

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

@@ -773,7 +773,7 @@ UWORD uwIntSource = 0;
     cadence_voCadenceCal(uwIntSource);
 
 
-    if(TORG4BB_Get_CAD_PORT() == RESET)
+    if(Get_CAD_PORT() == RESET)
       {
         if(cadence_stFreGetOut.uwTaPinPortSta!=0)
         {

+ 5 - 3
3.BasicFunction/Include/AssistCurve.h

@@ -105,7 +105,7 @@
       0, 0, 0, 0,\
       0, 0, 0, 0,\
       0, 0, 0, 0,\
-    }// Y1, Y2, Y3, Z 单位:0.1 Nm 
+    }// Y1, Y2, Y3, Z 单位:0.1 Nm
 #define   ASS_CURVE_X1    30 // 单位:0.1Nm
 #define   ASS_CURVE_X2    100 // 单位:0.1Nm
 #define   ASS_CURVE_X3    300 // 单位:0.1Nm
@@ -137,7 +137,7 @@
         0, 0, 45000, 0, \
         0, 0, 45000, 0, \
         0, 0, 45000, 0 \
-    }		//35000改为45000  
+    }		//35000改为45000
 
 /***************************************
  *
@@ -306,7 +306,7 @@ typedef struct
     UWORD SOCValue;
     SWORD swCurFdbPu; //Q14
     SWORD swCurRefPu;
-    UWORD uwStartRunPulse;//启动脉冲个数计数 
+    UWORD uwStartRunPulse;//启动脉冲个数计数
     UWORD uwcadHighStopCnt;//踏频为0时,开始计数值
     UWORD uwcadLowStopCnt;//踏频为0时,开始计数值
 } ASS_PER_IN;
@@ -508,4 +508,6 @@ void Gear_LimitSpd(UWORD Gear);
  *
  */
 void AssistCurveRatio(void);
+
+uint32_t Get_CAD_PORT(void);
 #endif

+ 4 - 2
3.BasicFunction/Include/Customization.h

@@ -8,8 +8,10 @@
 #ifndef _CUSTOMIZATION_H_
 #define _CUSTOMIZATION_H_
 
-
+/*======================================================================*
+  定义宏用于表示客户定制化程序,标准化程序以下宏定义应全为0
+*=======================================================================*/
 #define TORG4BBTORQU_ENABLE                     1   //0-标准程序,1-塔基传感器定制
-
+#define HEYBIKEXINSIWEI_ENABLE                  1   //0-标准程序,1-heybike-新思维定制
 
 #endif /* 3_BASICFUNCTION_INCLUDE_CUSTOMIZATION_H_ */

+ 5 - 4
3.BasicFunction/Include/uart_Lidian2.h

@@ -100,8 +100,8 @@ typedef union MC_StatusInfo1
         UBYTE UnderVoltageErr: 1;//1: 欠压保护
         UBYTE ControllerErr: 1;//1: 控制器故障
         UBYTE ThrottleErr: 1;//1: 转把故障
-        UBYTE HallErr: 1;//霍尔故障 
-        UBYTE Walk: 1;//6Km 巡航 
+        UBYTE HallErr: 1;//霍尔故障
+        UBYTE Walk: 1;//6Km 巡航
     } Status_Bit;
     
     UBYTE Status;
@@ -117,7 +117,7 @@ typedef union MC_StatusInfo2
         UBYTE CommErr: 1;//1:通讯故障
         UBYTE Brake: 1;//
         UBYTE AssistSensorErr: 1;//默认为1
-        UBYTE Horizontal: 1;//1: 水平状态 0: 非水平状态,默认为1  
+        UBYTE Horizontal: 1;//1: 水平状态 0: 非水平状态,默认为1
     } Status_Bit;
     
     UBYTE Status;
@@ -143,7 +143,8 @@ void Lidian2_OBCSetPara(void);
 void Lidian2_USART_DataProcess(USART_Buf_TypeDef* ptUartTx, UBYTE* Data);
 void Lidian2_SendData_OBC(USART_Buf_TypeDef* ptUartTx);
 void Lidian2_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD dataCount);
+void Lidian2_XinSiWeiLimitThrottleSpd(UWORD speedPWM);
 
 #endif
 
-/*---------------------------- file end -------------------------------------*/
+/*---------------------------- file end -------------------------------------*/

+ 14 - 24
3.BasicFunction/Source/AssistCurve.c

@@ -405,10 +405,9 @@ void AssitCuvApplPerVolt(void)
     /* 启动标志判断 */
     if(ass_CalIn.uwtorquePer > ass_CalCoef.uwAssThreshold)
     {
-#if (TORG4BBTORQU_ENABLE == 1)
-        if(CadGpioSta != TORG4BB_Get_CAD_PORT()   )
+        if(CadGpioSta != Get_CAD_PORT())
         {
- 			CadGpioSta = TORG4BB_Get_CAD_PORT();
+            CadGpioSta = Get_CAD_PORT();
             if(ass_CalIn.uwStartRunPulse < 100)
             {
                 ass_CalIn.uwStartRunPulse ++;
@@ -417,23 +416,8 @@ void AssitCuvApplPerVolt(void)
             {
                 ass_CalIn.uwStartRunPulse = 100;
             }
-           
-        }
-#else
-        if(CadGpioSta !=Get_CAD_PORT()   )
-            {
-                CadGpioSta = Get_CAD_PORT();
-                if(ass_CalIn.uwStartRunPulse < 100)
-                {
-                    ass_CalIn.uwStartRunPulse ++;
-                }
-                else
-                {
-                    ass_CalIn.uwStartRunPulse = 100;
-                }
 
-            }
-#endif
+        }
     }
     else if (ass_CalIn.uwtorquePer < ass_CalCoef.uwAssStopThreshold)
     {
@@ -476,11 +460,8 @@ void AssitCuvApplPerVolt(void)
     {
         exit_pulse_cnt = 200;
     }
-#if (TORG4BBTORQU_ENABLE == 1)
-    if( TORG4BB_Get_CAD_PORT() == 0)
-#else
-        if( Get_CAD_PORT() == 0)
-#endif
+
+    if( Get_CAD_PORT() == 0)
     {
         if(ass_CalIn.uwcadLowStopCnt<=4000)
         {
@@ -1230,3 +1211,12 @@ void AssCurLimAccordIdc(UWORD uwIdcPu)
         ass_CurLimitCalBMSOut.uwIdcLimIqAbs = ass_CurLimCalBMSCoef.uwIqLimitInitAbs;
     }
 }
+
+uint32_t Get_CAD_PORT(void)
+{
+#if (TORG4BBTORQU_ENABLE == 1)
+    return TORG4BB_Get_CAD_PORT();
+#else
+    return DL_GPIO_readPins(INPUT_PORT, INPUT_Cadence_in_PIN);
+#endif
+}

+ 35 - 16
3.BasicFunction/Source/uart_Lidian2.c

@@ -41,7 +41,7 @@
 #include "syspar.h"
 #include "bikebrake.h"
 #include "bikethrottle.h"
-
+#include "Customization.h"
 /******************************
  *
  *  Parameter
@@ -113,19 +113,27 @@ void Lidian2_OBCSetPara(void)
 #endif
     
     /*限速阈值更新*/
-    if(MC_UpcInfo.stAssistInfo.uwAssistLimitBikeSpdStart != Lidian2_stOBC2MCInfo.ucSpeedLimiation)
+    if(Lidian2_stOBC2MCInfo.ucSpeedLimiation != (MC_UpcInfo.stAssistInfo.uwAssistLimitBikeSpdStart + MC_UpcInfo.stBikeInfo2.swDeltaBikeSpeedLimit))//有变化时更新
     {
-        MC_UpcInfo.stAssistInfo.uwAssistLimitBikeSpdStart = Lidian2_stOBC2MCInfo.ucSpeedLimiation;
-        MC_UpcInfo.stAssistInfo.uwAssistLimitBikeSpdStop = Lidian2_stOBC2MCInfo.ucSpeedLimiation + 2;
-        MC_UpcInfo.stBikeInfo.uwThrottleMaxSpdKmH = Lidian2_stOBC2MCInfo.ucSpeedLimiation;
-        MC_UpcInfo.stBikeInfo.uwSaveFlg = 1;
-        MC_UpcInfo.stAssistInfo.uwSaveFlg = 1;
-        cp_stFlg.ParaSaveEEFlg = TRUE;
-        cp_stFlg.ParaUpdateFlg = TRUE;
-        cp_stFlg.ParaAInfoUpdateFlg = TRUE;
-        cp_stFlg.ParaBikeInfoUpdateFlg = TRUE;
-        cp_stFlg.ParaAssistUpdateFinishFlg = TRUE;
+        SWORD deltaSpeed = 0;
+        deltaSpeed = (Lidian2_stOBC2MCInfo.ucSpeedLimiation - MC_UpcInfo.stAssistInfo.uwAssistLimitBikeSpdStart);
+        if(deltaSpeed > 0)
+        {
+            deltaSpeed = 0;
+        }
+        if(deltaSpeed != MC_UpcInfo.stBikeInfo2.swDeltaBikeSpeedLimit)
+        {
+            MC_UpcInfo.stBikeInfo2.swDeltaBikeSpeedLimit = deltaSpeed;
+            ass_ParaCong.swDeltaBikeSpeedLimit = deltaSpeed;
+            MC_UpcInfo.stBikeInfo2.uwSaveFlg = TRUE;
+            cp_stFlg.ParaSaveEEFlg = TRUE;
+            cp_stFlg.ParaUpdateFlg = TRUE;
+            cp_stFlg.ParaBikeInfo2UpdateFlg = TRUE;
+            cp_stFlg.ParaAssistUpdateFinishFlg = TRUE;
+        }
     }
+
+    Lidian2_XinSiWeiLimitThrottleSpd(Lidian2_stOBC2MCInfo.uwThrottlePWM);
 }
 /***************************************************************
  Function: SP_USART_DataProcess;
@@ -189,25 +197,26 @@ void Lidian2_USART_DataProcess(USART_Buf_TypeDef* ptUartTx, UBYTE* Data)
                 }
         
 #endif
+        //0-OFF, 1<=GearSt<6:ECO,  6<=GearSt<9:NORM,  9<=GearSt<12:SPORT,  12<=GearSt<15:TURBO,  15==GearSt:SMART
         if(MC_ControlCode.GearSt != MC_GearSt_WALK)
         {
             if(Lidian2_stOBC2MCInfo.ucGearSt == 15)
             {
                 MC_ControlCode.GearSt = MC_GearSt_SMART;
             }
-            else if(Lidian2_stOBC2MCInfo.ucGearSt == 12)               
+            else if(Lidian2_stOBC2MCInfo.ucGearSt >= 12)
             {
                 MC_ControlCode.GearSt = MC_GearSt_Torque_TURBO;
             }
-            else if((Lidian2_stOBC2MCInfo.ucGearSt == 9)||(Lidian2_stOBC2MCInfo.ucGearSt == 10) )
+            else if(Lidian2_stOBC2MCInfo.ucGearSt >= 9)
             {
                 MC_ControlCode.GearSt = MC_GearSt_Torque_SPORT;
             }
-            else if(Lidian2_stOBC2MCInfo.ucGearSt == 6)
+            else if(Lidian2_stOBC2MCInfo.ucGearSt >= 6)
             {
                 MC_ControlCode.GearSt = MC_GearSt_Torque_NORM;
             }
-            else if((Lidian2_stOBC2MCInfo.ucGearSt == 3)||(Lidian2_stOBC2MCInfo.ucGearSt == 5))
+            else if(Lidian2_stOBC2MCInfo.ucGearSt >= 1)
             {
                 MC_ControlCode.GearSt = MC_GearSt_Torque_ECO;
             }  
@@ -371,4 +380,14 @@ void Lidian2_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD
     }
 }
 
+void Lidian2_XinSiWeiLimitThrottleSpd(UWORD speedPWM)
+{
+#if(HEYBIKEXINSIWEI_ENABLE == 1)
+
+    speedPWM = (speedPWM & 0xFF);//只取低字节
+    ass_stCadAssCoef.uwThrottleMaxBikeSpeed = (((ass_ParaCong.uwThrottleMaxSpdKmH+ass_ParaCong.swDeltaBikeSpeedLimit)<<4) + 8)*speedPWM/255;
+    ass_stCadAssCoef.swThrottleMaxspd = ass_stCadAssCoef.swKmhToMSpdPu*((SLONG) ass_stCadAssCoef.uwThrottleMaxBikeSpeed + ASS_SPD_LIMIT_ERR)  >> 4;
+
+#endif
+}
 /************************ (C) END OF FILE *********************************/

+ 4 - 0
3.BasicFunction/Source/uart_TORG4BBSensor.c

@@ -62,6 +62,7 @@ TORG4BB_OUT stTORG4BB_stTorSensorOut;
 ****************************************************************/
 void TORG4BB_Init(void)
 {
+#if (TORG4BBTORQU_ENABLE == 1)
     stTORG4BB_stTorSensorOut.uwTorqueRegOffset = 217;//0.7/3.3*1024
     stTORG4BB_stTorSensorOut.uwTorqueReg2Pu = (((SQWORD)3300 << 14) >> 10) / 35 * 10 / TORQUEBASE;
     stTORG4BB_stTorSensorOut.uwTorqueLPFgain = TORG4BBCADENCE_LPF_GAIN;
@@ -71,6 +72,7 @@ void TORG4BB_Init(void)
     stTORG4BBInfo.uwTorqueReg = stTORG4BB_stTorSensorOut.uwTorqueRegOffset;
 
     mth_voLPFilterCoef(1000000/2, 100, &scm_stTORG4BBTorLpf.uwKx);
+#endif
 }
 /***************************************************************
  Function: TORG4BB_USART_DataProcess;
@@ -103,6 +105,7 @@ void TORG4BB_USART_DataProcess(USART_Buf_TypeDef* ptUartTx, UBYTE* Data)
 ****************************************************************/
 void TORG4BB_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD dataCount)
 {
+#if (TORG4BBTORQU_ENABLE == 1)
     static UBYTE Data[255];
     //UWORD Cmd, ID;
     UWORD i;
@@ -124,6 +127,7 @@ void TORG4BB_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD
             }
         }
     }
+#endif
 }
 /***************************************************************
  Function: TORG4BB_Torque_Handler;

+ 1 - 1
4.BasicHardwSoftwLayer/1.BasicHardwLayer/Include/UserGpio_Config.h

@@ -30,7 +30,7 @@
 
 
 
-#define Get_CAD_PORT()              DL_GPIO_readPins(INPUT_PORT, INPUT_Cadence_in_PIN)//  (GPIOB->idt &GPIO_PINS_9) // CAD
+//#define Get_CAD_PORT()              DL_GPIO_readPins(INPUT_PORT, INPUT_Cadence_in_PIN)//  (GPIOB->idt &GPIO_PINS_9) // CAD
 
 
 /* 前灯IO on/off */