rusEFI
The most advanced open source ECU
Public Member Functions | Data Fields
TpsAccelEnrichment Class Reference

#include <accel_enrichment.h>

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

Public Member Functions

 TpsAccelEnrichment ()
 
int getMaxDeltaIndex ()
 
float getMaxDelta ()
 
void setLength (int length)
 
void onNewValue (float currentValue)
 
floatms_t getTpsEnrichment ()
 
void onEngineCycleTps ()
 
void resetFractionValues ()
 
void resetAE ()
 

Data Fields

cyclic_buffer< float > cb
 
int onUpdateInvocationCounter = 0
 
- Data Fields inherited from tps_accel_state_s
percent_t tpsFrom = (percent_t)0
 
percent_t tpsTo = (percent_t)0
 
percent_t deltaTps = (percent_t)0
 
floatms_t extraFuel = (floatms_t)0
 
float valueFromTable = (float)0
 
bool isAboveAccelThreshold: 1 {}
 
bool isBelowDecelThreshold: 1 {}
 
bool isTimeToResetAccumulator: 1 {}
 
bool isFractionalEnrichment: 1 {}
 
bool belowEpsilon: 1 {}
 
bool tooShort: 1 {}
 
bool unusedBit_11_6: 1 {}
 
bool unusedBit_11_7: 1 {}
 
bool unusedBit_11_8: 1 {}
 
bool unusedBit_11_9: 1 {}
 
bool unusedBit_11_10: 1 {}
 
bool unusedBit_11_11: 1 {}
 
bool unusedBit_11_12: 1 {}
 
bool unusedBit_11_13: 1 {}
 
bool unusedBit_11_14: 1 {}
 
bool unusedBit_11_15: 1 {}
 
bool unusedBit_11_16: 1 {}
 
bool unusedBit_11_17: 1 {}
 
bool unusedBit_11_18: 1 {}
 
bool unusedBit_11_19: 1 {}
 
bool unusedBit_11_20: 1 {}
 
bool unusedBit_11_21: 1 {}
 
bool unusedBit_11_22: 1 {}
 
bool unusedBit_11_23: 1 {}
 
bool unusedBit_11_24: 1 {}
 
bool unusedBit_11_25: 1 {}
 
bool unusedBit_11_26: 1 {}
 
bool unusedBit_11_27: 1 {}
 
bool unusedBit_11_28: 1 {}
 
bool unusedBit_11_29: 1 {}
 
bool unusedBit_11_30: 1 {}
 
bool unusedBit_11_31: 1 {}
 
float fractionalInjFuel = (float)0
 
floatms_t accumulatedValue = (floatms_t)0
 
floatms_t maxExtraPerCycle = (floatms_t)0
 
floatms_t maxExtraPerPeriod = (floatms_t)0
 
floatms_t maxInjectedPerPeriod = (floatms_t)0
 
int cycleCnt = (int)0
 

Detailed Description

Definition at line 19 of file accel_enrichment.h.

Constructor & Destructor Documentation

◆ TpsAccelEnrichment()

TpsAccelEnrichment::TpsAccelEnrichment ( )

Definition at line 191 of file accel_enrichment.cpp.

191  {
192  resetAE();
193  cb.setSize(4);
194 }
cyclic_buffer< float > cb
Here is the call graph for this function:

Member Function Documentation

◆ getMaxDelta()

float TpsAccelEnrichment::getMaxDelta ( )

Definition at line 151 of file accel_enrichment.cpp.

151  {
152  int index = getMaxDeltaIndex();
153 
154  return (cb.get(index) - (cb.get(index - 1)));
155 }
Here is the call graph for this function:

◆ getMaxDeltaIndex()

int TpsAccelEnrichment::getMaxDeltaIndex ( )

Definition at line 128 of file accel_enrichment.cpp.

128  {
129  int len = minI(cb.getSize(), cb.getCount());
130  tooShort = len < 2;
131  if (tooShort)
132  return 0;
133  int ci = cb.currentIndex - 1;
134  float maxValue = cb.get(ci) - cb.get(ci - 1);
135  int resultIndex = ci;
136 
137  // todo: 'get' method is maybe a bit heavy because of the branching
138  // todo: this could be optimized with some careful magic
139 
140  for (int i = 1; i<len - 1;i++) {
141  float v = cb.get(ci - i) - cb.get(ci - i - 1);
142  if (v > maxValue) {
143  maxValue = v;
144  resultIndex = ci - i;
145  }
146  }
147 
148  return resultIndex;
149 }

Referenced by getMaxDelta(), and onNewValue().

Here is the caller graph for this function:

◆ getTpsEnrichment()

floatms_t TpsAccelEnrichment::getTpsEnrichment ( )
Returns
Extra fuel squirt duration for TPS acceleration

Definition at line 29 of file accel_enrichment.cpp.

29  {
31 
33  // If disabled, return 0.
34  return 0;
35  }
37  if (rpm == 0) {
38  return 0;
39  }
40 
44  } else if (isBelowDecelThreshold) {
46  } else {
47  extraFuel = 0;
48  }
49 
50  // Fractional enrichment (fuel portions are accumulated and split between several engine cycles.
51  // This is a crude imitation of carburetor's acceleration pump.
54  // make sure both values are non-zero
55  float periodF = (float)maxI(engineConfiguration->tpsAccelFractionPeriod, 1);
56  float divisor = maxF(engineConfiguration->tpsAccelFractionDivisor, 1.0f);
57 
58  // if current extra fuel portion is not "strong" enough, then we keep up the "pump pressure" with the accumulated portion
59  floatms_t maxExtraFuel = maxF(extraFuel, accumulatedValue);
60  // use only a fixed fraction of the accumulated portion
61  fractionalInjFuel = maxExtraFuel / divisor;
62 
63  // update max counters
66 
67  // evenly split it between several engine cycles
68  extraFuel = fractionalInjFuel / periodF;
69  } else {
71  }
72 
73 #if EFI_TUNER_STUDIO
74  if (engineConfiguration->debugMode == DBG_TPS_ACCEL) {
83  }
84 #endif /* EFI_TUNER_STUDIO */
85 
86  float mult = interpolate2d(rpm, config->tpsTspCorrValuesBins,
88  if (mult != 0 && (mult < 0.01 || mult > 100)) {
89  mult = 1;
90  }
91 
92  return extraFuel * mult;
93 }
static tps_tps_Map3D_t tpsTpsMap
TunerStudioOutputChannels outputChannels
Definition: engine.h:96
float getValue(float xColumn, float yRow) const final
Definition: table_helper.h:43
static float getOrZero(SensorType type)
Definition: sensor.h:92
Engine * engine
@ GetTpsEnrichment
persistent_config_s * config
engine_configuration_s * engineConfiguration
float floatms_t
Definition: rusefi_types.h:67
scaled_channel< uint8_t, 1, 50 > tpsTspCorrValuesBins[TPS_TPS_ACCEL_CLT_CORR_TABLE]
scaled_channel< uint8_t, 50, 1 > tpsTspCorrValues[TPS_TPS_ACCEL_CLT_CORR_TABLE]

Referenced by getInjectionMass().

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

◆ onEngineCycleTps()

void TpsAccelEnrichment::onEngineCycleTps ( )

Definition at line 95 of file accel_enrichment.cpp.

95  {
96  // we update values in handleFuel() directly by calling onNewValue()
97 
99 
100  // we used some extra fuel during the current cycle, so we "charge" our "acceleration pump" with it
103  maxExtraPerCycle = 0;
105 
106  // update the accumulated value every 'Period' engine cycles
109  maxExtraPerPeriod = 0;
110 
111  // we've injected this portion during the cycle, so we set what's left for the next cycle
114 
115  // it's an infinitely convergent series, so we set a limit at some point
116  // (also make sure that accumulatedValue is positive, for safety)
117  static const floatms_t smallEpsilon = 0.001f;
118  belowEpsilon = accumulatedValue < smallEpsilon;
119  if (belowEpsilon) {
120  accumulatedValue = 0;
121  }
122 
123  // reset the counter
125  }
126 }

Referenced by TriggerCentral::handleShaftSignal().

Here is the caller graph for this function:

◆ onNewValue()

void TpsAccelEnrichment::onNewValue ( float  currentValue)

Definition at line 174 of file accel_enrichment.cpp.

174  {
175  // Push new value in to the history buffer
176  cb.add(currentValue);
177 
178  // Update deltas
179  int maxDeltaIndex = getMaxDeltaIndex();
180  tpsFrom = cb.get(maxDeltaIndex - 1);
181  tpsTo = cb.get(maxDeltaIndex);
182  deltaTps = tpsTo - tpsFrom;
183 
184  // Update threshold detection
186 
187  // TODO: can deltaTps actually be negative? Will this ever trigger?
189 }

Referenced by Engine::periodicSlowCallback().

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

◆ resetAE()

void TpsAccelEnrichment::resetAE ( )

Definition at line 157 of file accel_enrichment.cpp.

157  {
158  cb.clear();
160 }

Referenced by resetAccel(), and TpsAccelEnrichment().

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

◆ resetFractionValues()

void TpsAccelEnrichment::resetFractionValues ( )

Definition at line 162 of file accel_enrichment.cpp.

162  {
163  accumulatedValue = 0;
164  maxExtraPerCycle = 0;
165  maxExtraPerPeriod = 0;
167  cycleCnt = 0;
168 }

Referenced by getTpsEnrichment(), and resetAE().

Here is the caller graph for this function:

◆ setLength()

void TpsAccelEnrichment::setLength ( int  length)

Definition at line 170 of file accel_enrichment.cpp.

170  {
171  cb.setSize(length);
172 }

Referenced by setTpsAccelLen().

Here is the caller graph for this function:

Field Documentation

◆ cb

cyclic_buffer<float> TpsAccelEnrichment::cb

◆ onUpdateInvocationCounter

int TpsAccelEnrichment::onUpdateInvocationCounter = 0

Definition at line 29 of file accel_enrichment.h.

Referenced by onEngineCycleTps().


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