mirror of https://github.com/rusefi/rusefi-1.git
parent
bb3f8cb76f
commit
f715210b39
|
@ -25,4 +25,5 @@ LDS_TPS_ACCEL,
|
|||
LDS_MAIN_RELAY,
|
||||
LDS_BOOST_CONTROL,
|
||||
LDS_LAUNCH_CONTROL,
|
||||
LDS_HIGH_PRESSURE,
|
||||
} live_data_e;
|
||||
|
|
|
@ -106,15 +106,17 @@ float HpfpQuantity::calcPI(int rpm, float calc_fuel_percent) {
|
|||
return p_control_percent + i_control_percent;
|
||||
}
|
||||
|
||||
angle_t HpfpQuantity::pumpAngleFuel(int rpm) {
|
||||
angle_t HpfpQuantity::pumpAngleFuel(int rpm, HpfpController *model) {
|
||||
// Math based on fuel requested
|
||||
float fuel_requested_percent = calcFuelPercent(rpm);
|
||||
model->fuel_requested_percent = calcFuelPercent(rpm);
|
||||
|
||||
model->fuel_requested_percent_pi = calcPI(rpm, model->fuel_requested_percent);
|
||||
// Apply PI control
|
||||
fuel_requested_percent += calcPI(rpm, fuel_requested_percent);
|
||||
float fuel_requested_percentTotal = model->fuel_requested_percent + model->fuel_requested_percent_pi;
|
||||
|
||||
|
||||
// Convert to degrees
|
||||
return interpolate2d(fuel_requested_percent,
|
||||
return interpolate2d(fuel_requested_percentTotal,
|
||||
engineConfiguration->hpfpLobeProfileQuantityBins,
|
||||
engineConfiguration->hpfpLobeProfileAngle);
|
||||
}
|
||||
|
@ -141,7 +143,7 @@ void HpfpController::onFastCallback() {
|
|||
|
||||
// We set deadtime first, then pump, in case pump used to be 0. Pump is what
|
||||
// determines whether we do anything or not.
|
||||
m_requested_pump = m_quantity.pumpAngleFuel(rpm);
|
||||
m_requested_pump = m_quantity.pumpAngleFuel(rpm, this);
|
||||
|
||||
if (!m_running) {
|
||||
m_running = true;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "high_pressure_fuel_pump_generated.h"
|
||||
|
||||
class HpfpLobe {
|
||||
public:
|
||||
|
@ -30,6 +31,8 @@ public:
|
|||
angle_t findNextLobe(); ///< Calculate the angle (after crank TDC) for the top of the next lobe
|
||||
};
|
||||
|
||||
class HpfpController;
|
||||
|
||||
class HpfpQuantity {
|
||||
public:
|
||||
float m_I_sum_percent = 0;
|
||||
|
@ -38,7 +41,7 @@ public:
|
|||
/**
|
||||
* Calculate where the pump should become active, in degrees before pump lobe TDC
|
||||
*/
|
||||
angle_t pumpAngleFuel(int rpm);
|
||||
angle_t pumpAngleFuel(int rpm, HpfpController *model);
|
||||
|
||||
/**
|
||||
* Calculate the percent of the pump stroke needed to replace the fuel injected. Also
|
||||
|
@ -73,7 +76,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class HpfpController : public EngineModule {
|
||||
class HpfpController : public EngineModule, public high_pressure_fuel_pump_s {
|
||||
public:
|
||||
void onFastCallback() final;
|
||||
|
||||
|
@ -86,7 +89,6 @@ private:
|
|||
HpfpLobe m_lobe;
|
||||
|
||||
volatile bool m_running = false; ///< Whether events are being scheduled or not
|
||||
volatile angle_t m_requested_pump = 0; ///< Computed requested pump duration in degrees (not including deadtime)
|
||||
volatile angle_t m_deadtime = 0; ///< Computed solenoid deadtime in degrees
|
||||
|
||||
void scheduleNextCycle();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
struct_no_prefix high_pressure_fuel_pump_s
|
||||
|
||||
angle_t m_requested_pump
|
||||
angle_t m_requested_pump;Computed requested pump duration in degrees (not including deadtime)
|
||||
float fuel_requested_percent
|
||||
float fuel_requested_percent_pi
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/engine_cycle/high_pressure_fuel_pump.txt Fri Dec 31 03:07:40 EST 2021
|
||||
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/engine_cycle/high_pressure_fuel_pump.txt Fri Dec 31 15:12:40 EST 2021
|
||||
// by class com.rusefi.output.CHeaderConsumer
|
||||
// begin
|
||||
#pragma once
|
||||
|
@ -6,6 +6,7 @@
|
|||
// start of high_pressure_fuel_pump_s
|
||||
struct high_pressure_fuel_pump_s {
|
||||
/**
|
||||
* Computed requested pump duration in degrees (not including deadtime)
|
||||
* offset 0
|
||||
*/
|
||||
angle_t m_requested_pump = (angle_t)0;
|
||||
|
@ -21,4 +22,4 @@ struct high_pressure_fuel_pump_s {
|
|||
};
|
||||
|
||||
// end
|
||||
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/engine_cycle/high_pressure_fuel_pump.txt Fri Dec 31 03:07:40 EST 2021
|
||||
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/engine_cycle/high_pressure_fuel_pump.txt Fri Dec 31 15:12:40 EST 2021
|
||||
|
|
|
@ -188,20 +188,22 @@ TEST(HPFP, Angle) {
|
|||
engineConfiguration->hpfpLobeProfileAngle[i] = 150. * i / (HPFP_LOBE_PROFILE_SIZE - 1);
|
||||
}
|
||||
|
||||
HpfpController model;
|
||||
|
||||
EXPECT_FLOAT_EQ(math.calcFuelPercent(1000), 25); // Double check baseline
|
||||
EXPECT_FLOAT_EQ(math.calcPI(1000, 10), 0); // Validate no PI
|
||||
EXPECT_NEAR(math.pumpAngleFuel(1000), 37.5, 0.4); // Given the profile, should be 50% higher
|
||||
EXPECT_NEAR(math.pumpAngleFuel(1000, &model), 37.5, 0.4); // Given the profile, should be 50% higher
|
||||
|
||||
engine->injectionMass[0] = 0.08 /* cc/cyl */ * fuelDensity;
|
||||
EXPECT_FLOAT_EQ(math.calcFuelPercent(1000), 40); // Double check baseline
|
||||
EXPECT_FLOAT_EQ(math.calcPI(1000, 10), 0); // Validate no PI
|
||||
EXPECT_NEAR(math.pumpAngleFuel(1000), 60, 0.4); // Given the profile, should be 50% higher
|
||||
EXPECT_NEAR(math.pumpAngleFuel(1000, &model), 60, 0.4); // Given the profile, should be 50% higher
|
||||
|
||||
engineConfiguration->hpfpPidP = 0.01;
|
||||
Sensor::setMockValue(SensorType::Map, 40);
|
||||
Sensor::setMockValue(SensorType::FuelPressureHigh, 1000);
|
||||
EXPECT_FLOAT_EQ(math.calcPI(1000, 10), 10.1);
|
||||
EXPECT_NEAR(math.pumpAngleFuel(1000), 50.1 * 1.5, 0.4); // Given the profile, should be 50% higher
|
||||
EXPECT_NEAR(math.pumpAngleFuel(1000, &model), 50.1 * 1.5, 0.4); // Given the profile, should be 50% higher
|
||||
}
|
||||
|
||||
TEST(HPFP, Schedule) {
|
||||
|
|
Loading…
Reference in New Issue