coding style improvements according to ticket #595.
This commit is contained in:
parent
cc8b981301
commit
2247badaa6
3 changed files with 18 additions and 15 deletions
|
@ -2,6 +2,7 @@
|
|||
// Based on original patch from Ian Dall <ian@beware.dropbear.id.au>
|
||||
// Date: Wed Jan 11 22:35:24 2012 +1030
|
||||
// #595 Support for electric motors in YASim (patch provided)
|
||||
// Improved by ThunderFly s.r.o. <info@thunderfly.cz>
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#include "Atmosphere.hpp"
|
||||
|
@ -9,14 +10,14 @@
|
|||
#include "ElectricEngine.hpp"
|
||||
namespace yasim {
|
||||
|
||||
// explain parameters!
|
||||
ElectricEngine::ElectricEngine(float V, float Kv, float Rm) :
|
||||
// idealized DC electric motor model
|
||||
ElectricEngine::ElectricEngine(float voltage, float Kv, float Rm) :
|
||||
_Rm(Rm)
|
||||
{
|
||||
_running = false;
|
||||
_omega0 = V * Kv;
|
||||
_K = 1/Kv;
|
||||
_torque0 = _K * _K * _omega0 / _Rm;
|
||||
_omega0 = voltage * Kv; // calculate RPM of unloaded motor
|
||||
_K = 1/Kv; // calculate reciprocal value of motor velocity constant
|
||||
_torque0 = _K * _K * _omega0 / _Rm; // rough estimate of full load torque valid for DC electric motor invalid for BLDC
|
||||
}
|
||||
|
||||
void ElectricEngine::calc(float pressure, float temp, float omega)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Based on original patch from Ian Dall <ian@beware.dropbear.id.au>
|
||||
// Date: Wed Jan 11 22:35:24 2012 +1030
|
||||
// #595 Support for electric motors in YASim (patch provided)
|
||||
// Improved by ThunderFly s.r.o. <info@thunderfly.cz>
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _ELECTRICENGINE_HPP
|
||||
|
@ -15,8 +16,10 @@ public:
|
|||
virtual ElectricEngine* isElectricEngine() { return this; }
|
||||
|
||||
// Initializes an engine from known "takeoff" parameters.
|
||||
// explain parameters: physical meaning? which dimensions (volts, meters, kilogram...)?
|
||||
ElectricEngine(float V, float Kv, float Rm);
|
||||
// voltage - power supply voltage applied to the motor in volts
|
||||
// Kv - electric motor velocity constant in RPM/1V
|
||||
// Rm - engine winding resistance in Ohms
|
||||
ElectricEngine(float voltage, float Kv, float Rm);
|
||||
|
||||
virtual void calc(float pressure, float temp, float speed);
|
||||
virtual void stabilize() { return; };
|
||||
|
@ -30,11 +33,11 @@ private:
|
|||
float _omega0 {0}; // Reference engine speed
|
||||
float _minThrottle {0.05f}; // minimum throttle [0:1]
|
||||
float _K {0}; // _K = Eb/omega = tau/Ia
|
||||
float _Rm {1};
|
||||
float _Rm {1}; // engine windig resistence
|
||||
|
||||
// Runtime state/output:
|
||||
float _torque {0};
|
||||
float _torque0 {1};
|
||||
float _torque {0}; // actual torque of the motor
|
||||
float _torque0 {1}; // nominal operating torque
|
||||
};
|
||||
|
||||
}; // namespace yasim
|
||||
|
|
|
@ -799,11 +799,10 @@ void FGFDM::parseTurbineEngine(const XMLAttributes* a)
|
|||
|
||||
void FGFDM::parseElectricEngine(const XMLAttributes* a)
|
||||
{
|
||||
//Kv is expected to be given as RPM in XML
|
||||
float Kv = attrf(a, "Kv") * RPM2RAD;
|
||||
float V = attrf(a, "V");
|
||||
float Rm = attrf(a, "Rm");
|
||||
ElectricEngine* eng = new ElectricEngine(V, Kv, Rm);
|
||||
float Kv = attrf(a, "Kv") * RPM2RAD; //Kv is expected to be given as RPM per volt in XML
|
||||
float voltage = attrf(a, "voltage"); // voltage applied at the motor windings in volts
|
||||
float Rm = attrf(a, "Rm"); // winding resistance in Ohms
|
||||
ElectricEngine* eng = new ElectricEngine(voltage, Kv, Rm);
|
||||
|
||||
((PropEngine*)_currObj)->setEngine(eng);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue