auto-sync
This commit is contained in:
parent
41fdaf9554
commit
d61835fa46
|
@ -156,7 +156,9 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
|
|||
sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER);
|
||||
dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm);
|
||||
|
||||
// todo: move this into slow callback, no reason for IAT corr to be here
|
||||
iatFuelCorrection = getIatCorrection(iat PASS_ENGINE_PARAMETER);
|
||||
// todo: move this into slow callback, no reason for CLT corr to be here
|
||||
if (boardConfiguration->useWarmupPidAfr && clt < engineConfiguration->warmupAfrThreshold) {
|
||||
if (rpm < 200) {
|
||||
cltFuelCorrection = 1;
|
||||
|
@ -377,7 +379,7 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
|
|||
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
engine->m.beforeFuelCalc = GET_TIMESTAMP();
|
||||
ENGINE(fuelMs) = getFuelMs(rpm PASS_ENGINE_PARAMETER) * engineConfiguration->globalFuelCorrection;
|
||||
ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER) * engineConfiguration->globalFuelCorrection;
|
||||
engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc;
|
||||
|
||||
prepareFuelSchedule(PASS_ENGINE_PARAMETER_F);
|
||||
|
|
|
@ -109,7 +109,7 @@ int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) {
|
|||
}
|
||||
|
||||
percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
floatms_t totalPerCycle = getFuelMs(rpm PASS_ENGINE_PARAMETER) * getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
floatms_t totalPerCycle = getInjectionDuration(rpm PASS_ENGINE_PARAMETER) * getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
floatms_t engineCycleDuration = getCrankshaftRevolutionTimeMs(rpm) * (engineConfiguration->operationMode == TWO_STROKE ? 1 : 2);
|
||||
return 100 * totalPerCycle / engineCycleDuration;
|
||||
}
|
||||
|
@ -117,14 +117,14 @@ percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
/**
|
||||
* @returns Length of each individual fuel injection, in milliseconds
|
||||
*/
|
||||
floatms_t getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
float theoreticalInjectionLength;
|
||||
if (isCrankingR(rpm)) {
|
||||
theoreticalInjectionLength = getCrankingFuel(PASS_ENGINE_PARAMETER_F)
|
||||
/ getNumberOfInjections(engineConfiguration->crankingInjectionMode PASS_ENGINE_PARAMETER);
|
||||
} else {
|
||||
float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
|
||||
float fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
|
||||
floatms_t baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
|
||||
floatms_t fuelPerCycle = getRunningFuel(baseFuel, rpm PASS_ENGINE_PARAMETER);
|
||||
theoreticalInjectionLength = fuelPerCycle
|
||||
/ getNumberOfInjections(engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ floatms_t getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_S);
|
|||
float getCltCorrection(float clt DECLARE_ENGINE_PARAMETER_S);
|
||||
floatms_t getCrankingFuel(DECLARE_ENGINE_PARAMETER_F);
|
||||
floatms_t getCrankingFuel3(float coolantTemperature, uint32_t revolutionCounterSinceStart DECLARE_ENGINE_PARAMETER_S);
|
||||
floatms_t getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_S);
|
||||
|
||||
#endif /* FUEL_MAP_H_ */
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include "efilib.h"
|
||||
#include "interpolation.h"
|
||||
|
||||
void setTableBin2(float array[], int size, float l, float r, float precision) {
|
||||
void setTableBin2(float array[], int size, float from, float to, float precision) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
float value = interpolateMsg("setTable", 0, l, size - 1, r, i);
|
||||
float value = interpolateMsg("setTable", 0, from, size - 1, to, i);
|
||||
/**
|
||||
* rounded values look nicer, also we want to avoid precision mismatch with Tuner Studio
|
||||
*/
|
||||
|
|
|
@ -147,8 +147,8 @@ typedef Map3D<BARO_CORR_SIZE, BARO_CORR_SIZE, float> baroCorr_Map3D_t;
|
|||
|
||||
void setRpmBin(float array[], int size, float idleRpm, float topRpm);
|
||||
|
||||
void setTableBin(float array[], int size, float l, float r);
|
||||
void setTableBin2(float array[], int size, float l, float r, float precision);
|
||||
void setTableBin(float array[], int size, float from, float to);
|
||||
void setTableBin2(float array[], int size, float from, float to, float precision);
|
||||
void setRpmTableBin(float array[], int size);
|
||||
|
||||
#endif /* TABLE_HELPER_H_ */
|
||||
|
|
|
@ -207,7 +207,7 @@ static ALWAYS_INLINE void handleFuel(bool limitedFuel, uint32_t eventIndex, int
|
|||
ENGINE(tpsAccelEnrichment.onNewValue(getTPS(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER));
|
||||
ENGINE(engineLoadAccelEnrichment.onEngineCycle(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
ENGINE(fuelMs) = getFuelMs(rpm PASS_ENGINE_PARAMETER) * CONFIG(globalFuelCorrection);
|
||||
ENGINE(fuelMs) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER) * CONFIG(globalFuelCorrection);
|
||||
|
||||
for (int injEventIndex = 0; injEventIndex < injectionEvents->size; injEventIndex++) {
|
||||
InjectionEvent *event = &injectionEvents->elements[injEventIndex];
|
||||
|
@ -542,7 +542,7 @@ static void showMainInfo(Engine *engine) {
|
|||
int rpm = engine->rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F);
|
||||
float el = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
|
||||
scheduleMsg(logger, "rpm %d engine_load %f", rpm, el);
|
||||
scheduleMsg(logger, "fuel %fms timing %f", getFuelMs(rpm PASS_ENGINE_PARAMETER), engine->engineState.timingAdvance);
|
||||
scheduleMsg(logger, "fuel %fms timing %f", getInjectionDuration(rpm PASS_ENGINE_PARAMETER), engine->engineState.timingAdvance);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ static void testRusefiMethods(const int count) {
|
|||
|
||||
// start = currentTimeMillis();
|
||||
// for (int i = 0; i < count; i++)
|
||||
// tempi += getFuelMs(1200, NULL); // todo
|
||||
// tempi += getInjectionDuration(1200, NULL); // todo
|
||||
// time = currentTimeMillis() - start;
|
||||
// if (tempi != 0)
|
||||
// scheduleMsg(logger, "Finished %d iterations of getFuelMs in %dms", count, time);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "fuel_math.h"
|
||||
#include "accel_enrichment.h"
|
||||
#include "thermistors.h"
|
||||
#include "advance_map.h"
|
||||
|
||||
extern int timeNow;
|
||||
|
||||
|
@ -52,16 +53,21 @@ EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persiste
|
|||
initThermistors(NULL PASS_ENGINE_PARAMETER);
|
||||
// this is needed to have valid CLT and IAT.
|
||||
engine->updateSlowSensors(PASS_ENGINE_PARAMETER_F);
|
||||
prepareTimingMap(PASS_ENGINE_PARAMETER_F);
|
||||
}
|
||||
|
||||
void EngineTestHelper::fireTriggerEvents2(int count, int duration) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
timeNow += duration;
|
||||
board_configuration_s * boardConfiguration = &engine.engineConfiguration->bc;
|
||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
||||
timeNow += duration;
|
||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
void EngineTestHelper::fireTriggerEvents(int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
timeNow += 5000; // 5ms
|
||||
board_configuration_s * boardConfiguration = &engine.engineConfiguration->bc;
|
||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_RISING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
||||
timeNow += 5000;
|
||||
engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, &engine, engine.engineConfiguration, &persistentConfig, boardConfiguration);
|
||||
}
|
||||
fireTriggerEvents2(count, 5000); // 5ms
|
||||
}
|
||||
|
||||
void EngineTestHelper::initTriggerShapeAndRpmCalculator() {
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
EngineTestHelper(engine_type_e engineType);
|
||||
void initTriggerShapeAndRpmCalculator();
|
||||
void fireTriggerEvents(int count);
|
||||
void fireTriggerEvents2(int count, int duration);
|
||||
|
||||
persistent_config_s persistentConfig;
|
||||
engine_configuration2_s ec2;
|
||||
|
|
|
@ -68,7 +68,6 @@ void testFuelMap(void) {
|
|||
|
||||
// because all the correction tables are zero
|
||||
printf("*************************************************** getRunningFuel 1\r\n");
|
||||
prepareTimingMap(PASS_ENGINE_PARAMETER_F);
|
||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
|
||||
float baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
|
||||
assertEqualsM("base fuel", 5.05, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
|
||||
|
|
|
@ -321,9 +321,6 @@ void testRpmCalculator(void) {
|
|||
triggerCallbackInstance.init(ð.engine);
|
||||
eth.engine.triggerCentral.addEventListener(mainTriggerCallback, "main loop", ð.engine);
|
||||
|
||||
// engine.rpmCalculator = ð.rpmState;
|
||||
prepareTimingMap(PASS_ENGINE_PARAMETER_F);
|
||||
|
||||
assertEqualsM("queue size/0", 0, schedulingQueue.size());
|
||||
|
||||
debugSignalExecutor = true;
|
||||
|
@ -588,5 +585,17 @@ void testFuelSchedulerBug299(void) {
|
|||
|
||||
assertEqualsM("CLT", 70, engine->engineState.clt);
|
||||
|
||||
engineConfiguration->trigger.type = TT_ONE;
|
||||
incrementGlobalConfigurationVersion();
|
||||
|
||||
eth.initTriggerShapeAndRpmCalculator();
|
||||
|
||||
assertEqualsM("RPM=0", 0, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
eth.fireTriggerEvents2(2, MS2US(50));
|
||||
|
||||
assertEqualsM("RPM", 1200, eth.engine.rpmCalculator.getRpm(PASS_ENGINE_PARAMETER_F));
|
||||
|
||||
assertEqualsM("fuel", 4.07, engine->fuelMs);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue