rusEFI
The most advanced open source ECU
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
HpfpController Class Reference

#include <high_pressure_fuel_pump.h>

Inheritance diagram for HpfpController:
Inheritance graph
[legend]
Collaboration diagram for HpfpController:
Collaboration graph
[legend]

Public Member Functions

void onFastCallback () final
 
- Public Member Functions inherited from EngineModule
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onSlowCallback ()
 
virtual void onIgnitionStateChanged (bool)
 
virtual bool needsDelayedShutoff ()
 

Private Member Functions

void scheduleNextCycle ()
 

Static Private Member Functions

static void pinTurnOn (HpfpController *self)
 
static void pinTurnOff (HpfpController *self)
 

Private Attributes

AngleBasedEvent m_event
 
HpfpQuantity m_quantity
 
HpfpLobe m_lobe
 
volatile bool m_running = false
 Whether events are being scheduled or not. More...
 
volatile angle_t m_deadtime = 0
 Computed solenoid deadtime in degrees. More...
 

Additional Inherited Members

- Data Fields inherited from high_pressure_fuel_pump_s
angle_t m_requested_pump = (angle_t)0
 
float fuel_requested_percent = (float)0
 
float fuel_requested_percent_pi = (float)0
 
bool noValve: 1 {}
 
bool angleAboveMin: 1 {}
 
bool isHpfpInactive: 1 {}
 
bool unusedBit_6_3: 1 {}
 
bool unusedBit_6_4: 1 {}
 
bool unusedBit_6_5: 1 {}
 
bool unusedBit_6_6: 1 {}
 
bool unusedBit_6_7: 1 {}
 
bool unusedBit_6_8: 1 {}
 
bool unusedBit_6_9: 1 {}
 
bool unusedBit_6_10: 1 {}
 
bool unusedBit_6_11: 1 {}
 
bool unusedBit_6_12: 1 {}
 
bool unusedBit_6_13: 1 {}
 
bool unusedBit_6_14: 1 {}
 
bool unusedBit_6_15: 1 {}
 
bool unusedBit_6_16: 1 {}
 
bool unusedBit_6_17: 1 {}
 
bool unusedBit_6_18: 1 {}
 
bool unusedBit_6_19: 1 {}
 
bool unusedBit_6_20: 1 {}
 
bool unusedBit_6_21: 1 {}
 
bool unusedBit_6_22: 1 {}
 
bool unusedBit_6_23: 1 {}
 
bool unusedBit_6_24: 1 {}
 
bool unusedBit_6_25: 1 {}
 
bool unusedBit_6_26: 1 {}
 
bool unusedBit_6_27: 1 {}
 
bool unusedBit_6_28: 1 {}
 
bool unusedBit_6_29: 1 {}
 
bool unusedBit_6_30: 1 {}
 
bool unusedBit_6_31: 1 {}
 
float m_pressureTarget_kPa = (float)0
 
angle_t nextLobe = (angle_t)0
 
float di_nextStart = (float)0
 

Detailed Description

Definition at line 82 of file high_pressure_fuel_pump.h.

Member Function Documentation

◆ onFastCallback()

void HpfpController::onFastCallback ( )
finalvirtual

Reimplemented from EngineModule.

Definition at line 156 of file high_pressure_fuel_pump.cpp.

156  {
157  // Pressure current/target calculation
159 
160  isHpfpInactive = rpm < rpm_spinning_cutoff ||
161  !isGdiEngine() ||
164  // What conditions can we not handle?
165  if (isHpfpInactive) {
166  m_quantity.reset();
167  m_requested_pump = 0;
168  m_deadtime = 0;
169  } else {
170 #if EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT
171  criticalAssertVoid(engine->triggerCentral.triggerShape.getSize() > engineConfiguration->hpfpCamLobes * 6, "Too few trigger tooth for this number of HPFP lobes");
172 #endif // EFI_PROD_CODE
173  // Convert deadtime from ms to degrees based on current RPM
174  float deadtime_ms = interpolate2d(
175  Sensor::get(SensorType::BatteryVoltage).value_or(VBAT_FALLBACK_VALUE),
178  m_deadtime = deadtime_ms * rpm * (360.f / 60.f / 1000.f);
179 
180  // We set deadtime first, then pump, in case pump used to be 0. Pump is what
181  // determines whether we do anything or not.
183 
184  if (!m_running) {
185  m_running = true;
187  }
188  }
189 }
TriggerCentral triggerCentral
Definition: engine.h:286
RegisteredNamedOutputPin hpfpValve
Definition: efi_gpio.h:80
volatile angle_t m_deadtime
Computed solenoid deadtime in degrees.
volatile bool m_running
Whether events are being scheduled or not.
angle_t pumpAngleFuel(int rpm, HpfpController *model)
bool isInitialized() const
Definition: efi_gpio.cpp:536
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
Definition: sensor.h:92
TriggerWaveform triggerShape
size_t getSize() const
EnginePins enginePins
Definition: efi_gpio.cpp:24
Engine * engine
bool isGdiEngine()
persistent_config_s * config
engine_configuration_s * engineConfiguration
scaled_channel< uint16_t, 1000, 1 > hpfpDeadtimeMS[HPFP_DEADTIME_SIZE]
Here is the call graph for this function:

◆ pinTurnOff()

void HpfpController::pinTurnOff ( HpfpController self)
staticprivate

Definition at line 204 of file high_pressure_fuel_pump.cpp.

204  {
205  enginePins.hpfpValve.setLow(HPFP_CONTROLLER);
206 
207  self->scheduleNextCycle();
208 }
virtual void setLow(const char *msg)
Definition: efi_gpio.cpp:441

Referenced by scheduleNextCycle().

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

◆ pinTurnOn()

void HpfpController::pinTurnOn ( HpfpController self)
staticprivate

Definition at line 193 of file high_pressure_fuel_pump.cpp.

193  {
194  enginePins.hpfpValve.setHigh(HPFP_CONTROLLER);
195 
196  // By scheduling the close after we already open, we don't have to worry if the engine
197  // stops, the valve will be turned off in a certain amount of time regardless.
201  { pinTurnOff, self });
202 }
AngleBasedEvent m_event
virtual void setHigh(const char *msg)
Definition: efi_gpio.cpp:419
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t nowNt, angle_t angle, action_s action)
scheduling_s eventScheduling
efitick_t getMomentNt() const
Definition: scheduler.h:64

Referenced by scheduleNextCycle().

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

◆ scheduleNextCycle()

void HpfpController::scheduleNextCycle ( )
private

We are good to use just one m_event instance because new events are scheduled when we turn off valve.

Definition at line 210 of file high_pressure_fuel_pump.cpp.

210  {
212  if (noValve) {
213  m_running = false;
214  return;
215  }
216 
217  angle_t lobe = m_lobe.findNextLobe();
218  angle_t angle_requested = m_requested_pump;
219 
220  angleAboveMin = angle_requested > engineConfiguration->hpfpMinAngle;
221  if (angleAboveMin) {
222  di_nextStart = lobe - angle_requested - m_deadtime;
224 
225 
226  /**
227  * We are good to use just one m_event instance because new events are scheduled when we turn off valve.
228  */
229  engine->module<TriggerScheduler>()->schedule(
230  "hpfp",
231  &m_event,
232  di_nextStart,
233  { pinTurnOn, this });
234 
235  // Off will be scheduled after turning the valve on
236  } else {
237  wrapAngle(lobe, "lobe", ObdCode::CUSTOM_ERR_6557);
238  // Schedule this, even if we aren't opening the valve this time, since this
239  // will schedule the next lobe.
240  // todo: would it have been cleaner to schedule 'scheduleNextCycle' directly?
241  engine->module<TriggerScheduler>()->schedule(
242  "hpfp",
243  &m_event, lobe,
244  { pinTurnOff, this });
245  }
246 }
constexpr auto & module()
Definition: engine.h:177
static void pinTurnOff(HpfpController *self)
static void pinTurnOn(HpfpController *self)
angle_t findNextLobe()
Calculate the angle (after crank TDC) for the top of the next lobe.
@ CUSTOM_ERR_6557
float angle_t
Definition: rusefi_types.h:58
void wrapAngle(angle_t &angle, const char *msg, ObdCode code)

Referenced by onFastCallback().

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

Field Documentation

◆ m_deadtime

volatile angle_t HpfpController::m_deadtime = 0
private

Computed solenoid deadtime in degrees.

Definition at line 95 of file high_pressure_fuel_pump.h.

Referenced by onFastCallback(), and scheduleNextCycle().

◆ m_event

AngleBasedEvent HpfpController::m_event
private

Definition at line 89 of file high_pressure_fuel_pump.h.

Referenced by scheduleNextCycle().

◆ m_lobe

HpfpLobe HpfpController::m_lobe
private

Definition at line 92 of file high_pressure_fuel_pump.h.

Referenced by scheduleNextCycle().

◆ m_quantity

HpfpQuantity HpfpController::m_quantity
private

Definition at line 91 of file high_pressure_fuel_pump.h.

Referenced by onFastCallback().

◆ m_running

volatile bool HpfpController::m_running = false
private

Whether events are being scheduled or not.

Definition at line 94 of file high_pressure_fuel_pump.h.

Referenced by onFastCallback(), and scheduleNextCycle().


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