Honda K cam wheels #3405

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

View File

@ -26,6 +26,14 @@
#define assertAngleRange(angle, msg, code) {} #define assertAngleRange(angle, msg, code) {}
#endif #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 * @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' * I guess this implementation would be faster than 'angle % engineCycle'
@ -40,11 +48,7 @@
float engineCycleDurationLocalCopy = engineCycle; \ float engineCycleDurationLocalCopy = engineCycle; \
/* todo: split this method into 'fixAngleUp' and 'fixAngleDown'*/ \ /* todo: split this method into 'fixAngleUp' and 'fixAngleDown'*/ \
/* as a performance optimization?*/ \ /* as a performance optimization?*/ \
while (angle < 0) \ doFixAngle(angle, engineCycleDurationLocalCopy); \
angle += engineCycleDurationLocalCopy; \
/* todo: would 'if' work as good as 'while'? */ \
while (angle >= engineCycleDurationLocalCopy) \
angle -= engineCycleDurationLocalCopy; \
} }
/** /**

View File

@ -302,8 +302,8 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
switch(engineConfiguration->vvtMode[camIndex]) { switch(engineConfiguration->vvtMode[camIndex]) {
case VVT_2JZ: 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 // 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]) && if ((currentPosition < engineConfiguration->fsio_setting[4] || currentPosition > engineConfiguration->fsio_setting[5]) &&
(currentPosition < engineConfiguration->fsio_setting[14] + 360 || currentPosition > engineConfiguration->fsio_setting[15] + 360)) { (currentPosition < engineConfiguration->fsio_setting[4] + 360 || currentPosition > engineConfiguration->fsio_setting[5] + 360)) {
// outside of the expected range // outside of the expected range
return; return;
} }
@ -323,7 +323,6 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
#endif /* EFI_TUNER_STUDIO */ #endif /* EFI_TUNER_STUDIO */
} }
} }
case VVT_HONDA_K:
default: default:
// else, do nothing // else, do nothing
break; break;
@ -345,6 +344,16 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
// shall adjust vvt position as well // shall adjust vvt position as well
vvtPosition -= crankOffset; vvtPosition -= crankOffset;
vvtPosition = wrapVvt(vvtPosition); 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) { 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 * 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