rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
high_pressure_fuel_pump.h
Go to the documentation of this file.
1/*
2 * @file high_pressure_fuel_pump.h
3 * @brief High Pressure Fuel Pump controller for GDI applications
4 *
5 * @date Nov 6, 2021
6 * @author Scott Smith, (c) 2021
7 */
8
9/*
10 * This file is part of rusEfi - see http://rusefi.com
11 *
12 * rusEfi is free software; you can redistribute it and/or modify it under the terms of
13 * the GNU General Public License as published by the Free Software Foundation; either
14 * version 3 of the License, or (at your option) any later version.
15 *
16 * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
17 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along with this program.
21 * If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
26
27class HpfpLobe {
28public:
29 uint8_t m_lobe_index = 0; ///< 0-based index of the last lobe returned
30
31 angle_t findNextLobe(); ///< Calculate the angle (after crank TDC) for the top of the next lobe
32};
33
34bool isGdiEngine();
35
36class HpfpController;
37
39public:
40 /**
41 * Calculate where the pump should become active, in degrees before pump lobe TDC
42 */
43 angle_t pumpAngleFuel(float rpm, HpfpController *model);
44
45 /**
46 * Calculate the percent of the pump stroke needed to replace the fuel injected. Also
47 * includes pump compensation calculations.
48 *
49 * This is used by internal tests and shouldn't be called directly. Instead use
50 * pumpAngleFuel.
51 *
52 * Return value is nominally 0-100, but may be outside that range (including negative) if
53 * model parameters are not accurate.
54 */
55 float calcFuelPercent(float rpm);
56
57 /**
58 * Calculates the PI controller contribution as a percent. This amount should be added to
59 * calcFuelPercent() above.
60 *
61 * This is used by internal tests and shouldn't be called directly. Instead use
62 * pumpAngleFuel.
63 *
64 * Return value is nominally 0-100, but may be outside that range (including negative) if
65 * model parameters are not accurate. The sum of this and calc_fuel_percent will be 0-100.
66 */
67 float calcPI(float rpm, float calc_fuel_percent, HpfpController *model);
68
69};
70
72public:
73 // Mockable<> interface
75
76 /**
77 * Reset internal state due to a stopped engine.
78 */
83
84 void onFastCallback() final;
85 angle_t m_deadangle = 0; ///< Computed solenoid deadtime in degrees
86
87#if !EFI_UNIT_TEST
88private:
89#endif // EFI_UNIT_TEST
91
94
95 volatile bool m_running = false; ///< Whether events are being scheduled or not
96
97 void scheduleNextCycle();
98
99 static void pinTurnOn(HpfpController *self);
100 static void pinTurnOff(HpfpController *self);
101};
AngleBasedEvent m_event
volatile bool m_running
Whether events are being scheduled or not.
static void pinTurnOff(HpfpController *self)
static void pinTurnOn(HpfpController *self)
angle_t m_deadangle
Computed solenoid deadtime in degrees.
uint8_t m_lobe_index
0-based index of the last lobe returned
angle_t findNextLobe()
Calculate the angle (after crank TDC) for the top of the next lobe.
float calcPI(float rpm, float calc_fuel_percent, HpfpController *model)
float calcFuelPercent(float rpm)
angle_t pumpAngleFuel(float rpm, HpfpController *model)
bool isGdiEngine()