rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
map_averaging.cpp File Reference

Detailed Description

In order to have best MAP estimate possible, we real MAP value at a relatively high frequency and average the value within a specified angle position window for each cylinder

Date
Dec 11, 2013
Author
Andrey Belomutskiy, (c) 2012-2020

This file is part of rusEfi - see http://rusefi.com

rusEfi is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file map_averaging.cpp.

Functions

 fail ("EFI_SHAFT_POSITION_INPUT required to have EFI_EMULATE_POSITION_SENSORS") static NamedOutputPin mapAveragingPin("map")
 
static void endAveraging (MapAverager *arg)
 
void startAveraging (mapSampler *s)
 
float filterMapValue (float value)
 
void mapAveragingAdcCallback (float instantVoltage)
 
static void applyMapMinBufferLength ()
 

Variables

static float averagedMapRunningBuffer [MAX_MAP_BUFFER_LENGTH]
 
static int mapMinBufferLength = 0
 
static int averagedMapBufIdx = 0
 
static size_t currentMapAverager = 0
 
static ExpAverage expAverage
 

Function Documentation

◆ applyMapMinBufferLength()

static void applyMapMinBufferLength ( )
static

Definition at line 167 of file map_averaging.cpp.

167 {
168 // check range
169 mapMinBufferLength = maxI(minI(engineConfiguration->mapMinBufferLength, MAX_MAP_BUFFER_LENGTH), 1);
170 // reset index
172 // fill with maximum values
173 for (int i = 0; i < mapMinBufferLength; i++) {
174 averagedMapRunningBuffer[i] = FLT_MAX;
175 }
176}
static constexpr engine_configuration_s * engineConfiguration
static float averagedMapRunningBuffer[MAX_MAP_BUFFER_LENGTH]
static int averagedMapBufIdx
static int mapMinBufferLength

Referenced by MapAveragingModule::init(), and MapAveragingModule::onConfigurationChange().

Here is the caller graph for this function:

◆ endAveraging()

static void endAveraging ( MapAverager arg)
static

Definition at line 160 of file map_averaging.cpp.

160 {
161 arg->stop();
162
164 mapAveragingPin.setLow();
165}
TunerStudioOutputChannels outputChannels
Definition engine.h:105
static Engine *const engine
Definition engine.h:388
Here is the call graph for this function:

◆ fail()

fail ( "EFI_SHAFT_POSITION_INPUT required to have EFI_EMULATE_POSITION_SENSORS"  )

this instance does not have a real physical pin - it's only used for engine sniffer

todo: we can kind of add real physical pin just for a very narrow case of troubleshooting but only if we ever need it :)

Engine idles around 20Hz and revs up to 140Hz, at 60/2 and 8 cylinders we have about 20Khz events If we can read buffer at 50Hz we want buffer to be about 400 elements.

Definition at line 34 of file trigger_emulator_algo.cpp.

41 {
42}

◆ filterMapValue()

float filterMapValue ( float  value)

Definition at line 99 of file map_averaging.cpp.

99 {
101 return expAverage.initOrAverage(value);
102}
void setSmoothingFactor(float p_smoothingFactor)
Definition exp_average.h:26
float initOrAverage(float value)
Definition exp_average.h:9
static ExpAverage expAverage

Referenced by MapAverager::stop().

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

◆ mapAveragingAdcCallback()

void mapAveragingAdcCallback ( float  instantVoltage)

This method is invoked from ADC callback.

Note
This method is invoked OFTEN, this method is a potential bottleneck - the implementation should be as fast as possible

Definition at line 140 of file map_averaging.cpp.

140 {
141 efiAssertVoid(ObdCode::CUSTOM_ERR_6650, hasLotsOfRemainingStack(), "lowstck#9a");
142
143 SensorResult mapResult = getMapAvg(currentMapAverager).submit(instantVoltage);
144
145 if (!mapResult) {
146 // hopefully this warning is not too much CPU consumption for fast ADC callback
147 warning(ObdCode::CUSTOM_INSTANT_MAP_DECODING, "Invalid MAP at %f", instantVoltage);
149 } else {
151 }
152
153#if EFI_TUNER_STUDIO
154 float instantMap = mapResult.value_or(0);
156#endif // EFI_TUNER_STUDIO
157}
SensorResult submit(float sensorVolts)
bool warning(ObdCode code, const char *fmt,...)
static size_t currentMapAverager
MapAverager & getMapAvg(size_t idx)
Definition init_map.cpp:28
@ CUSTOM_ERR_6650
@ CUSTOM_INSTANT_MAP_DECODING
expected< float > SensorResult
Definition sensor.h:46
scaled_channel< uint16_t, 30, 1 > instantMAPValue

Referenced by onFastAdcComplete().

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

◆ startAveraging()

void startAveraging ( mapSampler s)

Definition at line 56 of file map_averaging.cpp.

56 {
58 // Zero duration means the engine wasn't spinning or something, abort
59 return;
60 }
61 efiAssertVoid(ObdCode::CUSTOM_ERR_6649, hasLotsOfRemainingStack(), "lowstck#9");
62
63 // TODO: set currentMapAverager based on cylinder bank
64 auto& averager = getMapAvg(currentMapAverager);
65 averager.start(s->cylinderNumber);
66
67 mapAveragingPin.setHigh();
69
71 action_s::make<endAveraging>(&averager));
72}
EngineState engineState
Definition engine.h:329
angle_t mapAveragingDuration
efitick_t getTimeNowNt()
Definition efitime.cpp:19
@ CUSTOM_ERR_6649
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t nowNt, angle_t angle, action_s const &action)
scheduling_s timer
uint8_t cylinderNumber
Here is the call graph for this function:

Variable Documentation

◆ averagedMapBufIdx

int averagedMapBufIdx = 0
static

Definition at line 49 of file map_averaging.cpp.

Referenced by applyMapMinBufferLength(), and MapAverager::stop().

◆ averagedMapRunningBuffer

float averagedMapRunningBuffer[MAX_MAP_BUFFER_LENGTH]
static

Definition at line 47 of file map_averaging.cpp.

Referenced by applyMapMinBufferLength(), and MapAverager::stop().

◆ currentMapAverager

size_t currentMapAverager = 0
static

Definition at line 54 of file map_averaging.cpp.

Referenced by mapAveragingAdcCallback(), and startAveraging().

◆ expAverage

ExpAverage expAverage
static

Definition at line 96 of file map_averaging.cpp.

Referenced by filterMapValue().

◆ mapMinBufferLength

int mapMinBufferLength = 0
static

Definition at line 48 of file map_averaging.cpp.

Referenced by applyMapMinBufferLength(), and MapAverager::stop().

Go to the source code of this file.