Skip to content

Commit

Permalink
Mitsubishi 3A92 Support - 3 cylinder #4011
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Mar 19, 2022
1 parent c49e5ab commit d72c604
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
27 changes: 27 additions & 0 deletions firmware/controllers/trigger/decoders/trigger_mitsubishi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "trigger_mitsubishi.h"
#include "trigger_universal.h"

void configureFordAspireTriggerWaveform(TriggerWaveform * s) {
s->initialize(FOUR_STROKE_CAM_SENSOR);
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 10 additions & 4 deletions firmware/controllers/trigger/decoders/trigger_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ 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));
}
}
}

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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit d72c604

Please sign in to comment.