auto-sync

This commit is contained in:
rusEfi 2015-05-31 09:09:19 -04:00
parent 71a656ec04
commit 332a5a612b
8 changed files with 35 additions and 16 deletions

View File

@ -129,6 +129,18 @@ bool_t Engine::stopPins() {
return result; return result;
} }
void Engine::printKnockState(void) {
scheduleMsg(&logger, "knock now=%s/ever=%s", boolToString(knockNow), boolToString(knockEver));
}
void Engine::setKnockNow(bool_t isKnockNow) {
this->knockNow = isKnockNow;
knockEver |= isKnockNow;
if (isKnockNow) {
timeOfLastKnockEvent = getTimeNowUs();
}
}
void Engine::watchdog() { void Engine::watchdog() {
#if EFI_ENGINE_CONTROL #if EFI_ENGINE_CONTROL
if (isRunningPwmTest) if (isRunningPwmTest)

View File

@ -204,6 +204,8 @@ public:
*/ */
bool_t knockEver; bool_t knockEver;
efitimeus_t timeOfLastKnockEvent;
/** /**
* are we running any kind of functional test? this affect * are we running any kind of functional test? this affect
* some areas * some areas
@ -277,6 +279,9 @@ public:
monitoring_timestamps_s m; monitoring_timestamps_s m;
void setKnockNow(bool_t isKnockNow);
void printKnockState(void);
private: private:
/** /**
* By the way: * By the way:

View File

@ -483,7 +483,7 @@ static void getKnockInfo(void) {
adc_channel_e hwChannel = engineConfiguration->externalKnockSenseAdc; adc_channel_e hwChannel = engineConfiguration->externalKnockSenseAdc;
scheduleMsg(&logger, "externalKnockSenseAdc on ADC", getPinNameByAdcChannel(hwChannel, pinNameBuffer)); scheduleMsg(&logger, "externalKnockSenseAdc on ADC", getPinNameByAdcChannel(hwChannel, pinNameBuffer));
scheduleMsg(&logger, "knock now=%s/ever=%s", boolToString(engine->knockNow), boolToString(engine->knockEver)); engine->printKnockState();
} }
void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) { void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) {

View File

@ -354,8 +354,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL
if (eventIndex == engineConfiguration->ignMathCalculateAtIndex) { if (eventIndex == engineConfiguration->ignMathCalculateAtIndex) {
if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) { if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) {
float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc); float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc);
engine->knockNow = externalKnockValue > 2.5; engine->setKnockNow(externalKnockValue > 2.5);
engine->knockEver |= engine->knockNow;
} }
engine->m.beforeIgnitionMath = GET_TIMESTAMP(); engine->m.beforeIgnitionMath = GET_TIMESTAMP();

View File

@ -58,12 +58,10 @@ static int settingUpdateCount = 0;
static int totalKnockEventsCount = 0; static int totalKnockEventsCount = 0;
static int currentPrescaler; static int currentPrescaler;
static efitimeus_t timeOfLastKnockEvent = 0;
/** /**
* Int/Hold pin is controlled from scheduler callbacks which are set according to current RPM * Int/Hold pin is controlled from scheduler callbacks which are set according to current RPM
* *
* The following state make sure that we only have SPI communication while not integrating and that we take * The following state makes sure that we only have SPI communication while not integrating and that we take
* a good ADC reading after integrating. * a good ADC reading after integrating.
* *
* Once integtation window is over, we wait for the 2nd ADC callback and then initiate SPI communication if needed * Once integtation window is over, we wait for the 2nd ADC callback and then initiate SPI communication if needed
@ -119,7 +117,10 @@ static void showHipInfo(void) {
} }
printSpiState(logger, boardConfiguration); printSpiState(logger, boardConfiguration);
scheduleMsg(logger, "bore=%fmm freq=%fkHz PaSDO=%d", engineConfiguration->cylinderBore, getBand(), scheduleMsg(logger, "enabled=%s state=%d bore=%fmm freq=%fkHz PaSDO=%d",
boolToString(boardConfiguration->isHip9011Enabled),
state,
engineConfiguration->cylinderBore, getBand(),
engineConfiguration->hip9011PrescalerAndSDO); engineConfiguration->hip9011PrescalerAndSDO);
scheduleMsg(logger, "band_index=%d gain %f/index=%d", currentBandIndex, boardConfiguration->hip9011Gain, currentGainIndex); scheduleMsg(logger, "band_index=%d gain %f/index=%d", currentBandIndex, boardConfiguration->hip9011Gain, currentGainIndex);
@ -223,9 +224,10 @@ void hipAdcCallback(adcsample_t value) {
if (state == WAITING_FOR_ADC_TO_SKIP) { if (state == WAITING_FOR_ADC_TO_SKIP) {
state = WAITING_FOR_RESULT_ADC; state = WAITING_FOR_RESULT_ADC;
} else if (state == WAITING_FOR_RESULT_ADC) { } else if (state == WAITING_FOR_RESULT_ADC) {
if (adcToVoltsDivided(value) > engineConfiguration->hipThreshold) { bool isKnockNow = adcToVoltsDivided(value) > engineConfiguration->hipThreshold;
engine->setKnockNow(isKnockNow);
if (isKnockNow) {
totalKnockEventsCount++; totalKnockEventsCount++;
timeOfLastKnockEvent = getTimeNowUs();
} }
int integratorIndex = getIntegrationIndexByRpm(engine->rpmCalculator.rpmValue); int integratorIndex = getIntegrationIndexByRpm(engine->rpmCalculator.rpmValue);

View File

@ -529,7 +529,7 @@ custom idle_mode_e 4 bits, U32, @OFFSET@, [0:0], "false", "true"
float idleStepperReactionTime;;"ms", 1, 0, 1, 300, 0 float idleStepperReactionTime;;"ms", 1, 0, 1, 300, 0
float hipThreshold; float hipThreshold;;"V", 1, 0, 1, 5, 2
custom pin_input_mode_e 4 scalar, F32, @OFFSET@, "ms", 1, 0, 0, 200, 1 custom pin_input_mode_e 4 scalar, F32, @OFFSET@, "ms", 1, 0, 0, 200, 1
pin_input_mode_e[LE_COMMAND_COUNT iterate] fsioInputModes; pin_input_mode_e[LE_COMMAND_COUNT iterate] fsioInputModes;

View File

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

View File

@ -40,7 +40,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code ; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START ; CONFIG_DEFINITION_START
; this section was generated by ConfigDefinition.jar on Sat May 30 13:04:28 EDT 2015 ; this section was generated by ConfigDefinition.jar on Sun May 31 08:31:25 EDT 2015
pageSize = 15288 pageSize = 15288
page = 1 page = 1
@ -425,7 +425,7 @@ page = 1
;skipping knockDetectionWindowStart offset 1540 ;skipping knockDetectionWindowStart offset 1540
;skipping knockDetectionWindowEnd offset 1544 ;skipping knockDetectionWindowEnd offset 1544
idleStepperReactionTime = scalar, F32, 1548, "ms", 1, 0, 1, 300, 0 idleStepperReactionTime = scalar, F32, 1548, "ms", 1, 0, 1, 300, 0
;skipping hipThreshold offset 1552 hipThreshold = scalar, F32, 1552, "V", 1, 0, 1, 5, 2
fsioInputModes1 = scalar, F32, 1556, "ms", 1, 0, 0, 200, 1 fsioInputModes1 = scalar, F32, 1556, "ms", 1, 0, 0, 200, 1
fsioInputModes2 = scalar, F32, 1560, "ms", 1, 0, 0, 200, 1 fsioInputModes2 = scalar, F32, 1560, "ms", 1, 0, 0, 200, 1
fsioInputModes3 = scalar, F32, 1564, "ms", 1, 0, 0, 200, 1 fsioInputModes3 = scalar, F32, 1564, "ms", 1, 0, 0, 200, 1
@ -613,7 +613,7 @@ fileVersion = { 20150522 }
clutchUpState =bits, U32, 72, [11:11], "true", "false"; clutchUpState =bits, U32, 72, [11:11], "true", "false";
clutchDownState =bits, U32, 72, [12:12], "true", "false"; clutchDownState =bits, U32, 72, [12:12], "true", "false";
knockEverIndicator=bits, U32, 72, [13:13], "true", "false"; knockEverIndicator=bits, U32, 72, [13:13], "true", "false";
knockNowIndicator=bits, U32, 72, [13:13], "true", "false"; knockNowIndicator=bits, U32, 72, [14:14], "true", "false";
vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0; vehicleSpeedKph = scalar, F32, 76, "kph", 1, 0.0;
ind_tps_error = bits, U32, 80, [0:0], "true", "false"; ind_tps_error = bits, U32, 80, [0:0], "true", "false";
@ -882,8 +882,8 @@ fileVersion = { 20150522 }
indicator = { ind_iat_error}, "iat", "iat error", white, black, red, black indicator = { ind_iat_error}, "iat", "iat error", white, black, red, black
indicator = { ind_map_error}, "map", "map error", white, black, red, black indicator = { ind_map_error}, "map", "map error", white, black, red, black
indicator = { knockEverIndicator }, "", "Knock", white, black, red, black indicator = { knockEverIndicator }, "", "Knock recently", white, black, red, black
indicator = { knockNowIndicator }, "", "Knock NOW", white, black, red, black indicator = { knockNowIndicator }, "no knock", "Knock NOW", white, black, red, black
[Datalog] [Datalog]
@ -1193,6 +1193,7 @@ fileVersion = { 20150522 }
; Engine->hip9011 Settings ; Engine->hip9011 Settings
dialog = hipFunction, "HIP9011 Settings" dialog = hipFunction, "HIP9011 Settings"
field = "Enabled", isHip9011Enabled field = "Enabled", isHip9011Enabled
field = "Threshold", hipThreshold
field = "IntHold pin (hip9011 input)", hip9011IntHoldPin field = "IntHold pin (hip9011 input)", hip9011IntHoldPin
field = "ChipSelect pin", hip9011CsPin field = "ChipSelect pin", hip9011CsPin
field = "hip Output/stm input", hipOutputChannel field = "hip Output/stm input", hipOutputChannel