Mitsubishi 3A92 Support - 3 cylinder #4011

This commit is contained in:
Andrey 2022-03-19 17:51:47 -04:00
parent c49e5abafe
commit d72c60452a
2 changed files with 37 additions and 4 deletions

View File

@ -6,6 +6,7 @@
*/
#include "trigger_mitsubishi.h"
#include "trigger_universal.h"
void configureFordAspireTriggerWaveform(TriggerWaveform * s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
@ -52,7 +53,33 @@ void initializeMitsubishi4g18(TriggerWaveform *s) {
}
void initialize36_2_1_1(TriggerWaveform *s) {
s->initialize(FOUR_STROKE_CRANK_SENSOR);
int totalTeethCount = 36;
float engineCycle = FOUR_STROKE_ENGINE_CYCLE;
float toothWidth = 0.5;
float oneTooth = 720 / totalTeethCount;
float offset = (36 - 11) * oneTooth;
addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle,
NO_LEFT_FILTER, offset + 11 * oneTooth + 1);
offset += (11 + 1) * oneTooth;
// addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle,
// NO_LEFT_FILTER, offset + 11 * oneTooth);
offset += (11 + 1) * oneTooth;
// addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, 0, toothWidth, /*offset*/offset, engineCycle,
// NO_LEFT_FILTER, offset + 10 * oneTooth);
s->shapeWithoutTdc = true;
s->isSynchronizationNeeded = false;
}
void initializeVvt3A92(TriggerWaveform *s) {

View File

@ -173,7 +173,7 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig
if (!useOnlyRisingEdgeForTrigger) {
for (size_t i = 0; i < efi::size(expectedEventCount); i++) {
if (getExpectedEventCount(i) % 2 != 0) {
firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even %d %d", i, getExpectedEventCount(i));
firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even number of events index=%d count=%d", i, getExpectedEventCount(i));
}
}
}
@ -181,7 +181,7 @@ void TriggerWaveform::calculateExpectedEventCounts(bool useOnlyRisingEdgeForTrig
bool isSingleToothOnPrimaryChannel = useOnlyRisingEdgeForTrigger ? getExpectedEventCount(0) == 1 : getExpectedEventCount(0) == 2;
// todo: next step would be to set 'isSynchronizationNeeded' automatically based on the logic we have here
if (!shapeWithoutTdc && isSingleToothOnPrimaryChannel != !isSynchronizationNeeded) {
firmwareError(ERROR_TRIGGER_DRAMA, "trigger sync constraint violation");
firmwareError(ERROR_TRIGGER_DRAMA, "shapeWithoutTdc isSynchronizationNeeded isSingleToothOnPrimaryChannel constraint violation");
}
if (isSingleToothOnPrimaryChannel) {
useOnlyPrimaryForSync = true;
@ -237,7 +237,10 @@ void TriggerWaveform::addEvent(angle_t angle, trigger_wheel_e const channelIndex
expectedEventCount[channelIndex]++;
}
efiAssertVoid(CUSTOM_ERR_6599, angle > 0 && angle <= 1, "angle should be positive not above 1");
if (angle <= 0 || angle > 1) {
firmwareError(CUSTOM_ERR_6599, "angle should be positive not above 1: index=%d angle %f", channelIndex, angle);
return;
}
if (wave.phaseCount > 0) {
if (angle <= previousAngle) {
warning(CUSTOM_ERR_TRG_ANGLE_ORDER, "invalid angle order %s %s: new=%.2f/%f and prev=%.2f/%f, size=%d",
@ -599,8 +602,11 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat
setToothedWheelConfiguration(this, 3, 0, ambiguousOperationMode);
break;
case TT_36_2_1:
case TT_36_2_1_1:
initialize36_2_1_1(this);
break;
case TT_36_2_1:
case TT_TOOTHED_WHEEL_32_2:
setToothedWheelConfiguration(this, 32, 2, ambiguousOperationMode);
// todo: add this second/third into 'setToothedWheelConfiguration' as long as we have enough tooth?