auto-sync

This commit is contained in:
rusEfi 2015-04-29 09:12:15 -04:00
parent 10d957f73c
commit bfd767fbfd
9 changed files with 32 additions and 18 deletions

View File

@ -241,7 +241,7 @@ static void printState(void) {
// debugFloat(&logger, "table_spark", getAdvance(rpm, getMaf()), 2);
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER);
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
float baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
debugFloat(&logger, "fuel_base", baseFuel, 2);
// debugFloat(&logger, "fuel_iat", getIatCorrection(getIntakeAirTemperature()), 2);
@ -249,7 +249,7 @@ static void printState(void) {
debugFloat(&logger, "fuel_lag", engine->injectorLagMs, 2);
debugFloat(&logger, "fuel", getFuelMs(rpm PASS_ENGINE_PARAMETER), 2);
debugFloat(&logger, "timing", getAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER), 2);
debugFloat(&logger, "timing", engine->engineState.timingAdvance, 2);
// float map = getMap();
@ -412,7 +412,7 @@ static void showFuelInfo2(float rpm, float engineLoad) {
#if EFI_ENGINE_CONTROL
static void showFuelInfo(void) {
showFuelInfo2((float) getRpmE(engine), getEngineLoadT(PASS_ENGINE_PARAMETER));
showFuelInfo2((float) getRpmE(engine), getEngineLoadT(PASS_ENGINE_PARAMETER_F));
}
#endif
@ -541,7 +541,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
float coolant = getCoolantTemperature(PASS_ENGINE_PARAMETER_F);
float intake = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F);
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER);
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
float baseFuelMs = getBaseFuel(rpm PASS_ENGINE_PARAMETER);
// header
@ -605,7 +605,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->clutchUpState = engine->clutchUpState;
tsOutputChannels->clutchDownState = engine->clutchDownState;
tsOutputChannels->tCharge = getTCharge(rpm, tps, coolant, intake);
float timing = getAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER);
float timing = engine->engineState.timingAdvance;
tsOutputChannels->ignitionAdvance = timing > 360 ? timing - 720 : timing;
tsOutputChannels->sparkDwell = ENGINE(engineState.sparkDwell);
tsOutputChannels->baseFuel = baseFuelMs;

View File

@ -93,7 +93,7 @@ AccelEnrichmemnt::AccelEnrichmemnt() {
//static msg_t DiffEnrichmentThread(int param) {
// chRegSetThreadName("Diff Enrichment");
// while (TRUE) {
// instance.updateDiffEnrichment(engineConfiguration, getEngineLoadT(PASS_ENGINE_PARAMETER));
// instance.updateDiffEnrichment(engineConfiguration, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
// chThdSleepMilliseconds(100);
// }
//#if defined __GNUC__

View File

@ -1,5 +1,5 @@
/**
* @file advance_map.c
* @file advance_map.cpp
*
* @date Mar 27, 2013
* @author Andrey Belomutskiy, (c) 2012-2015

View File

@ -16,6 +16,7 @@
#include "trigger_central.h"
#include "fuel_math.h"
#include "engine_math.h"
#include "advance_map.h"
#if EFI_PROD_CODE
#include "injector_central.h"
@ -159,14 +160,23 @@ void Engine::watchdog() {
#endif
}
/**
* The idea of this method is to execute all heavy calculations in a lower-priority thread,
* so that trigger event handler/IO scheduler tasks are faster. Th
*/
void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
int rpm = rpmCalculator.rpmValue;
float engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
engineState.sparkDwell = getSparkDwellMsT(rpm PASS_ENGINE_PARAMETER);
// todo: move this field to engineState
dwellAngle = engineState.sparkDwell / getOneDegreeTimeMs(rpm);
engine->engineState.iatFuelCorrection = getIatCorrection(engine->engineState.iat PASS_ENGINE_PARAMETER);
engine->engineState.cltFuelCorrection = getCltCorrection(engine->engineState.clt PASS_ENGINE_PARAMETER);
engine->engineState.injectionAngle = getInjectionAngle(rpm PASS_ENGINE_PARAMETER);
engine->engineState.timingAdvance = getAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER);
}
StartupFuelPumping::StartupFuelPumping() {

View File

@ -95,6 +95,8 @@ public:
float iatFuelCorrection;
float cltFuelCorrection;
float injectorLag;
angle_t injectionAngle;
};
class RpmCalculator;

View File

@ -126,8 +126,8 @@ floatms_t getFuelMs(int rpm DECLARE_ENGINE_PARAMETER_S) {
}
floatms_t getRunningFuel(floatms_t baseFuel, int rpm DECLARE_ENGINE_PARAMETER_S) {
float iatCorrection = getIatCorrection(engine->engineState.iat PASS_ENGINE_PARAMETER);
float cltCorrection = getCltCorrection(engine->engineState.clt PASS_ENGINE_PARAMETER);
float iatCorrection = ENGINE(engineState.iatFuelCorrection);
float cltCorrection = ENGINE(engineState.cltFuelCorrection);
#if EFI_ACCEL_ENRICHMENT
float accelEnrichment = getAccelEnrichment();

View File

@ -165,7 +165,7 @@ void FuelSchedule::addFuelEvents(OutputSignalList *sourceList, injection_mode_e
* injection phase is scheduled by injection end, so we need to step the angle back
* for the duration of the injection
*/
float baseAngle = getInjectionAngle(engine->rpmCalculator.rpmValue PASS_ENGINE_PARAMETER)
float baseAngle = ENGINE(engineState.injectionAngle)
+ engineConfiguration->injectionAngle - MS2US(engine->fuelMs) / engine->rpmCalculator.oneDegreeUs;
switch (mode) {

View File

@ -283,16 +283,14 @@ static void ignitionCalc(int rpm DECLARE_ENGINE_PARAMETER_S) {
* Within one engine cycle all cylinders are fired with same timing advance.
* todo: one day we can control cylinders individually?
*/
float dwellMs = getSparkDwellMsT(rpm PASS_ENGINE_PARAMETER);
float dwellMs = ENGINE(engineState.sparkDwell);
if (cisnan(dwellMs) || dwellMs < 0) {
firmwareError("invalid dwell: %f at %d", dwellMs, rpm);
return;
}
float el = getEngineLoadT(PASS_ENGINE_PARAMETER_F);
engine->advance = -getAdvance(rpm, el PASS_ENGINE_PARAMETER);
engine->dwellAngle = dwellMs / getOneDegreeTimeMs(rpm);
// todo: eliminate this field
engine->advance = -ENGINE(engineState.timingAdvance);
}
extern OutputSignalList runningInjectonSignals CCM_OPTIONAL;
@ -436,10 +434,10 @@ void MainTriggerCallback::init(Engine *engine) {
static void showMainInfo(Engine *engine) {
#if EFI_PROD_CODE
int rpm = engine->rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F);
float el = getEngineLoadT(PASS_ENGINE_PARAMETER);
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),
getAdvance(rpm, el PASS_ENGINE_PARAMETER));
engine->engineState.timingAdvance);
#endif
}

View File

@ -15,6 +15,7 @@
#include "trigger_decoder.h"
#include "engine_test_helper.h"
#include "efiGpio.h"
#include "advance_map.h"
extern float testMafValue;
@ -70,6 +71,8 @@ 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));
@ -99,7 +102,8 @@ void testFuelMap(void) {
// 1005 * 2 for IAT correction
printf("*************************************************** getRunningFuel 2\r\n");
baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
baseFuel = getBaseTableFuel(eth.engine.engineConfiguration, 5, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
assertEqualsM("v1", 30150, getRunningFuel(baseFuel, 5 PASS_ENGINE_PARAMETER));
testMafValue = 0;