2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2020-07-23 01:12:38 -07:00
|
|
|
#include "airmass.h"
|
2021-01-10 21:54:37 -08:00
|
|
|
#include "idle_thread.h"
|
2020-09-06 16:06:32 -07:00
|
|
|
|
2021-05-14 04:17:22 -07:00
|
|
|
AirmassVeModelBase::AirmassVeModelBase(const ValueProvider3D& veTable) : m_veTable(&veTable) {}
|
2020-07-23 01:12:38 -07:00
|
|
|
|
2021-05-14 04:17:22 -07:00
|
|
|
float AirmassVeModelBase::getVeLoadAxis(float passedLoad) const {
|
2021-11-17 00:54:21 -08:00
|
|
|
switch(engineConfiguration->veOverrideMode) {
|
2020-09-07 07:15:42 -07:00
|
|
|
case VE_None: return passedLoad;
|
2021-10-05 16:59:07 -07:00
|
|
|
case VE_MAP: return Sensor::getOrZero(SensorType::Map);
|
|
|
|
case VE_TPS: return Sensor::getOrZero(SensorType::Tps1);
|
2020-09-07 07:15:42 -07:00
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 04:17:22 -07:00
|
|
|
float AirmassVeModelBase::getVe(int rpm, float load) const {
|
2020-07-23 01:12:38 -07:00
|
|
|
efiAssert(OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0);
|
|
|
|
|
2020-09-07 07:15:42 -07:00
|
|
|
// Override the load value if necessary
|
|
|
|
load = getVeLoadAxis(load);
|
|
|
|
|
2021-12-26 09:33:32 -08:00
|
|
|
percent_t ve = m_veTable->getValue(rpm, load);
|
2020-09-06 16:06:32 -07:00
|
|
|
|
|
|
|
auto tps = Sensor::get(SensorType::Tps1);
|
2021-01-10 21:54:37 -08:00
|
|
|
// get VE from the separate table for Idle if idling
|
2021-11-17 18:50:00 -08:00
|
|
|
if (engine->module<IdleController>().unmock().isIdlingOrTaper() &&
|
2021-11-17 09:13:19 -08:00
|
|
|
tps && engineConfiguration->useSeparateVeForIdle) {
|
2021-12-26 09:33:32 -08:00
|
|
|
percent_t idleVe = interpolate2d(rpm, config->idleVeBins, config->idleVe);
|
2020-09-06 16:06:32 -07:00
|
|
|
// interpolate between idle table and normal (running) table using TPS threshold
|
2021-11-17 00:54:21 -08:00
|
|
|
ve = interpolateClamped(0.0f, idleVe, engineConfiguration->idlePidDeactivationTpsThreshold, ve, tps.Value);
|
2020-09-06 16:06:32 -07:00
|
|
|
}
|
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
engine->engineState.currentVe = ve;
|
|
|
|
engine->engineState.currentVeLoad = load;
|
2021-12-26 09:33:32 -08:00
|
|
|
return ve * PERCENT_DIV;
|
2020-07-23 01:12:38 -07:00
|
|
|
}
|