derivedVarsGenerator.c File Reference

#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 Documentation

#define DERIVEDVARSGENERATOR_C

Definition at line 24 of file derivedVarsGenerator.c.


Function Documentation

void generateDerivedVars ( void   ) 

Definition at line 31 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().

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 = CoreVars->MAP;
00038         }else if(FALSE){ /* Use TPS as load */
00039                 DerivedVars->LoadMain = CoreVars->TPS;
00040         }else if(FALSE){ /* Use AAP corrected MAP as load */
00041                 DerivedVars->LoadMain = ((unsigned long)CoreVars->MAP * CoreVars->AAP) / seaLevelKPa;
00042         }else{ /* Default to MAP, but throw error */
00043                 DerivedVars->LoadMain = CoreVars->MAP;
00044                 /* If anyone is listening, let them know something is wrong */
00045                 sendErrorIfClear(LOAD_NOT_CONFIGURED_CODE); // or maybe queue it?
00046         }
00047 
00048 
00049         /* Look up VE with RPM and Load */
00050         DerivedVars->VEMain = lookupPagedMainTableCellValue((mainTable*)&TablesA.VETableMain, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage);
00051 
00052 
00053         /* Look up target Lambda with RPM and Load */
00054         DerivedVars->Lambda = lookupPagedMainTableCellValue((mainTable*)&TablesD.LambdaTable, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage);
00055 
00056 
00057         /* Look up injector dead time with battery voltage */
00058         DerivedVars->IDT = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.injectorDeadTimeTable, CoreVars->BRV);
00059 
00060 
00061         /* Calculate the engine temperature enrichment */
00062 //      unsigned short localETEPercentage = lookupTwoDTableUS(&engineTempEnrichmentTable, CoreVars.CHT);
00063 //      DerivedVars->ETE = ((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 = 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 = 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 += 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 += 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 += 0;
00090                 }
00091         }else{ /* Default to no correction */
00092                 DerivedVars->TFCTotal = 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:


Generated on Mon Dec 22 21:29:39 2008 for freeems by  doxygen 1.5.2