rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions
HpfpQuantity Class Reference

#include <high_pressure_fuel_pump.h>

Public Member Functions

angle_t pumpAngleFuel (float rpm, HpfpController *model)
 
float calcFuelPercent (float rpm)
 
float calcPI (float rpm, float calc_fuel_percent, HpfpController *model)
 

Detailed Description

Definition at line 38 of file high_pressure_fuel_pump.h.

Member Function Documentation

◆ calcFuelPercent()

float HpfpQuantity::calcFuelPercent ( float  rpm)

Calculate the percent of the pump stroke needed to replace the fuel injected. Also includes pump compensation calculations.

This is used by internal tests and shouldn't be called directly. Instead use pumpAngleFuel.

Return value is nominally 0-100, but may be outside that range (including negative) if model parameters are not accurate.

Definition at line 78 of file high_pressure_fuel_pump.cpp.

78 {
79 float fuel_requested_cc_per_cycle =
81 float fuel_requested_cc_per_lobe = fuel_requested_cc_per_cycle / engineConfiguration->hpfpCamLobes;
82 return 100.f *
83 fuel_requested_cc_per_lobe / engineConfiguration->hpfpPumpVolume +
84 interpolate3d(config->hpfpCompensation,
85 config->hpfpCompensationLoadBins, fuel_requested_cc_per_lobe,
87}
EngineState engineState
Definition engine.h:344
static EngineAccessor engine
Definition engine.h:413
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
constexpr float fuelDensity
float injectionMass[MAX_CYLINDER_COUNT]
scaled_channel< uint16_t, 1000, 1 > hpfpCompensationLoadBins[HPFP_COMPENSATION_SIZE]
int8_t hpfpCompensation[HPFP_COMPENSATION_SIZE][HPFP_COMPENSATION_SIZE]
scaled_channel< uint8_t, 1, 50 > hpfpCompensationRpmBins[HPFP_COMPENSATION_SIZE]

Referenced by pumpAngleFuel().

Here is the caller graph for this function:

◆ calcPI()

float HpfpQuantity::calcPI ( float  rpm,
float  calc_fuel_percent,
HpfpController model 
)

Calculates the PI controller contribution as a percent. This amount should be added to calcFuelPercent() above.

This is used by internal tests and shouldn't be called directly. Instead use pumpAngleFuel.

Return value is nominally 0-100, but may be outside that range (including negative) if model parameters are not accurate. The sum of this and calc_fuel_percent will be 0-100.

Definition at line 99 of file high_pressure_fuel_pump.cpp.

99 {
100 float load = getLoad();
101
102 float possibleValue = model->m_pressureTarget_kPa - (engineConfiguration->hpfpTargetDecay *
103 (FAST_CALLBACK_PERIOD_MS / 1000.));
104
105 model->m_pressureTarget_kPa = std::max<float>(possibleValue,
106 interpolate3d(config->hpfpTarget,
109
110 auto fuelPressure = Sensor::get(SensorType::FuelPressureHigh);
111 if (!fuelPressure) {
112 return 0;
113 }
114
115 float pressureError_kPa =
116 model->m_pressureTarget_kPa - fuelPressure.Value;
117
118 model->hpfp_p_control_percent = pressureError_kPa * engineConfiguration->hpfpPidP;
119 float i_factor_divisor =
120 1000. * // ms/sec
121 60. * // sec/min -> ms/min
122 2.; // rev/cycle -> (rev * ms) / (min * cycle)
123 float i_factor =
124 engineConfiguration->hpfpPidI * // % / (kPa * lobe)
125 rpm * // (% * revs) / (kPa * lobe * min)
126 engineConfiguration->hpfpCamLobes * // lobes/cycle -> (% * revs) / (kPa * min * cycles)
127 (FAST_CALLBACK_PERIOD_MS / // (% * revs * ms) / (kPa * min * cycles)
128 i_factor_divisor); // % / kPa
129 float unclamped_i_control_percent = model->hpfp_i_control_percent + pressureError_kPa * i_factor;
130 // Clamp the output so that calc_fuel_percent+i_control_percent is within 0% to 100%
131 // That way the I term can override any fuel calculations over the long term.
132 // The P term is still allowed to drive the total output over 100% or under 0% to react to
133 // short term errors.
134 model->hpfp_i_control_percent = clampF(-calc_fuel_percent, unclamped_i_control_percent,
135 100.f - calc_fuel_percent);
136 return model->hpfp_p_control_percent + model->hpfp_i_control_percent;
137}
virtual SensorResult get() const =0
static float getLoad()
scaled_channel< uint8_t, 1, 50 > hpfpTargetRpmBins[HPFP_TARGET_SIZE]
uint16_t hpfpTarget[HPFP_TARGET_SIZE][HPFP_TARGET_SIZE]
scaled_channel< uint16_t, 10, 1 > hpfpTargetLoadBins[HPFP_TARGET_SIZE]

Referenced by pumpAngleFuel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pumpAngleFuel()

angle_t HpfpQuantity::pumpAngleFuel ( float  rpm,
HpfpController model 
)

Calculate where the pump should become active, in degrees before pump lobe TDC

Definition at line 139 of file high_pressure_fuel_pump.cpp.

139 {
140 // Math based on fuel requested
142
143 model->fuel_requested_percent_pi = calcPI(rpm, model->fuel_requested_percent, model);
144 // Apply PI control
145 float fuel_requested_percentTotal = model->fuel_requested_percent + model->fuel_requested_percent_pi;
146
147 // Convert to degrees
148 return interpolate2d(fuel_requested_percentTotal,
151}
float calcPI(float rpm, float calc_fuel_percent, HpfpController *model)
float calcFuelPercent(float rpm)
scaled_channel< uint8_t, 2, 1 > hpfpLobeProfileQuantityBins[HPFP_LOBE_PROFILE_SIZE]
scaled_channel< uint8_t, 2, 1 > hpfpLobeProfileAngle[HPFP_LOBE_PROFILE_SIZE]

Referenced by HpfpController::onFastCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: