rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes
ClosedLoopFuelCellImpl Class Referencefinal

#include <closed_loop_fuel_cell.h>

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

Public Member Functions

void configure (const stft_cell_cfg_s *configuration, SensorType lambdaSensor)
 
float getLambdaError () const override
 
- Public Member Functions inherited from ClosedLoopFuelCellBase
void update (float lambdaDeadband, bool ignoreErrorMagnitude)
 
float getAdjustment () const
 

Protected Member Functions

float getMaxAdjustment () const override
 
float getMinAdjustment () const override
 
float getIntegratorGain () const override
 

Private Attributes

const stft_cell_cfg_sm_config = nullptr
 
SensorType m_lambdaSensor = SensorType::Invalid
 

Detailed Description

Definition at line 29 of file closed_loop_fuel_cell.h.

Member Function Documentation

◆ configure()

void ClosedLoopFuelCellImpl::configure ( const stft_cell_cfg_s configuration,
SensorType  lambdaSensor 
)
inline

Definition at line 31 of file closed_loop_fuel_cell.h.

31 {
32 m_config = configuration;
34 }
const stft_cell_cfg_s * m_config
static FunctionPointerSensor lambdaSensor(SensorType::Lambda1, []() { return afrWrapper.getLambda();})

◆ getIntegratorGain()

float ClosedLoopFuelCellImpl::getIntegratorGain ( ) const
overrideprotectedvirtual

Implements ClosedLoopFuelCellBase.

Definition at line 75 of file closed_loop_fuel_cell.cpp.

75 {
76 if (!m_config) {
77 // If no config, disallow adjustment.
78 return 0.0f;
79 }
80
81 // Clamp to reasonable limits - 100ms to 100s
82 float timeConstant = clampF(0.1f, m_config->timeConstant, 100);
83
84 return 1 / timeConstant;
85}

◆ getLambdaError()

float ClosedLoopFuelCellImpl::getLambdaError ( ) const
overridevirtual

Implements ClosedLoopFuelCellBase.

Definition at line 40 of file closed_loop_fuel_cell.cpp.

40 {
41 auto lambda = Sensor::get(m_lambdaSensor);
42
43 // Failed sensor -> no error
44 if (!lambda) {
45 return 0;
46 }
47
48 return lambda.Value - engine->fuelComputer.targetLambda;
49}
FuelComputer fuelComputer
Definition engine.h:139
virtual SensorResult get() const =0
static EngineAccessor engine
Definition engine.h:413
scaled_channel< uint16_t, 10000, 1 > targetLambda
Here is the call graph for this function:

◆ getMaxAdjustment()

float ClosedLoopFuelCellImpl::getMaxAdjustment ( ) const
overrideprotectedvirtual

Implements ClosedLoopFuelCellBase.

Definition at line 53 of file closed_loop_fuel_cell.cpp.

53 {
54 if (!m_config) {
55 // If no config, disallow adjustment.
56 return 0;
57 }
58
59 float raw = 0.01 * m_config->maxAdd;
60 // Don't allow maximum less than 0, or more than maximum adjustment
61 return clampF(0, raw, MAX_ADJ);
62}

◆ getMinAdjustment()

float ClosedLoopFuelCellImpl::getMinAdjustment ( ) const
overrideprotectedvirtual

Implements ClosedLoopFuelCellBase.

Definition at line 64 of file closed_loop_fuel_cell.cpp.

64 {
65 if (!m_config) {
66 // If no config, disallow adjustment.
67 return 0;
68 }
69
70 float raw = -0.01f * m_config->maxRemove;
71 // Don't allow minimum more than 0, or more than maximum adjustment
72 return clampF(-MAX_ADJ, raw, 0);
73}

Field Documentation

◆ m_config

const stft_cell_cfg_s* ClosedLoopFuelCellImpl::m_config = nullptr
private

◆ m_lambdaSensor

SensorType ClosedLoopFuelCellImpl::m_lambdaSensor = SensorType::Invalid
private

Definition at line 39 of file closed_loop_fuel_cell.h.

Referenced by configure(), and getLambdaError().


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