Skip to content

Commit

Permalink
Minor change of Miata NA trigger shape #2855 #669 (#2856)
Browse files Browse the repository at this point in the history
* Minor change of Miata NA trigger shape #2855 #669

* Minor change of Miata NA trigger shape #2855 #669
  • Loading branch information
rusefillc committed Jun 25, 2021
1 parent 942eb46 commit 0af5de0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
5 changes: 3 additions & 2 deletions firmware/controllers/trigger/decoders/trigger_mazda.cpp
Expand Up @@ -25,12 +25,13 @@

void initializeMazdaMiataNaShape(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
s->setTriggerSynchronizationGap2(1.4930 * 0.6f, 1.4930 * 1.4f);
s->setTriggerSynchronizationGap2(4 * 0.75f, 4 * 1.4f);
s->useRiseEdge = false;

s->bothFrontsRequired = true;
s->gapBothDirections = true;

s->tdcPosition = 294;
s->tdcPosition = 436.965;

/**
* http://rusefi.com/forum/viewtopic.php?f=3&t=729&p=12983#p12983
Expand Down
9 changes: 4 additions & 5 deletions unit_tests/tests/trigger/test_real_cranking_miata_NA.cpp
Expand Up @@ -98,14 +98,13 @@ TEST(cranking, realCrankingFromFile) {
reader.readLine(&eth);
}

ASSERT_EQ( 0, GET_RPM())<< reader.lineIndex << " @ 0";
ASSERT_EQ( 42, GET_RPM())<< reader.lineIndex << " @ 0";
ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#got synch";

ASSERT_EQ(0, engine->tdcScheduler[1].momentX);
reader.readLine(&eth);
ASSERT_EQ(3645170, engine->tdcScheduler[1].momentX); // let's assert TDC position and sync point

ASSERT_EQ( 32, GET_RPM())<< reader.lineIndex << " @ 1";
ASSERT_EQ( 213, GET_RPM())<< reader.lineIndex << " @ 1";

for (int i = 0; i < 30; i++) {
reader.readLine(&eth);
Expand All @@ -116,11 +115,11 @@ TEST(cranking, realCrankingFromFile) {
for (int i = 0; i < 30; i++) {
reader.readLine(&eth);
}
ASSERT_EQ( 344, GET_RPM())<< reader.lineIndex << " @ 2";
ASSERT_EQ( 297, GET_RPM())<< reader.lineIndex << " @ 2";

while (reader.haveMore()) {
reader.processLine(&eth);
}
ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#realCranking";
ASSERT_EQ( 499, GET_RPM())<< reader.lineIndex;
ASSERT_EQ( 560, GET_RPM())<< reader.lineIndex;
}
21 changes: 7 additions & 14 deletions unit_tests/tests/trigger/test_real_cranking_miata_na6.cpp
Expand Up @@ -56,38 +56,34 @@ TEST(cranking, hardcodedRealCranking) {
ASSERT_EQ( 0, GET_RPM()) << "RPM at the 14";
/* 14 */ EVENT(/* timestamp*/1.194742, T_PRIMARY, /*value*/true);
// first synch & fast spinning RPM
ASSERT_EQ( 48, GET_RPM()) << "RPM at the 14";
ASSERT_EQ( 31, GET_RPM()) << "RPM at the 14";
/* 15 */ EVENT(/* timestamp*/1.20417975, T_SECONDARY, /*value*/false);
/* 16 */ EVENT(/* timestamp*/1.25380075, T_SECONDARY, /*value*/true);
/* 17 */ EVENT(/* timestamp*/1.30114225, T_PRIMARY, /*value*/true);
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";
/* 18 */ EVENT(/* timestamp*/1.3341915, T_SECONDARY, /*value*/false);
/* 19 */ EVENT(/* timestamp*/1.383534, T_SECONDARY, /*value*/true);
ASSERT_EQ( 107, GET_RPM()) << "RPM at the 19";
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";
ASSERT_EQ( 67, GET_RPM()) << "RPM at the 19";

// second synch
/* 22 */ EVENT(/* timestamp*/1.45352675, T_PRIMARY, /*value*/true);
ASSERT_EQ( 1, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";
ASSERT_EQ( 464, GET_RPM()) << "RPM at the 22";
ASSERT_EQ( 33, GET_RPM()) << "RPM at the 22";
/* 23 */ EVENT(/* timestamp*/1.46291525, T_SECONDARY, /*value*/false);
/* 25 */ EVENT(/* timestamp*/1.49939025, T_PRIMARY, /*value*/false);
/* 27 */ EVENT(/* timestamp*/1.511785, T_SECONDARY, /*value*/true);
/* 28 */ EVENT(/* timestamp*/1.5908545, T_SECONDARY, /*value*/false);
/* 31 */ EVENT(/* timestamp*/1.6399845, T_SECONDARY, /*value*/true);
ASSERT_EQ( 1, eth.getWarningCounter()) << "warningCounter#realCranking";
/* 32 */ EVENT(/* timestamp*/1.70975875, T_PRIMARY, /*value*/true);
ASSERT_EQ( 2, eth.getWarningCounter()) << "warningCounter#realCranking";
/* 33 */ EVENT(/* timestamp*/1.7194455, T_SECONDARY, /*value*/false);
/* 36 */ EVENT(/* timestamp*/1.7697125, T_SECONDARY, /*value*/true);
/* 37 */ EVENT(/* timestamp*/1.817179, T_PRIMARY, /*value*/true);
/* 38 */ EVENT(/* timestamp*/1.8511055, T_SECONDARY, /*value*/false);
/* 41 */ EVENT(/* timestamp*/1.9011835, T_SECONDARY, /*value*/true);
/* 42 */ EVENT(/* timestamp*/1.97691675, T_PRIMARY, /*value*/true);
/* 43 */ EVENT(/* timestamp*/1.9822455, T_SECONDARY, /*value*/false);
ASSERT_EQ( 449, GET_RPM()) << "RPM at the 17";
ASSERT_EQ( 233, GET_RPM()) << "RPM at the 17";
/* 44 */ EVENT(/* timestamp*/2.001249, T_PRIMARY, /*value*/false);
ASSERT_EQ( 449, GET_RPM()) << "RPM at the 17";
ASSERT_EQ( 233, GET_RPM()) << "RPM at the 17";


/* 45 */ EVENT(/* timestamp*/2.0070235, T_SECONDARY, /*value*/true);
Expand All @@ -109,7 +105,6 @@ TEST(cranking, hardcodedRealCranking) {
/* 67 */ EVENT(/* timestamp*/2.308357, T_SECONDARY, /*value*/false);
/* 68 */ EVENT(/* timestamp*/2.33551175, T_SECONDARY, /*value*/true);
/* 69 */ EVENT(/* timestamp*/2.3601205, T_PRIMARY, /*value*/true);
ASSERT_EQ( 1, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";
/* 70 */ EVENT(/* timestamp*/2.382952, T_SECONDARY, /*value*/false);
/* 71 */ EVENT(/* timestamp*/2.41535525, T_SECONDARY, /*value*/true);
/* 74 */ EVENT(/* timestamp*/2.45321725, T_PRIMARY, /*value*/true);
Expand All @@ -120,7 +115,6 @@ TEST(cranking, hardcodedRealCranking) {
/* 81 */ EVENT(/* timestamp*/2.533664, T_SECONDARY, /*value*/true);
/* 84 */ EVENT(/* timestamp*/2.56564675, T_PRIMARY, /*value*/true);
/* 85 */ EVENT(/* timestamp*/2.57087425, T_SECONDARY, /*value*/false);
ASSERT_EQ( 2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";
/* 86 */ EVENT(/* timestamp*/2.59612075, T_SECONDARY, /*value*/true);
/* 89 */ EVENT(/* timestamp*/2.61853375, T_PRIMARY, /*value*/true);
/* 90 */ EVENT(/* timestamp*/2.6365195, T_SECONDARY, /*value*/false);
Expand Down Expand Up @@ -154,8 +148,7 @@ TEST(cranking, hardcodedRealCranking) {
/* 134 */ EVENT(/* timestamp*/3.031735, T_PRIMARY, /*value*/true);


ASSERT_EQ( 2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";
ASSERT_EQ(CUSTOM_SYNC_COUNT_MISMATCH, unitTestWarningCodeState.recentWarnings.get(0)) << "@0";
ASSERT_EQ( 0, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#realCranking";

ASSERT_EQ( 1231, GET_RPM()) << "RPM at the end";
ASSERT_EQ( 719, GET_RPM()) << "RPM at the end";
}
2 changes: 1 addition & 1 deletion unit_tests/tests/trigger/test_trigger_decoder.cpp
Expand Up @@ -519,7 +519,7 @@ TEST(misc, testTriggerDecoder) {
applyNonPersistentConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);

}
testTriggerDecoder2("miata 1990", MIATA_1990, 11, 0.2985, 0.3890);
testTriggerDecoder2("miata 1990", MIATA_1990, 8, 0.7015, 0.3890);
testTriggerDecoder3("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0, 2.9994);

testTriggerDecoder2("CAMARO_4", CAMARO_4, 40, 0.5, 0);
Expand Down

0 comments on commit 0af5de0

Please sign in to comment.