simplify cylinder phasing (#3650)
This commit is contained in:
parent
3b1b5c085e
commit
555a8d5f43
|
@ -330,11 +330,6 @@ public:
|
||||||
|
|
||||||
void resetEngineSnifferIfInTestMode();
|
void resetEngineSnifferIfInTestMode();
|
||||||
|
|
||||||
/**
|
|
||||||
* pre-calculated offset for given sequence index within engine cycle
|
|
||||||
* (not cylinder ID)
|
|
||||||
*/
|
|
||||||
angle_t ignitionPositionWithinEngineCycle[MAX_CYLINDER_COUNT];
|
|
||||||
/**
|
/**
|
||||||
* pre-calculated reference to which output pin should be used for
|
* pre-calculated reference to which output pin should be used for
|
||||||
* given sequence index within engine cycle
|
* given sequence index within engine cycle
|
||||||
|
|
|
@ -107,9 +107,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i ) {
|
||||||
warning(CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->name);
|
warning(CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
angle_t ignitionPositionWithinEngineCycle = engine->ignitionPositionWithinEngineCycle[i];
|
float angle = baseAngle + getCylinderAngle(i, ev->cylinderNumber);
|
||||||
|
|
||||||
float angle = baseAngle + ignitionPositionWithinEngineCycle;
|
|
||||||
|
|
||||||
if (TRIGGER_WAVEFORM(getSize()) < 1) {
|
if (TRIGGER_WAVEFORM(getSize()) < 1) {
|
||||||
warning(CUSTOM_ERR_NOT_INITIALIZED_TRIGGER, "uninitialized TriggerWaveform");
|
warning(CUSTOM_ERR_NOT_INITIALIZED_TRIGGER, "uninitialized TriggerWaveform");
|
||||||
|
|
|
@ -73,12 +73,14 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
||||||
// let's save planned duration so that we can later compare it with reality
|
// let's save planned duration so that we can later compare it with reality
|
||||||
event->sparkDwell = sparkDwell;
|
event->sparkDwell = sparkDwell;
|
||||||
|
|
||||||
// change of sign here from 'before TDC' to 'after TDC'
|
const angle_t sparkAngle =
|
||||||
angle_t ignitionPositionWithinEngineCycle = engine->ignitionPositionWithinEngineCycle[event->cylinderIndex];
|
// Negate because timing *before* TDC, and we schedule *after* TDC
|
||||||
assertAngleRange(ignitionPositionWithinEngineCycle, "aPWEC", CUSTOM_ERR_6566);
|
- engine->engineState.timingAdvance
|
||||||
// this correction is usually zero (not used)
|
// Offset by this cylinder's position in the cycle
|
||||||
float perCylinderCorrection = engineConfiguration->timing_offset_cylinder[event->cylinderIndex];
|
+ getCylinderAngle(event->cylinderIndex, event->cylinderNumber)
|
||||||
const angle_t sparkAngle = -engine->engineState.timingAdvance + engine->knockController.getKnockRetard() + ignitionPositionWithinEngineCycle + perCylinderCorrection;
|
// Pull any extra timing for knock retard
|
||||||
|
+ engine->knockController.getKnockRetard();
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_SPARK_ANGLE_9, !cisnan(sparkAngle), "findAngle#9");
|
efiAssertVoid(CUSTOM_SPARK_ANGLE_9, !cisnan(sparkAngle), "findAngle#9");
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
|
efiAssertVoid(CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
|
||||||
|
|
|
@ -440,10 +440,6 @@ void prepareOutputSignals() {
|
||||||
}
|
}
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
||||||
for (size_t i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
|
||||||
engine->ignitionPositionWithinEngineCycle[i] = engine->engineCycle * i / engineConfiguration->specs.cylindersCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
prepareIgnitionPinIndices(engineConfiguration->ignitionMode);
|
prepareIgnitionPinIndices(engineConfiguration->ignitionMode);
|
||||||
|
|
||||||
TRIGGER_WAVEFORM(prepareShape(&engine->triggerCentral.triggerFormDetails));
|
TRIGGER_WAVEFORM(prepareShape(&engine->triggerCentral.triggerFormDetails));
|
||||||
|
@ -452,6 +448,21 @@ void prepareOutputSignals() {
|
||||||
engine->injectionEvents.invalidate();
|
engine->injectionEvents.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
angle_t getCylinderAngle(uint8_t cylinderIndex, uint8_t cylinderNumber) {
|
||||||
|
// base = position of this cylinder in the firing order.
|
||||||
|
// We get a cylinder every n-th of an engine cycle where N is the number of cylinders
|
||||||
|
auto base = engine->engineCycle * cylinderIndex / engineConfiguration->specs.cylindersCount;
|
||||||
|
|
||||||
|
// Plus or minus any adjustment if this is an odd-fire engine
|
||||||
|
auto adjustment = engineConfiguration->timing_offset_cylinder[cylinderNumber];
|
||||||
|
|
||||||
|
auto result = base + adjustment;
|
||||||
|
|
||||||
|
assertAngleRange(result, "getCylinderAngle", CUSTOM_ERR_6566);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void setTimingRpmBin(float from, float to) {
|
void setTimingRpmBin(float from, float to) {
|
||||||
setRpmBin(config->ignitionRpmBins, IGN_RPM_COUNT, from, to);
|
setRpmBin(config->ignitionRpmBins, IGN_RPM_COUNT, from, to);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,3 +62,11 @@ void setSingleCoilDwell();
|
||||||
// while for toothed wheels user would have to provide a value
|
// while for toothed wheels user would have to provide a value
|
||||||
#define tdcPosition() \
|
#define tdcPosition() \
|
||||||
(TRIGGER_WAVEFORM(tdcPosition) + engineConfiguration->globalTriggerAngleOffset)
|
(TRIGGER_WAVEFORM(tdcPosition) + engineConfiguration->globalTriggerAngleOffset)
|
||||||
|
|
||||||
|
/** Gets phase offset for a particular cylinder's ID and number
|
||||||
|
* For example on 4 cylinder engine with firing order 1-3-4-2, this
|
||||||
|
* returns 0-180-360-540 for index 0-1-2-3
|
||||||
|
* Cylinder number is used for per-cylinder adjustment, if you have
|
||||||
|
* an odd-fire engine (v-twin, V10, some v6, etc)
|
||||||
|
*/
|
||||||
|
angle_t getCylinderAngle(uint8_t cylinderIndex, uint8_t cylinderNumber);
|
||||||
|
|
Loading…
Reference in New Issue