diff --git a/firmware/controllers/can/can_verbose.cpp b/firmware/controllers/can/can_verbose.cpp index ae7770ba22..4ca5bdd35d 100644 --- a/firmware/controllers/can/can_verbose.cpp +++ b/firmware/controllers/can/can_verbose.cpp @@ -27,8 +27,8 @@ struct Status { uint8_t fuelPump : 1; uint8_t checkEngine : 1; uint8_t o2Heater : 1; + uint8_t lambdaProtectActive : 1; - uint8_t pad6 : 1; uint8_t pad7 : 1; uint8_t pad8 : 1; @@ -47,6 +47,9 @@ static void populateFrame(Status& msg) { msg.checkEngine = enginePins.checkEnginePin.getLogicValue(); msg.o2Heater = enginePins.o2heater.getLogicValue(); + // TODO: https://github.com/FOME-Tech/fome-fw/issues/75 + msg.lambdaProtectActive = false; + msg.gear = Sensor::getOrZero(SensorType::DetectedGear); } diff --git a/firmware/controllers/can/rusEFI_CAN_verbose.dbc b/firmware/controllers/can/rusEFI_CAN_verbose.dbc index 37d288999f..4caf87b0ee 100644 --- a/firmware/controllers/can/rusEFI_CAN_verbose.dbc +++ b/firmware/controllers/can/rusEFI_CAN_verbose.dbc @@ -54,6 +54,7 @@ BO_ 512 BASE0: 8 Vector__XXX SG_ FuelPumpAct : 34|1@1+ (1,0) [0|0] "" Vector__XXX SG_ CELAct : 35|1@1+ (1,0) [0|0] "" Vector__XXX SG_ EGOHeatAct : 36|1@1+ (1,0) [0|0] "" Vector__XXX + SG_ LambdaProtectAct : 37|1@1+ (1,0) [0|0] "" Vector__XXX SG_ CurrentGear : 40|8@1+ (1,0) [0|0] "" Vector__XXX BO_ 513 BASE1: 8 Vector__XXX @@ -123,6 +124,7 @@ CM_ SG_ 512 MainRelayAct "Main Relay Active"; CM_ SG_ 512 FuelPumpAct "Fuel Pump Output Active"; CM_ SG_ 512 CELAct "Check Engine Light Active"; CM_ SG_ 512 EGOHeatAct "EGO Heater Commanded On"; +CM_ SG_ 512 LambdaProtectAct "Lambda protection active (fault detected)"; CM_ SG_ 512 CurrentGear "Current detected gear. 0 means neutral, 1 means first, etc."; CM_ SG_ 513 RPM "Current RPM"; CM_ SG_ 513 IgnitionTiming "Current Ignition Timing. Positive is advance."; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 4bd95500fb..16663238b2 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -406,7 +406,7 @@ injector_s injector bit isForcedInduction;Does the vehicle have a turbo or supercharger? bit useFordRedundantTps;On some Ford and Toyota vehicles one of the throttle sensors is not linear on the full range, i.e. in the specific range of the positions we effectively have only one sensor. -bit unused88b2 +bit lambdaProtectionEnable bit overrideTriggerGaps bit enableFan1WithAc;Turn on this fan when AC is on. bit enableFan2WithAc;Turn on this fan when AC is on. @@ -687,7 +687,8 @@ pin_input_mode_e throttlePedalUpPinMode; uint16_t autoscale fordInjectorSmallPulseSlope;;"g/s", 0.001, 0, 0, 65, 3 - uint8_t[2] unused638 + uint8_t autoscale lambdaProtectionMinRpm;;"RPM", 100, 0, 0, 25000, 0 + uint8_t autoscale lambdaProtectionMinLoad;;"", 10, 0, 0, 1000, 0 bit is_enabled_spi_1 bit is_enabled_spi_2 @@ -775,7 +776,10 @@ custom uart_device_e 1 bits, U08, @OFFSET@, [0:1], "Off", "UART1", "UART2", "UAR int16_t antiLagRpmTreshold;;"rpm", 1, 0, 0, 20000, 0 uint16_t startCrankingDuration;Maximum time to crank starter when start/stop button is pressed;"Seconds", 1, 0, 0, 30, 0 - uint8_t[3] unused748 + uint8_t autoscale lambdaProtectionMinTps;;"", 1, 0, 0, 100, 0 + uint8_t autoscale lambdaProtectionTimeout;Only respond once lambda is out of range for this period of time. Use to avoid transients triggering lambda protection when not needed;"s", 0.1, 0, 0, 10, 1 + + uint8_t unused748 pin_output_mode_e acRelayPinMode; output_pin_e acRelayPin; @@ -1702,6 +1706,10 @@ uint16_t[12] autoscale throttleEstimateEffectiveAreaValues;In units of g/s norma blend_table_s[BOOST_BLEND_COUNT iterate] boostOpenLoopBlends blend_table_s[BOOST_BLEND_COUNT iterate] boostClosedLoopBlends +uint8_t[4 x 4] autoscale lambdaMaxDeviationTable;;"lambda", 0.01, 0, 0, 1, 2 +uint16_t[4] lambdaMaxDeviationLoadBins;;"", 1, 0, 0, 1000, 0 +uint16_t[4] lambdaMaxDeviationRpmBins;;"RPM", 1, 0, 0, 18000, 0 + end_struct ! Pedal Position Sensor diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 8fc3fb5406..44f8daca03 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1156,6 +1156,12 @@ curve = 32Curve, "3-2 Shift Solenoid Percent by Speed" gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees. upDownLabel = "(RICHER)", "(LEANER)" + table = lambdaMaxDeviationTableTbl, lambdaMaxDeviationTableMap, "Maximum Lambda Deviation Table", 1 + xyLabels = "RPM", "" + xBins = lambdaMaxDeviationRpmBins, RPMValue + yBins = lambdaMaxDeviationLoadBins, afrTableYAxis + zBins = lambdaMaxDeviationTable + table = iacPidMultTbl, iacPidMultMap, "IAC PID Multiplier Table", 1 ; constant, variable xBins = iacPidMultRpmBins, RPMValue @@ -1898,6 +1904,11 @@ menuDialog = main subMenu = softwareKnock, "Software knock" @@if_ts_show_software_knock subMenu = maxKnockRetardTbl, "Max knock retard" @@if_ts_show_software_knock + + ; TODO: move lambdaProtection to the fuel menu once ready + ; https://github.com/FOME-Tech/fome-fw/issues/75 + subMenu = lambdaProtection, "Lambda Protection", 0, { isInjectionEnabled } + subMenu = std_separator subMenu = std_separator @@ -3437,6 +3448,20 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_ panel = stftPartitionSettingsPower, {fuelClosedLoopCorrectionEnabled == 1} panel = stftPartitionSettingsOverrun, {fuelClosedLoopCorrectionEnabled == 1} + dialog = lambdaProtectionLeft, "" + field = "Enable lambda protection", lambdaProtectionEnable + field = "Check above load", lambdaProtectionMinLoad, { lambdaProtectionEnable } + field = "Check above TPS", lambdaProtectionMinTps, { lambdaProtectionEnable } + field = "Check above RPM", lambdaProtectionMinRpm, { lambdaProtectionEnable } + field = "Check after delay", lambdaProtectionTimeout { lambdaProtectionEnable } + + dialog = lambdaProtectionRight, "Lambda Difference Limit Table" + panel = lambdaMaxDeviationTableTbl + + dialog = lambdaProtection, "Lambda Protection", border + panel = lambdaProtectionLeft, West + panel = lambdaProtectionRight, East + dialog = vvtPidDialog0, "Configuration" field = "Activation Delay", vvtActivationDelayMs field = "Do not control below RPM", vvtControlMinRpm