From 8d8e8ec260f20ffda913c94a774d712803d34059 Mon Sep 17 00:00:00 2001 From: shadowm60 Date: Tue, 22 Sep 2020 23:25:27 +0300 Subject: [PATCH] Launch control - experimental (#1816) * Update tachometer.cpp Initial implementation of E30 M3 Tach output solution #907, unit_test plus debugging next * tacho unit tests First successfull unit test for tachometer * RAM adjustment so it would link * refactoring tacho, broken! * starting to make some progress...still fails after a few seconds * Rework with SW PWM * Update after code review * unit_test update * First working unit_test * Update .gitignore * Update engine_controller.cpp * Update engine_controller.cpp * Update tachometer.h * Update test_tacho.cpp * Switched UART DMA on * Revert "Switched UART DMA on" This reverts commit 4a23974c431e0e7fd760595d2161e74e6854897e. * enable launch control make use of already existent code + integration * Delete compile_frankenso_all.sh remove it since it is not part of the project * Update main_trigger_callback.cpp broke unit_Tests Co-authored-by: rusefi --- firmware/config/stm32f4ems/efifeatures.h | 2 +- firmware/controllers/algo/launch_control.cpp | 2 +- firmware/controllers/algo/launch_control.h | 1 + .../engine_cycle/main_trigger_callback.cpp | 11 ++++++++++- firmware/tunerstudio/rusefi.input | 7 ++++--- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index e22baed2bf..3e35b54acb 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -13,7 +13,7 @@ #define EFI_BOOST_CONTROL TRUE -#define EFI_LAUNCH_CONTROL FALSE +#define EFI_LAUNCH_CONTROL TRUE #define EFI_FSIO TRUE diff --git a/firmware/controllers/algo/launch_control.cpp b/firmware/controllers/algo/launch_control.cpp index abc2da7a21..4b6cb15194 100644 --- a/firmware/controllers/algo/launch_control.cpp +++ b/firmware/controllers/algo/launch_control.cpp @@ -145,7 +145,7 @@ void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_EN (CONFIG(enableLaunchRetard) ? CONFIG(launchAdvanceRpmRange) : 0) + CONFIG(hardCutRpmRange); - if (retardThresholdRpm > GET_RPM()) { + if (retardThresholdRpm < GET_RPM()) { *limitedSpark = engine->isLaunchCondition && engineConfiguration->launchSparkCutEnable; *limitedFuel = engine->isLaunchCondition && engineConfiguration->launchFuelCutEnable; engine->rpmHardCut = true; diff --git a/firmware/controllers/algo/launch_control.h b/firmware/controllers/algo/launch_control.h index 71d48bf8fa..b9a16ddcbd 100644 --- a/firmware/controllers/algo/launch_control.h +++ b/firmware/controllers/algo/launch_control.h @@ -11,3 +11,4 @@ void initLaunchControl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); void setDefaultLaunchParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE); +void applyLaunchControlLimiting(bool *limitedSpark, bool *limitedFuel DECLARE_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 0f6e095dc1..7ea4c63d8c 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -52,6 +52,9 @@ #include "engine.h" #include "perf_trace.h" #include "sensor.h" +#if EFI_LAUNCH_CONTROL +#include "launch_control.h" +#endif #include "backup_ram.h" @@ -427,7 +430,13 @@ static void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEvent limitedFuel = true; } } - +#if EFI_LAUNCH_CONTROL + if ((!limitedSpark)&&(!limitedFuel)) + { + /* in case we are not already on a limited conditions, check launch as well */ + applyLaunchControlLimiting(&limitedSpark,&limitedFuel PASS_ENGINE_PARAMETER_SUFFIX); + } +#endif if (trgEventIndex == 0) { if (HAVE_CAM_INPUT()) { engine->triggerCentral.validateCamVvtCounters(); diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index b9e6be0ce8..a00df0c126 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1446,8 +1446,8 @@ menuDialog = main subMenu = etbTpsBiasCurve, "Electronic throttle body bias curve" @@if_ts_show_etb subMenu = pedalToTpsTbl, "Electronic Pedal Map" @@if_ts_show_etb subMenu = std_separator -# subMenu = smLaunchControl, "Launch Control" -# subMenu = std_separator + subMenu = smLaunchControl, "Launch Control" + subMenu = std_separator # subMenu = smRollingLaunch, "Rolling Launch" # subMenu = std_separator # subMenu = antiLag, "Antilag Setup" @@ -3158,7 +3158,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" field = "Log recent errors list", enableLogErrorList ; Racing Features->Launch Control - dialog = smLaunchControl, "Launch Control Settings NOT WORKING" + dialog = smLaunchControl, "Launch Control Settings EXPERIMENTAL" field = "Enable Launch Control", launchControlEnabled field = "Activation Mode", launchActivationMode field = "Switch Input", launchActivatePin, {launchActivationMode == 0 && launchControlEnabled == 1} @@ -3170,6 +3170,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" field = "Launch RPM", launchRpm, {launchControlEnabled == 1} field = "Extra Fuel", launchFuelAdded, {launchControlEnabled == 1} field = "Boost Solenoid Duty", launchBoostDuty, {launchControlEnabled == 1} + field = "Ignition Retard enable", enableLaunchRetard, {launchControlEnabled == 1} field = "Ignition Retard", launchTimingRetard, {launchControlEnabled == 1} field = "Ignition Retard RPM Range", launchTimingRpmRange, {launchControlEnabled == 1} field = "Smooth Retard Mode", launchSmoothRetard, {launchControlEnabled == 1}