trigger and VVT duty cycle integration into limp manager #2523

This commit is contained in:
rusefi 2021-04-07 15:17:01 -04:00
parent a27e2c4a19
commit 3f914bf3ed
3 changed files with 19 additions and 6 deletions

View File

@ -105,20 +105,26 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) {
} }
} }
static void initVvtShape(Logging *logger, int index, TriggerState &initState DECLARE_ENGINE_PARAMETER_SUFFIX) { static void initVvtShape(Logging *logger, int camIndex, TriggerState &initState DECLARE_ENGINE_PARAMETER_SUFFIX) {
vvt_mode_e vvtMode = engineConfiguration->vvtMode[index]; vvt_mode_e vvtMode = engineConfiguration->vvtMode[camIndex];
TriggerWaveform *shape = &ENGINE(triggerCentral).vvtShape[index]; TriggerWaveform *shape = &ENGINE(triggerCentral).vvtShape[camIndex];
// not ideas but good for now code
ENGINE(triggerCentral).vvtState[0][0].name = "vvt00";
ENGINE(triggerCentral).vvtState[0][1].name = "vvt01";
ENGINE(triggerCentral).vvtState[1][0].name = "vvt10";
ENGINE(triggerCentral).vvtState[1][1].name = "vvt11";
if (vvtMode != VVT_INACTIVE) { if (vvtMode != VVT_INACTIVE) {
trigger_config_s config; trigger_config_s config;
ENGINE(triggerCentral).vvtTriggerType[index] = config.type = getVvtTriggerType(vvtMode); ENGINE(triggerCentral).vvtTriggerType[camIndex] = config.type = getVvtTriggerType(vvtMode);
shape->initializeTriggerWaveform(logger, shape->initializeTriggerWaveform(logger,
engineConfiguration->ambiguousOperationMode, engineConfiguration->ambiguousOperationMode,
CONFIG(vvtCamSensorUseRise), &config); CONFIG(vvtCamSensorUseRise), &config);
shape->initializeSyncPoint(initState, shape->initializeSyncPoint(initState,
engine->vvtTriggerConfiguration[index], engine->vvtTriggerConfiguration[camIndex],
config); config);
} }
@ -150,6 +156,7 @@ void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_
calculateTriggerSynchPoint(ENGINE(triggerCentral.triggerShape), calculateTriggerSynchPoint(ENGINE(triggerCentral.triggerShape),
initState PASS_ENGINE_PARAMETER_SUFFIX); initState PASS_ENGINE_PARAMETER_SUFFIX);
ENGINE(triggerCentral.triggerState).name = "TRG";
engine->engineCycleEventCount = TRIGGER_WAVEFORM(getLength()); engine->engineCycleEventCount = TRIGGER_WAVEFORM(getLength());
} }

View File

@ -550,7 +550,12 @@ void TriggerState::decodeTriggerEvent(
int rpm = GET_RPM(); int rpm = GET_RPM();
floatms_t engineCycleDuration = getEngineCycleDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX); floatms_t engineCycleDuration = getEngineCycleDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX);
scheduleMsg(logger, "duty %f", currentCycle.totalTimeNt[0] / engineCycleDuration); int time = currentCycle.totalTimeNt[0];
scheduleMsg(logger, "%s duty %f %d",
name,
time / engineCycleDuration,
time
);
for (int i = 0;i<triggerShape.gapTrackingLength;i++) { for (int i = 0;i<triggerShape.gapTrackingLength;i++) {
float ratioFrom = triggerShape.syncronizationRatioFrom[i]; float ratioFrom = triggerShape.syncronizationRatioFrom[i];

View File

@ -131,6 +131,7 @@ public:
efitick_t toothed_previous_time; efitick_t toothed_previous_time;
current_cycle_state_s currentCycle; current_cycle_state_s currentCycle;
const char *name = nullptr;
int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM]; int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM];