Cranking defaults (#2787)

* defaults

* more

* cranking fuel

* cranking timing

* cranking time digits

* ugh these tests shouldn't depend on defaults
This commit is contained in:
Matthew Kennedy 2021-06-01 22:21:36 -07:00 committed by GitHub
parent 14bb5dd6eb
commit 790ac08a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 53 additions and 80 deletions

View File

@ -170,9 +170,6 @@ static void miataNAcommonEngineSettings(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->manIdlePosition = 34;
miataNA_setCrankingCycleBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setCrankingFuelBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setCltIdleCorrBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setCltIdleRpmBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setIacCoastingBins(PASS_CONFIG_PARAMETER_SIGNATURE);

View File

@ -10,16 +10,6 @@
EXTERN_CONFIG;
// todo: use these defaults wider? make them global defaults maybe?
static const float hardCodedcrankingCycleBins[8] = {1.0, 16.0, 35.0, 54.0, 76.0, 102.0, 132.0, 169.0};
static const float hardCodedcrankingCycleCoef[8] = {1.9800034, 1.800003, 1.5999985, 1.4000015, 1.2300034, 1.1200027, 1.050003, 1.0199966};
/* Generated by TS2C on Thu Jul 30 00:03:20 EDT 2020*/
void miataNA_setCrankingCycleBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
copyArray(config->crankingCycleBins, hardCodedcrankingCycleBins);
copyArray(config->crankingCycleCoef, hardCodedcrankingCycleCoef);
}
// todo: use these defaults wider? make them global defaults maybe?
static const float hardCodedcrankingFuelBins[8] = {-20.0, -10.0, 3.6799927, 22.77002, 34.049805, 49.95996, 65.0, 90.0};
static const float hardCodedcrankingFuelCoef[8] = {2.7999878, 2.2000122, 1.6900024, 1.2900009, 1.199997, 1.050003, 1.0, 1.0};

View File

@ -369,9 +369,6 @@ static void setMazdaMiataEngineNB2Defaults(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->idleRpmPid.dFactor = 5;
engineConfiguration->idleRpmPid.periodMs = 10;
miataNA_setCrankingCycleBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setCrankingFuelBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setCltIdleCorrBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setCltIdleRpmBins(PASS_CONFIG_PARAMETER_SIGNATURE);
miataNA_setIacCoastingBins(PASS_CONFIG_PARAMETER_SIGNATURE);

View File

@ -43,27 +43,6 @@ static int minCrankingRpm = 0;
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
static const float iatTimingRpmBins[IGN_LOAD_COUNT] = {880, 1260, 1640, 2020, 2400, 2780, 3000, 3380, 3760, 4140, 4520, 5000, 5700, 6500, 7200, 8000};
//880 1260 1640 2020 2400 2780 3000 3380 3760 4140 4520 5000 5700 6500 7200 8000
static const int8_t defaultIatTiming[16][16] = {
// NOTE: this table is stored in tenths of a degree (so we can use int8_t instead of float), converted upon copy (see copyTable call below)
{ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20 },
{ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20 },
{ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20 },
{ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 20, 20, 20, 20 },
{ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 20, 20, 20, 20, 20 },
{ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 2},
{ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9},
{ -33, -34, -49, -49, -49, -49, -44, -44, -44, -44, -44, -9, -9, -9, -9, -9},
{ -44, -49, -59, -59, -59, -59, -49, -49, -49, -49, -49, -24, -24, -24, -24, -24},
{ -44, -49, -59, -59, -59, -59, -49, -49, -49, -49, -49, -29, -29, -29, -29, -29},
{ -44, -49, -59, -59, -59, -59, -49, -49, -49, -49, -49, -39, -39, -39, -39, -39},
{ -44, -49, -59, -59, -59, -59, -49, -49, -49, -49, -49, -39, -39, -39, -39, -39},
{ -44, -49, -59, -59, -59, -59, -49, -49, -49, -49, -49, -39, -39, -39, -39, -39},
};
#endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */
/**
@ -244,8 +223,30 @@ void setDefaultIatTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
setLinearCurve(config->ignitionIatCorrLoadBins, /*from*/CLT_CURVE_RANGE_FROM, 110, 1);
#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
copyArray(config->ignitionIatCorrRpmBins, iatTimingRpmBins);
// defaultIatTiming stored in tenths of a degree, see table above
copyTable(config->ignitionIatCorrTable, defaultIatTiming, 0.1f);
static constexpr int8_t defaultIatCorr[16] = {
4, // -40 deg
4,
3,
2,
0, // 0 deg
0,
0,
0,
0,
-1, // 50 deg
-2,
-4,
-4,
-4,
-4,
-4, // 110 deg
};
// Set each row of the table to the same value (no rpm dependence by default)
for (size_t i = 0; i < efi::size(defaultIatCorr); i++) {
setArrayValues(config->ignitionIatCorrTable[i], (float)defaultIatCorr[i]);
}
#else
setLinearCurve(config->ignitionIatCorrLoadBins, /*from*/0, 6000, 1);
#endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */

View File

@ -427,9 +427,9 @@ static void setDefaultCrankingSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
2.8,
2.2,
1.8,
1.5,
1.0,
1.0,
1.55,
1.3,
1.1,
1.0,
1.0
};
@ -440,7 +440,7 @@ static void setDefaultCrankingSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
-20,
-10,
5,
30,
20,
35,
50,
65,
@ -450,29 +450,15 @@ static void setDefaultCrankingSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// Cranking cycle compensation
static const float crankingCycleCoef[] = {
1.5,
1.35,
1.05,
0.75,
0.5,
0.5,
0.5,
0.5
};
copyArray(config->crankingCycleCoef, crankingCycleCoef);
// Whole table is 1.0, except first two values are steeper
setArrayValues(config->crankingCycleCoef, 1.0f);
config->crankingCycleCoef[0] = 2.0f;
config->crankingCycleCoef[1] = 1.3f;
static const float crankingCycleBins[] = {
4,
8,
12,
16,
74,
75,
76,
77
};
copyArray(config->crankingCycleBins, crankingCycleBins);
// X values are simply counting up cycle number starting at 1
for (size_t i = 0; i < efi::size(config->crankingCycleBins); i++) {
config->crankingCycleBins[i] = i + 1;
}
// Cranking ignition timing
static const float advanceValues[] = { 0, 0, 0, 0 };
@ -487,6 +473,8 @@ static void setDefaultCrankingSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif
engineConfiguration->postCrankingDurationSec = 10;
CONFIG(crankingTimingAngle) = 6;
}
/**

View File

@ -1348,7 +1348,7 @@ tle8888_mode_e tle8888mode;
float unused244_3;;"units", 1, 0, -20, 100, 0
float unused2432;;"units", 1, 0, -20, 100, 0
float postCrankingFactor;+Fuel multiplier (enrichment) immediately after engine start;"mult", 1, 0, 1, 3, 2
float postCrankingDurationSec;+Time over which to taper out after start enrichment;"seconds", 1, 0, 0, 30, 2
float postCrankingDurationSec;+Time over which to taper out after start enrichment;"seconds", 1, 0, 0, 30, 0
ThermistorConf auxTempSensor1;todo: finish implementation #332
ThermistorConf auxTempSensor2;todo: finish implementation #332
uint8_t[6] unused2508;;"units", 1, 0, -20, 100, 0

View File

@ -78,16 +78,16 @@ TEST(misc, testFuelMap) {
// Should use 20 degree correction in case of failed sensor
Sensor::resetMockValue(SensorType::Clt);
EXPECT_NEAR( 9.71999, getCrankingFuel3(2, 0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
EXPECT_NEAR(12.4, getCrankingFuel3(2, 0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
Sensor::setMockValue(SensorType::Clt, 0);
EXPECT_NEAR(11.6, getCrankingFuel3(2, 4 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
EXPECT_NEAR(7.7333, getCrankingFuel3(2, 4 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
Sensor::setMockValue(SensorType::Clt, 8);
EXPECT_NEAR(5.82120, getCrankingFuel3(2, 15 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
EXPECT_NEAR(7, getCrankingFuel3(2, 15 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
Sensor::setMockValue(SensorType::Clt, 70);
EXPECT_NEAR(6.000, getCrankingFuel3(2, 0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
EXPECT_NEAR(8, getCrankingFuel3(2, 0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
Sensor::setMockValue(SensorType::Clt, 70);
EXPECT_NEAR(2.41379, getCrankingFuel3(2, 50 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
EXPECT_NEAR(4, getCrankingFuel3(2, 50 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
}

View File

@ -25,8 +25,8 @@ TEST(issues, issueOneCylinderSpecialCase968) {
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);
ASSERT_EQ( 2, engine->executor.size()) << "first revolution(s)";
eth.assertEvent5("spark up#0", 0, (void*)turnSparkPinHigh, -43500);
eth.assertEvent5("spark down#0", 1, (void*)fireSparkAndPrepareNextSchedule, -37500);
eth.assertEvent5("spark up#0", 0, (void*)turnSparkPinHigh, -44293);
eth.assertEvent5("spark down#0", 1, (void*)fireSparkAndPrepareNextSchedule, -38293);
eth.fireTriggerEvents2(/* count */ 1, 50 /* ms */);

View File

@ -25,7 +25,7 @@ TEST(engine, testPlainCrankingWithoutAdvancedFeatures) {
// two simultaneous injections
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
eth.assertEvent5("sim start", 0, (void*)startSimultaniousInjection, 100000 - 1875);
eth.assertEvent5("sim start", 0, (void*)startSimultaniousInjection, 100000 - 1625);
// -1 because ugh floating point math
eth.assertEvent5("sim end", 1, (void*)endSimultaniousInjection, 100000 - 1);
}

View File

@ -50,8 +50,8 @@ TEST(cranking, testFasterEngineSpinningUp) {
// test if ignition mode is temporary changed to wasted spark, if set to individual coils
ASSERT_EQ(IM_WASTED_SPARK, getCurrentIgnitionMode(PASS_ENGINE_PARAMETER_SIGNATURE));
// check real events
eth.assertEvent5("inj start#1", 0, (void*)startSimultaniousInjection, 98125);
eth.assertEvent5("inj end#1", 1, (void*)endSimultaniousInjection, 99999);
eth.assertEvent5("inj start#1", 0, (void*)startSimultaniousInjection, 97500);
eth.assertEvent5("inj end#1", 1, (void*)endSimultaniousInjection, 100000);
// skip the rest of the cycle
eth.fireFall(200);
@ -72,7 +72,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// two simultaneous injections
ASSERT_EQ( 4, engine->executor.size()) << "plain#2";
// check real events
eth.assertEvent5("inj start#2", 0, (void*)startSimultaniousInjection, 148125);
eth.assertEvent5("inj start#2", 0, (void*)startSimultaniousInjection, 148375);
eth.assertEvent5("inj end#2", 1, (void*)endSimultaniousInjection, 149999);
// skip, clear & advance 1 more revolution at higher RPM
@ -92,7 +92,7 @@ TEST(cranking, testFasterEngineSpinningUp) {
// check real events for sequential injection
// Note: See addFuelEvents() fix inside setRpmValue()!
eth.assertEvent5("inj start#3", 0, (void*)turnInjectionPinHigh, -31875);
eth.assertEvent5("inj start#3", 0, (void*)turnInjectionPinHigh, -31625);
eth.assertEvent5("inj end#3", 1, (void*)turnInjectionPinLow, -30001);
}

View File

@ -188,10 +188,10 @@ TEST(misc, test1995FordInline6TriggerDecoder) {
IgnitionEventList *ecl = &engine->ignitionEvents;
ASSERT_EQ( 1, ecl->isReady) << "ford inline ignition events size";
ASSERT_EQ( 0, ecl->elements[0].dwellPosition.triggerEventIndex) << "event index";
ASSERT_NEAR(7.8621, ecl->elements[0].dwellPosition.angleOffsetFromTriggerEvent, EPS4D) << "angle offset#1";
ASSERT_NEAR(7.9579, ecl->elements[0].dwellPosition.angleOffsetFromTriggerEvent, EPS4D) << "angle offset#1";
ASSERT_EQ( 10, ecl->elements[5].dwellPosition.triggerEventIndex) << "event index";
ASSERT_NEAR(7.8621, ecl->elements[5].dwellPosition.angleOffsetFromTriggerEvent, EPS4D) << "angle offset#2";
ASSERT_NEAR(7.9579, ecl->elements[5].dwellPosition.angleOffsetFromTriggerEvent, EPS4D) << "angle offset#2";
ASSERT_FLOAT_EQ(0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER_SUFFIX)) << "running dwell";