Honda K cam wheels #3405
This commit is contained in:
parent
fbd37ae0e7
commit
a6a969390f
|
@ -26,14 +26,6 @@
|
||||||
#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'
|
||||||
|
@ -48,7 +40,11 @@
|
||||||
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?*/ \
|
||||||
doFixAngle(angle, engineCycleDurationLocalCopy); \
|
while (angle < 0) \
|
||||||
|
angle += engineCycleDurationLocalCopy; \
|
||||||
|
/* todo: would 'if' work as good as 'while'? */ \
|
||||||
|
while (angle >= engineCycleDurationLocalCopy) \
|
||||||
|
angle -= engineCycleDurationLocalCopy; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -157,13 +157,13 @@ static angle_t adjustCrankPhase(int camIndex DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static angle_t wrapVvt(angle_t vvtPosition) {
|
static angle_t wrapVvt(angle_t vvtPosition, int period) {
|
||||||
// Wrap VVT position in to the range [-360, 360)
|
// Wrap VVT position in to the range [-360, 360)
|
||||||
while (vvtPosition < -360) {
|
while (vvtPosition < -period / 2) {
|
||||||
vvtPosition += 720;
|
vvtPosition += period;
|
||||||
}
|
}
|
||||||
while (vvtPosition >= 360) {
|
while (vvtPosition >= period / 2) {
|
||||||
vvtPosition -= 720;
|
vvtPosition -= period;
|
||||||
}
|
}
|
||||||
return vvtPosition;
|
return vvtPosition;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
|
||||||
|
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
// todo: only assign initial position of not first cam once cam was synchronized
|
// todo: only assign initial position of not first cam once cam was synchronized
|
||||||
tc->vvtPosition[bankIndex][camIndex] = wrapVvt(vvtPosition);
|
tc->vvtPosition[bankIndex][camIndex] = wrapVvt(vvtPosition, 720);
|
||||||
// at the moment we use only primary VVT to sync crank phase
|
// at the moment we use only primary VVT to sync crank phase
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -341,12 +341,13 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL
|
||||||
// vvtPosition was calculated against wrong crank zero position. Now that we have adjusted crank position we
|
// vvtPosition was calculated against wrong crank zero position. Now that we have adjusted crank position we
|
||||||
// shall adjust vvt position as well
|
// shall adjust vvt position as well
|
||||||
vvtPosition -= crankOffset;
|
vvtPosition -= crankOffset;
|
||||||
vvtPosition = wrapVvt(vvtPosition);
|
vvtPosition = wrapVvt(vvtPosition, 720);
|
||||||
|
|
||||||
// this could be just an 'if' but let's have it expandable for future use :)
|
// this could be just an 'if' but let's have it expandable for future use :)
|
||||||
switch(engineConfiguration->vvtMode[camIndex]) {
|
switch(engineConfiguration->vvtMode[camIndex]) {
|
||||||
case VVT_HONDA_K:
|
case VVT_HONDA_K:
|
||||||
doFixAngle(vvtPosition, 180);
|
// honda K has four tooth in VVT intake trigger, so we just wrap each of those to 720 / 4
|
||||||
|
vvtPosition = wrapVvt(vvtPosition, 180);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// else, do nothing
|
// else, do nothing
|
||||||
|
|
Loading…
Reference in New Issue