This commit is contained in:
rusefi 2020-02-14 22:39:32 -05:00
commit fd1f34c5c1
7 changed files with 85 additions and 10 deletions

View File

@ -843,6 +843,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 201200211;
return 201200214;
}
#endif /* EFI_UNIT_TEST */

View File

@ -95,7 +95,9 @@ void initializeMazdaMiataNb2Crank(TriggerWaveform *s) {
s->tdcPosition = 60 + 655;
s->setTriggerSynchronizationGap2(0.35f, 0.98f);
// 384
s->addEvent720(o + 4 * 56.0f, T_PRIMARY, TV_FALL);
// 400
s->addEvent720(o + 4 * 60.0f, T_PRIMARY, TV_RISE);
s->addEvent720(o + 4 * 136.0f, T_PRIMARY, TV_FALL);
s->addEvent720(o + 4 * 140.0f, T_PRIMARY, TV_RISE);

View File

@ -361,9 +361,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
// That's easy - trigger cycle matches engine cycle
triggerIndexForListeners = triggerState.getCurrentIndex();
} else {
// todo: should this logic reuse getCycleDuration?
bool isCrankDriven = operationMode == FOUR_STROKE_CRANK_SENSOR || operationMode == FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR;
int crankDivider = isCrankDriven ? 2 : 4;
int crankDivider = operationMode == FOUR_STROKE_CRANK_SENSOR ? 2 : SYMMETRICAL_CRANK_SENSOR_DIVIDER;
int crankInternalIndex = triggerState.getTotalRevolutionCounter() % crankDivider;

View File

@ -12,6 +12,8 @@
#include "trigger_decoder.h"
#include "trigger_central_generated.h"
class Engine;
typedef void (*ShaftPositionListener)(trigger_event_e signal, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
@ -79,3 +81,4 @@ void onConfigurationChangeTriggerCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool checkIfTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool isTriggerConfigChanged(DECLARE_ENGINE_PARAMETER_SIGNATURE);
#define SYMMETRICAL_CRANK_SENSOR_DIVIDER 4

View File

@ -123,12 +123,24 @@ TEST(sensors, testNB2CamInput) {
eth.setTriggerType(TT_ONE PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_EQ( 0, GET_RPM()) << "testNB2CamInput RPM";
for (int i = 0; i < 5;i++) {
eth.fireRise(50);
for (int i = 0; i < 7;i++) {
eth.fireRise(25);
ASSERT_EQ( 0, GET_RPM()) << "testNB2CamInput RPM";
}
eth.fireRise(25);
// first time we have RPM
ASSERT_EQ(1200, GET_RPM()) << "testNB2CamInput RPM";
// this would be ignored since we only consude one kind the other kind of fronts here
int totalRevolutionCountBeforeVvtSync = 10;
// need to be out of VVT sync to see VVT sync in action
eth.fireRise(25);
eth.fireRise(25);
ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
ASSERT_TRUE((totalRevolutionCountBeforeVvtSync % SYMMETRICAL_CRANK_SENSOR_DIVIDER) != 0);
eth.moveTimeForwardUs(MS2US(3)); // shifting VVT phase a few anlges
// this would be ignored since we only consume the other kind of fronts here
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
eth.moveTimeForwardUs(MS2US(20));
// this would be be first VVT signal - gap duration would be calculated against 'DEEP_IN_THE_PAST_SECONDS' initial value
@ -139,13 +151,13 @@ TEST(sensors, testNB2CamInput) {
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition());
ASSERT_EQ(5, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
eth.moveTimeForwardUs(MS2US(130));
// this third important front would give us first comparison between two real gaps
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_NEAR(-46, engine->triggerCentral.getVVTPosition(), EPS3D);
ASSERT_NEAR(-67.6, engine->triggerCentral.getVVTPosition(), EPS3D);
// actually position based on VVT!
ASSERT_EQ(8, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
ASSERT_EQ(totalRevolutionCountBeforeVvtSync + 2, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
}

View File

@ -0,0 +1,59 @@
/*
* @file test_symmetrical_crank.cpp
*
* @date Feb 14, 2020
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "engine_test_helper.h"
static void postFourEvents(EngineTestHelper *eth, float mult) {
eth->fireFall(mult * 384);
eth->fireRise(mult * 16);
eth->fireFall(mult * 304);
eth->fireRise(mult * 16);
}
TEST(engine, testSymmetricalCrank) {
WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003);
// this test is not about isFasterEngineSpinUpEnabled so let's disable it to simplify things
CONFIG(isFasterEngineSpinUpEnabled) = false;
ASSERT_EQ(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR, engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE));
float mult = 0.02;
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
postFourEvents(&eth, mult);
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
eth.fireFall(mult * 384);
eth.fireRise(mult * 16);
eth.fireFall(mult * 304);
ASSERT_FALSE(engine->triggerCentral.triggerState.shaft_is_synchronized);
eth.fireRise(mult * 16);
ASSERT_TRUE(engine->triggerCentral.triggerState.shaft_is_synchronized);
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
for (int i = 0; i < 6 ; i++) {
postFourEvents(&eth, mult);
ASSERT_EQ( 0, GET_RPM()) << "RPM#0";
}
mult = 0.1;
postFourEvents(&eth, mult);
ASSERT_EQ( 1041, GET_RPM()) << "RPM#11";
postFourEvents(&eth, mult);
ASSERT_EQ( 1041, GET_RPM()) << "RPM#11";
postFourEvents(&eth, mult);
ASSERT_EQ( 1041, GET_RPM()) << "RPM#11";
}

View File

@ -11,6 +11,7 @@ TESTS_SRC_CPP = \
tests/test_miata_na6_real_cranking.cpp \
tests/test_fasterEngineSpinningUp.cpp \
tests/test_dwell_corner_case_issue_796.cpp \
tests/test_symmetrical_crank.cpp \
tests/test_idle_controller.cpp \
tests/test_trigger_decoder.cpp \
tests/test_trigger_noiseless.cpp \