derivedVarsGenerator.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EXTERN   extern

Functions

EXTERN void generateDerivedVars (void) FPAGE_FE
 Generate the derived variables.

Detailed Description

Definition in file derivedVarsGenerator.h.


Define Documentation

#define EXTERN   extern

Definition at line 47 of file derivedVarsGenerator.h.


Function Documentation

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.

Author:
Fred Cooke

Definition at line 53 of file derivedVarsGenerator.c.

References CoreVar::AAP, CoreVar::BRV, CoreVar::CHT, CoreVars, currentFuelRPage, CoreVar::DDRPM, DerivedVars, CoreVar::DRPM, DerivedVar::ETE, FALSE, DerivedVar::IDT, DerivedVar::Lambda, lengthOfSecondaryLowPulses, LOAD_NOT_CONFIGURED_CODE, DerivedVar::LoadMain, lookupPagedMainTableCellValue(), lookupTwoDTableUS(), CoreVar::MAP, CoreVar::RPM, seaLevelKPa, sendErrorIfClear(), DerivedVar::sp1, DerivedVar::TFCTotal, timeBetweenSuccessivePrimaryPulses, LongTime::timeLong, LongTime::timeShorts, CoreVar::TPS, TRUE, and DerivedVar::VEMain.

Referenced by main().

00053                           {
00054     /*&&&&&&&&&&&&&&&&&&&& Use basic variables to lookup and calculate derived variables &&&&&&&&&&&&&&&&&&&*/
00055 
00056 
00057     /* Determine load based on options */
00058     if(TRUE){ /* Use MAP as load */
00059         DerivedVars->LoadMain = CoreVars->MAP;
00060     }else if(FALSE){ /* Use TPS as load */
00061         DerivedVars->LoadMain = CoreVars->TPS;
00062     }else if(FALSE){ /* Use AAP corrected MAP as load */
00063         DerivedVars->LoadMain = ((unsigned long)CoreVars->MAP * CoreVars->AAP) / seaLevelKPa;
00064     }else{ /* Default to MAP, but throw error */
00065         DerivedVars->LoadMain = CoreVars->MAP;
00066         /* If anyone is listening, let them know something is wrong */
00067         sendErrorIfClear(LOAD_NOT_CONFIGURED_CODE); // or maybe queue it?
00068     }
00069 
00070 
00071     /* Look up VE with RPM and Load */
00072     DerivedVars->VEMain = lookupPagedMainTableCellValue((mainTable*)&TablesA.VETableMain, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage);
00073 
00074 
00075     /* Look up target Lambda with RPM and Load */
00076     DerivedVars->Lambda = lookupPagedMainTableCellValue((mainTable*)&TablesD.LambdaTable, CoreVars->RPM, DerivedVars->LoadMain, currentFuelRPage);
00077 
00078 
00079     /* Look up injector dead time with battery voltage */
00080     DerivedVars->IDT = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.injectorDeadTimeTable, CoreVars->BRV);
00081 
00082 
00083     /* Look up the engine temperature enrichment percentage with temperature */
00084     DerivedVars->ETE = lookupTwoDTableUS((twoDTableUS*)&TablesA.SmallTablesA.engineTempEnrichmentTablePercent, CoreVars->CHT);
00085     /* TODO The above needs some careful thought put into it around different loads and correction effects. */
00086 
00087 
00088     /* Calculate the Transient Fuel Correction */
00089     if(TRUE /*WWTFC*/){ /* Do ONLY WW correction if enabled */
00090         // Do ww stuff, maybe pre done via RTC/RTI for consistent period?
00091         DerivedVars->TFCTotal = 0; /* TODO replace with real code */
00092     }else if(FALSE /*STDTFC*/){ /* Do any combination of standard approximate methods */
00093         /* Initialse the variable as a base */
00094         DerivedVars->TFCTotal = 0;
00095         /* Based on the rate of change of MAP and some history/taper time */
00096         if(FALSE /*MAPTFC*/){
00097             // Do MAP based
00098             DerivedVars->TFCTotal += 0;
00099         }
00100 
00101         /* Based on the rate of change of TPS and some history/taper time */
00102         if(FALSE /*TPSTFC*/){
00103             // Do TPS based
00104             DerivedVars->TFCTotal += 0;
00105         }
00106 
00107         /* Based on the rate of change of RPM and some history/taper time */
00108         if(FALSE /*RPMTFC*/){
00109             // Do RPM based
00110             DerivedVars->TFCTotal += 0;
00111         }
00112     }else{ /* Default to no correction */
00113         DerivedVars->TFCTotal = 0;
00114         /* Don't throw error as correction may not be required */
00115     }
00116 
00117     // debug
00118 
00119     LongTime breakout2, breakout4;
00120 //  breakout.timeLong = timeBetweenSuccessivePrimaryPulsesBuffer;
00121     breakout2.timeLong = timeBetweenSuccessivePrimaryPulses;
00122 //  breakout3.timeLong = lengthOfSecondaryHighPulses;
00123     breakout4.timeLong = lengthOfSecondaryLowPulses;
00124 
00125 //  DerivedVars->sp1 = Counters.primaryTeethSeen;
00126 //  DerivedVars->sp2 = Counters.secondaryTeethSeen;
00127 
00128 //  DerivedVars->sp3 = breakout4.timeShorts[0];
00129     DerivedVars->sp1 = breakout4.timeShorts[1];
00130 
00131 //  DerivedVars->TFCTotal = *RPMRecord;
00132 
00133 //  CoreVars->DMAP = breakout3.timeShorts[0];
00134 //  CoreVars->DTPS = breakout3.timeShorts[1];
00135 
00136     CoreVars->DRPM = breakout2.timeShorts[0];
00137     CoreVars->DDRPM = breakout2.timeShorts[1];
00138 
00139     /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
00140 }

Here is the call graph for this function:

Generated on Sat Oct 16 21:29:07 2010 for FreeEMS by  doxygen 1.6.3