Honda K cam wheels #3405

This commit is contained in:
Andrey 2021-10-28 11:40:31 -04:00
parent b82ff0d823
commit de350131e6
2 changed files with 21 additions and 8 deletions

View File

@ -26,6 +26,14 @@
#define assertAngleRange(angle, msg, code) {}
#endif
#define doFixAngle(angle, limit) \
while (angle < 0) \
angle += limit; \
/* todo: would 'if' work as good as 'while'? */ \
while (angle >= limit) \
angle -= limit;
/**
* @brief Shifts angle into the [0..720) range for four stroke and [0..360) for two stroke
* I guess this implementation would be faster than 'angle % engineCycle'
@ -40,11 +48,7 @@
float engineCycleDurationLocalCopy = engineCycle; \
/* todo: split this method into 'fixAngleUp' and 'fixAngleDown'*/ \
/* as a performance optimization?*/ \
while (angle < 0) \
angle += engineCycleDurationLocalCopy; \
/* todo: would 'if' work as good as 'while'? */ \
while (angle >= engineCycleDurationLocalCopy) \
angle -= engineCycleDurationLocalCopy; \
doFixAngle(angle, engineCycleDurationLocalCopy); \
}
/**

View File

@ -302,8 +302,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
switch(engineConfiguration->vvtMode[camIndex]) {
case VVT_2JZ:
// we do not know if we are in sync or out of sync, so we have to be looking for both possibilities
if ((currentPosition < engineConfiguration->fsio_setting[14] || currentPosition > engineConfiguration->fsio_setting[15]) &&
(currentPosition < engineConfiguration->fsio_setting[14] + 360 || currentPosition > engineConfiguration->fsio_setting[15] + 360)) {
if ((currentPosition < engineConfiguration->fsio_setting[4] || currentPosition > engineConfiguration->fsio_setting[5]) &&
(currentPosition < engineConfiguration->fsio_setting[4] + 360 || currentPosition > engineConfiguration->fsio_setting[5] + 360)) {
// outside of the expected range
return;
}
@ -323,7 +323,6 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
#endif /* EFI_TUNER_STUDIO */
}
}
case VVT_HONDA_K:
default:
// else, do nothing
break;
@ -345,6 +344,16 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
// shall adjust vvt position as well
vvtPosition -= crankOffset;
vvtPosition = wrapVvt(vvtPosition);
switch(engineConfiguration->vvtMode[camIndex]) {
case VVT_HONDA_K:
doFixAngle(vvtPosition, 180);
break;
default:
// else, do nothing
break;
}
if (absF(vvtPosition - tdcPosition()) < 7) {
/**
* we prefer not to have VVT sync right at trigger sync so that we do not have phase detection error if things happen a bit in