From 9d096ab64968a94212dbc71a2a7a42f541fa2def Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 11 Sep 2014 20:02:50 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/engine_controller.cpp | 17 +++-- .../controllers/trigger/trigger_decoder.cpp | 19 ----- .../trigger/trigger_mitsubishi.cpp | 22 ++++++ .../controllers/trigger/trigger_mitsubishi.h | 1 + firmware/emulation/wave_analyzer.cpp | 73 ++++++++++--------- .../src/com/irnems/core/EngineState.java | 1 + .../models/src/com/irnems/core/Sensor.java | 6 +- .../com/rusefi/ui/widgets/UpDownImage.java | 2 + unit_tests/test_trigger_decoder.cpp | 2 +- 9 files changed, 78 insertions(+), 65 deletions(-) diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 2ad24efb8b..844db66580 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -221,8 +221,7 @@ static char pinNameBuffer[16]; static void printAnalogChannelInfoExt(const char *name, adc_channel_e hwChannel, float adcVoltage) { float voltage = adcVoltage * engineConfiguration->analogInputDividerCoefficient; - scheduleMsg(&logger, "%s ADC%d %s %s rawValue=%f/divided=%fv", name, hwChannel, - getAdcMode(hwChannel), + scheduleMsg(&logger, "%s ADC%d %s %s rawValue=%f/divided=%fv", name, hwChannel, getAdcMode(hwChannel), getPinNameByAdcChannel(hwChannel, pinNameBuffer), adcVoltage, voltage); } @@ -244,11 +243,11 @@ static void printAnalogInfo(void) { static THD_WORKING_AREA(csThreadStack, UTILITY_THREAD_STACK_SIZE); // declare thread stack void initEngineContoller(void) { - if (hasFirmwareError()) + if (hasFirmwareError()) { return; + } initLogging(&logger, "Engine Controller"); - initSensors(); initPwmGenerator(); @@ -298,10 +297,12 @@ void initEngineContoller(void) { #endif /* EFI_MAP_AVERAGING */ #if EFI_ENGINE_CONTROL - /** - * This method initialized the main listener which actually runs injectors & ignition - */ - initMainEventListener(&engine, engineConfiguration2); + if (boardConfiguration->isEngineControlEnabled) { + /** + * This method initialized the main listener which actually runs injectors & ignition + */ + initMainEventListener(&engine, engineConfiguration2); + } #endif /* EFI_ENGINE_CONTROL */ #if EFI_IDLE_CONTROL diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index a23625bef1..1cd463ea6d 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -173,25 +173,6 @@ void initializeSkippedToothTriggerShapeExt(trigger_shape_s *s, int totalTeethCou s->wave.checkSwitchTimes(s->getSize()); } -static void configureFordAspireTriggerShape(trigger_config_s *triggerConfig, trigger_shape_s * s) { - s->isSynchronizationNeeded = false; - s->reset(FOUR_STROKE_CAM_SENSOR); - - s->shaftPositionEventCount = 10; - - s->addEvent(53.747, T_SECONDARY, TV_HIGH); - s->addEvent(121.90, T_SECONDARY, TV_LOW); // delta = 68.153 - s->addEvent(232.76, T_SECONDARY, TV_HIGH); // delta = 110.86 - s->addEvent(300.54, T_SECONDARY, TV_LOW); // delta = 67.78 - s->addEvent(360, T_PRIMARY, TV_HIGH); - - s->addEvent(409.8412, T_SECONDARY, TV_HIGH); // delta = 49.8412 - s->addEvent(478.6505, T_SECONDARY, TV_LOW); // delta = 68.8093 - s->addEvent(588.045, T_SECONDARY, TV_HIGH); // delta = 109.3945 - s->addEvent(657.03, T_SECONDARY, TV_LOW); - s->addEvent(720, T_PRIMARY, TV_LOW); -} - /** * External logger is needed because at this point our logger is not yet initialized */ diff --git a/firmware/controllers/trigger/trigger_mitsubishi.cpp b/firmware/controllers/trigger/trigger_mitsubishi.cpp index 5ffcfa3aef..c25ee5ca76 100644 --- a/firmware/controllers/trigger/trigger_mitsubishi.cpp +++ b/firmware/controllers/trigger/trigger_mitsubishi.cpp @@ -7,6 +7,28 @@ #include "trigger_mitsubishi.h" +void configureFordAspireTriggerShape(trigger_config_s *triggerConfig, trigger_shape_s * s) { + s->isSynchronizationNeeded = false; + s->reset(FOUR_STROKE_CAM_SENSOR); + + s->shaftPositionEventCount = 10; + + float x = 121.90; + float y = 110.86; + + s->addEvent(x + y - 180, T_SECONDARY, TV_HIGH); + s->addEvent(x, T_SECONDARY, TV_LOW); + s->addEvent(x + y, T_SECONDARY, TV_HIGH); + s->addEvent(x + 180, T_SECONDARY, TV_LOW); + s->addEvent(360, T_PRIMARY, TV_HIGH); + + s->addEvent(x + 180 + y, T_SECONDARY, TV_HIGH); + s->addEvent(x + 360, T_SECONDARY, TV_LOW); + s->addEvent(x + 360 + y, T_SECONDARY, TV_HIGH); + s->addEvent(x + 540, T_SECONDARY, TV_LOW); + s->addEvent(720, T_PRIMARY, TV_LOW); +} + void initializeMitsubishi4g18(trigger_shape_s *s) { s->reset(FOUR_STROKE_CAM_SENSOR); s->useRiseEdge = false; diff --git a/firmware/controllers/trigger/trigger_mitsubishi.h b/firmware/controllers/trigger/trigger_mitsubishi.h index 3d72956fbe..1c82a4ec25 100644 --- a/firmware/controllers/trigger/trigger_mitsubishi.h +++ b/firmware/controllers/trigger/trigger_mitsubishi.h @@ -10,5 +10,6 @@ #include "trigger_structure.h" void initializeMitsubishi4g18(trigger_shape_s *s); +void configureFordAspireTriggerShape(trigger_config_s *triggerConfig, trigger_shape_s * s); #endif /* TRIGGER_MITSUBISHI_H_ */ diff --git a/firmware/emulation/wave_analyzer.cpp b/firmware/emulation/wave_analyzer.cpp index 0a41697d50..99d7056b0e 100644 --- a/firmware/emulation/wave_analyzer.cpp +++ b/firmware/emulation/wave_analyzer.cpp @@ -104,11 +104,11 @@ static void setWaveModeSilent(int index, int mode) { setWaveReaderMode(&reader->hw, mode); } -static int getEventCounter(int index) { - WaveReader *reader = &readers[index]; - ensureInitialized(reader); - return reader->eventCounter; -} +//static int getEventCounter(int index) { +// WaveReader *reader = &readers[index]; +// ensureInitialized(reader); +// return reader->eventCounter; +//} static void initWave(const char *name, int index) { brain_pin_e brainPin = boardConfiguration->logicAnalyzerPins[index]; @@ -191,48 +191,49 @@ static float getSignalPeriodMs(int index) { return reader->signalPeriodUs / 1000.0f; } -static uint64_t getWidthEventTime(int index) { - WaveReader *reader = &readers[index]; - ensureInitialized(reader); - return reader->widthEventTimeUs; -} +//static uint64_t getWidthEventTime(int index) { +// WaveReader *reader = &readers[index]; +// ensureInitialized(reader); +// return reader->widthEventTimeUs; +//} static void reportWave(Logging *logging, int index) { + if (readers[index].hw.started) { // int counter = getEventCounter(index); // debugInt2(logging, "ev", index, counter); - float dwellMs = getSignalOnTime(index); - float periodMs = getSignalPeriodMs(index); + float dwellMs = getSignalOnTime(index); + float periodMs = getSignalPeriodMs(index); - appendPrintf(logging, "duty%d%s", index, DELIMETER); - appendFloat(logging, 100.0f * dwellMs / periodMs, 2); - appendPrintf(logging, "%s", DELIMETER); + appendPrintf(logging, "duty%d%s", index, DELIMETER); + appendFloat(logging, 100.0f * dwellMs / periodMs, 2); + appendPrintf(logging, "%s", DELIMETER); - /** - * that's the ON time of the LAST signal - */ - appendPrintf(logging, "dwell%d%s", index, DELIMETER); - appendFloat(logging, dwellMs, 2); - appendPrintf(logging, "%s", DELIMETER); + /** + * that's the ON time of the LAST signal + */ + appendPrintf(logging, "dwell%d%s", index, DELIMETER); + appendFloat(logging, dwellMs, 2); + appendPrintf(logging, "%s", DELIMETER); - /** - * that's the total ON time during the previous engine cycle - */ - appendPrintf(logging, "total_dwell%d%s", index, DELIMETER); - appendFloat(logging, readers[index].prevTotalOnTimeUs / 1000.0f, 2); - appendPrintf(logging, "%s", DELIMETER); + /** + * that's the total ON time during the previous engine cycle + */ + appendPrintf(logging, "total_dwell%d%s", index, DELIMETER); + appendFloat(logging, readers[index].prevTotalOnTimeUs / 1000.0f, 2); + appendPrintf(logging, "%s", DELIMETER); + appendPrintf(logging, "period%d%s", index, DELIMETER); + appendFloat(logging, periodMs, 2); + appendPrintf(logging, "%s", DELIMETER); - appendPrintf(logging, "period%d%s", index, DELIMETER); - appendFloat(logging, periodMs, 2); - appendPrintf(logging, "%s", DELIMETER); + uint32_t offsetUs = getWaveOffset(index); + float oneDegreeUs = getOneDegreeTimeUs(getRpm()); - uint32_t offsetUs = getWaveOffset(index); - float oneDegreeUs = getOneDegreeTimeUs(getRpm()); - - appendPrintf(logging, "advance%d%s", index, DELIMETER); - appendFloat(logging, fixAngle((offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset), 3); - appendPrintf(logging, "%s", DELIMETER); + appendPrintf(logging, "advance%d%s", index, DELIMETER); + appendFloat(logging, fixAngle((offsetUs / oneDegreeUs) - engineConfiguration->globalTriggerAngleOffset), 3); + appendPrintf(logging, "%s", DELIMETER); + } } void printWave(Logging *logging) { diff --git a/java_console/models/src/com/irnems/core/EngineState.java b/java_console/models/src/com/irnems/core/EngineState.java index f72c658b03..8a63d186da 100644 --- a/java_console/models/src/com/irnems/core/EngineState.java +++ b/java_console/models/src/com/irnems/core/EngineState.java @@ -75,6 +75,7 @@ public class EngineState { SensorStats.startStandardDeviation(Sensor.DWELL0, Sensor.DWELL0_SD); SensorStats.startDelta(Sensor.INJECTOR_1_DWELL, Sensor.INJECTOR_2_DWELL, Sensor.INJ_1_2_DELTA); + SensorStats.startDelta(Sensor.INJECTOR_3_DWELL, Sensor.INJECTOR_4_DWELL, Sensor.INJ_3_4_DELTA); registerStringValueAction("adcfast_co", NOTHING); registerStringValueAction("adcfast_max", NOTHING); diff --git a/java_console/models/src/com/irnems/core/Sensor.java b/java_console/models/src/com/irnems/core/Sensor.java index f0193dbd2c..c9990232c2 100644 --- a/java_console/models/src/com/irnems/core/Sensor.java +++ b/java_console/models/src/com/irnems/core/Sensor.java @@ -69,9 +69,13 @@ public enum Sensor { ADC_FAST_AVG("ADC_FAST_AVG", "b", 4000), INJECTOR_1_DWELL("inj #1"), INJECTOR_2_DWELL("inj #2"), + INJECTOR_3_DWELL("inj #3"), + INJECTOR_4_DWELL("inj #4"), - INJ_1_2_DELTA("inj 1-2 delta"),; + INJ_1_2_DELTA("inj 1-2 delta"), + INJ_3_4_DELTA("inj 3-4 delta"), + ; private final String name; private final String units; diff --git a/java_console/ui/src/com/rusefi/ui/widgets/UpDownImage.java b/java_console/ui/src/com/rusefi/ui/widgets/UpDownImage.java index 416df7bc06..52fedc87be 100644 --- a/java_console/ui/src/com/rusefi/ui/widgets/UpDownImage.java +++ b/java_console/ui/src/com/rusefi/ui/widgets/UpDownImage.java @@ -42,6 +42,8 @@ public class UpDownImage extends JPanel { static { name2sensor.put("inj1", Sensor.INJECTOR_1_DWELL); name2sensor.put("inj2", Sensor.INJECTOR_2_DWELL); + name2sensor.put("inj3", Sensor.INJECTOR_3_DWELL); + name2sensor.put("inj4", Sensor.INJECTOR_4_DWELL); } public UpDownImage(final String name) { diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index d53c22ecd6..bed3fef4bc 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -458,7 +458,7 @@ void testTriggerDecoder(void) { testFordAspire(); // lame duty cycle implementation! - testTriggerDecoder2("ford aspire", FORD_ASPIRE_1996, 4, 0.5, 0.3802); + testTriggerDecoder2("ford aspire", FORD_ASPIRE_1996, 4, 0.5, 0.3841); test1995FordInline6TriggerDecoder(); testMazdaMianaNbDecoder();