rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
default_fuel.cpp
Go to the documentation of this file.
1#include "pch.h"
2
3#include "defaults.h"
4#include "table_helper.h"
5#include "mazda_miata_vvt.h"
7
8static void setBosch02880155868(injector_s& cfg) {
9 // http://www.boschdealer.com/specsheets/0280155868cs.jpg (use web.archive.org)
10#if (VBAT_INJECTOR_CURVE_PRESSURE_SIZE == 2) && (VBAT_INJECTOR_CURVE_SIZE == 8)
11 // see https://github.com/rusefi/rusefi/issues/7521 for adding more values
13#endif
14
15#if (VBAT_INJECTOR_CURVE_SIZE == 8)
16 static const float vBattBins[8] = { 6.0, 8.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 };
17 copyArray(cfg.battLagCorrBattBins, vBattBins);
18#else
19 setLinearCurve(cfg.battLagCorrBattBins, 6, 15, 0.1);
20#endif
21
22#if (VBAT_INJECTOR_CURVE_PRESSURE_SIZE == 2)
23 static const float pressureBins[2] = { 206.843, 413.685 };
24 copyArray(cfg.battLagCorrPressBins,pressureBins);
25#else
26 setLinearCurve(cfg.battLagCorrPressBins, 300, 400, 1);
27#endif
28
29}
30
32#if CLT_CURVE_SIZE == 16
33 static const float bins[] =
34 {
35 -40,
36 -30,
37 -20,
38 -10,
39 0,
40 10,
41 20,
42 30,
43 40,
44 50,
45 60,
46 70,
47 80,
48 90,
49 100,
50 110
51 };
52
53 copyArray(config->cltFuelCorrBins, bins);
54
55 static const float values[] =
56 {
57 1.50,
58 1.50,
59 1.42,
60 1.36,
61 1.28,
62 1.19,
63 1.12,
64 1.10,
65 1.06,
66 1.06,
67 1.03,
68 1.01,
69 1,
70 1,
71 1,
72 1
73 };
74
75 copyArray(config->cltFuelCorr, values);
76#endif // CLT_CURVE_SIZE
77}
78
79static void setDefaultVETable() {
81#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16)
82 static const float hardCodedveTable[16][16] = {
83{49.300, 49.300, 49.400, 49.600, 50.200, 51.400, 52.600, 53.800, 54.400, 54.600, 54.400, 53.700, 52.800, 51.800, 50.900, 50.000, },
84{49.600, 50.500, 51.500, 54.100, 57.500, 60.700, 62.900, 64.400, 65.000, 65.000, 64.500, 63.500, 62.300, 61.100, 60.000, 58.800, },
85{50.300, 52.400, 54.300, 58.500, 62.700, 66.100, 68.200, 69.700, 70.200, 70.100, 69.500, 68.400, 67.100, 65.800, 64.500, 63.300, },
86{51.400, 55.200, 58.200, 63.500, 68.000, 71.400, 73.500, 74.900, 75.300, 75.200, 74.500, 73.300, 71.800, 70.400, 69.000, 67.700, },
87{54.300, 60.900, 64.900, 70.700, 75.100, 78.300, 80.300, 81.700, 82.100, 81.900, 81.100, 79.700, 78.100, 76.500, 75.000, 73.500, },
88{56.400, 64.400, 68.700, 74.500, 78.700, 81.800, 83.800, 85.100, 85.500, 85.300, 84.400, 83.000, 81.300, 79.600, 78.000, 76.400, },
89{60.700, 70.200, 74.500, 79.900, 83.800, 86.800, 88.900, 90.200, 90.600, 90.300, 89.400, 87.800, 86.000, 84.200, 82.500, 80.800, },
90{65.800, 76.000, 80.000, 85.000, 88.800, 91.800, 93.900, 95.200, 95.600, 95.300, 94.300, 92.600, 90.700, 88.800, 87.000, 85.200, },
91{69.400, 79.100, 82.900, 87.800, 91.700, 94.800, 97.000, 98.300, 98.800, 98.400, 97.400, 95.600, 93.500, 91.500, 89.600, 87.700, },
92{73.000, 82.200, 85.900, 90.700, 94.600, 97.800, 100.000, 101.500, 101.900, 101.600, 100.400, 98.500, 96.400, 94.200, 92.200, 90.200, },
93{76.600, 85.300, 88.800, 93.500, 97.400, 100.700, 103.100, 104.600, 105.100, 104.700, 103.500, 101.500, 99.200, 96.900, 94.800, 92.600, },
94{80.300, 88.500, 91.800, 96.400, 100.300, 103.700, 106.200, 107.800, 108.200, 107.800, 106.500, 104.400, 102.000, 99.700, 97.400, 95.100, },
95{83.900, 91.600, 94.700, 99.200, 103.200, 106.700, 109.200, 110.900, 111.400, 110.900, 109.600, 107.400, 104.800, 102.400, 99.900, 97.600, },
96{87.500, 94.700, 97.600, 102.000, 106.100, 109.700, 112.300, 114.000, 114.500, 114.100, 112.600, 110.300, 107.700, 105.100, 102.500, 100.100, },
97{91.100, 97.800, 100.600, 104.900, 108.900, 112.600, 115.300, 117.200, 117.700, 117.200, 115.700, 113.300, 110.500, 107.800, 105.100, 102.500, },
98{94.700, 100.900, 103.500, 107.700, 111.800, 115.600, 118.400, 120.300, 120.800, 120.300, 118.700, 116.200, 113.300, 110.500, 107.700, 105.000, },
99};
101#else
102 setTable(config->veTable, 80);
103#endif
104
107
108 setLinearCurve(config->tmfRatioBins, 0.5, 1.5, 0.1);
109
110 // Default baro table is all 1.0, we can't recommend a reasonable default here
112
113 // Give default axes for cylinder trim tables
114#if FUEL_TRIM_SIZE == 4
115 copyArray(config->fuelTrimRpmBins, { 1000, 3000, 5000, 7000 });
116 copyArray(config->fuelTrimLoadBins, { 20, 50, 80, 100 });
117#else
120#endif
121
122 // Default axes for VE blends
123 for (size_t i = 0; i < efi::size(config->veBlends); i++) {
124 auto& blend = config->veBlends[i];
125 setLinearCurve(blend.loadBins, 0, 100, 10);
126 setLinearCurve(blend.rpmBins, 0, 7000);
127
128 setLinearCurve(blend.blendBins, 0, 100);
129 setLinearCurve(blend.blendValues, 0, 100);
130 }
131
132 for (size_t i = 0; i < efi::size(config->targetAfrBlends); i++) {
133 auto& blend = config->targetAfrBlends[i];
134 setLinearCurve(blend.rpmBins, 0, 7000);
135
136 setLinearCurve(blend.blendBins, 0, 100);
137 setLinearCurve(blend.blendValues, 0, 100);
138 }
139}
140
149
151 auto& cfg = engineConfiguration->stft;
152
153 // Default to disabled
155
156 // Default to proportional mode (for wideband sensors)
158
159 // Also used in lambda monitor
161
162 // 60 second startup delay - some O2 sensors are slow to warm up.
163 cfg.startupDelay = 60;
164
165 // Only correct in [12.0, 17.0]
166 cfg.minAfr = 12;
167 cfg.maxAfr = 17;
168
169 // Above 60 deg C
170 cfg.minClt = 60;
171
172 // 0.5% deadband
173 cfg.deadband = 0.5f;
174
175 // Sensible region defaults
176 cfg.maxIdleRegionRpm = 1000;
177 cfg.maxOverrunLoad = 35;
178 cfg.minPowerLoad = 85;
179
180 // Sensible cell defaults
181 for (size_t i = 0; i < efi::size(cfg.cellCfgs); i++) {
182 // 30 second time constant - nice and slow
183 cfg.cellCfgs[i].timeConstant = 30;
184
185 /// Allow +-5%
186 cfg.cellCfgs[i].maxAdd = 5;
187 cfg.cellCfgs[i].maxRemove = 5;
188 }
189}
190
192 auto& cfg = engineConfiguration->ltft;
193
194 // Default to allow learning, but do not apply learned corrections
195 cfg.enabled = true;
196 cfg.correctionEnabled = false;
197
198 // Default to very slow learning
199 cfg.timeConstant = 3000;
200
201 // 0.5% deadband
202 cfg.deadband = 0.5f;
203
204 // Allow +-12.5%
205 cfg.maxAdd = 12.5;
206 cfg.maxRemove = 12.5;
207}
208
209static const uint8_t tpsTpsTable[TPS_TPS_ACCEL_TABLE][TPS_TPS_ACCEL_TABLE] = {
210/* Generated by TS2C on Tue Apr 18 21:29:16 EDT 2017*/
211{/* 0 0 *//* 0 0.0*/0, /* 1 10.0*/0, /* 2 20.0*/0, /* 3 35.0*/0, /* 4 50.0*/0, /* 5 65.0*/0, /* 6 80.0*/0, /* 7 100.0*/0, },
212{/* 1 10 *//* 0 0.0*/10, /* 1 10.0*/0, /* 2 20.0*/0, /* 3 35.0*/0, /* 4 50.0*/0, /* 5 65.0*/0, /* 6 80.0*/0, /* 7 100.0*/0, },
213{/* 2 20 *//* 0 0.0*/17, /* 1 10.0*/10, /* 2 20.0*/0, /* 3 35.0*/0, /* 4 50.0*/0, /* 5 65.0*/0, /* 6 80.0*/0, /* 7 100.0*/0, },
214{/* 3 35 *//* 0 0.0*/23, /* 1 10.0*/17, /* 2 20.0*/10, /* 3 35.0*/0, /* 4 50.0*/0, /* 5 65.0*/0, /* 6 80.0*/0, /* 7 100.0*/0, },
215{/* 4 50 *//* 0 0.0*/28, /* 1 10.0*/23, /* 2 20.0*/17, /* 3 35.0*/10, /* 4 50.0*/0, /* 5 65.0*/0, /* 6 80.0*/0, /* 7 100.0*/0, },
216{/* 5 65 *//* 0 0.0*/32, /* 1 10.0*/28, /* 2 20.0*/23, /* 3 35.0*/17, /* 4 50.0*/10, /* 5 65.0*/0, /* 6 80.0*/0, /* 7 100.0*/0, },
217{/* 6 80 *//* 0 0.0*/35, /* 1 10.0*/32, /* 2 20.0*/28, /* 3 35.0*/23, /* 4 50.0*/17, /* 5 65.0*/10, /* 6 80.0*/0, /* 7 100.0*/0, },
218{/* 7 100 *//* 0 0.0*/37, /* 1 10.0*/35, /* 2 20.0*/32, /* 3 35.0*/28, /* 4 50.0*/23, /* 5 65.0*/17, /* 6 80.0*/10, /* 7 100.0*/0, },
219};
220
226
229
230#if (FUEL_LOAD_COUNT == 16) && (FUEL_RPM_COUNT == 16)
232
233 // Set each row to the corresponding value from rowValues
234 for (size_t i = 0; i < efi::size(config->lambdaTable); i++) {
235 for (size_t j = 0; j < efi::size(config->lambdaTable[i]); j++) {
237 }
238 }
239#endif
240}
241
246
248#if !EFI_UNIT_TEST
249 // todo: this is a reasonable default for what kinds of engines exactly?
252#endif // EFI_UNIT_TEST
253
254 // linear reasonable bins
255 setLinearCurve(config->wwCltBins, -40, 100, 1);
256 setLinearCurve(config->wwMapBins, 10, 80, 1);
257
258 // These values are derived from the GM factory tune for a gen3 LS engine
259 // Who knows if they're good for anything else, but at least they look nice?
260 static constexpr float tauClt[] = {
261 1.45, 1.30, 1.17, 1.05, 0.90, 0.82, 0.75, 0.70
262 };
263 copyArray(config->wwTauCltValues, tauClt);
264
265 static constexpr float tauMap[] = {
266 0.38, 0.55, 0.69, 0.86, 0.90, 0.95, 0.97, 1.00
267 };
268 copyArray(config->wwTauMapValues, tauMap);
269
270 static constexpr float betaClt[] = {
271 0.73, 0.66, 0.57, 0.46, 0.38, 0.31, 0.24, 0.19
272 };
273 copyArray(config->wwBetaCltValues, betaClt);
274
275 static constexpr float betaMap[] = {
276 0.21, 0.40, 0.60, 0.79, 0.85, 0.90, 0.95, 1.00
277 };
278 copyArray(config->wwBetaMapValues, betaMap);
279}
280
282 for (size_t i = 0; i < CAN_WBO_COUNT; i++) {
283 engineConfiguration->canWbo[i].type = RUSEFI;
284 engineConfiguration->canWbo[i].reId = static_cast<can_wbo_re_id_e>(i);
285 engineConfiguration->canWbo[i].aemId = static_cast<can_wbo_aem_id_e>(i);
286 }
287}
288
301
302static void setDefaultPriming() {
303 // These defaults are reasonable for ~500cc cylinders
304 static constexpr int8_t primeBins[] = { -40, -20, 0, 20, 40, 60, 80, 100 };
305 static constexpr uint16_t primeValues[] = { 755, 605, 265, 140, 75, 50, 45, 40 };
306
307 copyArray(engineConfiguration->primeBins, primeBins);
308 copyArray(engineConfiguration->primeValues, primeValues);
309}
310
312 // Base injection configuration
314 engineConfiguration->injectionMode = IM_SEQUENTIAL;
315
316 /**
317 * By the way http://users.erols.com/srweiss/tableifc.htm has a LOT of data
318 */
322
323 // 9.0 = E100 pure ethanol
325
326 // Injector deadtime
329
330 // Tables
331 setFuelTablesLoadBin(10, 160);
333
336
339
342
345
349
350 setTable(config->injectionPhase, PORT_INJECTION_OFFSET);
351
352 // Charge temperature estimation
357 engineConfiguration->tChargeMode = TCHARGE_MODE_RPM_TPS;
363
364 // CLT correction table
366
367 // IAT correction table
368 // TODO
369
370 // Closed loop fuel correction
373
374 // Decel fuel cut
376
377 engineConfiguration->tpsAccelEnrichmentThreshold = 40; // TPS % change, per engine cycle
378
380
381 // TPS/TPS AE curve
383
384 // Some reasonable reference pressure that many vehicles use
386
388
389 // Lambda protection defaults
391
393
394 // Cut at 110% instantly
396 // Cut at 96% after 0.5 second
399}
static void setDefaultLtftSettings()
static void setDefaultWarmupFuelEnrichment()
static void setDefaultLambdaProtection()
void setDefaultWallWetting()
static void setBosch02880155868(injector_s &cfg)
static void setDefaultPriming()
static void setDefaultStftSettings()
static void setDefaultVETable()
void setDefaultFuel()
static void setMazdaMiataNbTpsTps()
static void setDefaultFuelCutParameters()
static void setDefaultLambdaTable()
static void setDefaultWboSettings()
void setGdiWallWetting()
static const uint8_t tpsTpsTable[TPS_TPS_ACCEL_TABLE][TPS_TPS_ACCEL_TABLE]
void setFuelTablesLoadBin(float minValue, float maxValue)
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
static const uint8_t hardCodedveTable[16][16]
constexpr BattLagCorrTable INJECTOR_BATT_LAG_CURR
can_wbo_aem_id_e
can_wbo_re_id_e
scaled_channel< int16_t, 1, 1 > primeBins[PRIME_CURVE_COUNT]
scaled_channel< uint8_t, 1, 5 > primeValues[PRIME_CURVE_COUNT]
scaled_channel< int16_t, 100, 1 > battLagCorrBattBins[VBAT_INJECTOR_CURVE_SIZE]
scaled_channel< uint32_t, 10, 1 > battLagCorrPressBins[VBAT_INJECTOR_CURVE_PRESSURE_SIZE]
scaled_channel< int16_t, 100, 1 > battLagCorrTable[VBAT_INJECTOR_CURVE_PRESSURE_SIZE][VBAT_INJECTOR_CURVE_SIZE]
scaled_channel< uint8_t, 100, 1 > wwTauMapValues[WWAE_TABLE_SIZE]
int16_t injectionPhase[INJ_PHASE_LOAD_COUNT][INJ_PHASE_RPM_COUNT]
float tpsTpsAccelTable[TPS_TPS_ACCEL_TABLE][TPS_TPS_ACCEL_TABLE]
scaled_channel< uint8_t, 1, 50 > tpsTspCorrValuesBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint8_t, 100, 1 > wwBetaMapValues[WWAE_TABLE_SIZE]
scaled_channel< uint16_t, 10, 1 > veTable[VE_LOAD_COUNT][VE_RPM_COUNT]
scaled_channel< uint8_t, 100, 1 > wwBetaCltValues[WWAE_TABLE_SIZE]
scaled_channel< uint16_t, 100, 1 > mapEstimateTpsBins[MAP_EST_LOAD_COUNT]
scaled_channel< uint8_t, 50, 1 > predictiveMapBlendDurationValues[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint8_t, 100, 1 > wwTauCltValues[WWAE_TABLE_SIZE]
scaled_channel< uint8_t, 50, 1 > tpsTspCorrValues[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint16_t, 100, 1 > mapEstimateTable[MAP_EST_LOAD_COUNT][MAP_EST_RPM_COUNT]
scaled_channel< uint8_t, 1, 50 > predictiveMapBlendDurationBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint8_t, 147, 1 > lambdaTable[FUEL_LOAD_COUNT][FUEL_RPM_COUNT]
constexpr void copyTable(TDest(&dest)[N][M], const TSource(&source)[N][M], float multiply=1.0f)
constexpr void setTable(TElement(&dest)[N][M], const VElement value)
void setRpmTableBin(TValue(&array)[TSize])
void setLinearCurve(TValue(&array)[TSize], float from, float to, float precision=0.01f)