auto-sync

This commit is contained in:
rusEfi 2017-01-05 21:12:06 -05:00
parent 421235be41
commit 54873240ce
11 changed files with 55 additions and 11 deletions

View File

@ -527,14 +527,17 @@ static OutputPin communicationPin;
OutputPin warningPin;
OutputPin runningPin;
static OutputPin *leds[] = { &warningPin, &runningPin, &enginePins.errorLedPin, &communicationPin, &enginePins.checkEnginePin };
static OutputPin *leds[] = { &warningPin, &runningPin, &enginePins.checkEnginePin,
&enginePins.errorLedPin, &communicationPin, &enginePins.checkEnginePin };
extern pin_output_mode_e DEFAULT_OUTPUT;
static void initStatisLeds() {
static void initStatusLeds(void) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
outputPinRegisterExt2("led: comm status", &communicationPin,
engineConfiguration->communicationPin, &DEFAULT_OUTPUT);
// we initialize this here so that we can blink it on start-up
outputPinRegisterExt2("MalfunctionIndicator", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
#endif
#if EFI_WARNING_LED || defined(__DOXYGEN__)
@ -829,7 +832,7 @@ void startStatusThreads(Engine *engine) {
// todo: refactoring needed, this file should probably be split into pieces
chThdCreateStatic(lcdThreadStack, sizeof(lcdThreadStack), NORMALPRIO, (tfunc_t) lcdThread, engine);
#if EFI_PROD_CODE || defined(__DOXYGEN__)
initStatisLeds();
initStatusLeds();
chThdCreateStatic(blinkingStack, sizeof(blinkingStack), NORMALPRIO, (tfunc_t) blinkingThread, NULL);
#endif /* EFI_PROD_CODE */
}

View File

@ -27,6 +27,8 @@
EXTERN_ENGINE;
extern TunerStudioOutputChannels tsOutputChannels;
static ign_Map3D_t advanceMap("advance");
static ign_Map3D_t iatAdvanceCorrectionMap("iat corr");
@ -80,8 +82,14 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
} else {
iatCorrection = iatAdvanceCorrectionMap.getValue((float) rpm, engine->engineState.iat);
}
if (engineConfiguration->debugMode == DBG_TIMING) {
tsOutputChannels.debugFloatField1 = iatCorrection;
tsOutputChannels.debugFloatField2 = engine->engineState.cltTimingCorrection;
}
float result = advanceMap.getValue((float) rpm, engineLoad) + iatCorrection
float result = advanceMap.getValue((float) rpm, engineLoad)
+ iatCorrection
+ engine->engineState.cltTimingCorrection
// todo: uncomment once we get useable knock - engine->knockCount
;
engine->m.advanceLookupTime = GET_TIMESTAMP() - engine->m.beforeAdvance;

View File

@ -139,6 +139,7 @@ EngineState::EngineState() {
targetAFR = 0;
tpsAccelEnrich = 0;
tChargeK = 0;
cltTimingCorrection = 0;
runningFuel = baseFuel = currentVE = 0;
timeOfPreviousWarning = -10;
baseTableFuel = iat = iatFuelCorrection = 0;
@ -188,9 +189,11 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
#endif
} else {
cltFuelCorrection = getCltCorrection(clt PASS_ENGINE_PARAMETER);
cltFuelCorrection = getCltFuelCorrection(clt PASS_ENGINE_PARAMETER);
}
cltTimingCorrection = getCltTimingCorrection(clt PASS_ENGINE_PARAMETER);
engineNoiseHipLevel = interpolate2d(rpm, engineConfiguration->knockNoiseRpmBins,
engineConfiguration->knockNoise, ENGINE_NOISE_CURVE_SIZE);

View File

@ -91,6 +91,9 @@ public:
int lastErrorCode;
efitimesec_t timeOfPreviousWarning;
/**
* speed-density logic, calculated air mass in gramms
*/
float airMass;
float engineNoiseHipLevel;
@ -118,6 +121,8 @@ public:
*/
angle_t dwellAngle;
angle_t cltTimingCorrection;
// fuel-related;
float iatFuelCorrection;
float cltFuelCorrection;

View File

@ -174,12 +174,19 @@ void prepareFuelMap(DECLARE_ENGINE_PARAMETER_F) {
/**
* @brief Engine warm-up fuel correction.
*/
float getCltCorrection(float clt DECLARE_ENGINE_PARAMETER_S) {
float getCltFuelCorrection(float clt DECLARE_ENGINE_PARAMETER_S) {
if (cisnan(clt))
return 1; // this error should be already reported somewhere else, let's just handle it
return interpolate2d(clt, config->cltFuelCorrBins, config->cltFuelCorr, CLT_CURVE_SIZE) / PERCENT_MULT;
}
angle_t getCltTimingCorrection(float clt DECLARE_ENGINE_PARAMETER_S) {
if (cisnan(clt))
return 0; // this error should be already reported somewhere else, let's just handle it
return interpolate2d(clt, engineConfiguration->cltTimingBins, engineConfiguration->cltTimingExtra, CLT_TIMING_CURVE_SIZE);
}
float getIatCorrection(float iat DECLARE_ENGINE_PARAMETER_S) {
if (cisnan(iat))
return 1; // this error should be already reported somewhere else, let's just handle it

View File

@ -30,7 +30,8 @@ int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S);
angle_t getinjectionOffset(float rpm DECLARE_ENGINE_PARAMETER_S);
float getIatCorrection(float iat DECLARE_ENGINE_PARAMETER_S);
floatms_t getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_S);
float getCltCorrection(float clt DECLARE_ENGINE_PARAMETER_S);
float getCltFuelCorrection(float clt DECLARE_ENGINE_PARAMETER_S);
angle_t getCltTimingCorrection(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 getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S);

View File

@ -652,7 +652,7 @@ typedef enum {
AUX_PID_1 = 7,
DBG_VVT = 8,
DBG_POST_CRANKING_ENRICH = 9,
DM_10 = 10,
DBG_TIMING = 10,
DM_11 = 11,
DM_12 = 12,
DM_13 = 13,

View File

@ -110,7 +110,6 @@ void initOutputPins(void) {
// outputPinRegister("ext led 2", LED_EXT_2, EXTRA_LED_2_PORT, EXTRA_LED_2_PIN);
// outputPinRegister("ext led 3", LED_EXT_3, EXTRA_LED_2_PORT, EXTRA_LED_3_PIN);
// outputPinRegister("alive1", LED_DEBUG, GPIOD, 6);
outputPinRegisterExt2("MalfunctionIndicator", &enginePins.checkEnginePin, boardConfiguration->malfunctionIndicatorPin, &DEFAULT_OUTPUT);
// todo: are these needed here? todo: make configurable
// outputPinRegister("spi CS1", SPI_CS_1, SPI_CS1_PORT, SPI_CS1_PIN);

View File

@ -42,7 +42,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Jan 02 18:37:17 EST 2017
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Jan 05 20:49:12 EST 2017
pageSize = 16376
page = 1
@ -980,6 +980,14 @@ fileVersion = { 20161225 }
yBins = iatFuelCorr
gauge = IATGauge
curve = cltTimingCorrCurve, "Warmup timing correction"
columnLabel = "Coolant", "Extra"
xAxis = -40, 120, 10
yAxis = 0, 50, 100
xBins = cltTimingBins, coolant
yBins = cltTimingExtra
gauge = CLTGauge
curve = cltFuelCorrCurve, "Warmup fuel manual Multiplier"
columnLabel = "Coolant", "Multiplier"
xAxis = -40, 120, 10
@ -1388,6 +1396,7 @@ fileVersion = { 20161225 }
subMenu = cltFuelCorrCurve, "Warmup fuel manual Multiplier", 0, {useWarmupPidAfr == 0}
subMenu = warmupTargetAfrCurve, "Warmup fuel auto correction AFR target", 0, {useWarmupPidAfr == 1}
subMenu = cltIdleCurve, "Warmup IAC position manual Multiplier"
subMenu = cltTimingCorrCurve, "Warmup timing correction"
subMenu = std_separator
subMenu = fuelTableTbl, "Fuel Table", 0, {fuelAlgorithm != 3}
subMenu = veTableTbl, "VE Table", 0, {fuelAlgorithm == 3}

View File

@ -925,6 +925,14 @@ fileVersion = { 20161225 }
yBins = iatFuelCorr
gauge = IATGauge
curve = cltTimingCorrCurve, "Warmup timing correction"
columnLabel = "Coolant", "Extra"
xAxis = -40, 120, 10
yAxis = 0, 50, 100
xBins = cltTimingBins, coolant
yBins = cltTimingExtra
gauge = CLTGauge
curve = cltFuelCorrCurve, "Warmup fuel manual Multiplier"
columnLabel = "Coolant", "Multiplier"
xAxis = -40, 120, 10
@ -1333,6 +1341,7 @@ fileVersion = { 20161225 }
subMenu = cltFuelCorrCurve, "Warmup fuel manual Multiplier", 0, {useWarmupPidAfr == 0}
subMenu = warmupTargetAfrCurve, "Warmup fuel auto correction AFR target", 0, {useWarmupPidAfr == 1}
subMenu = cltIdleCurve, "Warmup IAC position manual Multiplier"
subMenu = cltTimingCorrCurve, "Warmup timing correction"
subMenu = std_separator
subMenu = fuelTableTbl, "Fuel Table", 0, {fuelAlgorithm != 3}
subMenu = veTableTbl, "VE Table", 0, {fuelAlgorithm == 3}

View File

@ -90,7 +90,7 @@ void testFuelMap(void) {
assertEquals(NAN, getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F));
float iatCorrection = getIatCorrection(-KELV PASS_ENGINE_PARAMETER);
assertEqualsM("IAT", 2, iatCorrection);
float cltCorrection = getCltCorrection(getCoolantTemperature(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER);
float cltCorrection = getCltFuelCorrection(getCoolantTemperature(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER);
assertEqualsM("CLT", 1, cltCorrection);
float injectorLag = getInjectorLag(getVBatt(PASS_ENGINE_PARAMETER_F) PASS_ENGINE_PARAMETER);
assertEqualsM("injectorLag", 0, injectorLag);