Enabled softRevLimit time limit (#602)

Co-authored-by: Josh Stewart <josh@noisymime.org>
This commit is contained in:
Vitor Moreno B. Sales 2021-12-21 23:29:13 -03:00 committed by GitHub
parent 241917cc7f
commit d9bde09f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 11 deletions

View File

@ -782,14 +782,19 @@ int8_t correctionSoftRevLimit(int8_t advance)
{
byte ignSoftRevValue = advance;
BIT_CLEAR(currentStatus.spark, BIT_SPARK_SFTLIM);
if (configPage6.engineProtectType == PROTECT_CUT_IGN || configPage6.engineProtectType == PROTECT_CUT_BOTH) {
if (configPage6.engineProtectType == PROTECT_CUT_IGN || configPage6.engineProtectType == PROTECT_CUT_BOTH)
{
if (currentStatus.RPM > ((unsigned int)(configPage4.SoftRevLim) * 100) ) //Softcut RPM limit
{
BIT_SET(currentStatus.spark, BIT_SPARK_SFTLIM);
if (configPage2.SoftLimitMode == SOFT_LIMIT_RELATIVE) { ignSoftRevValue = ignSoftRevValue - configPage4.SoftLimRetard; } //delay timing by configured number of degrees in relative mode
else if (configPage2.SoftLimitMode == SOFT_LIMIT_FIXED) { ignSoftRevValue = configPage4.SoftLimRetard; } //delay timing to configured number of degrees in fixed mode
}
if( (runSecsX10 - softStartTime) < configPage4.SoftLimMax )
{
BIT_SET(currentStatus.spark, BIT_SPARK_SFTLIM);
if (configPage2.SoftLimitMode == SOFT_LIMIT_RELATIVE) { ignSoftRevValue = ignSoftRevValue - configPage4.SoftLimRetard; } //delay timing by configured number of degrees in relative mode
else if (configPage2.SoftLimitMode == SOFT_LIMIT_FIXED) { ignSoftRevValue = configPage4.SoftLimRetard; } //delay timing to configured number of degrees in fixed mode
}
}
else if( BIT_CHECK(LOOP_TIMER, BIT_TIMER_10HZ) ) { softStartTime = runSecsX10; } //Only copy time at runSecsX10 update rate
}
return ignSoftRevValue;

View File

@ -7,7 +7,7 @@ byte checkEngineProtect()
byte protectActive = 0;
if(checkRevLimit() || checkBoostLimit() || checkOilPressureLimit() || checkAFRLimit())
{
if(currentStatus.RPM > (configPage4.engineProtectMaxRPM*100U)) { protectActive = 1; }
if( currentStatus.RPMdiv100 > configPage4.engineProtectMaxRPM ) { protectActive = 1; }
}
return protectActive;
@ -20,13 +20,15 @@ byte checkRevLimit()
BIT_CLEAR(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_RPM);
BIT_CLEAR(currentStatus.spark, BIT_SPARK_HRDLIM);
if (configPage6.engineProtectType != PROTECT_CUT_OFF) {
if (currentStatus.RPM > ((unsigned int)(configPage4.HardRevLim) * 100) )
if (configPage6.engineProtectType != PROTECT_CUT_OFF)
{
if ( (currentStatus.RPMdiv100 > configPage4.HardRevLim) || ((runSecsX10 - softStartTime) >= configPage4.SoftLimMax) )
{
BIT_SET(currentStatus.spark, BIT_SPARK_HRDLIM); //Legacy and likely to be removed at some point
BIT_SET(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_RPM);
revLimiterActive = 1;
}
}
else { BIT_CLEAR(currentStatus.spark, BIT_SPARK_HRDLIM); }
}
return revLimiterActive;

View File

@ -560,6 +560,7 @@ extern int ignition8StartAngle;
extern bool initialisationComplete; //Tracks whether the setup() function has run completely
extern byte fpPrimeTime; //The time (in seconds, based on currentStatus.secl) that the fuel pump started priming
extern uint16_t softStartTime; //The time (in 0.1 seconds, based on seclx10) that the soft limiter started
extern volatile uint16_t mainLoopCount;
extern unsigned long revolutionTime; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that)
extern volatile unsigned long timer5_overflow_count; //Increments every time counter 5 overflows. Used for the fast version of micros()
@ -948,7 +949,7 @@ struct config4 {
byte floodClear; ///< TPS (raw adc count? % ?) value that triggers flood clear mode (No fuel whilst cranking, See @ref correctionFloodClear())
byte SoftRevLim; ///< Soft rev limit (RPM/100)
byte SoftLimRetard; ///< Amount soft limit (ignition) retard (degrees)
byte SoftLimMax; ///< Time the soft limit can run (units ?)
byte SoftLimMax; ///< Time the soft limit can run (units 0.1S)
byte HardRevLim; ///< Hard rev limit (RPM/100)
byte taeBins[4]; ///< TPS based acceleration enrichment bins (Unit: %/s)
byte taeValues[4]; ///< TPS based acceleration enrichment rates (Unit: % to add), values matched to thresholds of taeBins

View File

@ -124,6 +124,7 @@ int ignition8EndAngle = 0;
//These are variables used across multiple files
bool initialisationComplete = false; ///< Tracks whether the setup() function has run completely (true = has run)
byte fpPrimeTime = 0; ///< The time (in seconds, based on @ref statuses.secl) that the fuel pump started priming
uint16_t softStartTime = 0; //The time (in 0.1 seconds, based on seclx10) that the soft limiter started
volatile uint16_t mainLoopCount; //Main loop counter (incremented at each main loop rev., used for maintaining currentStatus.loopsPerSecond)
unsigned long revolutionTime; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that)
volatile unsigned long timer5_overflow_count = 0; //Increments every time counter 5 overflows. Used for the fast version of micros()