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