diff --git a/firmware/config/engines/bmw_e34.cpp b/firmware/config/engines/bmw_e34.cpp index 4133f846a6..da6a388be7 100644 --- a/firmware/config/engines/bmw_e34.cpp +++ b/firmware/config/engines/bmw_e34.cpp @@ -65,6 +65,8 @@ void setBmwE34(DECLARE_ENGINE_PARAMETER_F) { setConstantDwell(3 PASS_ENGINE_PARAMETER); // a bit shorter dwell engineConfiguration->ignMathCalculateAtIndex = 14; + engineConfiguration->mapAveragingSchedulingAtIndex = 6; + // Cranking engineConfiguration->cranking.rpm = 600; engineConfiguration->crankingInjectionMode = IM_BATCH; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 33ecf85d3a..4b48882940 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Wed Apr 15 12:11:02 EDT 2015 +// this section was generated by config_definition.jar on Sat Apr 18 18:59:21 EDT 2015 // begin #include "rusefi_types.h" typedef struct { @@ -1099,7 +1099,11 @@ typedef struct { /** * offset 1648 */ - int unused3[134]; + int mapAveragingSchedulingAtIndex; + /** + * offset 1652 + */ + int unused3[133]; /** * offset 2184 */ @@ -1279,4 +1283,4 @@ typedef struct { } persistent_config_s; // end -// this section was generated by config_definition.jar on Wed Apr 15 12:11:02 EDT 2015 +// this section was generated by config_definition.jar on Sat Apr 18 18:59:21 EDT 2015 diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp index c10b870dd6..21bd4a43cd 100644 --- a/firmware/controllers/map_averaging.cpp +++ b/firmware/controllers/map_averaging.cpp @@ -32,6 +32,7 @@ #include "interpolation.h" #include "signal_executor.h" #include "engine.h" +#include "engine_math.h" #if EFI_ANALOG_CHART #include "analog_chart.h" @@ -168,7 +169,7 @@ static void endAveraging(void *arg) { static void mapAveragingCallback(trigger_event_e ckpEventType, uint32_t index DECLARE_ENGINE_PARAMETER_S) { // this callback is invoked on interrupt thread engine->m.beforeMapAveragingCb = GET_TIMESTAMP(); - if (index != 0) + if (index != engineConfiguration->mapAveragingSchedulingAtIndex) return; int rpm = engine->rpmCalculator.rpmValue; @@ -180,17 +181,23 @@ static void mapAveragingCallback(trigger_event_e ckpEventType, uint32_t index DE MAP_sensor_config_s * config = &engineConfiguration->map; - angle_t samplingStart = interpolate2d(rpm, config->samplingAngleBins, config->samplingAngle, MAP_ANGLE_SIZE); + angle_t currentAngle = TRIGGER_SHAPE(eventAngles[index]); + + angle_t samplingStart = interpolate2d(rpm, config->samplingAngleBins, config->samplingAngle, MAP_ANGLE_SIZE) - currentAngle; angle_t samplingDuration = interpolate2d(rpm, config->samplingWindowBins, config->samplingWindow, MAP_WINDOW_SIZE); if (samplingDuration <= 0) { firmwareError("map sampling angle should be positive"); return; } + fixAngle(samplingStart); + + angle_t samplingEnd = samplingStart + samplingDuration; + fixAngle(samplingEnd); int structIndex = getRevolutionCounter() % 2; // todo: schedule this based on closest trigger event, same as ignition works scheduleByAngle(rpm, &startTimer[structIndex], samplingStart, startAveraging, NULL, &engine->rpmCalculator); - scheduleByAngle(rpm, &endTimer[structIndex], samplingStart + samplingDuration, endAveraging, NULL, &engine->rpmCalculator); + scheduleByAngle(rpm, &endTimer[structIndex], samplingEnd, endAveraging, NULL, &engine->rpmCalculator); engine->m.mapAveragingCbTime = GET_TIMESTAMP() - engine->m.beforeMapAveragingCb; } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 46b8b30d4d..a280552425 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -487,7 +487,10 @@ custom pin_input_mode_e 4 scalar, F32, @OFFSET@, "ms", 1, 0, 0, 200, 1 brain_pin_e stepperEnablePin; float noAccelAfterHardLimitPeriodSecs;;"sec", 1, 0, 0, 60, 0 - int[134] unused3; + +int mapAveragingSchedulingAtIndex; + + int[133] unused3; int tpsAccelLength;;"len", 1, 0, 1, 200, 3 float tpsAccelEnrichmentThreshold;;"roc", 1, 0, 0, 200, 3 diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index bdfc508e72..3f96610d5a 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -40,7 +40,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated by ConfigDefinition.jar on Wed Apr 15 12:11:03 EDT 2015 +; this section was generated by ConfigDefinition.jar on Sat Apr 18 18:59:23 EDT 2015 pageSize = 15288 page = 1 @@ -453,7 +453,8 @@ page = 1 idleStepperTotalSteps = scalar, S32, 1636, "count", 1, 0, 5, 3000, 0 stepperEnablePin = bits, U32, 1640, [0:6], "GPIOA_0", "GPIOA_1", "GPIOA_2", "GPIOA_3", "GPIOA_4", "GPIOA_5", "GPIOA_6", "GPIOA_7", "GPIOA_8", "GPIOA_9", "GPIOA_10", "GPIOA_11", "GPIOA_12", "GPIOA_13", "GPIOA_14", "GPIOA_15", "GPIOB_0", "GPIOB_1", "GPIOB_2", "GPIOB_3", "GPIOB_4", "GPIOB_5", "GPIOB_6", "GPIOB_7", "GPIOB_8", "GPIOB_9", "GPIOB_10", "GPIOB_11", "GPIOB_12", "GPIOB_13", "GPIOB_14", "GPIOB_15", "GPIOC_0", "GPIOC_1", "GPIOC_2", "GPIOC_3", "GPIOC_4", "GPIOC_5", "GPIOC_6", "GPIOC_7", "GPIOC_8", "GPIOC_9", "GPIOC_10", "GPIOC_11", "GPIOC_12", "GPIOC_13", "GPIOC_14", "GPIOC_15", "GPIOD_0", "GPIOD_1", "GPIOD_2", "GPIOD_3", "GPIOD_4", "GPIOD_5", "GPIOD_6", "GPIOD_7", "GPIOD_8", "GPIOD_9", "GPIOD_10", "GPIOD_11", "GPIOD_12", "GPIOD_13", "GPIOD_14", "GPIOD_15", "GPIOE_0", "GPIOE_1", "GPIOE_2", "GPIOE_3", "GPIOE_4", "GPIOE_5", "GPIOE_6", "GPIOE_7", "GPIOE_8", "GPIOE_9", "GPIOE_10", "GPIOE_11", "GPIOE_12", "GPIOE_13", "GPIOE_14", "GPIOE_15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" noAccelAfterHardLimitPeriodSecs = scalar, F32, 1644, "sec", 1, 0, 0, 60, 0 -;skipping unused3 offset 1648 +;skipping mapAveragingSchedulingAtIndex offset 1648 +;skipping unused3 offset 1652 tpsAccelLength = scalar, S32, 2184, "len", 1, 0, 1, 200, 3 tpsAccelEnrichmentThreshold = scalar, F32, 2188, "roc", 1, 0, 0, 200, 3 tpsAccelEnrichmentMultiplier = scalar, F32, 2192, "coeff", 1, 0, 0, 200, 3 diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index bdbff3d0db..d59b61ca17 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -62,6 +62,8 @@ public class AutoTest { x = 688.464; assertWave(msg, chart, WaveChart.SPARK_1, 0.0597999999, x, x + 180, x + 360, x + 540); + + assertWave(msg, chart, WaveChart.MAP_AVERAGING, 0.139, 17.784); } private static void testMitsu() { diff --git a/java_console/models/src/com/rusefi/waves/WaveChart.java b/java_console/models/src/com/rusefi/waves/WaveChart.java index a7340d0f01..b09d868f6b 100644 --- a/java_console/models/src/com/rusefi/waves/WaveChart.java +++ b/java_console/models/src/com/rusefi/waves/WaveChart.java @@ -29,6 +29,7 @@ public class WaveChart { public static final String TRIGGER_1 = "t1"; public static final String TRIGGER_2 = "t2"; + public static final String MAP_AVERAGING = "map"; public final Map map;