rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions
map_averaging.h File Reference

Detailed Description

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

Definition in file map_averaging.h.

Data Structures

struct  mapSampler
 
class  MapAverager
 
class  MapAveragingModule
 

Functions

void mapAveragingAdcCallback (float instantVoltage)
 
MapAveragergetMapAvg (size_t idx)
 
float filterMapValue (float value)
 
void startAveraging (struct mapSampler *s)
 

Function Documentation

◆ 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 constexpr engine_configuration_s * engineConfiguration
static ExpAverage expAverage

Referenced by MapAverager::stop().

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

◆ getMapAvg()

MapAverager & getMapAvg ( size_t  idx)

Definition at line 28 of file init_map.cpp.

28 {
29 // May 2025: cylinderBankIndex is always zero, second MAP sensor feature is not finished
30 return cylinderBankIndex == 0 ? fastMapSensor : fastMapSensor2;
31}
static MapAverager fastMapSensor(SensorType::MapFast, MS2NT(200))
static MapAverager fastMapSensor2(SensorType::MapFast2, MS2NT(200))

Referenced by mapAveragingAdcCallback(), and startAveraging().

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}
TunerStudioOutputChannels outputChannels
Definition engine.h:109
SensorResult submit(float sensorVolts)
static EngineAccessor engine
Definition engine.h:413
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 ( struct 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:344
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:

Go to the source code of this file.