From 5fd3056d405f4eb6222c9a4cf2135fa060dba491 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 3 Apr 2024 14:16:28 -0700 Subject: [PATCH] add firing orders --- firmware/CHANGELOG.md | 1 + firmware/controllers/algo/firing_order.h | 5 +++-- firmware/controllers/math/engine_math.cpp | 20 ++++++++++++++------ firmware/integration/rusefi_config.txt | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index ce3d0e5672..86a0e869e7 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -38,6 +38,7 @@ or - Increased precision available for Lua tables - Add EGT values to CAN broadcast format #398 - Add options to enable/disable optional CAN frames (cams, EGT so far) + - Add 1-5-4-8-3-7-2-6 and 1-6-5-10-2-7-3-8-4-9 firing orders ### Fixed - Improve performance with Lua CAN reception of a high volume of frames diff --git a/firmware/controllers/algo/firing_order.h b/firmware/controllers/algo/firing_order.h index f9106ba5a1..a20e58ae01 100644 --- a/firmware/controllers/algo/firing_order.h +++ b/firmware/controllers/algo/firing_order.h @@ -55,6 +55,7 @@ typedef enum __attribute__ ((__packed__)) { FO_1_3_7_2_6_5_4_8 = 20, // Ford 5.0 HO and 351W FO_1_2_3_4_5_6_7_8 = 25, // linearly incrementing, for V8 testing FO_1_5_4_8_6_3_7_2 = 26, // Audi 4.2 40v V8 + FO_1_5_4_8_3_7_2_6 = 32, // Ford Voodoo FO_1_8_7_3_6_5_4_2 = 28, // VH41DE (Japaneese Y32 Variant) // 9 cylinder - for instance radial :) @@ -63,7 +64,7 @@ typedef enum __attribute__ ((__packed__)) { // 10 cylinder FO_1_10_9_4_3_6_5_8_7_2 = 14, // dodge and viper ram v10 - // 1-6-5-10-2-7-3-8-4-9 BMW S85 + FO_1_6_5_10_2_7_3_8_4_9 = 33, // BMW, Lamborghini, etc // 12 cylinder FO_1_7_5_11_3_9_6_12_2_8_4_10 = 15, // bmw M70 & M73, Ferrari 456M GT V12 @@ -78,6 +79,6 @@ typedef enum __attribute__ ((__packed__)) { // unfortunately not supported by default firmware because MAX_CYLINDER_COUNT=12 by default FO_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10 = 22, // WR16 - // next value to use: 32 + // next value to use: 34 } firing_order_e; diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 0b3c0242e7..11ac28c622 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -143,12 +143,14 @@ static const uint8_t order_1_3_7_2_6_5_4_8[] = { 1, 3, 7, 2, 6, 5, 4, 8 }; static const uint8_t order_1_2_3_4_5_6_7_8[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; static const uint8_t order_1_5_4_8_6_3_7_2[] = { 1, 5, 4, 8, 6, 3, 7, 2 }; static const uint8_t order_1_8_7_3_6_5_4_2[] = { 1, 8, 7, 3, 6, 5, 4, 2 }; +static const uint8_t order_1_5_4_8_3_7_2_6[] = { 1, 5, 4, 8, 3, 7, 2, 6 }; // 9 cylinder static const uint8_t order_1_2_3_4_5_6_7_8_9[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // 10 cylinder static const uint8_t order_1_10_9_4_3_6_5_8_7_2[] = {1, 10, 9, 4, 3, 6, 5, 8, 7, 2}; +static const uint8_t order_1_6_5_10_2_7_3_8_4_9[] = {1, 6, 5, 10, 2, 7, 3, 8, 4, 9}; // 12 cyliner static const uint8_t order_1_7_5_11_3_9_6_12_2_8_4_10[] = {1, 7, 5, 11, 3, 9, 6, 12, 2, 8, 4, 10}; @@ -201,6 +203,7 @@ static size_t getFiringOrderLength() { case FO_1_2_3_4_5_6_7_8: case FO_1_5_4_8_6_3_7_2: case FO_1_8_7_3_6_5_4_2: + case FO_1_5_4_8_3_7_2_6: return 8; // 9 cylinder radial @@ -209,6 +212,7 @@ static size_t getFiringOrderLength() { // 10 cylinder case FO_1_10_9_4_3_6_5_8_7_2: + case FO_1_6_5_10_2_7_3_8_4_9: return 10; // 12 cylinder @@ -221,9 +225,10 @@ static size_t getFiringOrderLength() { case FO_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10: return 16; - default: - firmwareError(ObdCode::CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder); } + + firmwareError(ObdCode::CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder); + return 1; } @@ -286,6 +291,8 @@ static const uint8_t* getFiringOrderTable() return order_1_2_3_4_5_6_7_8; case FO_1_5_4_8_6_3_7_2: return order_1_5_4_8_6_3_7_2; + case FO_1_5_4_8_3_7_2_6: + return order_1_5_4_8_3_7_2_6; case FO_1_8_7_3_6_5_4_2: return order_1_8_7_3_6_5_4_2; @@ -298,6 +305,8 @@ static const uint8_t* getFiringOrderTable() // 10 cylinder case FO_1_10_9_4_3_6_5_8_7_2: return order_1_10_9_4_3_6_5_8_7_2; + case FO_1_6_5_10_2_7_3_8_4_9: + return order_1_6_5_10_2_7_3_8_4_9; // 12 cylinder case FO_1_7_5_11_3_9_6_12_2_8_4_10: @@ -312,12 +321,11 @@ static const uint8_t* getFiringOrderTable() // do not ask case FO_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10: return order_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10; - - default: - firmwareError(ObdCode::CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder); } - return NULL; + firmwareError(ObdCode::CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder); + + return nullptr; } /** diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index a3e9d16cf1..f5cf217b82 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -462,7 +462,7 @@ uint32_t cylindersCount;Number of cylinder the engine has.;"", 1, 0, 1, @@MAX_CY ! FO_1_8_4_3_6_5_7_2 = 5 ! FO_1_2_4_5_3 = 6 -custom firing_order_e 1 bits, U08, @OFFSET@, [0:5], "One Cylinder", "1-3-4-2", "1-2-4-3", "1-3-2-4", "1-5-3-6-2-4", "1-8-4-3-6-5-7-2", "1-2-4-5-3", "1-4-2-5-3-6", "1-2", "1-2-3-4-5-6", "1-2-3", "1-8-7-2-6-5-4-3", "1-5-4-2-6-3-7-8", "1-6-3-2-5-4", "1-10-9-4-3-6-5-8-7_2", "1-7-5-11-3-9-6-12-2-8-4-10", "1-7-4-10-2-8-6-12-3-9-5-11", "1-4-3-2", "1-12-5-8-3-10-6-7-2-11-4-9", "1-2-7-8-4-5-6-3", "1-3-7-2-6-5-4-8", "1-2-3-4-5-6-7-8-9", "INVALID", "1-2-3-4-5-6-7-8-9-10-11-12", "1-3-2", "1-2-3-4-5-6-7-8", "1-5-4-8-6-3-7-2", "1-4-3-6-2-5", "1-8-7-3-6-5-4-2", "1-6-2-4-3-5", "1-6-5-4-3-2", "1-4-5-2-3-6", "fo32", "fo33", "fo34", "fo35", "fo36", "fo37" +custom firing_order_e 1 bits, U08, @OFFSET@, [0:5], "One Cylinder", "1-3-4-2", "1-2-4-3", "1-3-2-4", "1-5-3-6-2-4", "1-8-4-3-6-5-7-2", "1-2-4-5-3", "1-4-2-5-3-6", "1-2", "1-2-3-4-5-6", "1-2-3", "1-8-7-2-6-5-4-3", "1-5-4-2-6-3-7-8", "1-6-3-2-5-4", "1-10-9-4-3-6-5-8-7_2", "1-7-5-11-3-9-6-12-2-8-4-10", "1-7-4-10-2-8-6-12-3-9-5-11", "1-4-3-2", "1-12-5-8-3-10-6-7-2-11-4-9", "1-2-7-8-4-5-6-3", "1-3-7-2-6-5-4-8", "1-2-3-4-5-6-7-8-9", "INVALID", "1-2-3-4-5-6-7-8-9-10-11-12", "1-3-2", "1-2-3-4-5-6-7-8", "1-5-4-8-6-3-7-2", "1-4-3-6-2-5", "1-8-7-3-6-5-4-2", "1-6-2-4-3-5", "1-6-5-4-3-2", "1-4-5-2-3-6", "1-5-4-8-3-7-2-6", "1-6-5-10-2-7-3-8-4-9" firing_order_e firingOrder; uint8_t vvtBumpAmount;;"deg", 1, 0, -30, 30, 0