| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | JSBSim |
| 4 | Author: Jon S. Berndt |
| 5 | Date started: 08/24/00 |
| 6 | ------------- Copyright (C) 2000 Jon S. Berndt ([email protected]) ------------- |
| 7 | |
| 8 | Header: FGTransmission.h |
| 9 | Author: T.Kreitler |
| 10 | Date started: 02/05/12 |
| 11 | |
| 12 | ------------- Copyright (C) 2012 T. Kreitler ([email protected]) ------------- |
| 13 | |
| 14 | This program is free software; you can redistribute it and/or modify it under |
| 15 | the terms of the GNU Lesser General Public License as published by the Free Software |
| 16 | Foundation; either version 2 of the License, or (at your option) any later |
| 17 | version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 21 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 22 | details. |
| 23 | |
| 24 | You should have received a copy of the GNU Lesser General Public License along with |
| 25 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
| 26 | Place - Suite 330, Boston, MA 02111-1307, USA. |
| 27 | |
| 28 | Further information about the GNU Lesser General Public License can also be found on |
| 29 | the world wide web at http://www.gnu.org. |
| 30 | |
| 31 | HISTORY |
| 32 | -------------------------------------------------------------------------------- |
| 33 | 02/05/12 T.Kreitler Created |
| 34 | |
| 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 36 | SENTRY |
| 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 38 | |
| 39 | #ifndef FGTRANSMISSION_H |
| 40 | #define FGTRANSMISSION_H |
| 41 | |
| 42 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 43 | INCLUDES |
| 44 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 45 | |
| 46 | #include "FGJSBBase.h" |
| 47 | #include "FGFDMExec.h" |
| 48 | #include "input_output/FGPropertyManager.h" |
| 49 | |
| 50 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 51 | FORWARD DECLARATIONS |
| 52 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 53 | |
| 54 | namespace JSBSim { |
| 55 | |
| 56 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 57 | CLASS DOCUMENTATION |
| 58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 59 | |
| 60 | /** Utility class that handles power transmission in conjunction with FGRotor. |
| 61 | |
| 62 | This class provides brake, clutch and free-wheel-unit (FWU) functionality |
| 63 | for the rotor model. Also it is responsible for the RPM calculations. |
| 64 | |
| 65 | When the engine is off the brake could be used to slow/hold down a spinning |
| 66 | rotor. The maximum brake power is defined in the rotors' config file. |
| 67 | (Right now there is no checking if the input is in the [0..1] range.) |
| 68 | |
| 69 | The clutch operation is based on a heuristic approach. In the intermediate |
| 70 | state the transfer is proportional to the clutch position. But equal RPM |
| 71 | values are enforced on the thruster and rotor sides when approaching the |
| 72 | closed state. |
| 73 | |
| 74 | The FWU inhibits that the rotor is driving the engine. To do so, the code |
| 75 | just predicts the upcoming FWU state based on current torque conditions. |
| 76 | |
| 77 | Some engines won't work properly when the clutch is open. To keep them |
| 78 | controllable some load must be provided on the engine side (EngineFriction, |
| 79 | aka gear-loss). See the notes under 'Engine issues' in FGRotor. |
| 80 | |
| 81 | <h3>Property tree</h3> |
| 82 | |
| 83 | The following properties are created (with x = your thruster number): |
| 84 | <pre> |
| 85 | propulsion/engine[x]/brake-ctrl-norm |
| 86 | propulsion/engine[x]/free-wheel-transmission |
| 87 | propulsion/engine[x]/clutch-ctrl-norm |
| 88 | </pre> |
| 89 | |
| 90 | <h3>Notes</h3> |
| 91 | |
| 92 | <ul> |
| 93 | <li> EngineFriction is assumed constant, so better orientate at low RPM |
| 94 | values, because piston and turboprop engines don't 'like' high |
| 95 | load at startup.</li> |
| 96 | <li> The model doesn't support backward operation.</li> |
| 97 | <li> And even worse, the torque calculations silently assume a minimal |
| 98 | RPM value of approx. 1.</li> |
| 99 | </ul> |
| 100 | |
| 101 | */ |
| 102 | |
| 103 | |
| 104 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 105 | CLASS DECLARATION |
| 106 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 107 | |
| 108 | class FGTransmission : public FGJSBBase { |
| 109 | |
| 110 | public: |
| 111 | /** Constructor for FGTransmission. |
| 112 | @param exec a pointer to the main executive object |
| 113 | @param num the number of the thruster that uses this object |
| 114 | @param dt simulation delta T */ |
| 115 | FGTransmission(FGFDMExec *exec, int num, double dt); |
| 116 | |
| 117 | /// Destructor for FGTransmission |
| 118 | ~FGTransmission(); |
| 119 | |
| 120 | void Calculate(double EnginePower, double ThrusterTorque, double dt); |
| 121 | |
| 122 | void SetMaxBrakePower(double x) {MaxBrakePower=x;} |
| 123 | double GetMaxBrakePower() const {return MaxBrakePower;} |
| 124 | void SetEngineFriction(double x) {EngineFriction=x;} |
| 125 | double GetEngineFriction() const {return EngineFriction;} |
| 126 | void SetEngineMoment(double x) {EngineMoment=x;} |
| 127 | double GetEngineMoment() const {return EngineMoment;} |
| 128 | void SetThrusterMoment(double x) {ThrusterMoment=x;} |
| 129 | double GetThrusterMoment() const {return ThrusterMoment;} |
| 130 | |
| 131 | double GetFreeWheelTransmission() const {return FreeWheelTransmission;} |
| 132 | void SetEngineRPM(double x) {EngineRPM=x;} |
| 133 | double GetEngineRPM() {return EngineRPM;} |
| 134 | void SetThrusterRPM(double x) {ThrusterRPM=x;} |
| 135 | double GetThrusterRPM() {return ThrusterRPM;} |
| 136 | |
| 137 | double GetBrakeCtrlNorm() const {return BrakeCtrlNorm;} |
| 138 | void SetBrakeCtrlNorm(double x) {BrakeCtrlNorm=x;} |
| 139 | double GetClutchCtrlNorm() const {return ClutchCtrlNorm;} |
| 140 | void SetClutchCtrlNorm(double x) {ClutchCtrlNorm=x;} |
| 141 | |
| 142 | private: |
| 143 | bool BindModel(int num); |
| 144 | void Debug(int from); |
| 145 | |
| 146 | inline double omega_to_rpm(double w) { |
| 147 | return w * 9.54929658551372014613302580235; // omega/(2.0*PI) * 60.0 |
| 148 | } |
| 149 | inline double rpm_to_omega(double r) { |
| 150 | return r * 0.104719755119659774615421446109; // (rpm/60.0)*2.0*PI |
| 151 | } |
| 152 | |
| 153 | Filter FreeWheelLag; |
| 154 | double FreeWheelTransmission; // state, 0: free, 1:locked |
| 155 | |
| 156 | double ThrusterMoment; |
| 157 | double EngineMoment; // estimated MOI of gear and engine, influences acceleration |
| 158 | double EngineFriction; // estimated friction in gear and possibly engine |
| 159 | |
| 160 | double ClutchCtrlNorm; |
| 161 | double BrakeCtrlNorm; |
| 162 | double MaxBrakePower; |
| 163 | |
| 164 | double EngineRPM; |
| 165 | double ThrusterRPM; |
| 166 | FGPropertyManager* PropertyManager; |
| 167 | |
| 168 | }; |
| 169 | |
| 170 | } |
| 171 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 172 | #endif |