Tps-based Advance Table (#611)

* typedefs

* Impl. TPS-based Advance
This commit is contained in:
andreika-git 2018-09-26 11:13:16 +03:00 committed by rusefi
parent b6c2eceb3b
commit 967b852752
3 changed files with 17 additions and 2 deletions

View File

@ -32,6 +32,7 @@ extern TunerStudioOutputChannels tsOutputChannels;
#endif
static ign_Map3D_t advanceMap("advance");
static ign_tps_Map3D_t advanceTpsMap("advanceTps", 1.0 / ADVANCE_TPS_STORAGE_MULT);
static ign_Map3D_t iatAdvanceCorrectionMap("iat corr");
static int minCrankingRpm = 0;
@ -81,8 +82,14 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
if (isStep1Condition(rpm PASS_ENGINE_PARAMETER_SUFFIX)) {
return engineConfiguration->step1timing;
}
float advanceAngle = advanceMap.getValue((float) rpm, engineLoad);
float advanceAngle;
if (CONFIG(useTPSAdvanceTable)) {
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
advanceAngle = advanceTpsMap.getValue((float) rpm, tps);
} else {
advanceAngle = advanceMap.getValue((float) rpm, engineLoad);
}
// get advance from the separate table for Idle
if (CONFIG(useSeparateAdvanceForIdle)) {
@ -169,6 +176,8 @@ void setDefaultIatTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
void prepareTimingMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
advanceMap.init(config->ignitionTable, config->ignitionLoadBins,
config->ignitionRpmBins);
advanceTpsMap.init(CONFIG(ignitionTpsTable), CONFIG(ignitionTpsBins),
config->ignitionRpmBins);
iatAdvanceCorrectionMap.init(config->ignitionIatCorrTable, config->ignitionIatCorrLoadBins,
config->ignitionIatCorrRpmBins);
}

View File

@ -74,6 +74,7 @@ typedef uint8_t afr_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT];
// todo: merge these two types together? but these tables have different TS parameters like ranges etc
typedef float fuel_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT];
typedef float ignition_table_t[IGN_LOAD_COUNT][IGN_RPM_COUNT];
typedef int16_t ignition_tps_table_t[IGN_LOAD_COUNT][IGN_RPM_COUNT];
typedef float baro_corr_table_t[BARO_CORR_SIZE][BARO_CORR_SIZE];

View File

@ -139,9 +139,14 @@ void copy2DTable(const vType source[LOAD_BIN_SIZE][RPM_BIN_SIZE], vType destinat
* AFR value is packed into uint8_t with a multiplier of 10
*/
#define AFR_STORAGE_MULT 10
/**
* TPS-based Advance value is packed into int16_t with a multiplier of 100
*/
#define ADVANCE_TPS_STORAGE_MULT 100
typedef Map3D<FUEL_RPM_COUNT, FUEL_LOAD_COUNT, uint8_t> afr_Map3D_t;
typedef Map3D<IGN_RPM_COUNT, IGN_LOAD_COUNT, float> ign_Map3D_t;
typedef Map3D<IGN_RPM_COUNT, IGN_LOAD_COUNT, int16_t> ign_tps_Map3D_t;
typedef Map3D<FUEL_RPM_COUNT, FUEL_LOAD_COUNT, float> fuel_Map3D_t;
typedef Map3D<BARO_CORR_SIZE, BARO_CORR_SIZE, float> baroCorr_Map3D_t;