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

Detailed Description

Date
Mar 27, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file ignition_state.cpp.

Functions

angle_t getRunningAdvance (float rpm, float engineLoad)
 
angle_t getCltTimingCorrection (float engineLoad)
 
angle_t getAdvanceCorrections (float engineLoad)
 
angle_t getCrankingAdvance (float rpm, float engineLoad)
 
PUBLIC_API_WEAK_SOMETHING_WEIRD angle_t getCylinderIgnitionTrim (size_t cylinderNumber, float rpm, float ignitionLoad)
 
size_t getMultiSparkCount (float rpm)
 
void initIgnitionAdvanceControl ()
 

Variables

static Map3D< TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t > tcTimingDropTable {"tct"}
 
static Map3D< TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t > tcSparkSkipTable {"tcs"}
 

Function Documentation

◆ getAdvanceCorrections()

angle_t getAdvanceCorrections ( float  engineLoad)

Definition at line 164 of file ignition_state.cpp.

164 {
166
167 if (!iat) {
169 } else {
172 config->ignitionIatCorrLoadBins, engineLoad,
174 );
175 }
176
177#if EFI_IDLE_CONTROL
179
181#endif // EFI_IDLE_CONTROL
182
184
185#if EFI_TUNER_STUDIO
187#endif /* EFI_TUNER_STUDIO */
188
193}
TriggerCentral triggerCentral
Definition engine.h:326
IgnitionState ignitionState
Definition engine.h:247
EngineState engineState
Definition engine.h:352
TunerStudioOutputChannels outputChannels
Definition engine.h:113
constexpr auto & module()
Definition engine.h:204
multispark_state multispark
virtual SensorResult get() const =0
InstantRpmCalculator instantRpm
static EngineAccessor engine
Definition engine.h:421
static constexpr persistent_config_s * config
static CCM_OPTIONAL FunctionalSensor iat(SensorType::Iat, MS2NT(10))
instantRpm("sync: instant RPM", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 326, 1.0, 0.0, 0.0, "rpm")
scaled_channel< int16_t, 100, 1 > dfcoTimingRetard
scaled_channel< int16_t, 100, 1 > timingPidCorrection
scaled_channel< int16_t, 100, 1 > cltTimingCorrection
scaled_channel< int16_t, 100, 1 > timingIatCorrection
scaled_channel< int16_t, 10, 1 > ignitionIatCorrTable[IAT_IGN_CORR_LOAD_COUNT][IAT_IGN_CORR_TEMP_COUNT]
scaled_channel< uint8_t, 1, 5 > ignitionIatCorrLoadBins[IAT_IGN_CORR_LOAD_COUNT]

Referenced by IgnitionState::getAdvance().

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

◆ getCltTimingCorrection()

angle_t getCltTimingCorrection ( float  engineLoad)

Definition at line 147 of file ignition_state.cpp.

147 {
148 const auto clt = Sensor::get(SensorType::Clt);
149
150 if (!clt)
151 return 0; // this error should be already reported somewhere else, let's just handle it
152
153 return interpolate3d(
155 config->ignitionCltCorrLoadBins, engineLoad,
157 );
158}
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
scaled_channel< int16_t, 10, 1 > ignitionCltCorrTable[CLT_TIMING_LOAD_AXIS_SIZE][CLT_TIMING_TEMP_AXIS_SIZE]
scaled_channel< uint8_t, 1, 5 > ignitionCltCorrLoadBins[CLT_TIMING_LOAD_AXIS_SIZE]
scaled_channel< int16_t, 1, 1 > ignitionCltCorrTempBins[CLT_TIMING_TEMP_AXIS_SIZE]
Here is the call graph for this function:

◆ getCrankingAdvance()

angle_t getCrankingAdvance ( float  rpm,
float  engineLoad 
)
Returns
ignition timing angle advance before TDC for Cranking

Definition at line 198 of file ignition_state.cpp.

198 {
199 // get advance from the separate table for Cranking
201 return interpolate2d(rpm, config->crankingAdvanceBins, config->crankingAdvance);
202 }
203
204 // Interpolate the cranking timing angle to the earlier running angle for faster engine start
205 angle_t crankingToRunningTransitionAngle = getRunningAdvance(engineConfiguration->cranking.rpm, engineLoad);
206 // interpolate not from zero, but starting from min. possible rpm detected
208}
RpmCalculator rpmCalculator
Definition engine.h:314
float getMinCrankingRpm() const
float interpolateClamped(float x1, float y1, float x2, float y2, float x)
static constexpr engine_configuration_s * engineConfiguration
angle_t getRunningAdvance(float rpm, float engineLoad)
float angle_t
scaled_channel< int16_t, 100, 1 > crankingAdvance[CRANKING_ADVANCE_CURVE_SIZE]
uint16_t crankingAdvanceBins[CRANKING_ADVANCE_CURVE_SIZE]

Referenced by IgnitionState::getAdvance().

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

◆ getCylinderIgnitionTrim()

PUBLIC_API_WEAK_SOMETHING_WEIRD angle_t getCylinderIgnitionTrim ( size_t  cylinderNumber,
float  rpm,
float  ignitionLoad 
)

Definition at line 257 of file ignition_state.cpp.

257 {
258 return IgnitionState::getInterpolatedIgnitionTrim(cylinderNumber, rpm, ignitionLoad);
259}
static angle_t getInterpolatedIgnitionTrim(size_t cylinderNumber, float rpm, float ignitionLoad)
ignitionLoad("Ignition: load", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1420, 1.0, -1.0, -1.0, "")

Referenced by EngineState::periodicFastCallback().

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

◆ getMultiSparkCount()

size_t getMultiSparkCount ( float  rpm)

Definition at line 261 of file ignition_state.cpp.

261 {
262 // Compute multispark (if enabled)
264 && rpm <= engineConfiguration->multisparkMaxRpm
266 // For zero RPM, disable multispark. We don't yet know the engine speed, so multispark may not be safe.
267 if (rpm == 0) {
268 return 0;
269 }
270
272 floatus_t multiDwell = 1000.0f * engineConfiguration->multisparkDwell;
273
274 // dwell times are below 10 seconds here so we use 32 bit type for performance reasons
275 engine->engineState.multispark.delay = (uint32_t)USF2NT(multiDelay);
276 engine->engineState.multispark.dwell = (uint32_t)USF2NT(multiDwell);
277
278 constexpr float usPerDegreeAt1Rpm = 60e6 / 360;
279 floatus_t usPerDegree = usPerDegreeAt1Rpm / rpm;
280
281 // How long is there for sparks? The user configured an angle, convert to time.
282 floatus_t additionalSparksUs = usPerDegree * engineConfiguration->multisparkMaxSparkingAngle;
283 // How long does one spark take?
284 floatus_t oneSparkTime = multiDelay + multiDwell;
285
286 // How many sparks can we fit in the alloted time?
287 float sparksFitInTime = additionalSparksUs / oneSparkTime;
288
289 // Take the floor (convert to uint8_t) - we want to undershoot, not overshoot
290 uint32_t floored = sparksFitInTime;
291
292 // Allow no more than the maximum number of extra sparks
294 } else {
295 return 0;
296 }
297}

Referenced by EngineState::periodicFastCallback().

Here is the caller graph for this function:

◆ getRunningAdvance()

angle_t getRunningAdvance ( float  rpm,
float  engineLoad 
)
Returns
ignition timing angle advance before TDC

Definition at line 37 of file ignition_state.cpp.

37 {
38 if (std::isnan(engineLoad)) {
39 warning(ObdCode::CUSTOM_NAN_ENGINE_LOAD, "NaN engine load");
40 return NAN;
41 }
42
43 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(engineLoad), "invalid el", NAN);
44
45 // compute base ignition angle from main table
46 float advanceAngle = IgnitionState::getInterpolatedIgnitionAngle(rpm, engineLoad);
47
48 float vehicleSpeed = Sensor::getOrZero(SensorType::VehicleSpeed);
50 engine->ignitionState.tractionAdvanceDrop = tcTimingDropTable.getValue(wheelSlip, vehicleSpeed);
51 engine->engineState.tractionControlSparkSkip = tcSparkSkipTable.getValue(wheelSlip, vehicleSpeed);
53
55
56#if EFI_ANTILAG_SYSTEM
61 config->alsIgnRetardLoadBins, throttleIntent,
63 );
65 }
66#endif /* EFI_ANTILAG_SYSTEM */
67
68 // Add any adjustments if configured
69 for (size_t i = 0; i < efi::size(config->ignBlends); i++) {
70 auto result = calculateBlend(config->ignBlends[i], rpm, engineLoad);
71
72 engine->outputChannels.ignBlendParameter[i] = result.BlendParameter;
73 engine->outputChannels.ignBlendBias[i] = result.Bias;
74 engine->outputChannels.ignBlendOutput[i] = result.Value;
75 engine->outputChannels.ignBlendYAxis[i] = result.TableYAxis;
76
77 advanceAngle += result.Value;
78 }
79
80 // get advance from the separate table for Idle
81#if EFI_IDLE_CONTROL
84 float idleAdvance = interpolate2d(rpm, config->idleAdvanceBins, config->idleAdvance);
85
87 if (tps) {
88 // interpolate between idle table and normal (running) table using TPS threshold
89 // 0 TPS -> idle table
90 // 1/2 threshold -> idle table
91 // idle threshold -> normal table
93 advanceAngle = interpolateClamped(idleThreshold / 2, idleAdvance, idleThreshold, advanceAngle, tps.Value);
94 }
95 }
96#endif
97
98#if EFI_IDLE_CONTROL
99 // reset ignition table dot, see #8198
104 } else {
108 }
109#endif
110
111#if EFI_LAUNCH_CONTROL
113 const float launchAngle = engineConfiguration->launchTimingRetard;
115 const int launchRpm = engineConfiguration->launchRpm;
116 const int smoothRetardStartRpm = (launchRpm - engineConfiguration->launchRpmWindow);
117 const int smoothRetardEndRpm = (launchRpm - engineConfiguration->launchCorrectionsEndRpm);
118 if (smoothRetardStartRpm <= rpm) {
119 if (engineConfiguration->launchSmoothRetard && (rpm <= smoothRetardEndRpm)) {
120 // https://github.com/rusefi/rusefi/issues/5611#issuecomment-2130431696
121 return interpolateClamped(smoothRetardStartRpm, advanceAngle, smoothRetardEndRpm, launchAngle, rpm);
122 } else {
123 return launchAngle;
124 }
125 }
127 return launchAngle;
128 }
129 }
132 ) {
134 }
137 }
138#endif /* EFI_LAUNCH_CONTROL */
139
140#ifdef MODULE_VVL_CONTROLLER
141 advanceAngle += engine->module<VvlController>().unmock().getTimingModifier();
142#endif /* MODULE_VVL_CONTROLLER */
143
144 return advanceAngle;
145}
LaunchControlBase launchController
Definition engine.h:224
AntilagSystemBase antilagController
Definition engine.h:232
ShiftTorqueReductionController shiftTorqueReductionController
Definition engine.h:225
void updateSparkSkip()
Definition engine2.cpp:137
bool isIdlingOrTaper() const override
Definition idle_thread.h:88
bool isCoastingAdvance() const override
Definition idle_thread.h:92
static angle_t getInterpolatedIgnitionAngle(float rpm, float ignitionLoad)
static float getOrZero(SensorType type)
Definition sensor.h:83
float getTimingModifier() const
BlendResult calculateBlend(blend_table_s &cfg, float rpm, float load)
bool warning(ObdCode code, const char *fmt,...)
static Map3D< TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t > tcTimingDropTable
static Map3D< TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t > tcSparkSkipTable
@ CUSTOM_NAN_ENGINE_LOAD
@ CUSTOM_ERR_ASSERT
@ DriverThrottleIntent
scaled_channel< int16_t, 100, 1 > timingALSCorrection
scaled_channel< int16_t, 50, 1 > tractionAdvanceDrop
scaled_channel< int16_t, 100, 1 > ignBlendOutput[IGN_BLEND_COUNT]
scaled_channel< int16_t, 10, 1 > ignBlendParameter[IGN_BLEND_COUNT]
scaled_channel< uint8_t, 2, 1 > ignBlendBias[IGN_BLEND_COUNT]
scaled_channel< int16_t, 10, 1 > ignBlendYAxis[IGN_BLEND_COUNT]
scaled_channel< int16_t, 10, 1 > ALSTimingRetardTable[ALS_SIZE][ALS_RPM_SIZE]
scaled_channel< uint8_t, 1, 50 > idleAdvanceBins[IDLE_ADVANCE_CURVE_SIZE]

Referenced by IgnitionState::getAdvance(), and getCrankingAdvance().

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

◆ initIgnitionAdvanceControl()

void initIgnitionAdvanceControl ( )

Definition at line 299 of file ignition_state.cpp.

299 {
302}
uint8_t tractionControlSpeedBins[TRACTION_CONTROL_ETB_DROP_SPEED_SIZE]
int8_t tractionControlTimingDrop[TRACTION_CONTROL_ETB_DROP_SPEED_SIZE][TRACTION_CONTROL_ETB_DROP_SLIP_SIZE]
scaled_channel< uint16_t, 100, 1 > tractionControlSlipBins[TRACTION_CONTROL_ETB_DROP_SLIP_SIZE]
int8_t tractionControlIgnitionSkip[TRACTION_CONTROL_ETB_DROP_SPEED_SIZE][TRACTION_CONTROL_ETB_DROP_SLIP_SIZE]

Referenced by commonInitEngineController().

Here is the caller graph for this function:

Variable Documentation

◆ tcSparkSkipTable

Map3D<TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t> tcSparkSkipTable {"tcs"}
static

Definition at line 30 of file ignition_state.cpp.

30{"tcs"};

Referenced by getRunningAdvance(), and initIgnitionAdvanceControl().

◆ tcTimingDropTable

Map3D<TRACTION_CONTROL_ETB_DROP_SLIP_SIZE, TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, int8_t, uint16_t, uint8_t> tcTimingDropTable {"tct"}
static

Definition at line 29 of file ignition_state.cpp.

29{"tct"};

Referenced by getRunningAdvance(), and initIgnitionAdvanceControl().

Go to the source code of this file.