firmware/controllers/algo/defaults/default_base_engine.cpp
| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | ||||
| 3 | #include "defaults.h" | |||
| 4 | #include "vr_pwm.h" | |||
| 5 | #include "kline.h" | |||
| 6 | #include "engine_configuration_defaults.h" | |||
| 7 | #include <rusefi/manifest.h> | |||
| 8 | #if HW_PROTEUS | |||
| 9 | #include "proteus_meta.h" | |||
| 10 | #endif // HW_PROTEUS | |||
| 11 | ||||
| 12 | #if EFI_ALTERNATOR_CONTROL | |||
| 13 | 605 | static void setDefaultAlternatorParameters() { | ||
| 14 | 605 | setTable(config->alternatorVoltageTargetTable, 14); | ||
| 15 | ||||
| 16 | 605 | engineConfiguration->alternatorControl.offset = 0; | ||
| 17 | 605 | engineConfiguration->alternatorControl.pFactor = 30; | ||
| 18 | 605 | engineConfiguration->alternatorControl.periodMs = 100; | ||
| 19 | 605 | } | ||
| 20 | #endif // EFI_ALTERNATOR_CONTROL | |||
| 21 | ||||
| 22 | 606 | void setHpfpLobeProfileAngle(int lobes) { | ||
| 23 | #if HPFP_LOBE_PROFILE_SIZE == 16 | |||
| 24 | static const float hardCodedHpfpLobeProfileAnglesForThreeLobes[16] = {0.0, 7.5, 16.5, 24.0, | |||
| 25 | 32.0 , 40.0, 48.0, 56.0, | |||
| 26 | 64.0 , 72.0, 80.0, 88.0, | |||
| 27 | 96.0 , 103.5, 112.5, 120.0 | |||
| 28 | }; | |||
| 29 | ||||
| 30 | 606 | float multiplier = 3.0 / lobes; | ||
| 31 |
2/2✓ Branch 0 taken 9696 times.
✓ Branch 1 taken 606 times.
|
2/2✓ Decision 'true' taken 9696 times.
✓ Decision 'false' taken 606 times.
|
10302 | for (size_t i = 0; i < HPFP_LOBE_PROFILE_SIZE; i++) { |
| 32 | 9696 | config->hpfpLobeProfileAngle[i] = multiplier * hardCodedHpfpLobeProfileAnglesForThreeLobes[i]; | ||
| 33 | } | |||
| 34 | #endif // HPFP_LOBE_PROFILE_SIZE | |||
| 35 | 606 | } | ||
| 36 | ||||
| 37 | 605 | static void setDefaultHPFP() { | ||
| 38 | #if ! EFI_UNIT_TEST | |||
| 39 | // unit tests rely on 'hpfpCamLobes' for isGdiEngine() and we need not-GDI by default for unit tests | |||
| 40 | engineConfiguration->hpfpCamLobes = 3; | |||
| 41 | #endif | |||
| 42 | ||||
| 43 | // todo: would be nice for unit tests to be happy about these defaults | |||
| 44 | #if EFI_PROD_CODE || EFI_SIMULATOR | |||
| 45 | engineConfiguration->hpfpPumpVolume = 0.290; | |||
| 46 | #endif | |||
| 47 | 605 | engineConfiguration->hpfpMinAngle = 10; | ||
| 48 | 605 | engineConfiguration->hpfpActivationAngle = 30; | ||
| 49 | 605 | engineConfiguration->hpfpTargetDecay = 2000; | ||
| 50 | 605 | engineConfiguration->hpfpPidP = 0.01; | ||
| 51 | 605 | engineConfiguration->hpfpPidI = 0.0003; | ||
| 52 | 605 | engineConfiguration->hpfpPeakPos = 10; | ||
| 53 | 605 | } | ||
| 54 | ||||
| 55 | 605 | static void setGdiDefaults() { | ||
| 56 | 605 | setDefaultHPFP(); | ||
| 57 | ||||
| 58 | 605 | setRpmTableBin(config->hpfpTargetRpmBins); | ||
| 59 | 605 | setLinearCurve(config->hpfpTargetLoadBins, 0, 180, 1); | ||
| 60 | 605 | setTable(config->hpfpTarget, 5000); | ||
| 61 | ||||
| 62 | 605 | setLinearCurve(config->hpfpFuelMassCompensationFuelMass, 0.0, 500, 10); | ||
| 63 | 605 | setLinearCurve(config->hpfpFuelMassCompensationFuelPressure, 0, 300, 25); | ||
| 64 | 605 | setTable(config->hpfpFuelMassCompensation, 1.0); | ||
| 65 | ||||
| 66 | 605 | setLinearCurve(config->injectorFlowLinearizationFuelMassBins, 0.0, 500, 10); | ||
| 67 | 605 | setLinearCurve(config->injectorFlowLinearizationPressureBins, 0, 300, 25); | ||
| 68 | 605 | } | ||
| 69 | ||||
| 70 | 1 | void setGDIFueling() { | ||
| 71 | #ifdef HW_HELLEN_8CHAN | |||
| 72 | engineConfiguration->externalRusEfiGdiModule = true; | |||
| 73 | #endif | |||
| 74 | ||||
| 75 | 1 | engineConfiguration->injectionMode = IM_SEQUENTIAL; | ||
| 76 | 1 | engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL; | ||
| 77 | 1 | engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; | ||
| 78 | ||||
| 79 | 1 | setGdiWallWetting(); | ||
| 80 | // Use high pressure sensor | |||
| 81 | 1 | engineConfiguration->injectorPressureType = IPT_High; | ||
| 82 | // Automatic compensation of injector flow based on rail pressure | |||
| 83 | 1 | engineConfiguration->injectorCompensationMode = ICM_SensedRailPressure; | ||
| 84 | // Reference rail pressure is 10 000 kPa = 100 bar | |||
| 85 | 1 | engineConfiguration->fuelReferencePressure = 10000; | ||
| 86 | //setting "flat" 0.2 ms injector's lag time | |||
| 87 | 1 | setTable(engineConfiguration->injector.battLagCorrTable, 0.2); | ||
| 88 | ||||
| 89 | 1 | setTable(config->injectionPhase, -200.0f); | ||
| 90 | 1 | engineConfiguration->injectionTimingMode = InjectionTimingMode::Center; | ||
| 91 | 1 | engineConfiguration->isPhaseSyncRequiredForIgnition = true; | ||
| 92 | 1 | } | ||
| 93 | ||||
| 94 | /* Cylinder to bank mapping */ | |||
| 95 | ✗ | void setLeftRightBanksNeedBetterName() { | ||
| 96 | ✗ | for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { | ||
| 97 | // zero-based index | |||
| 98 | ✗ | engineConfiguration->cylinderBankSelect[i] = i % 2; | ||
| 99 | } | |||
| 100 | ✗ | } | ||
| 101 | ||||
| 102 | 605 | static void mc33810defaults() { | ||
| 103 | 605 | engineConfiguration->mc33810Nomi = 5.5; | ||
| 104 | 605 | engineConfiguration->mc33810maxDwellTimer = mc33810maxDwellTimer_e::DWELL_8MS; | ||
| 105 | 605 | engineConfiguration->mc33810Maxi = 14; | ||
| 106 | 605 | } | ||
| 107 | ||||
| 108 | 602 | void setDynoDefaults() { | ||
| 109 | 602 | config->dynoRpmStep = 100; | ||
| 110 | ||||
| 111 | 602 | config->dynoSaeTemperatureC = 20; | ||
| 112 | 602 | config->dynoSaeBaro = STD_ATMOSPHERE; | ||
| 113 | 602 | config->dynoSaeRelativeHumidity = 80; | ||
| 114 | ||||
| 115 | 602 | config->dynoCarWheelDiaInch = 18; | ||
| 116 | 602 | config->dynoCarWheelTireWidthMm = 235; | ||
| 117 | 602 | config->dynoCarWheelAspectRatio = 40; | ||
| 118 | ||||
| 119 | 602 | config->dynoCarGearPrimaryReduction = 1; | ||
| 120 | 602 | config->dynoCarGearRatio = 1.0; | ||
| 121 | 602 | config->dynoCarGearFinalDrive = 4.2; | ||
| 122 | ||||
| 123 | 602 | config->dynoCarCarMassKg = 1000; | ||
| 124 | 602 | config->dynoCarCargoMassKg = 95; | ||
| 125 | 602 | config->dynoCarCoeffOfDrag = 0.29; | ||
| 126 | 602 | config->dynoCarFrontalAreaM2 = 1.85; | ||
| 127 | 602 | } | ||
| 128 | ||||
| 129 | 1208 | void defaultsOrFixOnBurn() { | ||
| 130 |
2/2✓ Branch 1 taken 602 times.
✓ Branch 2 taken 606 times.
|
2/2✓ Decision 'true' taken 602 times.
✓ Decision 'false' taken 606 times.
|
1208 | if (config->dynoCarCarMassKg == 0) { |
| 131 | 602 | setDynoDefaults(); | ||
| 132 | } | |||
| 133 | ||||
| 134 |
3/4✓ Branch 0 taken 603 times.
✓ Branch 1 taken 605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->mapExpAverageAlpha <= 0 || engineConfiguration->mapExpAverageAlpha > 1) { |
| 135 | 605 | engineConfiguration->mapExpAverageAlpha = 1; | ||
| 136 | } | |||
| 137 | ||||
| 138 |
3/4✓ Branch 0 taken 603 times.
✓ Branch 1 taken 605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->ppsExpAverageAlpha <= 0 || engineConfiguration->ppsExpAverageAlpha > 1) { |
| 139 | 605 | engineConfiguration->ppsExpAverageAlpha = 1; | ||
| 140 | } | |||
| 141 |
3/4✓ Branch 0 taken 603 times.
✓ Branch 1 taken 605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->afrExpAverageAlpha <= 0 || engineConfiguration->afrExpAverageAlpha > 1) { |
| 142 | 605 | engineConfiguration->afrExpAverageAlpha = 1; | ||
| 143 | } | |||
| 144 | ||||
| 145 |
2/2✓ Branch 0 taken 605 times.
✓ Branch 1 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->referenceTorqueForGenerator == 0) { |
| 146 | 605 | engineConfiguration->referenceTorqueForGenerator = 250; | ||
| 147 | } | |||
| 148 |
2/2✓ Branch 0 taken 605 times.
✓ Branch 1 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->referenceMapForGenerator == 0) { |
| 149 | 605 | engineConfiguration->referenceMapForGenerator = 100; | ||
| 150 | } | |||
| 151 |
2/2✓ Branch 0 taken 605 times.
✓ Branch 1 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->referenceVeForGenerator == 0) { |
| 152 | 605 | engineConfiguration->referenceVeForGenerator = 75; | ||
| 153 | } | |||
| 154 | ||||
| 155 |
2/2✓ Branch 0 taken 605 times.
✓ Branch 1 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->alternator_iTermMin == 0) { |
| 156 | 605 | engineConfiguration->alternator_iTermMin = -1000; | ||
| 157 | } | |||
| 158 |
2/2✓ Branch 0 taken 605 times.
✓ Branch 1 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->alternator_iTermMax == 0) { |
| 159 | 605 | engineConfiguration->alternator_iTermMax = 1000; | ||
| 160 | } | |||
| 161 |
2/2✓ Branch 1 taken 605 times.
✓ Branch 2 taken 603 times.
|
2/2✓ Decision 'true' taken 605 times.
✓ Decision 'false' taken 603 times.
|
1208 | if (engineConfiguration->idleReturnTargetRampDuration <= 0.1){ |
| 162 | 605 | engineConfiguration->idleReturnTargetRampDuration = 3; | ||
| 163 | } | |||
| 164 | ||||
| 165 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1206 times.
|
2/2✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1206 times.
|
1208 | if (engineConfiguration->vvtControlMinRpm < engineConfiguration->cranking.rpm) { |
| 166 | 2 | engineConfiguration->vvtControlMinRpm = engineConfiguration->cranking.rpm; | ||
| 167 | } | |||
| 168 | 1208 | } | ||
| 169 | ||||
| 170 | 605 | void setDefaultBaseEngine() { | ||
| 171 | // Base Engine Settings | |||
| 172 | 605 | engineConfiguration->displacement = 2; | ||
| 173 | 605 | engineConfiguration->knockDetectionUseDoubleFrequency = true; | ||
| 174 | #if MAX_CYLINDER_COUNT >= 4 | |||
| 175 | 605 | setInline4(); | ||
| 176 | #else | |||
| 177 | // todo: invoke more complete one cylinder default? | |||
| 178 | engineConfiguration->cylindersCount = 1; | |||
| 179 | #endif | |||
| 180 | ||||
| 181 | 605 | engineConfiguration->isTuningDetectorEnabled = true; | ||
| 182 | ||||
| 183 |
2/2✓ Branch 0 taken 2420 times.
✓ Branch 1 taken 605 times.
|
2/2✓ Decision 'true' taken 2420 times.
✓ Decision 'false' taken 605 times.
|
3025 | for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) { |
| 184 | // one knock sensor by default. See also 'setLeftRightBanksNeedBetterName()' | |||
| 185 | // zero-based index | |||
| 186 | 2420 | engineConfiguration->cylinderBankSelect[i] = 0; | ||
| 187 | } | |||
| 188 | ||||
| 189 | 605 | engineConfiguration->ltft.enabled = true; | ||
| 190 | 605 | engineConfiguration->ltft.correctionEnabled = true; | ||
| 191 | ||||
| 192 | 605 | engineConfiguration->compressionRatio = 9; | ||
| 193 | 605 | engineConfiguration->vssFilterReciprocal = VSS_FILTER_MIN; | ||
| 194 | 605 | engineConfiguration->boardUseCanTerminator = true; | ||
| 195 | 605 | engineConfiguration->acLowRpmLimit = 500; | ||
| 196 | ||||
| 197 | 605 | engineConfiguration->mafFilterParameter = 1; | ||
| 198 | ||||
| 199 | #ifdef EFI_KLINE | |||
| 200 | engineConfiguration->kLinePeriodUs = 300 /* us*/; | |||
| 201 | engineConfiguration->kLineDoHondaSend = true; | |||
| 202 | #endif | |||
| 203 | ||||
| 204 | 605 | setGdiDefaults(); | ||
| 205 | ||||
| 206 | // it's useful to know what starting point is given tune based on | |||
| 207 | 605 | engineConfiguration->calibrationBirthday = compilationYear() * 10000 + compilationMonth() * 100 + compilationDay(); | ||
| 208 | ||||
| 209 | 605 | engineConfiguration->enableExtendedCanBroadcast = true; | ||
| 210 | ||||
| 211 | 605 | engineConfiguration->fan1ExtraIdle = 2; | ||
| 212 | 605 | engineConfiguration->fan2ExtraIdle = 2; | ||
| 213 | ||||
| 214 | 605 | engineConfiguration->auxSpeed1Multiplier = 1; | ||
| 215 | 605 | engineConfiguration->magicNumberAvailableForDevTricks = 1; | ||
| 216 | ||||
| 217 | 605 | engineConfiguration->acrRevolutions = 5; | ||
| 218 | 605 | engineConfiguration->acPressure.v2 = 5; | ||
| 219 | 605 | engineConfiguration->acPressure.value2 = 100; | ||
| 220 | ||||
| 221 | 605 | engineConfiguration->lowPressureFuel.v2 = 5; | ||
| 222 | 605 | engineConfiguration->lowPressureFuel.value2 = 100; | ||
| 223 | ||||
| 224 | 605 | engineConfiguration->wastegatePositionOpenedVoltage = 4.0; | ||
| 225 | ||||
| 226 | 605 | engineConfiguration->fuelLevelAveragingAlpha = engine_configuration_defaults::FUEL_LEVEL_AVERAGING_ALPHA; | ||
| 227 | 605 | engineConfiguration->fuelLevelUpdatePeriodSec = engine_configuration_defaults::FUEL_LEVEL_UPDATE_PERIOD_SEC; | ||
| 228 | 605 | engineConfiguration->fuelLevelLowThresholdVoltage = engine_configuration_defaults::FUEL_LEVEL_LOW_THRESHOLD_VOLTAGE; | ||
| 229 | 605 | engineConfiguration->fuelLevelHighThresholdVoltage = engine_configuration_defaults::FUEL_LEVEL_HIGH_THRESHOLD_VOLTAGE; | ||
| 230 | ||||
| 231 | 605 | engineConfiguration->watchOutForLinearTime = true; | ||
| 232 | ||||
| 233 | 605 | setLinearCurve(engineConfiguration->tractionControlSlipBins, /*from*/0.9, /*to*/1.2, 0.05); | ||
| 234 | 605 | setLinearCurve(engineConfiguration->tractionControlSpeedBins, /*from*/10, /*to*/120, 5); | ||
| 235 | ||||
| 236 | 605 | engineConfiguration->turbochargerFilter = 0.01f; | ||
| 237 | ||||
| 238 | 605 | mc33810defaults(); | ||
| 239 | ||||
| 240 | 605 | setRpmTableBin(config->torqueRpmBins); | ||
| 241 | // here we assume load is TPS | |||
| 242 | 605 | setLinearCurve(config->torqueLoadBins, 0, 100, 1); | ||
| 243 | ||||
| 244 | 605 | engineConfiguration->fuelAlgorithm = engine_load_mode_e::LM_SPEED_DENSITY; | ||
| 245 | // let's have valid default while we still have the field | |||
| 246 | 605 | engineConfiguration->debugMode = DBG_EXECUTOR; | ||
| 247 | ||||
| 248 | 605 | engineConfiguration->speedometerPulsePerKm = 2485; // GM GMT800 platform | ||
| 249 | ||||
| 250 | 605 | engineConfiguration->primingDelay = 0.5; | ||
| 251 | // this should not be below default rpm! maybe even make them equal? | |||
| 252 | 605 | engineConfiguration->vvtControlMinRpm = 600; | ||
| 253 | ||||
| 254 | // todo: this "2JZ" trigger is very powerful for many low tooth quantity applications | |||
| 255 | // todo: we might be getting closer to a re-name | |||
| 256 | // by the way 2GRFE intake likes position 160 / precision 20 | |||
| 257 | // see also https://github.com/rusefi/rusefi/issues/7345 | |||
| 258 | // | |||
| 259 | // 2JZ values | |||
| 260 | 605 | engineConfiguration->camDecoder2jzPosition = 95; | ||
| 261 | 605 | engineConfiguration->camDecoder2jzPrecision = 40; | ||
| 262 | ||||
| 263 | // Limits and Fallbacks | |||
| 264 | 605 | engineConfiguration->rpmHardLimit = 7000; | ||
| 265 | 605 | engineConfiguration->rpmHardLimitHyst = 50; | ||
| 266 | 605 | engineConfiguration->cutFuelOnHardLimit = true; | ||
| 267 | 605 | engineConfiguration->cutSparkOnHardLimit = true; | ||
| 268 | 605 | engineConfiguration->etbRevLimitRange = 250; | ||
| 269 | ||||
| 270 | 605 | engineConfiguration->tpsAccelFractionDivisor = 1; | ||
| 271 | ||||
| 272 | 605 | engineConfiguration->rpmSoftLimitTimingRetard = 4; | ||
| 273 | ||||
| 274 | // CLT RPM limit table - just the X axis | |||
| 275 | 605 | copyArray(config->cltRevLimitRpmBins, { -20, 0, 40, 80 }); | ||
| 276 | ||||
| 277 | 605 | engineConfiguration->ALSMinRPM = 400; | ||
| 278 | 605 | engineConfiguration->ALSMaxRPM = 3200; | ||
| 279 | 605 | engineConfiguration->ALSMaxDuration = 3; | ||
| 280 | 605 | engineConfiguration->ALSMaxCLT = 105; | ||
| 281 | // engineConfiguration->alsMinPps = 10; | |||
| 282 | 605 | engineConfiguration->alsMinTimeBetween = 5; | ||
| 283 | 605 | engineConfiguration->alsEtbPosition = 30; | ||
| 284 | 605 | engineConfiguration->ALSMaxTPS = 5; | ||
| 285 | ||||
| 286 | 605 | engineConfiguration->torqueReductionActivationTemperature = 60; | ||
| 287 | ||||
| 288 | 605 | engineConfiguration->knockRetardAggression = 20; | ||
| 289 | 605 | engineConfiguration->knockRetardReapplyRate = 3; | ||
| 290 | 605 | engineConfiguration->knockFuelTrim = 0; | ||
| 291 | 605 | engineConfiguration->knockSuppressMinTps = 10; | ||
| 292 | ||||
| 293 | 605 | setRpmTableBin(config->maxKnockRetardRpmBins); | ||
| 294 | 605 | setLinearCurve(config->maxKnockRetardLoadBins, 0, 100, 1); | ||
| 295 | 605 | setTable(config->maxKnockRetardTable, 20); | ||
| 296 | ||||
| 297 | // Trigger | |||
| 298 | 605 | engineConfiguration->trigger.type = trigger_type_e::TT_TOOTHED_WHEEL_60_2; | ||
| 299 | ||||
| 300 | #if EFI_SIMULATOR | |||
| 301 | engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH; | |||
| 302 | engineConfiguration->vvtOffsets[0] = 450; | |||
| 303 | engineConfiguration->vvtPins[0] = Gpio::A0; // a random unused pin needed to unblock startSimplePwmExt() | |||
| 304 | #endif // EFI_SIMULATOR | |||
| 305 | ||||
| 306 | #if EFI_SIMULATOR | |||
| 307 | // R | |||
| 308 | config->tcuSolenoidTable[0][0] = 99; | |||
| 309 | config->tcuSolenoidTable[0][1] = 1; | |||
| 310 | config->tcuSolenoidTable[0][2] = 2; | |||
| 311 | config->tcuSolenoidTable[0][3] = 3; | |||
| 312 | config->tcuSolenoidTable[0][4] = 4; | |||
| 313 | config->tcuSolenoidTable[0][5] = 5; | |||
| 314 | // P/N | |||
| 315 | config->tcuSolenoidTable[1][0] = 10; | |||
| 316 | config->tcuSolenoidTable[1][1] = 11; | |||
| 317 | config->tcuSolenoidTable[1][2] = 12; | |||
| 318 | config->tcuSolenoidTable[1][3] = 13; | |||
| 319 | config->tcuSolenoidTable[1][4] = 14; | |||
| 320 | config->tcuSolenoidTable[1][5] = 15; | |||
| 321 | config->tcuSolenoidTable[1][6] = 16; | |||
| 322 | config->tcuSolenoidTable[1][7] = 17; | |||
| 323 | config->tcuSolenoidTable[1][8] = 18; | |||
| 324 | config->tcuSolenoidTable[1][9] = 19; | |||
| 325 | // 1 | |||
| 326 | config->tcuSolenoidTable[2][0] = 20; | |||
| 327 | config->tcuSolenoidTable[2][1] = 21; | |||
| 328 | config->tcuSolenoidTable[2][2] = 22; | |||
| 329 | // 2 | |||
| 330 | config->tcuSolenoidTable[3][0] = 30; | |||
| 331 | config->tcuSolenoidTable[3][1] = 31; | |||
| 332 | config->tcuSolenoidTable[3][3] = 33; | |||
| 333 | // 3 | |||
| 334 | config->tcuSolenoidTable[4][0] = 40; | |||
| 335 | config->tcuSolenoidTable[4][1] = 41; | |||
| 336 | config->tcuSolenoidTable[4][4] = 44; | |||
| 337 | // 4 | |||
| 338 | config->tcuSolenoidTable[5][0] = 50; | |||
| 339 | config->tcuSolenoidTable[5][1] = 51; | |||
| 340 | config->tcuSolenoidTable[5][5] = 55; | |||
| 341 | ||||
| 342 | // [tag:runNotSquareTest] huh why is this not a unit test?! | |||
| 343 | config->scriptTable4[0][0] = 140; | |||
| 344 | config->scriptTable4[0][1] = 141; | |||
| 345 | config->scriptTable4[0][2] = 142; | |||
| 346 | config->scriptTable4[0][3] = 143; | |||
| 347 | config->scriptTable4[0][4] = 144; | |||
| 348 | config->scriptTable4[0][5] = 145; | |||
| 349 | ||||
| 350 | config->scriptTable4[1][0] = 240; | |||
| 351 | config->scriptTable4[1][1] = 241; | |||
| 352 | config->scriptTable4[1][2] = 242; | |||
| 353 | config->scriptTable4[1][3] = 243; | |||
| 354 | config->scriptTable4[1][4] = 244; | |||
| 355 | config->scriptTable4[1][5] = 245; | |||
| 356 | ||||
| 357 | config->scriptTable4[4][0] = 40; | |||
| 358 | config->scriptTable4[4][2] = 41; | |||
| 359 | config->scriptTable4[4][3] = 42; | |||
| 360 | config->scriptTable4[4][4] = 43; | |||
| 361 | config->scriptTable4[4][5] = 44; | |||
| 362 | config->scriptTable4[4][5] = 45; | |||
| 363 | ||||
| 364 | config->scriptTable4[5][0] = 50; | |||
| 365 | config->scriptTable4[5][1] = 51; | |||
| 366 | config->scriptTable4[5][2] = 52; | |||
| 367 | config->scriptTable4[5][3] = 53; | |||
| 368 | config->scriptTable4[5][4] = 54; | |||
| 369 | config->scriptTable4[5][5] = 55; | |||
| 370 | ||||
| 371 | #endif // EFI_SIMULATOR | |||
| 372 | ||||
| 373 | 605 | engineConfiguration->globalTriggerAngleOffset = 0; | ||
| 374 | ||||
| 375 | // Default this to on - if you want to diagnose, turn it off. | |||
| 376 | 605 | engineConfiguration->silentTriggerError = true; | ||
| 377 | ||||
| 378 | 605 | engineConfiguration->idleStepperReactionTime = 3; | ||
| 379 | 605 | engineConfiguration->idleStepperTotalSteps = 200; | ||
| 380 | 605 | engineConfiguration->stepperForceParkingEveryRestart = true; | ||
| 381 | 605 | engineConfiguration->iacByTpsTaper = 2; | ||
| 382 | ||||
| 383 | 605 | engineConfiguration->etbSplit = MAX_TPS_PPS_DISCREPANCY; | ||
| 384 | ||||
| 385 | // Advanced Trigger | |||
| 386 | ||||
| 387 | // Battery and alternator | |||
| 388 | 605 | engineConfiguration->vbattDividerCoeff = ((float) (15 + 65)) / 15; | ||
| 389 | ||||
| 390 | #if EFI_ALTERNATOR_CONTROL | |||
| 391 | 605 | setDefaultAlternatorParameters(); | ||
| 392 | #endif /* EFI_ALTERNATOR_CONTROL */ | |||
| 393 | ||||
| 394 | // Fuel pump | |||
| 395 | // todo: maybe change to 2s as default? | |||
| 396 | 605 | engineConfiguration->startUpFuelPumpDuration = 4; | ||
| 397 | ||||
| 398 | 605 | engineConfiguration->kLineBaudRate = KLINE_BAUD_RATE; | ||
| 399 | ||||
| 400 | 605 | engineConfiguration->benchTestOnTime = 4; | ||
| 401 | 605 | engineConfiguration->benchTestOffTime = 500; | ||
| 402 | 605 | engineConfiguration->benchTestCount = 3; | ||
| 403 | ||||
| 404 | ||||
| 405 | // Tachometer | |||
| 406 | // 50% duty cycle is the default for tach signal | |||
| 407 | 605 | engineConfiguration->tachPulseDurationAsDutyCycle = true; | ||
| 408 | 605 | engineConfiguration->tachPulseDuractionMs = 0.5; | ||
| 409 | 605 | engineConfiguration->tachPulsePerRev = 1; | ||
| 410 | ||||
| 411 | 605 | engineConfiguration->etbMinimumPosition = 1; | ||
| 412 | 605 | engineConfiguration->etbMaximumPosition = 100; | ||
| 413 | ||||
| 414 | 605 | engineConfiguration->tcuInputSpeedSensorTeeth = 1; | ||
| 415 | 605 | engineConfiguration->issFilterReciprocal = 2; | ||
| 416 | ||||
| 417 | //knock | |||
| 418 | #ifdef KNOCK_SPECTROGRAM | |||
| 419 | engineConfiguration->enableKnockSpectrogram = false; | |||
| 420 | engineConfiguration->enableKnockSpectrogramFilter = false; | |||
| 421 | engineConfiguration->knockSpectrumSensitivity = 1.0; | |||
| 422 | engineConfiguration->knockFrequency = 0.0; | |||
| 423 | #endif | |||
| 424 | ||||
| 425 | // Check engine light | |||
| 426 | #if EFI_PROD_CODE | |||
| 427 | engineConfiguration->warningPeriod = 10; | |||
| 428 | #else | |||
| 429 | 605 | engineConfiguration->warningPeriod = 0; | ||
| 430 | #endif /* EFI_PROD_CODE */ | |||
| 431 | ||||
| 432 | 605 | setDefaultVrThresholds(); | ||
| 433 | ||||
| 434 | // Oil pressure protection | |||
| 435 | 605 | engineConfiguration->minimumOilPressureTimeout = 0.5f; | ||
| 436 | 605 | setRpmTableBin(config->minimumOilPressureBins); | ||
| 437 | 605 | setRpmTableBin(config->maximumOilPressureBins); | ||
| 438 | ||||
| 439 | 18755 | engine->engineModules.apply_all([](auto & m) { m.setDefaultConfiguration(); }); | ||
| 440 | ||||
| 441 | 605 | engineConfiguration->useMetricOnInterface = true; | ||
| 442 | ||||
| 443 | // we invoke this last so that we can validate even defaults | |||
| 444 | 605 | defaultsOrFixOnBurn(); | ||
| 445 | 605 | } | ||
| 446 | ||||
| 447 | 1 | void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2) { | ||
| 448 | 1 | engineConfiguration->throttlePedalPositionAdcChannel = pps1; | ||
| 449 | 1 | engineConfiguration->throttlePedalPositionSecondAdcChannel = pps2; | ||
| 450 | 1 | } | ||
| 451 | ||||
| 452 | ✗ | void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2) { | ||
| 453 | ✗ | engineConfiguration->tps1_1AdcChannel = tps1; | ||
| 454 | ✗ | engineConfiguration->tps1_2AdcChannel = tps2; | ||
| 455 | ✗ | } | ||
| 456 | ||||
| 457 | 606 | void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax) { | ||
| 458 | 606 | engineConfiguration->tpsMin = tpsMin; | ||
| 459 | 606 | engineConfiguration->tpsMax = tpsMax; | ||
| 460 | 606 | } | ||
| 461 | ||||
| 462 | 606 | void setTPS1Calibration(uint16_t tpsMin, uint16_t tpsMax, uint16_t tps1SecondaryMin, uint16_t tps1SecondaryMax) { | ||
| 463 | 606 | setTPS1Calibration(tpsMin, tpsMax); | ||
| 464 | ||||
| 465 | ||||
| 466 | 606 | engineConfiguration->tps1SecondaryMin = tps1SecondaryMin; | ||
| 467 | 606 | engineConfiguration->tps1SecondaryMax = tps1SecondaryMax; | ||
| 468 | 606 | } | ||
| 469 | ||||
| 470 | 10 | void setCustomMap(float lowValue, float mapLowValueVoltage, float highValue, float mapHighValueVoltage) { | ||
| 471 | 10 | engineConfiguration->map.sensor.type = MT_CUSTOM; | ||
| 472 | 10 | engineConfiguration->map.sensor.lowValue = lowValue; | ||
| 473 | 10 | engineConfiguration->mapLowValueVoltage = mapLowValueVoltage; | ||
| 474 | 10 | engineConfiguration->map.sensor.highValue = highValue; | ||
| 475 | 10 | engineConfiguration->mapHighValueVoltage = mapHighValueVoltage; | ||
| 476 | 10 | } | ||
| 477 | ||||
| 478 | 608 | void setPPSCalibration(float primaryUp, float primaryDown, float secondaryUp, float secondaryDown) { | ||
| 479 | 608 | engineConfiguration->throttlePedalUpVoltage = primaryUp; | ||
| 480 | 608 | engineConfiguration->throttlePedalWOTVoltage = primaryDown; | ||
| 481 | 608 | engineConfiguration->throttlePedalSecondaryUpVoltage = secondaryUp; | ||
| 482 | 608 | engineConfiguration->throttlePedalSecondaryWOTVoltage = secondaryDown; | ||
| 483 | 608 | } | ||
| 484 | ||||
| 485 | 1 | void setEtbPID(float p, float i, float d) { | ||
| 486 | 1 | engineConfiguration->etb.pFactor = p; | ||
| 487 | 1 | engineConfiguration->etb.iFactor = i; | ||
| 488 | 1 | engineConfiguration->etb.dFactor = d; | ||
| 489 | 1 | } | ||
| 490 | ||||
| 491 | 609 | void setInline4() { | ||
| 492 | 609 | engineConfiguration->cylindersCount = 4; | ||
| 493 | 609 | engineConfiguration->firingOrder = FO_1_3_4_2; | ||
| 494 | 609 | } | ||
| 495 | ||||
| 496 | ✗ | void setProteusEtbIO() { | ||
| 497 | #if HW_PROTEUS && EFI_PROD_CODE | |||
| 498 | engineConfiguration->tps1_2AdcChannel = PROTEUS_IN_TPS1_2; | |||
| 499 | setPPSInputs(PROTEUS_IN_PPS, PROTEUS_IN_PPS2); | |||
| 500 | #endif // HW_PROTEUS | |||
| 501 | ✗ | } | ||
| 502 | ||||
| 503 | ✗ | void setupTLE9201(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) { | ||
| 504 | // TLE9201 driver | |||
| 505 | // This chip has three control pins: | |||
| 506 | // DIR - sets direction of the motor | |||
| 507 | // PWM - pwm control (enable high, coast low) | |||
| 508 | // DIS - disables motor (enable low) | |||
| 509 | ||||
| 510 | // PWM pin | |||
| 511 | ✗ | engineConfiguration->etbIo[dcIndex].controlPin = controlPin; | ||
| 512 | // DIR pin | |||
| 513 | ✗ | engineConfiguration->etbIo[dcIndex].directionPin1 = direction; | ||
| 514 | // Disable pin | |||
| 515 | ✗ | engineConfiguration->etbIo[dcIndex].disablePin = disable; | ||
| 516 | ||||
| 517 | // we only have pwm/dir, no dira/dirb | |||
| 518 | ✗ | engineConfiguration->etb_use_two_wires = false; | ||
| 519 | ✗ | } | ||
| 520 | ||||
| 521 | ✗ | void setupTLE9201IncludingStepper(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) { | ||
| 522 | ✗ | setupTLE9201(controlPin, direction, disable, dcIndex); | ||
| 523 | ||||
| 524 | // on SBC style stepper IAC fully-extended valve shaft would give least idle air | |||
| 525 | // fully-retracted valve shaft would give most idle air | |||
| 526 | ✗ | int stepperIndexWeirdness = 1 - dcIndex; | ||
| 527 | ✗ | engineConfiguration->stepperDcIo[stepperIndexWeirdness].controlPin = controlPin; | ||
| 528 | ✗ | engineConfiguration->stepperDcIo[stepperIndexWeirdness].directionPin1 = direction; | ||
| 529 | ✗ | engineConfiguration->stepperDcIo[stepperIndexWeirdness].directionPin2 = Gpio::Unassigned; | ||
| 530 | ✗ | engineConfiguration->stepperDcIo[stepperIndexWeirdness].disablePin = disable; | ||
| 531 | ✗ | } | ||
| 532 |