rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
default_ignition.cpp File Reference

Functions

static void setDefaultMultisparkParameters ()
 
static void setDefaultIatTimingCorrection ()
 
static void setDefaultCltTimingCorrection ()
 
static void setDefaultTrailingSparkTable ()
 
static float getAdvanceForRpm (float rpm, float advanceMax)
 
float getInitialAdvance (float rpm, float map, float advanceMax)
 
static void buildTimingMap (float advanceMax)
 
void setDefaultIgnition ()
 

Function Documentation

◆ buildTimingMap()

static void buildTimingMap ( float  advanceMax)
static

this method builds a good-enough base timing advance map bases on a number of heuristics

good enough (but do not trust us!) default timing map in case of MAP-based engine load

Definition at line 87 of file default_ignition.cpp.

87 {
88 if (engineConfiguration->fuelAlgorithm != engine_load_mode_e::LM_SPEED_DENSITY) {
89 warning(ObdCode::CUSTOM_WRONG_ALGORITHM, "wrong algorithm for MAP-based timing");
90 return;
91 }
92 /**
93 * good enough (but do not trust us!) default timing map in case of MAP-based engine load
94 */
95 for (int loadIndex = 0; loadIndex < IGN_LOAD_COUNT; loadIndex++) {
96 float load = config->ignitionLoadBins[loadIndex];
97 for (int rpmIndex = 0;rpmIndex<IGN_RPM_COUNT;rpmIndex++) {
98 float rpm = config->ignitionRpmBins[rpmIndex];
99 config->ignitionTable[loadIndex][rpmIndex] = getInitialAdvance(rpm, load, advanceMax);
100 }
101 }
102}
float getInitialAdvance(float rpm, float map, float advanceMax)
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
bool warning(ObdCode code, const char *fmt,...)
@ CUSTOM_WRONG_ALGORITHM
scaled_channel< int16_t, 10, 1 > ignitionTable[IGN_LOAD_COUNT][IGN_RPM_COUNT]

Referenced by setDefaultIgnition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdvanceForRpm()

static float getAdvanceForRpm ( float  rpm,
float  advanceMax 
)
static

Definition at line 61 of file default_ignition.cpp.

61 {
62 if (rpm >= 3000) {
63 return advanceMax;
64 }
65
66 if (rpm < 600) {
67 return 10;
68 }
69
70 return interpolateMsg("advance", 600, 10, 3000, advanceMax, rpm);
71}
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x)
Linear interpolation by two points.

Referenced by getInitialAdvance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInitialAdvance()

float getInitialAdvance ( float  rpm,
float  map,
float  advanceMax 
)

this method is used to build default advance map

Definition at line 75 of file default_ignition.cpp.

75 {
76 map = std::min(map, 100.0f);
77 float advance = getAdvanceForRpm(rpm, advanceMax);
78
79 if (rpm >= 3000)
80 return round10(advance + 0.1 * (100 - map));
81 return round10(advance + 0.1 * (100 - map) * rpm / 3000);
82}
static float getAdvanceForRpm(float rpm, float advanceMax)

Referenced by buildTimingMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDefaultCltTimingCorrection()

static void setDefaultCltTimingCorrection ( )
static

Definition at line 37 of file default_ignition.cpp.

37 {
38 setLinearCurve(config->ignitionCltCorrLoadBins, /*from=*/ 0, /*to*/ 140, 1);
40
41#if CLT_TIMING_CURVE_SIZE == 5
42 for (size_t i = 0; i < CLT_TIMING_CURVE_SIZE; i++) {
43 // huh? use setArrayValues? and we probably get all zeros by default anyway?
44 copyArray(config->ignitionCltCorrTable[i], {0.0, 0.0, 0.0, 0.0, 0.0});
45 }
46#endif
47}
scaled_channel< int16_t, 10, 1 > ignitionCltCorrTable[CLT_TIMING_CURVE_SIZE][CLT_TIMING_CURVE_SIZE]
scaled_channel< int16_t, 1, 1 > ignitionCltCorrTempBins[CLT_TIMING_CURVE_SIZE]
scaled_channel< uint8_t, 1, 5 > ignitionCltCorrLoadBins[CLT_TIMING_CURVE_SIZE]
void setLinearCurve(TValue(&array)[TSize], float from, float to, float precision=0.01f)

Referenced by setDefaultIgnition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDefaultIatTimingCorrection()

static void setDefaultIatTimingCorrection ( )
static

Definition at line 18 of file default_ignition.cpp.

18 {
19 setLinearCurve(config->ignitionIatCorrLoadBins, /*from=*/ 0, /*to*/ 140, 1);
20#if IAT_IGN_CORR_COUNT == 8
21 copyArray(config->ignitionIatCorrTempBins, { -40, 0, 10, 20, 30, 40, 50, 60});
22
23 // top 5 rows are the same
24 for (size_t i = 3; i < IAT_IGN_CORR_COUNT; i++) {
25 // 40 50 60 deg C
26 copyArray(config->ignitionIatCorrTable[i], {0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -2.0, -3.0});
27 }
28
29 // 6th row tapers out
30 // 40 50 60 deg C
31 copyArray(config->ignitionIatCorrTable[2], {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -2.0});
32#else
33 setLinearCurve(config->ignitionIatCorrTempBins, /*from=*/ -40, /*to*/ 60, 1);
34#endif
35}
scaled_channel< int16_t, 10, 1 > ignitionIatCorrTable[IAT_IGN_CORR_LOAD_COUNT][IAT_IGN_CORR_COUNT]
scaled_channel< uint8_t, 1, 5 > ignitionIatCorrLoadBins[IAT_IGN_CORR_LOAD_COUNT]

Referenced by setDefaultIgnition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDefaultIgnition()

void setDefaultIgnition ( )

Definition at line 104 of file default_ignition.cpp.

104 {
105 // Ignition base settings
107
108 engineConfiguration->timingMode = TM_DYNAMIC;
110
113
114 // Dwell table - a bit conservative but reasonable
116
119
120 // Multispark
122
123 // Ignition advance table
125 setTimingRpmBin(800, 7000);
126 buildTimingMap(35);
127
129
130 // CLT correction
132
133 // IAT correction
135
136 // Give default axes for cylinder trim tables
137#if IGN_TRIM_SIZE == 4
138 copyArray(config->ignTrimRpmBins, { 1000, 3000, 5000, 7000 });
139 copyArray(config->ignTrimLoadBins, { 20, 50, 80, 100 });
140#else
143#endif
144
145 // Default axes for VE blends
146 for (size_t i = 0; i < efi::size(config->ignBlends); i++) {
147 auto& blend = config->ignBlends[i];
148 setLinearCurve(blend.loadBins, 0, 100, 10);
149 setLinearCurve(blend.rpmBins, 0, 7000);
150
151 setLinearCurve(blend.blendBins, 0, 100);
152 setLinearCurve(blend.blendValues, 0, 100);
153 }
154}
static void setDefaultCltTimingCorrection()
static void setDefaultTrailingSparkTable()
static void buildTimingMap(float advanceMax)
static void setDefaultMultisparkParameters()
static void setDefaultIatTimingCorrection()
void setConstantDwell(floatms_t dwellMs)
Sets the same dwell time across the whole getRpm() range set dwell X.
void setTimingRpmBin(float from, float to)
scaled_channel< uint8_t, 10, 1 > dwellVoltageCorrVoltBins[DWELL_CURVE_SIZE]
scaled_channel< uint8_t, 50, 1 > dwellVoltageCorrValues[DWELL_CURVE_SIZE]
void setRpmTableBin(TValue(&array)[TSize])

Referenced by setDefaultEngineConfiguration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDefaultMultisparkParameters()

static void setDefaultMultisparkParameters ( )
static

Definition at line 7 of file default_ignition.cpp.

Referenced by setDefaultIgnition().

Here is the caller graph for this function:

◆ setDefaultTrailingSparkTable()

static void setDefaultTrailingSparkTable ( )
static

Definition at line 49 of file default_ignition.cpp.

49 {
52
53#if TRAILING_SPARK_SIZE == 4
54 for (size_t i = 0; i < TRAILING_SPARK_SIZE; i++) {
55 copyArray(config->trailingSparkTable[i], {7,9,10,12});
56 }
57#endif
58
59}
scaled_channel< int8_t, 10, 1 > trailingSparkTable[TRAILING_SPARK_SIZE][TRAILING_SPARK_SIZE]
scaled_channel< uint8_t, 1, 5 > trailingSparkLoadBins[TRAILING_SPARK_SIZE]
scaled_channel< uint8_t, 1, 50 > trailingSparkRpmBins[TRAILING_SPARK_SIZE]

Referenced by setDefaultIgnition().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.