From 304ff216971aec2c7e852e2a4fe456f393663608 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 13 Feb 2002 14:35:10 +0000 Subject: [PATCH] Latest JSBSim fixes, including Dave Luff's mixture improvements for the JSBSim piston-engine model. --- src/FDM/JSBSim/FGPiston.cpp | 29 +++++++++++++------- src/FDM/JSBSim/filtersjb/FGFCSComponent.h | 2 +- src/FDM/JSBSim/filtersjb/FGSummer.cpp | 8 ++++++ src/FDM/JSBSim/filtersjb/FGSummer.h | 32 +++++++++++++++++++---- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/FDM/JSBSim/FGPiston.cpp b/src/FDM/JSBSim/FGPiston.cpp index ea54f7c20..e96146cb9 100644 --- a/src/FDM/JSBSim/FGPiston.cpp +++ b/src/FDM/JSBSim/FGPiston.cpp @@ -154,19 +154,23 @@ double FGPiston::Calculate(double PowerRequired) IAS = Auxiliary->GetVcalibratedKTS(); - if (Mixture >= 0.3) { doEngineStartup(); doManifoldPressure(); doAirFlow(); doFuelFlow(); - doEnginePower(); + + //Now that the fuel flow is done check if the mixture is too lean to run the engine + //Assume lean limit at 22 AFR for now - thats a thi of 0.668 + //This might be a bit generous, but since there's currently no audiable warning of impending + //cutout in the form of misfiring and/or rough running its probably reasonable for now. + if(equivalence_ratio < 0.668) + Running = false; + + doEnginePower(); doEGT(); doCHT(); doOilTemperature(); doOilPressure(); - } else { - HP = 0; - } PowerAvailable = (HP * hptoftlbssec) - PowerRequired; return PowerAvailable; @@ -227,11 +231,16 @@ void FGPiston::doEngineStartup(void) if ((!Running) && (spark) && (fuel)) { // start the engine if revs high enough - if ((RPM > 450) && (crank_counter > 175)) { - // For now just instantaneously start but later we should maybe crank for - // a bit - Running = true; - // RPM = 600; + if(Cranking) { + if ((RPM > 450) && (crank_counter > 175)) { + //Add a little delay to startup on the starter + Running = true; + } + } else { + if (RPM > 450) { + Running = true; + //This allows us to in-air start when windmilling + } } } diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h index 8a6ec33f8..c8df597b4 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h @@ -104,7 +104,7 @@ public: protected: /// Pilot/Aircraft, FCS, Autopilot inputs - enum eInputType {itPilotAC, itFCS, itAP} InputType; + enum eInputType {itPilotAC, itFCS, itAP, itBias} InputType; FGFCS* fcs; string Type; string Name; diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.cpp b/src/FDM/JSBSim/filtersjb/FGSummer.cpp index 3b9de8846..dba37c458 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSummer.cpp @@ -54,6 +54,7 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), eParam tmpInputIndex; clip = false; + Bias = 0.0; InputIndices.clear(); InputTypes.clear(); @@ -73,6 +74,10 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), tmpInputIndex = fcs->GetState()->GetParameterIndex(token); InputIndices.push_back(tmpInputIndex); InputTypes.push_back(itPilotAC); + } else if (token.find(".") != token.npos) { // bias + *AC_cfg >> Bias; + InputIndices.push_back((eParam)0); + InputTypes.push_back(itBias); } else { *AC_cfg >> tmpInputIndex; InputIndices.push_back(tmpInputIndex); @@ -119,6 +124,9 @@ bool FGSummer::Run(void ) case itFCS: Output += fcs->GetComponentOutput(InputIndices[idx]); break; + case itBias: + Output += Bias; + break; } } diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.h b/src/FDM/JSBSim/filtersjb/FGSummer.h index f4234897c..2ff7674a6 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.h +++ b/src/FDM/JSBSim/filtersjb/FGSummer.h @@ -26,10 +26,6 @@ HISTORY -------------------------------------------------------------------------------- -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -COMMENTS, REFERENCES, and NOTES -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SENTRY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -57,11 +53,31 @@ INCLUDES #include "../FGConfigFile.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -DEFINES +DEFINITIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #define ID_SUMMER "$Id$" +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +FORWARD DECLARATIONS +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CLASS DOCUMENTATION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +/** Models a flight control system summing component. + The Summer component sums multiple inputs. These can be pilot control inputs, + state variables, or even floating point numbers (e.g. for a bias). + @author Jon S. Berndt + @version $Id$ + @see +*/ + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DECLARATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -69,9 +85,14 @@ CLASS DECLARATION class FGSummer : public FGFCSComponent { public: + /** Constructor. + @param fcs a pointer to the parent FGFCS object. + @param AC_cfg a pointer to the configuration file object. */ FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg); + /// Destructor ~FGSummer(); + /// The execution method for this FCS component. bool Run(void); private: @@ -80,6 +101,7 @@ private: vector InputTypes; bool clip; double clipmin,clipmax; + double Bias; void Debug(int from); }; -- 2.39.5