rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
advance_map.h File Reference

Functions

angle_t getCylinderIgnitionTrim (size_t cylinderNumber, float rpm, float ignitionLoad)
 
float getInitialAdvance (float rpm, float map, float advanceMax)
 
angle_t getCrankingAdvance (float rpm, float engineLoad)
 
angle_t getRunningAdvance (float rpm, float engineLoad)
 
angle_t getAdvanceCorrections (float engineLoad)
 
size_t getMultiSparkCount (float rpm)
 
void initIgnitionAdvanceControl ()
 

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:

◆ 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()

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:

◆ 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:

◆ 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:

Go to the source code of this file.