Remove value copy from controller into outputChannels #4095

This commit is contained in:
rusefillc 2022-05-08 08:50:27 -04:00
parent 04da97c1e3
commit bd9639b91d
8 changed files with 18 additions and 25 deletions

View File

@ -310,9 +310,6 @@ uint8_t unusedWat
uint8_t autoscale boostControllerOutput;@@GAUGE_NAME_BOOST_OUTPUT@@;"%", 0.5, 0, 0, 100, 1
uint8_t autoscale boostControllerOpenLoopPart;@@GAUGE_NAME_BOOST_OPEN_LOOP@@;"%", 0.5, 0, 0, 100, 1
float autoscale triggerSyncGapRatio;@@GAUGE_NAME_TRG_GAP@@;"", 1, 0, -10000, 10000, 3
uint16_t autoscale fallbackMap;;"kPa", 0.1, 0, 0, 1000, 1
int8_t autoscale boostControllerClosedLoopPart;@@GAUGE_NAME_BOOST_CLOSED_LOOP@@;"%", 0.5, 0, -50, 50, 1

View File

@ -115,7 +115,7 @@ static angle_t syncAndReport(TriggerCentral *tc, int divider, int remainder) {
angle_t offset = tc->triggerState.syncSymmetricalCrank(divider, remainder, engineCycle);
if (offset > 0) {
engine->outputChannels.vvtSyncCounter++;
tc->triggerState.vvtSyncCounter++;
}
return offset;
}
@ -292,8 +292,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
engine->vvtTriggerConfiguration[camIndex],
front == TV_RISE ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING, nowNt);
// yes we log data from all VVT channels into same fields for now
engine->outputChannels.vvtSyncGapRatio = vvtState->currentGap;
engine->outputChannels.vvtStateIndex = vvtState->currentCycle.current_index;
tc->triggerState.vvtSyncGapRatio = vvtState->triggerSyncGapRatio;
tc->triggerState.vvtStateIndex = vvtState->currentCycle.current_index;
}
tc->vvtCamCounter++;
@ -314,9 +314,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
tc->currentVVTEventPosition[bankIndex][camIndex] = currentPosition;
#endif // EFI_UNIT_TEST
#if EFI_TUNER_STUDIO
engine->outputChannels.vvtCurrentPosition = currentPosition;
#endif /* EFI_TUNER_STUDIO */
tc->triggerState.vvtCurrentPosition = currentPosition;
if (isVvtWithRealDecoder && tc->vvtState[bankIndex][camIndex].currentCycle.current_index != 0) {
// this is not sync tooth - exiting
@ -337,9 +335,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) {
break;
}
#if EFI_TUNER_STUDIO
engine->outputChannels.vvtCounter++;
#endif /* EFI_TUNER_STUDIO */
tc->triggerState.vvtCounter++;
auto vvtPosition = engineConfiguration->vvtOffsets[bankIndex * CAMS_PER_BANK + camIndex] - currentPosition;
@ -627,10 +623,8 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
engine->primaryTriggerConfiguration,
signal, timestamp);
#if EFI_TUNER_STUDIO
engine->outputChannels.triggerSyncGapRatio = triggerState.currentGap;
engine->outputChannels.triggerStateIndex = triggerState.currentCycle.current_index;
#endif /* EFI_TUNER_STUDIO */
triggerState.triggerStateIndex = triggerState.currentCycle.current_index;
/**

View File

@ -561,7 +561,7 @@ void TriggerState::decodeTriggerEvent(
bool wasSynchronized = getShaftSynchronized();
if (triggerShape.isSynchronizationNeeded) {
currentGap = (float)toothDurations[0] / toothDurations[1];
triggerSyncGapRatio = (float)toothDurations[0] / toothDurations[1];
isSynchronizationPoint = isSyncPoint(triggerShape, triggerConfiguration.TriggerType);
if (isSynchronizationPoint) {
@ -576,7 +576,7 @@ void TriggerState::decodeTriggerEvent(
bool silentTriggerError = triggerShape.getSize() > 40 && engineConfiguration->silentTriggerError;
#if EFI_UNIT_TEST
actualSynchGap = currentGap;
actualSynchGap = triggerSyncGapRatio;
#endif /* EFI_UNIT_TEST */
#if EFI_PROD_CODE || EFI_SIMULATOR
@ -718,7 +718,7 @@ bool TriggerState::isSyncPoint(const TriggerWaveform& triggerShape, trigger_type
if (triggerType == TT_MIATA_VVT) {
auto secondGap = (float)toothDurations[1] / toothDurations[2];
bool currentGapOk = isInRange(triggerShape.syncronizationRatioFrom[0], currentGap, triggerShape.syncronizationRatioTo[0]);
bool currentGapOk = isInRange(triggerShape.syncronizationRatioFrom[0], triggerSyncGapRatio, triggerShape.syncronizationRatioTo[0]);
bool secondGapOk = isInRange(triggerShape.syncronizationRatioFrom[1], secondGap, triggerShape.syncronizationRatioTo[1]);
// One or both teeth was impossible range, this is not the sync point
@ -728,7 +728,7 @@ bool TriggerState::isSyncPoint(const TriggerWaveform& triggerShape, trigger_type
// If both teeth are in the range of possibility, return whether this gap is
// shorter than the last or not. If it is, this is the sync point.
return currentGap < secondGap;
return triggerSyncGapRatio < secondGap;
}
for (int i = 0; i < triggerShape.gapTrackingLength; i++) {

View File

@ -174,6 +174,7 @@ private:
bool isFirstEvent;
bool m_hasSynchronizedSymmetrical = false;
Timer synchronizedSymmetrical;
};
// we only need 90 degrees of events so /4 or maybe even /8 should work?

View File

@ -1,8 +1,9 @@
struct_no_prefix trigger_state_s
float currentGap;
uint32_t totalRevolutionCounter;Crank revolution counter
float autoscale vvtSyncGapRatio;;"", 1, 0, -10000, 10000, 3
float autoscale vvtCurrentPosition;;"", 1, 0, -10000, 10000, 3
float autoscale triggerSyncGapRatio;@@GAUGE_NAME_TRG_GAP@@;"", 1, 0, -10000, 10000, 3
float triggerActualSyncGapRatio;
uint8_t triggerStateIndex
uint8_t vvtCounter

View File

@ -8,7 +8,7 @@ struct trigger_state_s {
/**
* offset 0
*/
float currentGap = (float)0;
float triggerSyncGapRatio = (float)0;
/**
* Crank revolution counter
* offset 4

View File

@ -25,7 +25,7 @@ TEST(trigger, map_cam_by_magic_point) {
ASSERT_EQ(150, Sensor::getOrZero(SensorType::Rpm)) << "RPM";
ASSERT_EQ(1, engine->triggerCentral.mapVvt_map_peak);
ASSERT_EQ(0, engine->outputChannels.vvtSyncCounter);
ASSERT_EQ(0, engine->triggerCentral.triggerState.vvtSyncCounter);
// Nothing should have been scheduled yet
ASSERT_EQ(1, engine->executor.size());
@ -36,7 +36,7 @@ TEST(trigger, map_cam_by_magic_point) {
eth.smartFireTriggerEvents2(/*count*/4, /*delayMs*/200);
ASSERT_EQ(2, engine->triggerCentral.mapVvt_map_peak);
ASSERT_EQ(1, engine->outputChannels.vvtSyncCounter);
ASSERT_EQ(1, engine->triggerCentral.triggerState.vvtSyncCounter);
ASSERT_EQ(10, engine->triggerCentral.mapVvt_MAP_AT_CYCLE_COUNT);
ASSERT_EQ(ClearReason::None, eth.engine.limpManager.allowIgnition().reason);

View File

@ -24,7 +24,7 @@ TEST(realCrankingNB2, normalCranking) {
// Check the number of times VVT information was used to adjust crank phase
// This should happen exactly once: once we sync, we shouldn't lose it.
EXPECT_EQ(engine->outputChannels.vvtSyncCounter, 1);
EXPECT_EQ(engine->triggerCentral.triggerState.vvtSyncCounter, 1);
ASSERT_EQ(942, round(Sensor::getOrZero(SensorType::Rpm)));