Go to the source code of this file.
Defines | |
#define | EXTERN extern |
Functions | |
EXTERN void | generateDerivedVars (void) FPAGE_FE |
Generate the derived variables. |
Definition in file derivedVarsGenerator.h.
#define EXTERN extern |
Definition at line 44 of file derivedVarsGenerator.h.
EXTERN void generateDerivedVars | ( | void | ) |
Generate the derived variables.
This function uses the core variables to lookup and calculate further second order variables such as load, VE, Lamdda, Transient fuel correction, engine temperature enrichment, Injector dead time, etc.
Definition at line 50 of file derivedVarsGenerator.c.
References CoreVar::AAP, CoreVar::BRV, CoreVars, currentFuelRPage, DerivedVars, FALSE, DerivedVar::IDT, DerivedVar::Lambda, LOAD_NOT_CONFIGURED_CODE, DerivedVar::LoadMain, lookupPagedMainTableCellValue(), lookupTwoDTableUS(), CoreVar::MAP, CoreVar::RPM, seaLevelKPa, sendErrorIfClear(), DerivedVar::TFCTotal, CoreVar::TPS, TRUE, and DerivedVar::VEMain.
Referenced by main().
00050 { 00051 /*&&&&&&&&&&&&&&&&&&&& Use basic variables to lookup and calculate derived variables &&&&&&&&&&&&&&&&&&&*/ 00052 00053 00054 /* Determine load based on options */ 00055 if(TRUE){ /* Use MAP as load */ 00056 DerivedVars->LoadMain = CoreVars->MAP; 00057 }else if(FALSE){ /* Use TPS as load */ 00058 DerivedVars->LoadMain = CoreVars->TPS; 00059 }else if(FALSE){ /* Use AAP corrected MAP as load */ 00060 DerivedVars->LoadMain = ((unsigned long)CoreVars->MAP * CoreVars->AAP) / seaLevelKPa; 00061 }else{ /* Default to MAP, but throw error */ 00062 DerivedVars->LoadMain = CoreVars->MAP; 00063 /* If anyone is listening, let them know something is wrong */ 00064 sendErrorIfClear(LOAD_NOT_CONFIGURED_CODE); // or maybe queue it? 00065 } 00066 00067 00068 /* Look up VE with RPM and Load */ 00069 DerivedVars->VEMain = lookupPagedMainTableCellValue((mainTable*)&TablesA.VETableMain, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage); 00070 00071 00072 /* Look up target Lambda with RPM and Load */ 00073 DerivedVars->Lambda = lookupPagedMainTableCellValue((mainTable*)&TablesD.LambdaTable, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage); 00074 00075 00076 /* Look up injector dead time with battery voltage */ 00077 DerivedVars->IDT = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.injectorDeadTimeTable, CoreVars->BRV); 00078 00079 00080 /* Calculate the engine temperature enrichment */ 00081 // unsigned short localETEPercentage = lookupTwoDTableUS(&engineTempEnrichmentTable, CoreVars.CHT); 00082 // DerivedVars->ETE = ((unsigned long)finalMasterTotalEndPW * localETEPercentage) / oneHundredPercentETE; 00083 /* TODO The above needs some careful thought put into it around different loads and correction effects. */ 00084 00085 00086 /* Calculate the Transient Fuel Correction */ 00087 if(TRUE /*WWTFC*/){ /* Do ONLY WW correction if enabled */ 00088 // Do ww stuff, maybe pre done via RTC/RTI for consistent period? 00089 DerivedVars->TFCTotal = 0; /* TODO replace with real code */ 00090 }else if(FALSE /*STDTFC*/){ /* Do any combination of standard approximate methods */ 00091 /* Initialse the variable as a base */ 00092 DerivedVars->TFCTotal = 0; 00093 /* Based on the rate of change of MAP and some history/taper time */ 00094 if(FALSE /*MAPTFC*/){ 00095 // Do MAP based 00096 DerivedVars->TFCTotal += 0; 00097 } 00098 00099 /* Based on the rate of change of TPS and some history/taper time */ 00100 if(FALSE /*TPSTFC*/){ 00101 // Do TPS based 00102 DerivedVars->TFCTotal += 0; 00103 } 00104 00105 /* Based on the rate of change of RPM and some history/taper time */ 00106 if(FALSE /*RPMTFC*/){ 00107 // Do RPM based 00108 DerivedVars->TFCTotal += 0; 00109 } 00110 }else{ /* Default to no correction */ 00111 DerivedVars->TFCTotal = 0; 00112 /* Don't throw error as correction may not be required */ 00113 } 00114 00115 00116 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ 00117 }