launch control #203

This commit is contained in:
rusefi 2020-03-24 19:55:12 -04:00
parent 1955af0b6c
commit 9e125ecbdf
3 changed files with 24 additions and 15 deletions

View File

@ -61,6 +61,7 @@ typedef struct {
unsigned int isWarnNow : 1; // bit 25
unsigned int isPedalError : 1; // bit 26
unsigned int isKnockChipOk : 1; // bit 27
unsigned int launchTriggered : 1; // bit 28
// RPM, vss
scaled_channel<uint16_t> rpm; // 4

View File

@ -832,6 +832,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->isKnockChipOk = (instance.invalidHip9011ResponsesCount == 0);
#endif /* EFI_HIP_9011 */
#if EFI_LAUNCH_CONTROL
tsOutputChannels->launchTriggered = engine->isLaunchCondition;
#endif
tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;
// engine load acceleration

View File

@ -27,6 +27,7 @@
#include "tps.h"
#include "idle_thread.h"
#include "allsensors.h"
#include "launch_control.h"
#if EFI_ENGINE_CONTROL
@ -69,33 +70,23 @@ static const ignition_table_t defaultIatTiming = {
#endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */
//Todo: There are some more conditions that needs to be true, and RPM range must be added to launchrpm?
//bool isLaunchCondition(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
// return CONFIG(launchControlEnabled) && rpm >= engineConfiguration->launchRpm;
//}
/**
* @return ignition timing angle advance before TDC
*/
static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (CONFIG(timingMode) == TM_FIXED)
if (CONFIG(timingMode) == TM_FIXED) {
return engineConfiguration->fixedTiming;
}
engine->m.beforeAdvance = getTimeNowLowerNt();
if (cisnan(engineLoad)) {
warning(CUSTOM_NAN_ENGINE_LOAD, "NaN engine load");
return NAN;
}
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(engineLoad), "invalid el", NAN);
engine->m.beforeZeroTest = getTimeNowLowerNt();
engine->m.zeroTestTime = getTimeNowLowerNt() - engine->m.beforeZeroTest;
//See comment at line 70
// if (isLaunchCondition(rpm PASS_ENGINE_PARAMETER_SUFFIX)) {
// return engineConfiguration->launchTimingRetard;
// }
float advanceAngle;
if (CONFIG(useTPSAdvanceTable)) {
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
@ -103,7 +94,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
} else {
advanceAngle = advanceMap.getValue((float) rpm, engineLoad);
}
// get advance from the separate table for Idle
if (CONFIG(useSeparateAdvanceForIdle)) {
float idleAdvance = interpolate2d("idleAdvance", rpm, config->idleAdvanceBins, config->idleAdvance);
@ -112,7 +103,21 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
advanceAngle = interpolateClamped(0.0f, idleAdvance, CONFIG(idlePidDeactivationTpsThreshold), advanceAngle, tps);
}
engine->m.advanceLookupTime = getTimeNowLowerNt() - engine->m.beforeAdvance;
#if EFI_LAUNCH_CONTROL
if (engine->isLaunchCondition && CONFIG(enableLaunchRetard)) {
if (CONFIG(launchSmoothRetard)) {
float launchAngle = CONFIG(launchTimingRetard);
int launchAdvanceRpmRange = CONFIG(launchTimingRpmRange);
int launchRpm = CONFIG(launchRpm);
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm + launchTimingRpmRange
return interpolateClamped(launchRpm, advanceAngle, (launchRpm + launchAdvanceRpmRange), launchAngle, rpm);
} else {
return engineConfiguration->launchTimingRetard;
}
}
#endif /* EFI_LAUNCH_CONTROL */
return advanceAngle;
}