#include "inc/freeEMS.h"
#include "inc/commsCore.h"
#include "inc/tableLookup.h"
#include "inc/derivedVarsGenerator.h"
Include dependency graph for derivedVarsGenerator.c:
Go to the source code of this file.
Defines | |
#define | DERIVEDVARSGENERATOR_C |
Functions | |
void | generateDerivedVars () |
#define DERIVEDVARSGENERATOR_C |
Definition at line 24 of file derivedVarsGenerator.c.
void generateDerivedVars | ( | void | ) |
Definition at line 31 of file derivedVarsGenerator.c.
References CoreVar::AAP, CoreVar::BRV, CoreVars, currentFuelRPage, DerivedVars, FALSE, DerivedVar::IDT, DerivedVar::Lambda, DerivedVar::LoadMain, lookupPagedMainTableCellValue(), lookupTwoDTableUS(), CoreVar::MAP, mathInternalBank, CoreVar::RPM, seaLevelKPa, DerivedVar::TFCTotal, CoreVar::TPS, TRUE, and DerivedVar::VEMain.
Referenced by main().
00031 { 00032 /*&&&&&&&&&&&&&&&&&&&& Use basic variables to lookup and calculate derived variables &&&&&&&&&&&&&&&&&&&*/ 00033 00034 00035 /* Determine load based on options */ 00036 if(TRUE){ /* Use MAP as load */ 00037 DerivedVars.LoadMain[mathInternalBank] = CoreVars.MAP[mathInternalBank]; 00038 }else if(FALSE){ /* Use TPS as load */ 00039 DerivedVars.LoadMain[mathInternalBank] = CoreVars.TPS[mathInternalBank]; 00040 }else if(FALSE){ /* Use AAP corrected MAP as load */ 00041 DerivedVars.LoadMain[mathInternalBank] = ((unsigned long)CoreVars.MAP[mathInternalBank] * CoreVars.AAP[mathInternalBank]) / seaLevelKPa; 00042 }else{ /* Default to MAP, but throw error */ 00043 DerivedVars.LoadMain[mathInternalBank] = CoreVars.MAP[mathInternalBank]; 00044 /* If anyone is listening, let them know something is wrong */ 00045 // sendError(LOAD_NOT_CONFIGURED_CODE); // or maybe queue it? 00046 } 00047 00048 00049 /* Look up VE with RPM and Load */ 00050 DerivedVars.VEMain[mathInternalBank] = lookupPagedMainTableCellValue((mainTable*)&TablesA.VETableMain, CoreVars.RPM[mathInternalBank], DerivedVars.LoadMain[mathInternalBank], currentFuelRPage); 00051 00052 00053 /* Look up target Lambda with RPM and Load */ 00054 DerivedVars.Lambda[mathInternalBank] = lookupPagedMainTableCellValue((mainTable*)&TablesD.LambdaTable, CoreVars.RPM[mathInternalBank], DerivedVars.LoadMain[mathInternalBank], currentFuelRPage); 00055 00056 00057 /* Look up injector dead time with battery voltage */ 00058 DerivedVars.IDT[mathInternalBank] = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.injectorDeadTimeTable, CoreVars.BRV[mathInternalBank]); 00059 00060 00061 /* Calculate the engine temperature enrichment */ 00062 // unsigned short localETEPercentage = lookupTwoDTableUS(&engineTempEnrichmentTable, CoreVars.CHT[mathInternalBank]); 00063 // DerivedVars.ETE[mathInternalBank] = ((unsigned long)finalMasterTotalEndPW * localETEPercentage) / oneHundredPercentETE; 00064 /* TODO The above needs some careful thought put into it around different loads and correction effects. */ 00065 00066 00067 /* Calculate the Transient Fuel Correction */ 00068 if(TRUE /*WWTFC*/){ /* Do ONLY WW correction if enabled */ 00069 // Do ww stuff, maybe pre done via RTC/RTI for consistent period? 00070 DerivedVars.TFCTotal[mathInternalBank] = 0; /* TODO replace with real code */ 00071 }else if(FALSE /*STDTFC*/){ /* Do any combination of standard approximate methods */ 00072 /* Initialse the variable as a base */ 00073 DerivedVars.TFCTotal[mathInternalBank] = 0; 00074 /* Based on the rate of change of MAP and some history/taper time */ 00075 if(FALSE /*MAPTFC*/){ 00076 // Do MAP based 00077 DerivedVars.TFCTotal[mathInternalBank] += 0; 00078 } 00079 00080 /* Based on the rate of change of TPS and some history/taper time */ 00081 if(FALSE /*TPSTFC*/){ 00082 // Do TPS based 00083 DerivedVars.TFCTotal[mathInternalBank] += 0; 00084 } 00085 00086 /* Based on the rate of change of RPM and some history/taper time */ 00087 if(FALSE /*RPMTFC*/){ 00088 // Do RPM based 00089 DerivedVars.TFCTotal[mathInternalBank] += 0; 00090 } 00091 }else{ /* Default to no correction */ 00092 DerivedVars.TFCTotal[mathInternalBank] = 0; 00093 /* Don't throw error as correction may not be required */ 00094 } 00095 00096 00097 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ 00098 }
Here is the call graph for this function: