rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
firing_order.h File Reference

Functions

enum __attribute__ ((__packed__))
 
size_t getCylinderNumberAtIndex (size_t cylinderIndex)
 

Variables

 firing_order_e
 

Function Documentation

◆ __attribute__()

enum __attribute__ ( (__packed__)  )

thank you https://www.ingenieriaymecanicaautomotriz.com/firing-order-its-purpose-and-order-in-different-numbers-of-cylinders/

Definition at line 1 of file firing_order.h.

17 {
18 FO_1 = 0,
19
20 // 2 cylinder
21 FO_1_2 = 8,
22
23 // 3 cylinder
24 FO_1_2_3 = 10,
25 FO_1_3_2 = 24,
26
27 // 4 cylinder
28 FO_1_3_4_2 = 1, // typical inline 4
29 FO_1_2_4_3 = 2,
30 FO_1_3_2_4 = 3, // for example horizontally opposed engine
31 FO_1_4_3_2 = 17, // for example VW aircooled boxer engine
32
33 // 5 cylinder
34 FO_1_2_4_5_3 = 6,
35
36 // 6 cylinder
37 FO_1_5_3_6_2_4 = 4, // VAG VR6, Straight-6, Opel Omega A
38 FO_1_6_5_4_3_2 = 30, // GM 3800 engine
39 FO_1_4_5_2_3_6 = 31, // Chevrolet Corvair
40 FO_1_4_2_5_3_6 = 7, // Mercedes-Benz M104 engine
41 FO_1_2_3_4_5_6 = 9, // all Nissan v6, GM 60-Degree V6 engine
42 FO_1_6_3_2_5_4 = 13, // EG33
43 FO_1_4_3_6_2_5 = 27, // VAG v6 different from VAG VR6
44 FO_1_6_2_4_3_5 = 29, // Some 911
45
46
47 // todo: one day we shall support 7 cylinder radial, probably not before one actually approaches us
48 // 1-3-5-7-2-4-6 7-cylinder single row radial engine
49
50 // 8 cylinder
51 FO_1_8_4_3_6_5_7_2 = 5, // SBC, Dodge
52 FO_1_8_7_2_6_5_4_3 = 11, // GM Gen. 3, 4, 5 LT1
53 FO_1_5_4_2_6_3_7_8 = 12, // Ford Mustang
54 FO_1_2_7_8_4_5_6_3 = 19,
55 FO_1_3_7_2_6_5_4_8 = 20, // Ford 5.0 HO and 351W
56 FO_1_2_3_4_5_6_7_8 = 25, // linearly incrementing, for V8 testing
57 FO_1_5_4_8_6_3_7_2 = 26, // Audi 4.2 40v V8
58 FO_1_5_4_8_3_7_2_6 = 32, // Ford Voodoo
59 FO_1_8_7_3_6_5_4_2 = 28, // VH41DE (Japaneese Y32 Variant)
60 FO_1_8_6_2_7_3_4_5 = 34, // Ferrari-Maserati F136
61
62 // 9 cylinder - for instance radial :)
63 // PS: Matt says that 9cyl is actually 1-3-5-7-9-2-4-6-8 or 1-8-6-4-2-9-7-5-3 for reverse rotation
64 FO_1_2_3_4_5_6_7_8_9 = 21,
65
66 // 10 cylinder
67 FO_1_10_9_4_3_6_5_8_7_2 = 14, // dodge and viper ram v10
68 FO_1_6_5_10_2_7_3_8_4_9 = 33, // BMW S85, also Audi 5.2 R8 and huracan GDI
69
70 // 12 cylinder
71 FO_1_7_5_11_3_9_6_12_2_8_4_10 = 15, // bmw M70 & M73, Ferrari 456M GT V12
72 FO_1_7_4_10_2_8_6_12_3_9_5_11 = 16, // Lamborghini Diablo VT, typical rusEfi use-case
73 FO_1_12_5_8_3_10_6_7_2_11_4_9 = 18, // VAG W12, M120
74 // 1,12,7,6,3,10,11,2,5,8,9,4 Rolls-Royce Merlin
75 // 1,12,4,9,2,11,6,7,3,10,5,8 Lamborghini Aventador
76 FO_1_2_3_4_5_6_7_8_9_10_11_12 = 23, // mostly for hardware testing purposes
77
78
79 // 16 cylinder
80 // unfortunately not supported by default firmware because MAX_CYLINDER_COUNT=12 by default
81 FO_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10 = 22, // WR16
82
83 // next value to use: 35
84
firing_order_e

◆ getCylinderNumberAtIndex()

size_t getCylinderNumberAtIndex ( size_t  index)
Parameters
cylinderIndexQueried position in the firing order. 0 means the first cylinder to fire, 1 means second, etc. Maximum cylinderCount - 1.
Returns
The cylinder number in the requested position, from 0 to cylindersCount - 1. For example, getCylinderNumberAtIndex(2) means the 3rd cylinder to fire, and on a 1342 4-cyl will return 3, indicating cylinder 4.
Parameters
indexfrom zero to cylindersCount - 1
Returns
cylinderId from one to cylindersCount

Definition at line 229 of file firing_order.cpp.

229 {
230 const size_t firingOrderLength = getFiringOrderLength();
231
232 if (firingOrderLength < 1 || firingOrderLength > MAX_CYLINDER_COUNT) {
233 firmwareError(ObdCode::CUSTOM_FIRING_LENGTH, "fol %d", firingOrderLength);
234 return 0;
235 }
236 if (engineConfiguration->cylindersCount != firingOrderLength) {
237 // May 2020 this somehow still happens with functional tests, maybe race condition?
238 firmwareError(ObdCode::CUSTOM_OBD_WRONG_FIRING_ORDER, "Wrong cyl count for firing order, expected %d cylinders, got %d", firingOrderLength, engineConfiguration->cylindersCount);
239 return 0;
240 }
241
242 if (index >= firingOrderLength) {
243 // May 2020 this somehow still happens with functional tests, maybe race condition?
244 warning(ObdCode::CUSTOM_ERR_6686, "firing order index %d", index);
245 return 0;
246 }
247
248 if (auto firingOrderTable = getFiringOrderTable()) {
249 return firingOrderTable[index] - 1;
250 } else {
251 // error already reported
252 return 0;
253 }
254}
static constexpr engine_configuration_s * engineConfiguration
bool warning(ObdCode code, const char *fmt,...)
void firmwareError(ObdCode code, const char *fmt,...)
static const uint8_t * getFiringOrderTable()
static size_t getFiringOrderLength()
@ CUSTOM_ERR_6686
@ CUSTOM_FIRING_LENGTH
@ CUSTOM_OBD_WRONG_FIRING_ORDER

Referenced by prepareCylinderIgnitionSchedule(), InjectionEvent::update(), and EngineCylinders::updateCylinders().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ firing_order_e

firing_order_e

Definition at line 85 of file firing_order.h.

Referenced by setFiringOrder().

Go to the source code of this file.