Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firmware/config/engines/bmw_m73.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void m73engine() {
engineConfiguration->cranking.baseFuel = 27;

engineConfiguration->crankingTimingAngle = 15;
setTable(config->veTable, 45);
setTable(config->veTableAlphaN, 45);

engineConfiguration->cylinderBore = 85.0;
}
Expand Down
2 changes: 1 addition & 1 deletion firmware/config/engines/dodge_neon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void setDodgeNeonNGCEngineConfiguration() {
*/
//setWholeTimingTable_d(12);

//setMap(config->veTable, 50);
//setMap(config->veTableAlphaN, 50);

// set cranking_timing_angle 710
engineConfiguration->crankingTimingAngle = -710;
Expand Down
4 changes: 3 additions & 1 deletion firmware/config/engines/ford_festiva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ void setFordEscortGt() {
copyArray(config->veRpmBins, veRpmBins);


copyTable(config->veTable, racingFestivaVeTable);
copyTable(config->veTableSd, racingFestivaVeTable);
copyTable(config->veTableMaf, racingFestivaVeTable);
copyTable(config->veTableAlphaN, racingFestivaVeTable);

// engineConfiguration->triggerInputPins[0] = Gpio::C6; // 2G YEL/BLU
// engineConfiguration->triggerInputPins[1] = Gpio::A5; // 2E White CKP
Expand Down
4 changes: 3 additions & 1 deletion firmware/config/engines/mazda_miata_1_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ static const uint8_t hardCodedveTable[16][16] = {
static void setMapVeTable() {
copyArray(config->veLoadBins, hardCodedveLoadBins);
copyArray(config->veRpmBins, hardCodedveRpmBins);
copyTable(config->veTable, hardCodedveTable);
copyTable(config->veTableSd, hardCodedveTable);
copyTable(config->veTableMaf, hardCodedveTable);
copyTable(config->veTableAlphaN, hardCodedveTable);
}

#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT
Expand Down
4 changes: 3 additions & 1 deletion firmware/config/engines/mazda_miata_custom_hunchback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ void setMazdaMiata2003EngineConfigurationNaFuelRail() {

copyArray(config->veRpmBins, mazda_miata_nb2_RpmBins);
copyArray(config->veLoadBins, mazda_miata_nb2_LoadBins);
copyTable(config->veTable, mapBased18vvtVeTable_NA_fuel_rail);
copyTable(config->veTableSd, mapBased18vvtVeTable_NA_fuel_rail);
copyTable(config->veTableMaf, mapBased18vvtVeTable_NA_fuel_rail);
copyTable(config->veTableAlphaN, mapBased18vvtVeTable_NA_fuel_rail);

engineConfiguration->vvtOffsets[0] = 83; // 2002 green car value

Expand Down
4 changes: 3 additions & 1 deletion firmware/config/engines/mazda_miata_vvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ static void setCommonMazdaNB() {
// Tables
copyArray(config->veRpmBins, mazda_miata_nb2_RpmBins);
copyArray(config->veLoadBins, mazda_miata_nb2_LoadBins);
copyTable(config->veTable, mapBased18vvtVeTable_NB_fuel_rail);
copyTable(config->veTableSd, mapBased18vvtVeTable_NB_fuel_rail);
copyTable(config->veTableMaf, mapBased18vvtVeTable_NB_fuel_rail);
copyTable(config->veTableAlphaN, mapBased18vvtVeTable_NB_fuel_rail);

copyArray(config->ignitionRpmBins, ignition18vvtRpmBins);
copyArray(config->ignitionLoadBins, ignition18vvtLoadBins);
Expand Down
4 changes: 3 additions & 1 deletion firmware/config/engines/vw_b6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ static inline void commonPassatB6() {

engineConfiguration->hpfpPeakPos = 10;

setTable(config->veTable, 55);
setTable(config->veTableSd, 55);
setTable(config->veTableMaf, 55);
setTable(config->veTableAlphaN, 55);
setBoschVAGETB();

// random number just to take position away from zero
Expand Down
25 changes: 24 additions & 1 deletion firmware/controllers/algo/airmass/airmass.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "engine_configuration.h"
#include "engine_configuration_generated_structures.h"
#include "pch.h"

#include "airmass.h"
#include "idle_thread.h"
#include "table_helper.h"

AirmassVeModelBase::AirmassVeModelBase(const ValueProvider3D* veTable) : m_veTable(veTable) {}

Expand Down Expand Up @@ -74,8 +77,28 @@ float AirmassVeModelBase::getVe(float rpm, float load, bool postState) const {
}

float AirmassVeModelBase::getVeImpl(float rpm, percent_t load) const {
auto veTable = &config->veTableSd;

switch (engineConfiguration->fuelAlgorithm) {
case LM_SPEED_DENSITY:
veTable = &config->veTableSd;
break;
case LM_REAL_MAF:
veTable = &config->veTableMaf;
break;
case LM_ALPHA_N:
veTable = &config->veTableAlphaN;
break;
// case LM_LUA: // #if EFI_LUA
// case LM_MOCK: // #if EFI_UNIT_TEST
default:
// firmwareError(ObdCode::CUSTOM_ERR_ASSERT, "Invalid airmass mode %d", engineConfiguration->fuelAlgorithm);
// return 0;
break;
}

return interpolate3d(
config->veTable,
*veTable,
config->veLoadBins, load,
config->veRpmBins, rpm
);
Expand Down
4 changes: 3 additions & 1 deletion firmware/controllers/algo/defaults/default_fuel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ static void setDefaultWarmupFuelEnrichment() {

static void setDefaultVETable() {
setRpmTableBin(config->veRpmBins);
setTable(config->veTable, 80);
setTable(config->veTableSd, 80);
setTable(config->veTableMaf, 80);
setTable(config->veTableAlphaN, 80);

setRpmTableBin(config->baroCorrRpmBins);
setLinearCurve(config->baroCorrPressureBins, 75, 105, 1);
Expand Down
1 change: 0 additions & 1 deletion firmware/controllers/algo/fuel_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "fuel_math.h"
#include "fuel_computer.h"
#include "injector_model.h"
#include "speed_density.h"
#include "speed_density_base.h"
#include "lua_hooks.h"

Expand Down
4 changes: 3 additions & 1 deletion firmware/integration/rusefi_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,9 @@ int16_t[IGN_RPM_COUNT x IGN_LOAD_COUNT] autoscale ignitionTable;;"deg", 0.1, 0,
uint16_t[IGN_LOAD_COUNT] ignitionLoadBins;;"Load", 1, 0, 0, 1000, 0
uint16_t[IGN_RPM_COUNT] ignitionRpmBins;;"RPM", 1, 0, 0, 18000, 0

uint16_t[FUEL_RPM_COUNT x FUEL_LOAD_COUNT] autoscale veTable;;"%", 0.1, 0, 0, 999, 1
uint16_t[FUEL_RPM_COUNT x FUEL_LOAD_COUNT] autoscale veTableSd;VE table used with speed-density fuel strategy;"%", 0.1, 0, 0, 999, 1
uint16_t[FUEL_RPM_COUNT x FUEL_LOAD_COUNT] autoscale veTableMaf;VE table used with MAF fuel strategy;"%", 0.1, 0, 0, 999, 1
uint16_t[FUEL_RPM_COUNT x FUEL_LOAD_COUNT] autoscale veTableAlphaN;VE table used with Alpha-N fuel strategy;"%", 0.1, 0, 0, 999, 1
uint16_t[FUEL_LOAD_COUNT] veLoadBins;;"kPa", 1, 0, 0, 1000, 0
uint16_t[FUEL_RPM_COUNT] veRpmBins;;"RPM", 1, 0, 0, 18000, 0

Expand Down
42 changes: 31 additions & 11 deletions firmware/tunerstudio/tunerstudio.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ enable2ndByteCanID = false

; tableName, lambdaTargetTableName, lambdaChannel, egoCorrectionChannel, activeCondition
#if LAMBDA
veAnalyzeMap = veTableTbl, lambdaTableTbl, lambdaValues1, egoCorrectionForVeAnalyze, { 1 }
veAnalyzeMap = veTableSdTbl, veTableMafTbl, veTableAlphaNTbl, lambdaTableTbl, lambdaValues1, egoCorrectionForVeAnalyze, { 1 }
lambdaTargetTables = lambdaTableTbl, afrTSCustom
#else
veAnalyzeMap = veTableTbl, afrTableTbl, afrGasolineScale, egoCorrectionForVeAnalyze, { 1 }
veAnalyzeMap = veTableSdTbl, veTableMafTbl, veTableAlphaNTbl, afrTableTbl, afrGasolineScale, egoCorrectionForVeAnalyze, { 1 }
lambdaTargetTables = afrTableTbl, afrTSCustom
#endif

Expand Down Expand Up @@ -979,16 +979,34 @@ curve = 32Curve, "3-2 Shift Solenoid Percent by Speed"
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"

table = veTableTbl, veTableMap, "VE Table", 1
table = veTableSdTbl, veTableSdMap, "VE Table: Speed Density", 1
xyLabels = "RPM", "load"
xBins = veRpmBins, RPMValue
yBins = veLoadBins, veTableYAxis
zBins = veTable
zBins = veTableSd
; gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"

table = idleVeTableTbl, idleVeTable, "Idle VE"
table = veTableMafTbl, veTableMafMap, "VE Table: MAF", 1
xyLabels = "RPM", "load"
xBins = veRpmBins, RPMValue
yBins = veLoadBins, veTableYAxis
zBins = veTableMaf
; gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"

table = veTableAlphaNTbl, veTableAlphaNMap, "VE Table: Alpha-N", 1
xyLabels = "RPM", "load"
xBins = veRpmBins, RPMValue
yBins = veLoadBins, veTableYAxis
zBins = veTableAlphaN
; gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.
upDownLabel = "(RICHER)", "(LEANER)"

table = idleVeTableTbl, idleVeTableMap, "Idle VE"
xyLabels = "RPM", "load"
xBins = idleVeRpmBins, RPMValue
yBins = idleVeLoadBins, idleVeTableYAxis
Expand Down Expand Up @@ -4219,11 +4237,11 @@ dialog = tcuControls, "Transmission Settings"

dialog = veTableDialog
topicHelp = "veTableDialogHelp"
panel = veTableTbl, South

dialog = veTableDialog3D, "VE Table"
topicHelp = "veTableDialogHelp"
panel = veTableMap, South
field = "Fuel strategy", fuelAlgorithm
; TODO(nms): a button to copy current fuelAlgorithm's veTable to the others
panel = veTableSdTbl, South, { fuelAlgorithm == @@engine_load_mode_e_LM_SPEED_DENSITY@@ }
panel = veTableMafTbl, South, { fuelAlgorithm == @@engine_load_mode_e_LM_REAL_MAF@@ }
panel = veTableAlphaNTbl, South, { fuelAlgorithm == @@engine_load_mode_e_LM_ALPHA_N@@ }

dialog = etbPidDialog, "PID settings"
field = "pFactor", etb_pFactor
Expand Down Expand Up @@ -4708,7 +4726,9 @@ dialog = tcuControls, "Transmission Settings"

[Tools]
;addTool = toolName, PanelName
addTool = veTableGenerator, "VE Table Generator", veTableTbl
addTool = veTableGenerator, "VE Table Generator: Speed Density", veTableSdTbl
addTool = veTableGenerator, "VE Table Generator: MAF", veTableMafTbl
addTool = veTableGenerator, "VE Table Generator: Alpha-N", veTableAlphaNTbl
#if LAMBDA
#else
addTool = afrTableGenerator, "AFR Table Generator", afrTableTbl
Expand Down
Loading