MAP phase sensing #3544

This commit is contained in:
rusefillc 2021-11-24 14:26:41 -05:00
parent d32af2a484
commit 446252d77d
3 changed files with 11 additions and 9 deletions

View File

@ -70,6 +70,7 @@ static float v_averagedMapValue;
static float averagedMapRunningBuffer[MAX_MAP_BUFFER_LENGTH];
int mapMinBufferLength = 0;
static int averagedMapBufIdx = 0;
static adcsample_t fastestRawAdc;
/**
* here we have averaging start and averaging end points for each cylinder
@ -109,18 +110,17 @@ static void startAveraging(scheduling_s *endAveragingScheduling) {
* as fast as possible
*/
void mapAveragingAdcCallback(adcsample_t adcValue) {
efiAssertVoid(CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a");
fastestRawAdc = adcValue;
if (!isAveraging && engine->sensorChartMode != SC_MAP) {
return;
}
/* Calculates the average values from the ADC samples.*/
measurementsPerRevolutionCounter++;
efiAssertVoid(CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a");
#if EFI_SENSOR_CHART && EFI_ANALOG_SENSORS
if (engine->sensorChartMode == SC_MAP) {
if (measurementsPerRevolutionCounter % FAST_MAP_CHART_SKIP_FACTOR
== 0) {
measurementsPerRevolutionCounter++;
if (measurementsPerRevolutionCounter % FAST_MAP_CHART_SKIP_FACTOR == 0) {
float voltage = adcToVoltsDivided(adcValue);
float currentPressure = convertMap(voltage).value_or(0);
scAddData(
@ -130,7 +130,8 @@ void mapAveragingAdcCallback(adcsample_t adcValue) {
}
#endif /* EFI_SENSOR_CHART */
{
/* Calculates the average values from the ADC samples.*/
if (isAveraging) {
// with locking we will have a consistent state
chibios_rt::CriticalSectionLocker csl;
mapAdcAccumulator += adcValue;
@ -189,6 +190,7 @@ void postMapState(TunerStudioOutputChannels *tsOutputChannels) {
tsOutputChannels->debugFloatField2 = engine->engineState.mapAveragingDuration;
tsOutputChannels->debugFloatField3 = Sensor::getOrZero(SensorType::MapFast);
tsOutputChannels->debugIntField1 = mapMeasurementsCounter;
tsOutputChannels->debugIntField1 = fastestRawAdc;
}
#endif /* EFI_TUNER_STUDIO */

View File

@ -472,7 +472,7 @@ enable2ndByteCanID = false
debugFieldF6List = bits, U08, [0:7], "Alt: D Term", "", "", "Idle: D Term", "Idle df6", "Current Gap", "", "VVT1: D Term", "", "", "", "", "", "", "", "", "", "ETB df6", "", "", "df6", "df6", "22df6", "", "24:df6", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Ki", "", "", "", "", "", "", "", "", "Lua Debug 6", "VVT2: D Term", "VVT3: D Term", "VVT4: D Term"
debugFieldF7List = bits, U08, [0:7], "Alt: Max-Value", "", "", "Idle: Max-Value", "Idle df7", "", "", "VVT1: Max-Value", "", "", "", "", "", "", "", "", "", "ETB df7", "", "", "df7", "df7", "22df7", "", "24:df7", "cj: f7", "", "", "", "", "", "", "", "", "", "", "", "S unused" "", "Kd", "", "", "", "", "", "", "", "", "Lua Debug 7", "", "", ""
debugFieldI1List = bits, U08, [0:7], "Alt: P Gain", "", "", "Idle: P Gain", "Idle di1", "Channel 1 Fall Counter", "", "VVT1: P Gain", "VVT Sync Counter", "Cycle Counter", "Multispark Count", "", "", "", "hip corr", "", "", "ETB P-Gain", "t counter", "", "di1", "di1", "Spark Event Gap","", "24:di1", "CJ125: state", "read count","MAP counter", "", "", "", "SPI Counter", "", "", "", "", "", "Start Count", "", "", "", "", "", "", "deltatime", "", "", "Solenoid 1 State", "Lua memory used","VVT2: P Gain", "VVT3: P Gain", "VVT4: P Gain"
debugFieldI2List = bits, U08, [0:7], "Alt: Offset", "", "", "Idle: Offset", "Idle di2", "Channel 2 Fall Counter", "", "VVT1: Offset", "", "", "", "", "", "", "hip incor", "", "", "ETB di2", "invocationcounter", "", "di2", "di2", "Inj Event Gap", "", "24:di2", "", "write count","", "", "", "", "Latest Transmit","", "", "", "", "", "Starter Enable", "", "", "", "", "", "", "", "", "", "Solenoid 2 State", "", "VVT2: Offset", "VVT3: Offset", "VVT4: Offset"
debugFieldI2List = bits, U08, [0:7], "Alt: Offset", "", "", "Idle: Offset", "Idle di2", "Channel 2 Fall Counter", "", "VVT1: Offset", "", "", "", "", "", "", "hip incor", "", "", "ETB di2", "invocationcounter", "", "di2", "di2", "Inj Event Gap", "", "24:di2", "", "write count","MAP raw ADC", "", "", "", "Latest Transmit","", "", "", "", "", "Starter Enable", "", "", "", "", "", "", "", "", "", "Solenoid 2 State", "", "VVT2: Offset", "VVT3: Offset", "VVT4: Offset"
debugFieldI3List = bits, U08, [0:7], "Alt: Reset Cnt", "", "", "Idle: Reset Cnt", "Idle di3", "Cycle Index", "", "VVT1: 10xTarget", "", "", "", "", "", "", "", "", "", "ETB di3", "s counter", "", "di3", "di3", "22di3", "", "24:di3", "", "write err", "", "", "", "", "Latest Received","", "", "", "", "", "Starter Disable","", "", "", "", "", "", "", "", "", "Solenoid 3 State", "", "VVT2: 10xTarger", "VVT3: 10xTarger", "VVT4: 10xTarger"
debugFieldI4List = bits, U08, [0:7], "Alt: Period", "", "", "Idle: State", "Idle di4", "Cycle Cnt 1", "", "", "", "", "", "", "", "", "", "", "", "ETB di4", "executor", "", "di4", "di4", "22di4", "", "24:di4", "", "", "", "", "", "", "Init Count", "", "", "", "", "", "S unused" "", "", "", "", "", "", "", "", "", "Solenoid 4 State", "", "", "", ""
debugFieldI5List = bits, U08, [0:7], "", "", "", "", "Idle di5", "Cycle Cnt 2", "", "", "", "", "", "", "", "", "", "di5", "di5", "ETB di5", "max executor", "di5", "di5", "di5", "22di5", "di5", "di5", "di5", "di5", "di5", "", "di5", "di5", "di5", "", "di5", "di5", "di5", "di5", "S di5" "", "", "", "", "", "", "", "", "", "Solenoid 5 State", "", "", "", ""