MAP phase sensing #3544

removing dead implementation
This commit is contained in:
rusefillc 2021-12-16 21:13:55 -05:00
parent 82c061a8e0
commit 06ccf524dd
7 changed files with 2 additions and 3106 deletions

View File

@ -809,7 +809,7 @@ void proteusHarley() {
// for now we need non wired camInput to keep TS field enable/disable logic happy
engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_6;
engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN;
engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN_ANOTHER;
engineConfiguration->mapCamAveragingLength = 16;
engineConfiguration->mapCamSkipFactor = 50;

View File

@ -109,12 +109,7 @@ typedef enum __attribute__ ((__packed__)) {
VVT_NISSAN_MR = 11,
/**
* MAP sensor gives us pressure drop corresponding to intake stroke of individual cylinder
* Due to uneven cylinder firing on a V-Twin this gives us a decodable virtual two tooth cam sensor.
* Most HD are 45 degrees with some 60 degree twin.
*/
VVT_MAP_V_TWIN = 12,
VVT_12 = 12,
VVT_MAP_V_TWIN_ANOTHER = 13,

View File

@ -108,24 +108,6 @@ void mapAveragingAdcCallback(adcsample_t adcValue) {
engine->outputChannels.instantMAPValue = instantMap;
#endif // EFI_TUNER_STUDIO
if (engineConfiguration->vvtMode[0] == VVT_MAP_V_TWIN &&
((fastMapCounter++ % engineConfiguration->mapCamSkipFactor) == 0)) {
engine->triggerCentral.mapState.add(instantMap);
bool isPeak = engine->triggerCentral.mapState.isPeak(engineConfiguration->mapCamLookForLowPeaks);
#if EFI_TUNER_STUDIO
engine->outputChannels.TEMPLOG_map_length = MAP_CAM_BUFFER;
engine->outputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = engine->triggerCentral.mapState.current;
if (isPeak) {
engine->outputChannels.TEMPLOG_map_peak++;
}
#endif //EFI_TUNER_STUDIO
if (isPeak) {
efitick_t stamp = getTimeNowNt();
hwHandleVvtCamSignal(TV_RISE, stamp, /*index*/0);
hwHandleVvtCamSignal(TV_FALL, stamp, /*index*/0);
}
}
/* Calculates the average values from the ADC samples.*/
if (isAveraging) {
// with locking we will have a consistent state

View File

@ -34,32 +34,6 @@ public:
efitick_t accumSignalPrevPeriods[HW_EVENT_TYPES];
};
struct MapState {
float current, previous, prevPrevious;
cyclic_buffer<float, MAP_CAM_BUFFER> mapBuffer;
void add(float value) {
// rotate state
prevPrevious = previous;
previous = current;
// add new value
mapBuffer.add(value);
current = mapBuffer.sum(engineConfiguration->mapCamAveragingLength);
}
bool isPeak(bool lookForLowPeak) {
if (mapBuffer.getCount() < MAP_CAM_BUFFER + 3)
return false;
if (lookForLowPeak) {
return previous < prevPrevious && previous <= current;
} else {
return previous > prevPrevious && previous >= current;
}
}
};
/**
* Maybe merge TriggerCentral and TriggerState classes into one class?
* Probably not: we have an instance of TriggerState which is used for trigger initialization,

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
/*
* test_instant_map.cpp
*
* Created on: Nov 30, 2021
* @author Andrey Belomutskiy, (c) 2012-2021
*/
#include "pch.h"
static char buffer[255];
static FILE *fp;
static int m_lineIndex = -1;
bool haveMore() {
bool result = fgets(buffer, sizeof(buffer), fp) != nullptr;
m_lineIndex++;
if (m_lineIndex == 0) {
// skip header
return haveMore();
}
return result;
}
TEST(trigger, instantMap) {
const char s[2] = ",";
fp = fopen("tests/resources/instant_map.csv", "r");
ASSERT_TRUE(fp != nullptr);
MapState mapState;
EngineTestHelper eth(TEST_ENGINE);
while (haveMore()) {
strtok(buffer, s);
strtok(NULL, s);
char *map = strtok(NULL, s);
if (map == nullptr) {
break;
}
double mapValue = std::stod(map);
printf("map %f\n", mapValue);
if (m_lineIndex != 105 && m_lineIndex != 183 && m_lineIndex < 289) {
ASSERT_FALSE(mapState.isPeak(false)) << m_lineIndex << " " << mapValue;
}
mapState.add(mapValue);
}
ASSERT_TRUE(m_lineIndex > 10);
}

View File

@ -3,73 +3,6 @@
#include "pch.h"
#include "trigger_central.h"
static int getZigZag(int index) {
index = index % 1000;
if (index < 400) {
// going up from 0 to 400
return index;
}
if (index < 500) {
// going down from 400 to 300
return 800 - index;
}
if (index < 600) {
// going up from 300 to 400
return index - 200;
}
// going down from 400 to 0
return 1000 - index;
}
TEST(trigger, map_cam) {
EngineTestHelper eth(TEST_ENGINE);
engineConfiguration->mapCamAveragingLength = 8;
MapState state;
int i = 0;
for (;i<403;i++) {
state.add(getZigZag(i));
if (state.mapBuffer.getCount() > engineConfiguration->mapCamAveragingLength) {
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
}
}
state.add(getZigZag(i));
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
i++;
state.add(getZigZag(i));
ASSERT_TRUE(state.isPeak(false)) << "high At " << i;
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
for (;i<504;i++) {
state.add(getZigZag(i));
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
}
state.add(getZigZag(i));
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
ASSERT_TRUE(state.isPeak(true)) << "low At " << i;
i++;
for (;i<604;i++) {
state.add(getZigZag(i));
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
}
state.add(getZigZag(i));
ASSERT_TRUE(state.isPeak(false)) << "high At " << i;
ASSERT_TRUE(state.isPeak(false)) << "low At " << i;
}
TEST(trigger, map_cam_by_magic_point) {
EngineTestHelper eth(TEST_CRANK_ENGINE);