pull out std air charge math (#1397)

This commit is contained in:
Matthew Kennedy 2020-05-05 05:01:40 -07:00 committed by GitHub
parent 27de7eabc0
commit 745b0c04ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 4 deletions

View File

@ -145,6 +145,8 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
cylinderCleanupControl(PASS_ENGINE_PARAMETER_SIGNATURE);
standardAirCharge = getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE);
#if (BOARD_TLE8888_COUNT > 0)
if (CONFIG(useTLE8888_cranking_hack) && ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) {
efitick_t nowNt = getTimeNowNt();

View File

@ -216,6 +216,9 @@ public:
*/
floatms_t actualLastInjection = 0;
// Standard cylinder air charge - 100% VE at standard temperature, grams per cylinder
float standardAirCharge = 0;
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE);

View File

@ -163,11 +163,9 @@ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
float halfCylCount = CONFIG(specs.cylindersCount) / 2.0f;
float cylinderAirmass = airPerRevolution / halfCylCount;
//Calculation of 100% VE air mass in g/rev - 1 cylinder filling at 1.2929g/L
float StandardAirCharge = CONFIG(specs.displacement) / CONFIG(specs.cylindersCount) * 1.2929;
//Create % load for fuel table using relative naturally aspiratedcylinder filling
float airChargeLoad = 100 * cylinderAirmass/StandardAirCharge;
float airChargeLoad = 100 * cylinderAirmass / ENGINE(standardAirCharge);
//Correct air mass by VE table
float corrCylAirmass = cylinderAirmass * veMap.getValue(rpm, airChargeLoad) / 100;
@ -452,6 +450,15 @@ floatms_t getCrankingFuel(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return getCrankingFuel3(Sensor::get(SensorType::Clt).value_or(20),
engine->rpmCalculator.getRevolutionCounterSinceStart() PASS_ENGINE_PARAMETER_SUFFIX);
}
float getStandardAirCharge(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
float totalDisplacement = CONFIG(specs.displacement);
float cylDisplacement = totalDisplacement / CONFIG(specs.cylindersCount);
// Calculation of 100% VE air mass in g/cyl - 1 cylinder filling at 1.204/L - air density at 20C
return cylDisplacement * 1.204f;
}
#endif
float getFuelRate(floatms_t totalInjDuration, efitick_t timePeriod DECLARE_ENGINE_PARAMETER_SUFFIX) {

View File

@ -37,5 +37,7 @@ floatms_t getCrankingFuel3(float coolantTemperature, uint32_t revolutionCounterS
floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
percent_t getInjectorDutyCycle(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
float getStandardAirCharge(DECLARE_ENGINE_PARAMETER_SIGNATURE);
// convert injection duration (Ms/Nt) to fuel rate (L/h)
float getFuelRate(floatms_t totalInjDuration, efitick_t timePeriod DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -0,0 +1,31 @@
#include "engine_test_helper.h"
#include "fuel_math.h"
#include "gtest/gtest.h"
TEST(FuelMath, getStandardAirCharge) {
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
// Miata 1839cc 4cyl
CONFIG(specs.displacement) = 1.839f;
CONFIG(specs.cylindersCount) = 4;
EXPECT_FLOAT_EQ(0.553539f, getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE));
// LS 5.3 liter v8
CONFIG(specs.displacement) = 5.327f;
CONFIG(specs.cylindersCount) = 8;
EXPECT_FLOAT_EQ(0.80171353f, getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE));
// Chainsaw - single cylinder 32cc
CONFIG(specs.displacement) = 0.032f;
CONFIG(specs.cylindersCount) = 1;
EXPECT_FLOAT_EQ(0.038528003, getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE));
// Leopard 1 47.666 liter v12
CONFIG(specs.displacement) = 47.666f;
CONFIG(specs.cylindersCount) = 12;
EXPECT_FLOAT_EQ(4.782489f, getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE));
}

View File

@ -50,4 +50,5 @@ TESTS_SRC_CPP = \
tests/sensor/test_sensor_init.cpp \
tests/test_closed_loop_controller.cpp \
tests/test_gppwm.cpp \
tests/test_fuel_math.cpp \