auto-sync

This commit is contained in:
rusEfi 2016-08-23 23:03:01 -04:00
parent 06d17e7ade
commit 55b46a2305
8 changed files with 66 additions and 18 deletions

View File

@ -68,7 +68,10 @@ void setTestVVTEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED;
engineConfiguration->camInput = GPIOA_5;
// set_global_trigger_offset_angle
engineConfiguration->globalTriggerAngleOffset = 545;
// set_global_trigger_offset_angle 0
engineConfiguration->globalTriggerAngleOffset = 0;
engineConfiguration->vvtMode = VVT_SECOND_HALF;
engineConfiguration->debugMode = VVT;
}

View File

@ -108,6 +108,9 @@ void setToyota_2jz_vics(DECLARE_ENGINE_PARAMETER_F) {
boardConfiguration->triggerInputPins[0] = GPIOA_5; // crank sensor
boardConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // cam sensor will he handled by custom vtti code
engineConfiguration->camInput = GPIOC_6;
engineConfiguration->vvtMode = VVT_2GZ;
// set_global_trigger_offset_angle 155
engineConfiguration->globalTriggerAngleOffset = 155; // todo

View File

@ -30,7 +30,7 @@
#include "adc_inputs.h"
#if EFI_WAVE_ANALYZER || defined(__DOXYGEN__)
#include "wave_analyzer.h"
#endif
#endif /* EFI_WAVE_ANALYZER */
// see RUS_EFI_VERSION_TAG in console source code
#define RUS_EFI_VERSION_TAG "rusEfiVersion"
@ -336,17 +336,18 @@ static void printInfo(systime_t nowSeconds) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
printOutPin(CRANK1, boardConfiguration->triggerInputPins[0]);
printOutPin(CRANK2, boardConfiguration->triggerInputPins[1]);
printOutPin(VVT_NAME, engineConfiguration->camInput);
#if EFI_WAVE_ANALYZER || defined(__DOXYGEN__)
printOutPin(WA_CHANNEL_1, boardConfiguration->logicAnalyzerPins[0]);
printOutPin(WA_CHANNEL_2, boardConfiguration->logicAnalyzerPins[1]);
#endif
#endif /* EFI_WAVE_ANALYZER */
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
printOutPin(enginePins.coils[i].name, boardConfiguration->ignitionPins[i]);
printOutPin(enginePins.injectors[i].name, boardConfiguration->injectionPins[i]);
}
#endif
#endif /* EFI_PROD_CODE */
}

View File

@ -24,6 +24,8 @@
#define CRANK2 "t2"
#define CRANK3 "t3"
#define VVT_NAME "VVT"
#define NOISY_RPM -1
#define UNREALISTIC_RPM 30000

View File

@ -25,7 +25,9 @@
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#include "rfiutil.h"
#include "pin_repository.h"
#endif
#include "tunerstudio.h"
extern TunerStudioOutputChannels tsOutputChannels;
#endif /* EFI_PROD_CODE */
#if EFI_ENGINE_SNIFFER || defined(__DOXYGEN__)
#include "engine_sniffer.h"
@ -75,8 +77,18 @@ uint32_t triggerMaxDuration = 0;
extern bool isInsideTriggerHandler;
void hwHandleVvtCamSignal(trigger_value_e front) {
if (ENGINE(isEngineChartEnabled)) {
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
addEngineSniffferEvent(VVT_NAME, front == TV_RISE ? WC_UP : WC_DOWN);
}
efitick_t offsetNt = getTimeNowNt() - engine->triggerCentral.timeAtVirtualZeroNt;
if (boardConfiguration->vvtCamSensorUseRise && front == TV_FALL) {
return;
}
TriggerCentral *tc = &engine->triggerCentral;
efitick_t offsetNt = getTimeNowNt() - tc->timeAtVirtualZeroNt;
angle_t vvtPosition = NT2US(offsetNt) / engine->rpmCalculator.oneDegreeUs;
@ -84,12 +96,35 @@ void hwHandleVvtCamSignal(trigger_value_e front) {
vvtPosition -= tdcPosition();
fixAngle(vvtPosition);
engine->triggerCentral.vvtPosition = vvtPosition;
tc->vvtPosition = vvtPosition;
if (engineConfiguration->vvtMode == VVT_FIRST_HALF) {
bool isEven = tc->triggerState.isEvenRevolution();
if (!isEven) {
/**
* we are here if we've detected the cam sensor within the wrong crank phase
* let's increase the trigger event counter, that would adjust the state of
* virtual crank-based trigger
*/
tc->triggerState.intTotalEventCounter();
#if EFI_PROD_CODE || defined(__DOXYGEN__)
if (engineConfiguration->debugMode == VVT) {
tsOutputChannels.debugIntField1++;
}
#endif /* EFI_PROD_CODE */
}
} else if (engineConfiguration->vvtMode == VVT_SECOND_HALF) {
bool isEven = tc->triggerState.isEvenRevolution();
if (isEven) {
// see above comment
#if EFI_PROD_CODE || defined(__DOXYGEN__)
tc->triggerState.intTotalEventCounter();
if (engineConfiguration->debugMode == VVT) {
tsOutputChannels.debugIntField1++;
}
#endif /* EFI_PROD_CODE */
}
if (ENGINE(isEngineChartEnabled)) {
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
addEngineSniffferEvent("VVT", front == TV_RISE ? WC_UP : WC_DOWN);
}
}
@ -186,7 +221,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR
// That's easy - trigger cycle matches engine cycle
triggerIndexForListeners = triggerState.getCurrentIndex();
} else {
bool isEven = triggerState.getTotalRevolutionCounter() & 1;
bool isEven = triggerState.isEvenRevolution();
triggerIndexForListeners = triggerState.getCurrentIndex() + (isEven ? 0 : TRIGGER_SHAPE(size));
}

View File

@ -303,5 +303,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array
return 20160822;
return 20160823;
}

View File

@ -42,7 +42,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Aug 23 21:52:05 EDT 2016
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Aug 23 22:54:36 EDT 2016
pageSize = 16376
page = 1
@ -866,6 +866,7 @@ fileVersion = { 20160702 }
warningCounter = scalar,U32, 236, "count", 1, 0
lastErrorCode = scalar,U32, 240, "error", 1, 0
internalMcuTemperature = scalar,F32, 244, "C", 1, 0
vvtPosition = scalar,F32, 248, "deg", 1, 0
egoCorrection = { 100 }
time = { timeNow }
@ -1158,6 +1159,7 @@ fileVersion = { 20160702 }
warningCounterGauge = warningCounter, "warn", "", 0, 100, 0, 0, 100, 100, 0, 0
lastErrorCodeGauge = lastErrorCode, "error", "", 0, 100, 0, 0, 100, 100, 0, 0
internalMcuTemperatureGauge = internalMcuTemperature, "internal temperature", "C", 0, 100, 0, 0, 100, 100, 0, 0
vvtPositionGauge = vvtPosition, "VVT position", "deg", 0, 100, 0, 0, 720, 720, 0, 0
[FrontPage]
@ -1457,8 +1459,8 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01"
field = "Primary input channel", triggerInputPins1
field = "Secondary channel", triggerInputPins2
field = "CAM input", camInput
field = "VVT mode", vvtMode
field = "VVT use rise front", vvtCamSensorUseRise
field = "VVT mode", vvtMode, {trigger_type != 80}
field = "VVT use rise front", vvtCamSensorUseRise, {trigger_type != 80}
field = "Trigger error LED", triggerErrorPin
field = "Trigger error LED mode", triggerErrorPinMode
dialog = triggerConfiguration

View File

@ -848,6 +848,7 @@ fileVersion = { 20160702 }
warningCounter = scalar,U32, 236, "count", 1, 0
lastErrorCode = scalar,U32, 240, "error", 1, 0
internalMcuTemperature = scalar,F32, 244, "C", 1, 0
vvtPosition = scalar,F32, 248, "deg", 1, 0
egoCorrection = { 100 }
time = { timeNow }
@ -1140,6 +1141,7 @@ fileVersion = { 20160702 }
warningCounterGauge = warningCounter, "warn", "", 0, 100, 0, 0, 100, 100, 0, 0
lastErrorCodeGauge = lastErrorCode, "error", "", 0, 100, 0, 0, 100, 100, 0, 0
internalMcuTemperatureGauge = internalMcuTemperature, "internal temperature", "C", 0, 100, 0, 0, 100, 100, 0, 0
vvtPositionGauge = vvtPosition, "VVT position", "deg", 0, 100, 0, 0, 720, 720, 0, 0
[FrontPage]
@ -1439,8 +1441,8 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01"
field = "Primary input channel", triggerInputPins1
field = "Secondary channel", triggerInputPins2
field = "CAM input", camInput
field = "VVT mode", vvtMode
field = "VVT use rise front", vvtCamSensorUseRise
field = "VVT mode", vvtMode, {trigger_type != 80}
field = "VVT use rise front", vvtCamSensorUseRise, {trigger_type != 80}
field = "Trigger error LED", triggerErrorPin
field = "Trigger error LED mode", triggerErrorPinMode
dialog = triggerConfiguration