This commit is contained in:
Matthew Kennedy 2020-08-10 21:41:03 -07:00
parent 1d0a244fa4
commit 1f64754b57
5 changed files with 7 additions and 44 deletions

View File

@ -290,7 +290,6 @@ static void showFuelInfo2(float rpm, float engineLoad) {
float magicAir = SpeedDensityBase::getAirmassImpl(1, 100, convertCelsiusToKelvin(20) PASS_ENGINE_PARAMETER_SUFFIX);
scheduleMsg(&logger, "SD magic fuel %.2f", getInjectionDurationForAirmass(magicAir, 14.7 PASS_ENGINE_PARAMETER_SUFFIX));
scheduleMsg(&logger, "inj flow %.2fcc/min displacement %.2fL", engineConfiguration->injector.flow,
engineConfiguration->specs.displacement);

View File

@ -27,6 +27,7 @@
#include "maf_airmass.h"
#include "speed_density_airmass.h"
#include "fuel_math.h"
#include "fuel_computer.h"
#include "interpolation.h"
#include "engine_configuration.h"
#include "allsensors.h"
@ -163,10 +164,10 @@ constexpr float convertToGramsPerSecond(float ccPerMinute) {
/**
* @return per cylinder injection time, in seconds
*/
float getInjectionDurationForAirmass(float airMass, float afr DECLARE_ENGINE_PARAMETER_SUFFIX) {
static float getInjectionDurationForFuelMass(float fuelMass DECLARE_ENGINE_PARAMETER_SUFFIX) {
float gPerSec = convertToGramsPerSecond(CONFIG(injector.flow));
return airMass / (afr * gPerSec);
return fuelMass / gPerSec;
}
static SpeedDensityAirmass sdAirmass(veMap);
@ -185,6 +186,8 @@ AirmassModelBase* getAirmassModel(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
}
}
static FuelComputer fuelComputer(afrMap);
/**
* per-cylinder fuel amount
* todo: rename this method since it's now base+TPSaccel
@ -202,17 +205,14 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
auto airmass = model->getAirmass(rpm);
// The airmass mode will tell us how to look up AFR - use the provided Y axis value
float targetAfr = afrMap.getValue(rpm, airmass.EngineLoadPercent);
// Plop some state for others to read
ENGINE(engineState.targetAFR) = targetAfr;
ENGINE(engineState.sd.airMassInOneCylinder) = airmass.CylinderAirmass;
ENGINE(engineState.fuelingLoad) = airmass.EngineLoadPercent;
// TODO: independently selectable ignition load mode
ENGINE(engineState.ignitionLoad) = airmass.EngineLoadPercent;
float baseFuel = getInjectionDurationForAirmass(airmass.CylinderAirmass, targetAfr PASS_ENGINE_PARAMETER_SUFFIX) * 1000;
float baseFuelMass = fuelComputer.getCycleFuel(airmass.CylinderAirmass, rpm, airmass.EngineLoadPercent);
float baseFuel = getInjectionDurationForFuelMass(baseFuelMass PASS_ENGINE_PARAMETER_SUFFIX) * 1000;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN baseFuel", 0);
engine->engineState.baseFuel = baseFuel;

View File

@ -39,4 +39,3 @@ 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);
float getInjectionDurationForAirmass(float airMass, float afr DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -1,34 +0,0 @@
/**
* @file test_speed_density.cpp
*
* @date Jun 26, 2014
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "engine_test_helper.h"
#include "speed_density.h"
#include "fuel_math.h"
TEST(big, testSpeedDensity) {
printf("*************************************************** testSpeedDensity\r\n");
WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995);
engineConfiguration->trigger.customTotalToothCount = 8;
eth.applyTriggerWaveform();
eth.fireTriggerEvents(36);
ASSERT_EQ( 1500, GET_RPM()) << "RPM";
// 427 cubic inches, that's a LOT of engine
engineConfiguration->specs.displacement = 6.99728;
engineConfiguration->specs.cylindersCount = 8;
engineConfiguration->injector.flow = gramm_second_to_cc_minute(5.303);
float airMass = SpeedDensityBase::getAirmassImpl(0.92, 98, 293.16 PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_FLOAT_EQ(0.9371106624, airMass);
// 0.01414 sec or 14.14 ms
EXPECT_NEAR(0.014137, getInjectionDurationForAirmass(airMass, 12.5 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
}

View File

@ -29,7 +29,6 @@ TESTS_SRC_CPP = \
tests/test_one_cylinder_logic.cpp \
tests/test_pwm_generator.cpp \
tests/test_logic_expression.cpp \
tests/test_speed_density.cpp \
tests/test_signal_executor.cpp \
tests/test_cpp_memory_layout.cpp \
tests/test_sensors.cpp \