2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2020-07-25 01:14:35 -07:00
|
|
|
#include "alphan_airmass.h"
|
|
|
|
|
2024-09-24 23:21:39 -07:00
|
|
|
AirmassResult AlphaNAirmass::getAirmass(float rpm, bool postState) {
|
2020-07-25 01:14:35 -07:00
|
|
|
auto tps = Sensor::get(SensorType::Tps1);
|
|
|
|
|
|
|
|
if (!tps.Valid) {
|
|
|
|
// We are fully reliant on TPS - if the TPS fails, stop the engine.
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// In this case, VE directly describes the cylinder filling relative to the ideal
|
2023-05-15 17:18:35 -07:00
|
|
|
float ve = getVe(rpm, tps.Value, postState);
|
2020-07-25 01:14:35 -07:00
|
|
|
|
2023-09-16 23:21:03 -07:00
|
|
|
// optionally use real IAT instead of fixed air temperature
|
2024-09-12 22:00:25 -07:00
|
|
|
constexpr float standardIat = 20.0f; // std atmosphere temperature
|
2023-09-16 23:21:03 -07:00
|
|
|
float iat = engineConfiguration->alphaNUseIat
|
|
|
|
? Sensor::get(SensorType::Iat).value_or(standardIat)
|
|
|
|
: standardIat;
|
|
|
|
|
2024-09-12 22:00:25 -07:00
|
|
|
float iatK = iat + 273;
|
|
|
|
|
2020-07-25 01:14:35 -07:00
|
|
|
// TODO: should this be barometric pressure and/or temperature compensated?
|
2021-12-26 10:41:10 -08:00
|
|
|
mass_t airmass = getAirmassImpl(
|
2020-09-06 16:06:32 -07:00
|
|
|
ve,
|
2020-07-25 01:14:35 -07:00
|
|
|
101.325f, // std atmosphere pressure
|
2024-09-12 22:00:25 -07:00
|
|
|
iatK
|
2020-07-25 01:14:35 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
airmass,
|
|
|
|
tps.Value
|
|
|
|
};
|
|
|
|
}
|