FreeEMS  0.2.0-SNAPSHOT-282-g9efc524
fuelAndIgnitionCalcs.h
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2  *
3  * Copyright 2008-2012 Fred Cooke
4  *
5  * This file is part of the FreeEMS project.
6  *
7  * FreeEMS software is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FreeEMS software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
19  *
20  * We ask that if you make any changes to this file you email them upstream to
21  * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22  *
23  * Thank you for choosing FreeEMS to run your engine!
24  */
25 
26 
27 /** @file
28  *
29  * @ingroup allHeaders
30  */
31 
32 
33 /* Header file multiple inclusion protection courtesy eclipse Header Template */
34 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
35 #ifndef FILE_FUELANDIGNITIONCALCS_H_SEEN
36 #define FILE_FUELANDIGNITIONCALCS_H_SEEN
37 
38 
39 #ifdef EXTERN
40 #warning "EXTERN already defined by another header, please sort it out!"
41 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
42 #endif
43 
44 
45 #ifdef FUELANDIGNITIONCALCS_C
46 #define EXTERN
47 #else
48 #define EXTERN extern
49 #endif
50 
51 
53 
54 
55 /* The scaling system was reworked extensively in the commit after:
56  *
57  * c11833092d0b22839287beb2c54787355c9f7adc
58  *
59  * Refer to all changes in the subsequent commit to decipher the docs below!
60  */
61 
62 
63 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Always show your working! &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
64 
65 /* At least, that is what my teachers used to say 15 years ago ;-) */
66 
67 /******************** The full calculations in an unusable form ******************/
68 
69 /* Full calcs on a single line */
70 // final master PW = ((msToTicks * (molarMassOfAir/ molarMassOfAirDivisor) * (airPressure / airPressureDivisor) * (lookedUpVE / (lookedUpVEDivisor * VEpercentageDivisor)) * (perCylinderVolume / perCylinderVolumeDivisor)) / ((universalGasConstant / universalGasConstantDivisor) * (airInletTemp / airInletTempDivisor) * (stoichiometricAFR / stoichiometricAFRDivisor) * (desiredLambda / desiredLambdaDivisor) * (densityOfFuel / (densityOfFuelDivisor * densityOfFuelUnitDivisor)) * (injectorFlow / (injectorFlowUnitDivisor * injectorFlowDivisor))));
71 
72 /* stripped with only variables and divisors left.*/
73 // finalMasterPulseWidth = (((airPressure / airPressureDivisor) * (lookedUpVE / (lookedUpVEDivisor * VEpercentageDivisor))) / ((airInletTemp / airInletTempDivisor) * (desiredLambda / desiredLambdaDivisor) * (densityOfFuel / (densityOfFuelDivisor * densityOfFuelUnitDivisor))));
74 
75 /* stripped with only divisors left.*/
76 // finalMasterPulseWidth = (airInletTempDivisor * oneLambdaDivisor * densityOfFuelTotalDivisor) / (airPressureDivisor * VETotalDivisor) ;
77 
78 /* stripped with only divisors left.*/
79 // divisors = 1;
80 
81 /* totally stripped with no divisors */
82 // finalMasterPulseWidth = ((airPressure * lookedUpVE) / (airInletTemp * desiredLambda * densityOfFuel));
83 
84 /**************************** The constant calculations **************************/
85 
86 // unsigned short constant;
87 /* stripped with only constants and divisors left.*/
88 // constant = ((msToTicks * (molarMassOfAir/ molarMassOfAirDivisor) * (perCylinderVolume / perCylinderVolumeDivisor)) / ((universalGasConstant / universalGasConstantDivisor) * (stoichiometricAFR / stoichiometricAFRDivisor) * (injectorFlow / (injectorFlowUnitDivisor * injectorFlowDivisor))));
89 
90 /* stripped with only divisors left. Top divisors go on bottom and bottom on top! */
91 // constDiv = (universalGasConstantDivisor * stoichiometricAFRDivisor * injectorFlowTotalDivisor) / (molarMassOfAirDivisor * perCylinderVolumeDivisor);
92 // 1310720 = (4096 * 1024 * 1024000 ) / (100 * 32768 );
93 
94 /* stripped with only constants left.*/
95 // constant = ((msToTicks * molarMassOfAir * perCylinderVolume) / (universalGasConstant * stoichiometricAFR * injectorFlow));
96 // constant = ((1250 * 2897 * 16384 ) / (34056 * 15053 * 4096 ));
97 
98 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
99 
100 
101 #undef EXTERN
102 
103 
104 #else
105  /* let us know if we are being untidy with headers */
106  #warning "Header file FUELANDIGNITIONCALCS_H seen before, sort it out!"
107 /* end of the wrapper ifdef from the very top */
108 #endif