mirror of https://github.com/rusefi/rusefi-1.git
trigger and VVT duty cycle integration into limp manager #2523
This commit is contained in:
parent
22e621c301
commit
e02f09495b
|
@ -90,6 +90,9 @@ void TriggerState::setTriggerErrorState() {
|
||||||
void TriggerState::resetCurrentCycleState() {
|
void TriggerState::resetCurrentCycleState() {
|
||||||
memset(currentCycle.eventCount, 0, sizeof(currentCycle.eventCount));
|
memset(currentCycle.eventCount, 0, sizeof(currentCycle.eventCount));
|
||||||
memset(currentCycle.timeOfPreviousEventNt, 0, sizeof(currentCycle.timeOfPreviousEventNt));
|
memset(currentCycle.timeOfPreviousEventNt, 0, sizeof(currentCycle.timeOfPreviousEventNt));
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
memcpy(currentCycle.totalTimeNtCopy, currentCycle.totalTimeNt, sizeof(currentCycle.totalTimeNt));
|
||||||
|
#endif
|
||||||
memset(currentCycle.totalTimeNt, 0, sizeof(currentCycle.totalTimeNt));
|
memset(currentCycle.totalTimeNt, 0, sizeof(currentCycle.totalTimeNt));
|
||||||
currentCycle.current_index = 0;
|
currentCycle.current_index = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,10 @@ typedef struct {
|
||||||
* Here we accumulate the amount of time this signal was ON within current trigger cycle
|
* Here we accumulate the amount of time this signal was ON within current trigger cycle
|
||||||
*/
|
*/
|
||||||
uint32_t totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM];
|
uint32_t totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
uint32_t totalTimeNtCopy[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||||
|
#endif // EFI_UNIT_TEST
|
||||||
} current_cycle_state_s;
|
} current_cycle_state_s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -152,14 +152,18 @@ TEST(sensors, testNB2CamInput) {
|
||||||
// this would be be first VVT signal - gap duration would be calculated against 'DEEP_IN_THE_PAST_SECONDS' initial value
|
// this would be be first VVT signal - gap duration would be calculated against 'DEEP_IN_THE_PAST_SECONDS' initial value
|
||||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
eth.moveTimeForwardUs(MS2US(20));
|
eth.moveTimeForwardUs(MS2US(10));
|
||||||
|
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
eth.moveTimeForwardUs(MS2US(10));
|
||||||
// this second important front would give us first real VVT gap duration
|
// this second important front would give us first real VVT gap duration
|
||||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition(0, 0));
|
ASSERT_FLOAT_EQ(0, engine->triggerCentral.getVVTPosition(0, 0));
|
||||||
ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
|
ASSERT_EQ(totalRevolutionCountBeforeVvtSync, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
|
||||||
|
|
||||||
eth.moveTimeForwardUs(MS2US(130));
|
eth.moveTimeForwardUs(MS2US(100));
|
||||||
|
hwHandleVvtCamSignal(TV_FALL, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
eth.moveTimeForwardUs(MS2US( 30));
|
||||||
// this third important front would give us first comparison between two real gaps
|
// this third important front would give us first comparison between two real gaps
|
||||||
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
hwHandleVvtCamSignal(TV_RISE, getTimeNowNt(), 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
|
@ -167,5 +171,9 @@ TEST(sensors, testNB2CamInput) {
|
||||||
// actually position based on VVT!
|
// actually position based on VVT!
|
||||||
ASSERT_EQ(totalRevolutionCountBeforeVvtSync + 2, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
|
ASSERT_EQ(totalRevolutionCountBeforeVvtSync + 2, engine->triggerCentral.triggerState.getTotalRevolutionCounter());
|
||||||
|
|
||||||
|
float dutyCycleNt = engine->triggerCentral.vvtState[0][0].currentCycle.totalTimeNtCopy[0];
|
||||||
|
ASSERT_FLOAT_EQ(6'000'000, dutyCycleNt);
|
||||||
|
ASSERT_FLOAT_EQ(0.059722222, engine->triggerCentral.vvtShape[0].expectedDutyCycle[0]);
|
||||||
|
|
||||||
ASSERT_EQ(26, waveChart.getSize());
|
ASSERT_EQ(26, waveChart.getSize());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue