diff --git a/firmware/config/engines/toyota_jzs147.cpp b/firmware/config/engines/toyota_jzs147.cpp index 4ec7c50cb8..e4420bcf81 100644 --- a/firmware/config/engines/toyota_jzs147.cpp +++ b/firmware/config/engines/toyota_jzs147.cpp @@ -7,8 +7,12 @@ * * http://wilbo666.pbworks.com/w/page/37134472/2JZ-GTE%20JZS147%20Aristo%20Engine%20Wiring * + * NON VVTi * set_engine_type 38 * + * VVTi + * set_engine_type 44 + * * @date Dec 30, 2015 * @author Andrey Belomutskiy, (c) 2012-2016 */ @@ -19,7 +23,7 @@ EXTERN_ENGINE; -void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { +static void common2jz(DECLARE_ENGINE_PARAMETER_F) { setCustomEngineConfiguration(PASS_ENGINE_PARAMETER_F); // default pinout engineConfiguration->isCanEnabled = true; @@ -30,27 +34,6 @@ void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { // set_ignition_mode 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); - engineConfiguration->trigger.type = TT_2JZ_1_12; - -//// temporary while I am fixing trigger bug -// setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); -// //set_trigger_type 16 -// engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; -// engineConfiguration->trigger.customTotalToothCount = 36; -// engineConfiguration->trigger.customSkippedToothCount = 2; -// -// engineConfiguration->ignitionMode = IM_WASTED_SPARK; -// engineConfiguration->twoWireBatchIgnition = true; -// -// engineConfiguration->crankingInjectionMode = IM_BATCH; -// engineConfiguration->injectionMode = IM_BATCH; -// engineConfiguration->twoWireBatchInjection = true; - -// boardConfiguration->triggerInputPins[0] = GPIOA_5; -// boardConfiguration->triggerInputPins[1] = GPIOC_6; - - boardConfiguration->ignitionPins[0] = GPIOE_14; boardConfiguration->ignitionPins[1] = GPIOC_7; boardConfiguration->ignitionPins[2] = GPIOC_9; @@ -72,7 +55,6 @@ void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->engineChartSize = 450; // engineConfiguration->useOnlyRisingEdgeForTrigger = true; - boardConfiguration->isSdCardEnabled = false; engineConfiguration->map.sensor.type = MT_CUSTOM; @@ -85,8 +67,41 @@ void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { setThermistorConfiguration(&engineConfiguration->clt, -20, 15000, 40, 1200, 120.0, 200.0); setThermistorConfiguration(&engineConfiguration->iat, -20, 15000, 40, 1200, 120.0, 200.0); +} + +void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { + common2jz(PASS_ENGINE_PARAMETER_F); + + setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); + engineConfiguration->trigger.type = TT_2JZ_1_12; + +//// temporary while I am fixing trigger bug +// setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); +// //set_trigger_type 16 +// engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; +// engineConfiguration->trigger.customTotalToothCount = 36; +// engineConfiguration->trigger.customSkippedToothCount = 2; +// +// engineConfiguration->ignitionMode = IM_WASTED_SPARK; +// engineConfiguration->twoWireBatchIgnition = true; +// +// engineConfiguration->crankingInjectionMode = IM_BATCH; +// engineConfiguration->injectionMode = IM_BATCH; +// engineConfiguration->twoWireBatchInjection = true; + +// boardConfiguration->triggerInputPins[0] = GPIOA_5; +// boardConfiguration->triggerInputPins[1] = GPIOC_6; + + boardConfiguration->isSdCardEnabled = false; + + +} + +void setToyota_2jz_vics(DECLARE_ENGINE_PARAMETER_F) { + common2jz(PASS_ENGINE_PARAMETER_F); + + boardConfiguration->isSdCardEnabled = true; } - diff --git a/firmware/config/engines/toyota_jzs147.h b/firmware/config/engines/toyota_jzs147.h index 9bbc6b2cf4..7b4afa4c4e 100644 --- a/firmware/config/engines/toyota_jzs147.h +++ b/firmware/config/engines/toyota_jzs147.h @@ -11,5 +11,6 @@ #include "engine.h" void setToyota_jzs147EngineConfiguration(DECLARE_ENGINE_PARAMETER_F); +void setToyota_2jz_vics(DECLARE_ENGINE_PARAMETER_F); #endif /* CONFIG_ENGINES_TOYOTA_JZS147_H_ */ diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index 7a5706d09d..a03b98f03a 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -124,7 +124,8 @@ typedef struct { float engineLoadDelta; // 228 float speedToRpmRatio; // 232 int warningCounter; // 236 - int unused3[9]; + int lastErrorCode; // 240 + int unused3[8]; } TunerStudioOutputChannels; #endif /* TUNERSTUDIO_CONFIGURATION_H_ */ diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 4fdc98ef2b..840fc5a9e8 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -196,6 +196,7 @@ static void printSensors(Logging *log, bool fileFormat) { } reportSensorI(log, fileFormat, "warn", "count", engine->engineState.warningCounter); + reportSensorI(log, fileFormat, "error", "code", engine->engineState.lastErrorCode); reportSensorF(log, fileFormat, "knck_c", "count", engine->knockCount, 0); reportSensorF(log, fileFormat, "knck_v", "v", engine->knockVolts, 2); @@ -704,6 +705,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ #endif /* EFI_PROD_CODE */ tsOutputChannels->warningCounter = engine->engineState.warningCounter; + tsOutputChannels->lastErrorCode = engine->engineState.lastErrorCode; tsOutputChannels->knockNowIndicator = engine->knockCount > 0; tsOutputChannels->knockEverIndicator = engine->knockEver; diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index bec06312a2..472ea8dbee 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -44,6 +44,8 @@ case CHEVY_C20_1973: return "CHEVY C20"; case TOYOTA_JZS147: return "TOYOTA_JZS147"; +case TOYOTA_2JZ_GTE_VVTi: + return "2JZ_GTE_VVTi"; case GEO_STORM: return "GEO_STORM"; case LADA_KALINA: diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 2f4fa8d7d2..80be8c0dbc 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -134,6 +134,11 @@ EngineState::EngineState() { engineNoiseHipLevel = 0; injectorLag = 0; warningCounter = 0; + lastErrorCode = 0; + targetAFR = 0; + tpsAccelEnrich = 0; + tChargeK = 0; + currentVE = 0; } void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_F) { diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index e58b5c7ac5..708e236741 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -123,6 +123,7 @@ public: float clt; int warningCounter; + int lastErrorCode; float airMass; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index a3da975154..c2221dd9a9 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -924,6 +924,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN case CHEVY_C20_1973: set1973c20(PASS_ENGINE_PARAMETER_F); break; + case TOYOTA_2JZ_GTE_VVTi: case TOYOTA_JZS147: setToyota_jzs147EngineConfiguration(PASS_ENGINE_PARAMETER_F); break; diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 0cf45ba43a..2b51f6a89c 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -116,7 +116,7 @@ typedef enum { CHEVY_C20_1973 = 37, - TOYOTA_JZS147 = 38, + TOYOTA_JZS147 = 38, // 2JZ-GTE NON VVTi LADA_KALINA = 39, @@ -129,7 +129,9 @@ typedef enum { HONDA_600 = 43, - ET_UNUSED = 44, + TOYOTA_2JZ_GTE_VVTi = 44, + + ET_UNUSED = 45, Force_4b_engine_type = ENUM_32_BITS, } engine_type_e; diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 6a79050581..21db372f82 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -70,6 +70,7 @@ int warning(obd_code_e code, const char *fmt, ...) { timeOfPreviousWarning = now; engine->engineState.warningCounter++; + engine->engineState.lastErrorCode = code; resetLogging(&logger); // todo: is 'reset' really needed here? appendMsgPrefix(&logger); diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 1e9a45e98b..3c9a4e0230 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -190,10 +190,6 @@ const char* getConfigurationName(engine_type_e engineType) { return "GM_2_2"; case DODGE_RAM: return "DODGE_RAM"; - case MAZDA_626: - return "Mazda626"; - case TOYOTA_JZS147: - return "TOYOTA_JZS147"; default: return getEngine_type_e(engineType); } diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index 496a564ac1..1aad9cf84f 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -110,11 +110,11 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int eventIndex, bool limitedF ENGINE(actualLastInjection) = injectionDuration; if (cisnan(injectionDuration)) { - warning(OBD_PCM_Processor_Fault, "NaN injection pulse"); + warning(CUSTOM_OBD_30, "NaN injection pulse"); return; } if (injectionDuration < 0) { - warning(OBD_PCM_Processor_Fault, "Negative injection pulse %f", injectionDuration); + warning(CUSTOM_OBD_31, "Negative injection pulse %f", injectionDuration); return; } @@ -362,10 +362,10 @@ static ALWAYS_INLINE void scheduleIgnitionAndFuelEvents(int rpm, int revolutionI } if (engine->engineState.dwellAngle == 0) { - warning(OBD_PCM_Processor_Fault, "dwell is zero?"); + warning(CUSTOM_OBD_32, "dwell is zero?"); } if (engine->engineState.dwellAngle > maxAllowedDwellAngle) { - warning(OBD_PCM_Processor_Fault, "dwell angle too long: %f", engine->engineState.dwellAngle); + warning(CUSTOM_OBD_33, "dwell angle too long: %f", engine->engineState.dwellAngle); } // todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that @@ -431,7 +431,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL } if (limitedSpark || limitedFuel) { - warning(OBD_PCM_Processor_Fault, "skipping stroke due to rpm=%d", rpm); + warning(CUSTOM_OBD_34, "skipping stroke due to rpm=%d", rpm); } #if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__) diff --git a/java_console/models/src/com/rusefi/core/Sensor.java b/java_console/models/src/com/rusefi/core/Sensor.java index 722ab57c26..4fd4f8ad89 100644 --- a/java_console/models/src/com/rusefi/core/Sensor.java +++ b/java_console/models/src/com/rusefi/core/Sensor.java @@ -120,6 +120,7 @@ public enum Sensor { debugIntField3(SensorCategory.OPERATIONS, FieldType.INT, 220, BackgroundColor.MUD, 0, 5), warningCounter(SensorCategory.OPERATIONS, FieldType.INT, 236, BackgroundColor.MUD, 0, 5), + lastErrorCode(SensorCategory.OPERATIONS, FieldType.INT, 240, BackgroundColor.MUD, 0, 5), RPM(SensorCategory.SENSOR_INPUTS, FieldType.INT, 0, BackgroundColor.RED, 0, 8000), TIME_SECONDS(SensorCategory.OPERATIONS, FieldType.INT, 224, BackgroundColor.MUD, 0, 5), diff --git a/java_console/ui/src/com/rusefi/SensorLogger.java b/java_console/ui/src/com/rusefi/SensorLogger.java index 31d96e4325..b92d430a31 100644 --- a/java_console/ui/src/com/rusefi/SensorLogger.java +++ b/java_console/ui/src/com/rusefi/SensorLogger.java @@ -44,6 +44,7 @@ public class SensorLogger { Sensor.debugIntField2, Sensor.debugIntField3, Sensor.warningCounter, + Sensor.lastErrorCode, Sensor.MAF, Sensor.IAT}; private static long fileStartTime;