parent
73fb5a2ef8
commit
e72d57438a
|
@ -37,6 +37,10 @@ void contextSwitchHook() {}
|
||||||
#endif /* ENABLE_PERF_TRACE */
|
#endif /* ENABLE_PERF_TRACE */
|
||||||
|
|
||||||
#if EFI_ENABLE_MOCK_ADC
|
#if EFI_ENABLE_MOCK_ADC
|
||||||
|
/**
|
||||||
|
* in 2021 the api is Sensor::setMockValue
|
||||||
|
* todo: remove this mockAdcState https://github.com/rusefi/rusefi/issues/3672
|
||||||
|
*/
|
||||||
void setMockVoltage(int hwChannel, float voltage) {
|
void setMockVoltage(int hwChannel, float voltage) {
|
||||||
engine->engineState.mockAdcState.setMockVoltage(hwChannel, voltage);
|
engine->engineState.mockAdcState.setMockVoltage(hwChannel, voltage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
|
||||||
return vvtMode != VVT_INACTIVE
|
return vvtMode != VVT_INACTIVE
|
||||||
&& vvtMode != VVT_2JZ
|
&& vvtMode != VVT_2JZ
|
||||||
&& vvtMode != VVT_HONDA_K
|
&& vvtMode != VVT_HONDA_K
|
||||||
|
&& vvtMode != VVT_MAP_V_TWIN_ANOTHER &&
|
||||||
&& vvtMode != VVT_SECOND_HALF
|
&& vvtMode != VVT_SECOND_HALF
|
||||||
&& vvtMode != VVT_FIRST_HALF;
|
&& vvtMode != VVT_FIRST_HALF;
|
||||||
}
|
}
|
||||||
|
@ -143,6 +144,7 @@ static angle_t adjustCrankPhase(int camIndex) {
|
||||||
|
|
||||||
switch (engineConfiguration->vvtMode[camIndex]) {
|
switch (engineConfiguration->vvtMode[camIndex]) {
|
||||||
case VVT_FIRST_HALF:
|
case VVT_FIRST_HALF:
|
||||||
|
case VVT_MAP_V_TWIN_ANOTHER:
|
||||||
return syncAndReport(tc, getCrankDivider(operationMode), 1);
|
return syncAndReport(tc, getCrankDivider(operationMode), 1);
|
||||||
case VVT_SECOND_HALF:
|
case VVT_SECOND_HALF:
|
||||||
return syncAndReport(tc, getCrankDivider(operationMode), 0);
|
return syncAndReport(tc, getCrankDivider(operationMode), 0);
|
||||||
|
@ -662,11 +664,43 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
||||||
|
|
||||||
mainTriggerCallback(triggerIndexForListeners, timestamp);
|
mainTriggerCallback(triggerIndexForListeners, timestamp);
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
|
||||||
auto toothAngle = engine->triggerCentral.triggerFormDetails.eventAngles[triggerIndexForListeners] - tdcPosition();
|
auto toothAngle = engine->triggerCentral.triggerFormDetails.eventAngles[triggerIndexForListeners] - tdcPosition();
|
||||||
wrapAngle(toothAngle, "currentEnginePhase", CUSTOM_ERR_6555);
|
wrapAngle(toothAngle, "currentEnginePhase", CUSTOM_ERR_6555);
|
||||||
|
#if EFI_TUNER_STUDIO
|
||||||
tsOutputChannels.currentEnginePhase = toothAngle;
|
tsOutputChannels.currentEnginePhase = toothAngle;
|
||||||
#endif
|
#endif // EFI_TUNER_STUDIO
|
||||||
|
|
||||||
|
if (engineConfiguration->vvtMode[0] == VVT_MAP_V_TWIN_ANOTHER) {
|
||||||
|
|
||||||
|
if (mapCamPrevToothAngle < engineConfiguration->mapCamDetectionAnglePosition && toothAngle > engineConfiguration->mapCamDetectionAnglePosition) {
|
||||||
|
// we are somewhere close to 'mapCamDetectionAnglePosition'
|
||||||
|
|
||||||
|
float map = Sensor::getOrZero(SensorType::Map);
|
||||||
|
|
||||||
|
if (map > mapCamPrevCycleValue) {
|
||||||
|
mapCamCounter++;
|
||||||
|
|
||||||
|
efitick_t stamp = getTimeNowNt();
|
||||||
|
hwHandleVvtCamSignal(TV_RISE, stamp, /*index*/0);
|
||||||
|
hwHandleVvtCamSignal(TV_FALL, stamp, /*index*/0);
|
||||||
|
}
|
||||||
|
#if EFI_TUNER_STUDIO
|
||||||
|
tsOutputChannels.TEMPLOG_MAP_INSTANT_AVERAGE = map;
|
||||||
|
tsOutputChannels.TEMPLOG_map_peak = mapCamCounter;
|
||||||
|
tsOutputChannels.TEMPLOG_MAP_AT_DIFF = map - mapCamPrevCycleValue;
|
||||||
|
#endif // EFI_TUNER_STUDIO
|
||||||
|
|
||||||
|
mapCamPrevCycleValue = map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mapCamPrevToothAngle = toothAngle;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,20 @@ public:
|
||||||
void resetCounters();
|
void resetCounters();
|
||||||
void validateCamVvtCounters();
|
void validateCamVvtCounters();
|
||||||
|
|
||||||
|
LocalVersionHolder triggerVersion;
|
||||||
|
|
||||||
MapState mapState;
|
MapState mapState;
|
||||||
|
|
||||||
|
|
||||||
|
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
|
* true if a recent configuration change has changed any of the trigger settings which
|
||||||
* we have not adjusted for yet
|
* we have not adjusted for yet
|
||||||
*/
|
*/
|
||||||
bool triggerConfigChanged = false;
|
bool triggerConfigChanged = false;
|
||||||
LocalVersionHolder triggerVersion;
|
|
||||||
|
|
||||||
bool checkIfTriggerConfigChanged();
|
bool checkIfTriggerConfigChanged();
|
||||||
bool isTriggerConfigChanged();
|
bool isTriggerConfigChanged();
|
||||||
|
|
|
@ -69,3 +69,26 @@ TEST(trigger, map_cam) {
|
||||||
ASSERT_TRUE(state.isPeak(false)) << "high At " << i;
|
ASSERT_TRUE(state.isPeak(false)) << "high At " << i;
|
||||||
ASSERT_TRUE(state.isPeak(false)) << "low At " << i;
|
ASSERT_TRUE(state.isPeak(false)) << "low At " << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(trigger, map_cam_by_magic_point) {
|
||||||
|
|
||||||
|
EngineTestHelper eth(TEST_ENGINE);
|
||||||
|
|
||||||
|
engineConfiguration->camInputs[0] = GPIOA_0;
|
||||||
|
engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN_ANOTHER;
|
||||||
|
|
||||||
|
Sensor::setMockValue(SensorType::Map, 100);
|
||||||
|
|
||||||
|
engineConfiguration->mapCamDetectionAnglePosition = 90;
|
||||||
|
|
||||||
|
eth.smartFireTriggerEvents2(/*count*/10, /*delayMs*/200);
|
||||||
|
ASSERT_EQ( 150, GET_RPM()) << "RPM";
|
||||||
|
ASSERT_EQ(1, engine->triggerCentral.mapCamCounter);
|
||||||
|
|
||||||
|
|
||||||
|
Sensor::setMockValue(SensorType::Map, 120);
|
||||||
|
eth.smartFireTriggerEvents2(/*count*/2, /*delayMs*/200);
|
||||||
|
ASSERT_EQ(2, engine->triggerCentral.mapCamCounter);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue