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

float minCrankingRpm = 0
 
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 168 of file ignition_state.cpp.

168 {
170
171 if (!iat) {
173 } else {
176 config->ignitionIatCorrLoadBins, engineLoad,
178 );
179 }
180
181#if EFI_IDLE_CONTROL
183
185#endif // EFI_IDLE_CONTROL
186
188
189#if EFI_TUNER_STUDIO
191#endif /* EFI_TUNER_STUDIO */
192
197}
TriggerCentral triggerCentral
Definition engine.h:318
IgnitionState ignitionState
Definition engine.h:239
EngineState engineState
Definition engine.h:344
TunerStudioOutputChannels outputChannels
Definition engine.h:109
constexpr auto & module()
Definition engine.h:200
multispark_state multispark
virtual SensorResult get() const =0
InstantRpmCalculator instantRpm
static EngineAccessor engine
Definition engine.h:413
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_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 151 of file ignition_state.cpp.

151 {
152 const auto clt = Sensor::get(SensorType::Clt);
153
154 if (!clt)
155 return 0; // this error should be already reported somewhere else, let's just handle it
156
157 return interpolate3d(
159 config->ignitionCltCorrLoadBins, engineLoad,
161 );
162}
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
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]
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 202 of file ignition_state.cpp.

202 {
203 // get advance from the separate table for Cranking
205 return interpolate2d(rpm, config->crankingAdvanceBins, config->crankingAdvance);
206 }
207
208 // Interpolate the cranking timing angle to the earlier running angle for faster engine start
209 angle_t crankingToRunningTransitionAngle = getRunningAdvance(engineConfiguration->cranking.rpm, engineLoad);
210 // interpolate not from zero, but starting from min. possible rpm detected
211 if (rpm < minCrankingRpm || minCrankingRpm == 0)
212 minCrankingRpm = rpm;
214}
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 minCrankingRpm
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 263 of file ignition_state.cpp.

263 {
264 return IgnitionState::getInterpolatedIgnitionTrim(cylinderNumber, rpm, ignitionLoad);
265}
static angle_t getInterpolatedIgnitionTrim(size_t cylinderNumber, float rpm, float ignitionLoad)
ignitionLoad("Ignition: load", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1412, 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 267 of file ignition_state.cpp.

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

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 41 of file ignition_state.cpp.

41 {
42 if (std::isnan(engineLoad)) {
43 warning(ObdCode::CUSTOM_NAN_ENGINE_LOAD, "NaN engine load");
44 return NAN;
45 }
46
47 efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(engineLoad), "invalid el", NAN);
48
49 // compute base ignition angle from main table
50 float advanceAngle = IgnitionState::getInterpolatedIgnitionAngle(rpm, engineLoad);
51
52 float vehicleSpeed = Sensor::getOrZero(SensorType::VehicleSpeed);
54 engine->ignitionState.tractionAdvanceDrop = tcTimingDropTable.getValue(wheelSlip, vehicleSpeed);
55 engine->engineState.tractionControlSparkSkip = tcSparkSkipTable.getValue(wheelSlip, vehicleSpeed);
57
59
60#if EFI_ANTILAG_SYSTEM
65 config->alsIgnRetardLoadBins, throttleIntent,
67 );
69 }
70#endif /* EFI_ANTILAG_SYSTEM */
71
72 // Add any adjustments if configured
73 for (size_t i = 0; i < efi::size(config->ignBlends); i++) {
74 auto result = calculateBlend(config->ignBlends[i], rpm, engineLoad);
75
76 engine->outputChannels.ignBlendParameter[i] = result.BlendParameter;
77 engine->outputChannels.ignBlendBias[i] = result.Bias;
78 engine->outputChannels.ignBlendOutput[i] = result.Value;
79 engine->outputChannels.ignBlendYAxis[i] = result.TableYAxis;
80
81 advanceAngle += result.Value;
82 }
83
84 // get advance from the separate table for Idle
85#if EFI_IDLE_CONTROL
88 float idleAdvance = interpolate2d(rpm, config->idleAdvanceBins, config->idleAdvance);
89
91 if (tps) {
92 // interpolate between idle table and normal (running) table using TPS threshold
93 // 0 TPS -> idle table
94 // 1/2 threshold -> idle table
95 // idle threshold -> normal table
97 advanceAngle = interpolateClamped(idleThreshold / 2, idleAdvance, idleThreshold, advanceAngle, tps.Value);
98 }
99 }
100#endif
101
102#if EFI_IDLE_CONTROL
103 // reset ignition table dot, see #8198
108 } else {
112 }
113#endif
114
115#if EFI_LAUNCH_CONTROL
117 const float launchAngle = engineConfiguration->launchTimingRetard;
119 const int launchRpm = engineConfiguration->launchRpm;
120 const int smoothRetardStartRpm = (launchRpm - engineConfiguration->launchRpmWindow);
121 const int smoothRetardEndRpm = (launchRpm - engineConfiguration->launchCorrectionsEndRpm);
122 if (smoothRetardStartRpm <= rpm) {
123 if (engineConfiguration->launchSmoothRetard && (rpm <= smoothRetardEndRpm)) {
124 // https://github.com/rusefi/rusefi/issues/5611#issuecomment-2130431696
125 return interpolateClamped(smoothRetardStartRpm, advanceAngle, smoothRetardEndRpm, launchAngle, rpm);
126 } else {
127 return launchAngle;
128 }
129 }
131 return launchAngle;
132 }
133 }
136 ) {
138 }
141 }
142#endif /* EFI_LAUNCH_CONTROL */
143
144#ifdef MODULE_VVL_CONTROLLER
145 advanceAngle += engine->module<VvlController>().unmock().getTimingModifier();
146#endif /* MODULE_VVL_CONTROLLER */
147
148 return advanceAngle;
149}
LaunchControlBase launchController
Definition engine.h:220
AntilagSystemBase antilagController
Definition engine.h:228
ShiftTorqueReductionController shiftTorqueReductionController
Definition engine.h:221
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< uint8_t, 1, 50 > idleAdvanceBins[IDLE_ADVANCE_CURVE_SIZE]
scaled_channel< int16_t, 10, 1 > ALSTimingRetardTable[ALS_SIZE][ALS_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 305 of file ignition_state.cpp.

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

Referenced by commonInitEngineController().

Here is the caller graph for this function:

Variable Documentation

◆ minCrankingRpm

float minCrankingRpm = 0

Definition at line 31 of file ignition_state.cpp.

Referenced by getCrankingAdvance().

◆ 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 34 of file ignition_state.cpp.

34{"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 33 of file ignition_state.cpp.

33{"tct"};

Referenced by getRunningAdvance(), and initIgnitionAdvanceControl().

Go to the source code of this file.