|
@@ -14,12 +14,14 @@
|
|
Compiler Directives:
|
|
Compiler Directives:
|
|
*************************************************************************/
|
|
*************************************************************************/
|
|
#include "syspar.h"
|
|
#include "syspar.h"
|
|
|
|
+#include "user.h"
|
|
#include "typedefine.h"
|
|
#include "typedefine.h"
|
|
#include "mathtool.h"
|
|
#include "mathtool.h"
|
|
#include "bikethrottle.h"
|
|
#include "bikethrottle.h"
|
|
#include "api.h"
|
|
#include "api.h"
|
|
#include "board_config.h"
|
|
#include "board_config.h"
|
|
#include "bikespeed.h"
|
|
#include "bikespeed.h"
|
|
|
|
+#include "bikebrake.h"
|
|
/******************************
|
|
/******************************
|
|
*
|
|
*
|
|
* static Parameter
|
|
* static Parameter
|
|
@@ -28,7 +30,7 @@
|
|
static BIKETHROTTLE_COF bikethrottle_stBikeThrottleCof = BIKETHROTTLE_COF_DEFAULT;
|
|
static BIKETHROTTLE_COF bikethrottle_stBikeThrottleCof = BIKETHROTTLE_COF_DEFAULT;
|
|
static LPF_OUT scm_stBikeThrottleLpf;
|
|
static LPF_OUT scm_stBikeThrottleLpf;
|
|
BIKETHROTTLE_OUT bikethrottle_stBikeThrottleOut = BIKETHROTTLE_OUT_DEFAULT;
|
|
BIKETHROTTLE_OUT bikethrottle_stBikeThrottleOut = BIKETHROTTLE_OUT_DEFAULT;
|
|
-
|
|
|
|
|
|
+BIKECRUISE_COF bikeCruise = BIKECRUISE_OUT_DEFAULT;
|
|
/******************************
|
|
/******************************
|
|
*
|
|
*
|
|
* extern Parameter
|
|
* extern Parameter
|
|
@@ -50,6 +52,7 @@ void bikethrottle_voBikeThrottleCof(void)
|
|
|
|
|
|
bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu = ((ULONG)BIKETHROTTLE_VOLTAGE_MAX_RANGE << 14) / (VBASE * 100); // Q15
|
|
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.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.uwThrottleVolSen2McuGain = BIKETHROTTLE_VOLTAGE_SEN2MCUGAIN;
|
|
bikethrottle_stBikeThrottleCof.uwThrottleVolLPFFrq = BIKETHROTTLE_LPF_FRQ;
|
|
bikethrottle_stBikeThrottleCof.uwThrottleVolLPFFrq = BIKETHROTTLE_LPF_FRQ;
|
|
bikethrottle_stBikeThrottleCof.uwThrottleVolLPFDisFrq = BIKETHROTTLE_LPF_DISCRETEHZ;
|
|
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_stBikeThrottleOut.uwThrottleVolLPFPu - bikethrottle_stBikeThrottleCof.uwThrottleOffsetPu) * 1000 /
|
|
(bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu - bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu);
|
|
(bikethrottle_stBikeThrottleCof.uwMaxThrottleVolOutputPu - bikethrottle_stBikeThrottleCof.uwMinThrottleVolOutputPu);
|
|
}
|
|
}
|
|
|
|
+ bikethrottle_voThrottlecruise();
|
|
|
|
+ bikethrottle_voStartAllow();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -155,7 +160,106 @@ void bikethrottle_voBikeThrottleADC(void) // need to match ADC_StartConversion(A
|
|
bikethrottle_stBikeThrottleOut.uwThrottlePercent = 0;
|
|
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)!
|
|
End of this File (EOF)!
|
|
Do not put anything after this part!
|
|
Do not put anything after this part!
|