make fuel math look more like ign math (#2214)
This commit is contained in:
parent
07bb157e81
commit
d534a00d5f
|
@ -1736,7 +1736,7 @@ typedef enum {
|
||||||
CUSTOM_OBD_PIN_CONFLICT = 6048,
|
CUSTOM_OBD_PIN_CONFLICT = 6048,
|
||||||
CUSTOM_OBD_LOW_FREQUENCY = 6049,
|
CUSTOM_OBD_LOW_FREQUENCY = 6049,
|
||||||
|
|
||||||
CUSTOM_OBD_ZERO_CYLINDER_COUNT = 6051,
|
CUSTOM_6051 = 6051,
|
||||||
CUSTOM_OBD_TS_PAGE_MISMATCH = 6052,
|
CUSTOM_OBD_TS_PAGE_MISMATCH = 6052,
|
||||||
CUSTOM_OBD_TS_OUTPUT_MISMATCH = 6053,
|
CUSTOM_OBD_TS_OUTPUT_MISMATCH = 6053,
|
||||||
CUSTOM_TOO_LONG_CRANKING_FUEL_INJECTION = 6054,
|
CUSTOM_TOO_LONG_CRANKING_FUEL_INJECTION = 6054,
|
||||||
|
|
|
@ -52,15 +52,15 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
|
||||||
*/
|
*/
|
||||||
floatms_t fuelMs = ENGINE(injectionDuration);
|
floatms_t fuelMs = ENGINE(injectionDuration);
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelMs), "NaN fuelMs", false);
|
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelMs), "NaN fuelMs", false);
|
||||||
angle_t injectionDuration = MS2US(fuelMs) / oneDegreeUs;
|
angle_t injectionDurationAngle = MS2US(fuelMs) / oneDegreeUs;
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(injectionDuration), "NaN injectionDuration", false);
|
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(injectionDurationAngle), "NaN injectionDurationAngle", false);
|
||||||
assertAngleRange(injectionDuration, "injectionDuration_r", CUSTOM_INJ_DURATION);
|
assertAngleRange(injectionDurationAngle, "injectionDuration_r", CUSTOM_INJ_DURATION);
|
||||||
floatus_t injectionOffset = ENGINE(engineState.injectionOffset);
|
floatus_t injectionOffset = ENGINE(engineState.injectionOffset);
|
||||||
if (cisnan(injectionOffset)) {
|
if (cisnan(injectionOffset)) {
|
||||||
// injection offset map not ready - we are not ready to schedule fuel events
|
// injection offset map not ready - we are not ready to schedule fuel events
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
angle_t baseAngle = injectionOffset - injectionDuration;
|
angle_t baseAngle = injectionOffset - injectionDurationAngle;
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseAngle), "NaN baseAngle", false);
|
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseAngle), "NaN baseAngle", false);
|
||||||
assertAngleRange(baseAngle, "baseAngle_r", CUSTOM_ERR_6554);
|
assertAngleRange(baseAngle, "baseAngle_r", CUSTOM_ERR_6554);
|
||||||
|
|
||||||
|
@ -81,18 +81,6 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
|
||||||
injectorIndex = 0;
|
injectorIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertAngleRange(baseAngle, "addFbaseAngle", CUSTOM_ADD_BASE);
|
|
||||||
|
|
||||||
int cylindersCount = CONFIG(specs.cylindersCount);
|
|
||||||
if (cylindersCount < 1) {
|
|
||||||
// May 2020 this somehow still happens with functional tests, maybe race condition?
|
|
||||||
warning(CUSTOM_OBD_ZERO_CYLINDER_COUNT, "Invalid cylinder count: %d", cylindersCount);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float angle = baseAngle
|
|
||||||
+ i * ENGINE(engineCycle) / cylindersCount;
|
|
||||||
|
|
||||||
InjectorOutputPin *secondOutput;
|
InjectorOutputPin *secondOutput;
|
||||||
if (mode == IM_BATCH && CONFIG(twoWireBatchInjection)) {
|
if (mode == IM_BATCH && CONFIG(twoWireBatchInjection)) {
|
||||||
/**
|
/**
|
||||||
|
@ -111,20 +99,22 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
|
||||||
InjectorOutputPin *output = &enginePins.injectors[injectorIndex];
|
InjectorOutputPin *output = &enginePins.injectors[injectorIndex];
|
||||||
bool isSimultanious = mode == IM_SIMULTANEOUS;
|
bool isSimultanious = mode == IM_SIMULTANEOUS;
|
||||||
|
|
||||||
|
InjectionEvent *ev = &elements[i];
|
||||||
|
INJECT_ENGINE_REFERENCE(ev);
|
||||||
|
|
||||||
|
ev->ownIndex = i;
|
||||||
|
ev->outputs[0] = output;
|
||||||
|
ev->outputs[1] = secondOutput;
|
||||||
|
ev->isSimultanious = isSimultanious;
|
||||||
|
|
||||||
if (!isSimultanious && !output->isInitialized()) {
|
if (!isSimultanious && !output->isInitialized()) {
|
||||||
// todo: extract method for this index math
|
// todo: extract method for this index math
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
InjectionEvent *ev = &elements[i];
|
angle_t ignitionPositionWithinEngineCycle = ENGINE(ignitionPositionWithinEngineCycle[i]);
|
||||||
ev->ownIndex = i;
|
|
||||||
INJECT_ENGINE_REFERENCE(ev);
|
|
||||||
fixAngle(angle, "addFuel#1", CUSTOM_ERR_6554);
|
|
||||||
|
|
||||||
ev->outputs[0] = output;
|
float angle = baseAngle + ignitionPositionWithinEngineCycle;
|
||||||
ev->outputs[1] = secondOutput;
|
|
||||||
|
|
||||||
ev->isSimultanious = isSimultanious;
|
|
||||||
|
|
||||||
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");
|
||||||
|
|
Loading…
Reference in New Issue