MAP phase sensing #3544

new implementation seems complete?
This commit is contained in:
Andrey 2021-12-07 21:08:25 -05:00
parent 940b04ab24
commit 50038167d8
10 changed files with 39 additions and 20 deletions

View File

@ -15,7 +15,7 @@
#include "test_engine.h"
// TEST_ENGINE
void setTestEngineConfiguration() {
void setTestCamEngineConfiguration() {
setDefaultFrankensoConfiguration();
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
@ -50,6 +50,13 @@ void setTestEngineConfiguration() {
engineConfiguration->ignitionPins[5] = GPIO_UNASSIGNED; // #6
}
void setTestCrankEngineConfiguration() {
setTestCamEngineConfiguration();
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
}
void setTestVVTEngineConfiguration() {
setDefaultFrankensoConfiguration();
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
@ -72,7 +79,7 @@ void setTestVVTEngineConfiguration() {
#if EFI_UNIT_TEST
void setTestEngineIssue366both() {
setTestEngineConfiguration();
setTestCamEngineConfiguration();
engineConfiguration->useOnlyRisingEdgeForTrigger = false;

View File

@ -9,7 +9,8 @@
#include "engine_configuration.h"
void setTestEngineConfiguration();
void setTestCamEngineConfiguration();
void setTestCrankEngineConfiguration();
void setTestVVTEngineConfiguration();
void setTestEngineIssue366both();

View File

@ -15,6 +15,11 @@
#include "tunerstudio_debug_struct.h"
#include "ts_outputs_generated.h"
#ifndef WITH_TS_STATE
// do we ever see a case of compiling without TSOutputChannels? Shall we wipe out all '#if EFI_TUNER_STUDIO' or replace with '#if WITH_TS_STATE'
#define WITH_TS_STATE TRUE
#endif
enum class TsCalMode : uint8_t {
None = 0,
Tps1Max = 1,

View File

@ -1,6 +1,6 @@
#include "global.h"
#include "engine_types.h"
// was generated automatically by rusEFI tool from engine_types.h // by enum2string.jar tool on Mon Dec 06 21:27:50 EST 2021
// was generated automatically by rusEFI tool from engine_types.h // by enum2string.jar tool on Tue Dec 07 20:56:44 EST 2021
// see also gen_config_and_enums.bat
@ -325,6 +325,8 @@ case TEST_110:
return "TEST_110";
case TEST_33816:
return "TEST_33816";
case TEST_CRANK_ENGINE:
return "TEST_CRANK_ENGINE";
case TEST_ENGINE:
return "TEST_ENGINE";
case TEST_ENGINE_VVT:
@ -351,8 +353,6 @@ case UNUSED101:
return "UNUSED101";
case UNUSED18:
return "UNUSED18";
case UNUSED28:
return "UNUSED28";
case UNUSED30:
return "UNUSED30";
case UNUSED39:

View File

@ -852,7 +852,10 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e
// nothing to do - we do it all in setBoardDefaultConfiguration
break;
case TEST_ENGINE:
setTestEngineConfiguration();
setTestCamEngineConfiguration();
break;
case TEST_CRANK_ENGINE:
setTestCrankEngineConfiguration();
break;
#if EFI_UNIT_TEST
case TEST_ISSUE_366_BOTH:
@ -1056,7 +1059,6 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e
setHonda600();
break;
case UNUSED9:
case UNUSED28:
case FORD_ESCORT_GT:
setFordEscortGt();
break;

View File

@ -89,7 +89,7 @@ typedef enum {
// see TriggerWaveform::bothFrontsRequired
TEST_ISSUE_898 = 27,
UNUSED28 = 28,
TEST_CRANK_ENGINE = 28,
SACHS = 29,

View File

@ -676,17 +676,18 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
float map = Sensor::getOrZero(SensorType::Map);
if (map > mapCamPrevCycleValue) {
mapCamCounter++;
#if WITH_TS_STATE
engine->outputChannels.TEMPLOG_map_peak++;
#endif // WITH_TS_STATE
efitick_t stamp = getTimeNowNt();
hwHandleVvtCamSignal(TV_RISE, stamp, /*index*/0);
hwHandleVvtCamSignal(TV_FALL, stamp, /*index*/0);
}
#if EFI_TUNER_STUDIO
#if WITH_TS_STATE
engine->outputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = map;
engine->outputChannels.TEMPLOG_map_peak = mapCamCounter;
engine->outputChannels.TEMPLOG_MAP_AT_DIFF = map - mapCamPrevCycleValue;
#endif // EFI_TUNER_STUDIO
#endif // WITH_TS_STATE
mapCamPrevCycleValue = map;

View File

@ -80,7 +80,6 @@ public:
angle_t mapCamPrevToothAngle = -1;
float mapCamPrevCycleValue = 0;
uint8_t mapCamCounter = 0;
/**
* true if a recent configuration change has changed any of the trigger settings which

View File

@ -32,7 +32,7 @@ public enum engine_type_e {
PROTEUS_LUA_DEMO,
TEST_ENGINE,
TEST_ISSUE_898,
UNUSED28,
TEST_CRANK_ENGINE,
SACHS,
UNUSED30,
MRE_BOARD_NEW_TEST,

View File

@ -72,7 +72,7 @@ TEST(trigger, map_cam) {
TEST(trigger, map_cam_by_magic_point) {
EngineTestHelper eth(TEST_ENGINE);
EngineTestHelper eth(TEST_CRANK_ENGINE);
engineConfiguration->camInputs[0] = GPIOA_0;
engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN_ANOTHER;
@ -82,13 +82,17 @@ TEST(trigger, map_cam_by_magic_point) {
engineConfiguration->mapCamDetectionAnglePosition = 90;
eth.smartFireTriggerEvents2(/*count*/10, /*delayMs*/200);
ASSERT_EQ( 150, GET_RPM()) << "RPM";
ASSERT_EQ(1, engine->triggerCentral.mapCamCounter);
ASSERT_EQ( 75, GET_RPM()) << "RPM";
ASSERT_EQ(1, engine->outputChannels.TEMPLOG_map_peak);
ASSERT_EQ(0, engine->outputChannels.vvtSyncCounter);
Sensor::setMockValue(SensorType::Map, 120);
eth.smartFireTriggerEvents2(/*count*/2, /*delayMs*/200);
ASSERT_EQ(2, engine->triggerCentral.mapCamCounter);
eth.smartFireTriggerEvents2(/*count*/4, /*delayMs*/200);
ASSERT_EQ(2, engine->outputChannels.TEMPLOG_map_peak);
ASSERT_EQ(1, engine->outputChannels.vvtSyncCounter);
}