| 1 | // Based on original patch from Ian Dall <[email protected]> |
| 2 | // Date: Wed Jan 11 22:35:24 2012 +1030 |
| 3 | // #595 Support for electric motors in YASim (patch provided) |
| 4 | // Improved by ThunderFly s.r.o. <[email protected]> |
| 5 | //////////////////////////////////////////////////////// |
| 6 | |
| 7 | #ifndef _ELECTRICENGINE_HPP |
| 8 | #define _ELECTRICENGINE_HPP |
| 9 | |
| 10 | #include "Engine.hpp" |
| 11 | |
| 12 | namespace yasim { |
| 13 | |
| 14 | class ElectricEngine : public Engine { |
| 15 | public: |
| 16 | virtual ElectricEngine* isElectricEngine() { return this; } |
| 17 | |
| 18 | // Initializes an engine from known "takeoff" parameters. |
| 19 | // voltage - power supply voltage applied to the motor in volts |
| 20 | // Kv - electric motor velocity constant in RPM/1V |
| 21 | // Rm - engine winding resistance in Ohms |
| 22 | ElectricEngine(float voltage, float Kv, float Rm); |
| 23 | |
| 24 | virtual void calc(float pressure, float temp, float speed); |
| 25 | virtual void stabilize() { return; }; |
| 26 | virtual void integrate(float dt) { return; }; |
| 27 | virtual float getTorque() { return _torque; }; |
| 28 | virtual float getFuelFlow() { return 0; }; |
| 29 | virtual float getOmega0() { return _omega0; }; |
| 30 | |
| 31 | private: |
| 32 | // Static configuration: |
| 33 | float _omega0 {0}; // Reference engine speed |
| 34 | float _minThrottle {0.05f}; // minimum throttle [0:1] |
| 35 | float _K {0}; // _K = Eb/omega = tau/Ia |
| 36 | float _Rm {1}; // engine windig resistence |
| 37 | |
| 38 | // Runtime state/output: |
| 39 | float _torque {0}; // actual torque of the motor |
| 40 | float _torque0 {1}; // nominal operating torque |
| 41 | }; |
| 42 | |
| 43 | }; // namespace yasim |
| 44 | #endif // _ELECTRICENGINE_HPP |