00001 /* FreeEMS - the open source engine management system 00002 00003 Copyright 2008 Fred Cooke 00004 00005 This file is part of the FreeEMS project. 00006 00007 FreeEMS software is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 FreeEMS software is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ 00019 00020 We ask that if you make any changes to this file you email them upstream to 00021 us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! 00022 00023 Thank you for choosing FreeEMS to run your engine! */ 00024 00025 00031 /* Header file multiple inclusion protection courtesy eclipse Header Template */ 00032 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */ 00033 #ifndef FILE_FUELANDIGNITIONCALCS_H_SEEN 00034 #define FILE_FUELANDIGNITIONCALCS_H_SEEN 00035 00036 00037 #ifdef EXTERN 00038 #warning "EXTERN already defined by another header, please sort it out!" 00039 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */ 00040 #endif 00041 00042 00043 #ifdef FUELANDIGNITIONCALCS_C 00044 #define EXTERN 00045 #else 00046 #define EXTERN extern 00047 #endif 00048 00049 00050 EXTERN void calculateFuelAndIgnition(void) FPAGE_FE; 00051 00052 00053 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Always show your working! &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ 00054 00055 /* At least, that is what my teachers used to say 15 years ago ;-) */ 00056 00057 /******************** The full calculations in an unusable form ******************/ 00058 00059 /* Full calcs on a single line */ 00060 // 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)))); 00061 00062 /* stripped with only variables and divisors left.*/ 00063 // finalMasterPulseWidth = (((airPressure / airPressureDivisor) * (lookedUpVE / (lookedUpVEDivisor * VEpercentageDivisor))) / ((airInletTemp / airInletTempDivisor) * (desiredLambda / desiredLambdaDivisor) * (densityOfFuel / (densityOfFuelDivisor * densityOfFuelUnitDivisor)))); 00064 00065 /* stripped with only divisors left.*/ 00066 // finalMasterPulseWidth = (airInletTempDivisor * oneLambdaDivisor * densityOfFuelTotalDivisor) / (airPressureDivisor * VETotalDivisor) ; 00067 00068 /* stripped with only divisors left.*/ 00069 // divisors = 1; 00070 00071 /* totally stripped with no divisors */ 00072 // finalMasterPulseWidth = ((airPressure * lookedUpVE) / (airInletTemp * desiredLambda * densityOfFuel)); 00073 00074 /**************************** The constant calculations **************************/ 00075 00076 // unsigned short constant; 00077 /* stripped with only constants and divisors left.*/ 00078 // constant = ((msToTicks * (molarMassOfAir/ molarMassOfAirDivisor) * (perCylinderVolume / perCylinderVolumeDivisor)) / ((universalGasConstant / universalGasConstantDivisor) * (stoichiometricAFR / stoichiometricAFRDivisor) * (injectorFlow / (injectorFlowUnitDivisor * injectorFlowDivisor)))); 00079 00080 /* stripped with only divisors left. Top divisors go on bottom and bottom on top! */ 00081 // constDiv = (universalGasConstantDivisor * stoichiometricAFRDivisor * injectorFlowTotalDivisor) / (molarMassOfAirDivisor * perCylinderVolumeDivisor); 00082 //1310720= (4096 * 1024 * 1024000 ) / (100 * 32768 ); 00083 00084 /* stripped with only constants left.*/ 00085 // constant = ((msToTicks * molarMassOfAir * perCylinderVolume) / (universalGasConstant * stoichiometricAFR * injectorFlow)); 00086 //nstant = ((1250 * 2897 * 16384 ) / (34056 * 15053 * 4096 )); 00087 00088 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ 00089 00090 00091 #undef EXTERN 00092 00093 00094 #else 00095 /* let us know if we are being untidy with headers */ 00096 #warning "Header file FUELANDIGNITIONCALCS_H seen before, sort it out!" 00097 /* end of the wrapper ifdef from the very top */ 00098 #endif