53#include "FGBrushLessDCMotor.h"
54#include "FGPropeller.h"
55#include "input_output/FGXMLElement.h"
76 err <<
"<maxvolts> is a mandatory parameter\n";
84 err <<
"<velocityconstant> is a mandatory parameter\n";
92 err <<
"<coilresistance> is a mandatory parameter\n";
99 err <<
"<noloadcurrent> is a mandatory parameter\n";
103 double MaxCurrent = MaxVolts / CoilResistance + ZeroTorqueCurrent;
105 PowerWatts = MaxCurrent * MaxVolts;
107 string base_property_name = CreateIndexedPropertyName(
"propulsion/engine", EngineNumber);
109 pm->Tie(base_property_name +
"/power-hp", &HP);
110 pm->Tie(base_property_name +
"/current-amperes", &Current);
128 if (Thruster->GetType() == FGThruster::ttPropeller) {
129 ((
FGPropeller*)Thruster)->SetAdvance(in.PropAdvance[EngineNumber]);
130 ((
FGPropeller*)Thruster)->SetFeather(in.PropFeather[EngineNumber]);
133 double RPM = Thruster->GetRPM();
134 double V = MaxVolts * in.ThrottlePos[EngineNumber];
136 Current = (V - RPM / Kv) / CoilResistance;
143 double FrictionCurrent;
146 FrictionCurrent = ZeroTorqueCurrent;
148 FrictionCurrent = -ZeroTorqueCurrent;
150 FrictionCurrent =
Constrain(-ZeroTorqueCurrent, Current, ZeroTorqueCurrent);
152 double Torque = (Current - FrictionCurrent) / Kv * WattperRPMtoftpound;
155 double EnginePower = ((2 * M_PI) * max(RPM, 0.0001) * Torque) / 60;
157 LoadThrusterInputs();
158 Thruster->Calculate(EnginePower);
165string FGBrushLessDCMotor::GetEngineLabels(
const string& delimiter)
167 std::ostringstream buf;
169 buf << Name <<
" HP (engine " << EngineNumber <<
")" << delimiter
170 << Thruster->GetThrusterLabels(EngineNumber, delimiter);
177string FGBrushLessDCMotor::GetEngineValues(
const string& delimiter)
179 std::ostringstream buf;
181 buf << HP << delimiter
182 << Thruster->GetThrusterValues(EngineNumber, delimiter);
207void FGBrushLessDCMotor::Debug(
int from)
209 if (debug_lvl <= 0)
return;
213 FGLogging log(LogLevel::DEBUG);
214 log <<
"\n Engine Name: " << Name <<
"\n";
215 log <<
" Power Watts: " << PowerWatts <<
"\n";
216 log <<
" Speed Factor: " << Kv <<
"\n";
217 log <<
" Coil Resistance: " << CoilResistance <<
"\n";
218 log <<
" NoLoad Current: " << ZeroTorqueCurrent <<
"\n";
221 if (debug_lvl & 2 ) {
222 FGLogging log(LogLevel::DEBUG);
223 if (from == 0) log <<
"Instantiated: FGBrushLessDCMotor\n";
224 if (from == 1) log <<
"Destroyed: FGBrushLessDCMotor\n";
226 if (debug_lvl & 4 ) {
228 if (debug_lvl & 8 ) {
230 if (debug_lvl & 16) {
232 if (debug_lvl & 64) {
Element * FindElement(const std::string &el="")
Searches for a specified element.
double FindElementValueAsNumberConvertTo(const std::string &el, const std::string &target_units)
Searches for the named element and converts and returns the data belonging to it.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
void Calculate(void)
Calculates the thrust of the engine, and other engine functions.
FGBrushLessDCMotor(FGFDMExec *exec, Element *el, int engine_number, FGEngine::Inputs &input)
Constructor.
~FGBrushLessDCMotor()
Destructor.
Base class for all engines.
Encapsulates the JSBSim simulation executive.
std::shared_ptr< FGPropertyManager > GetPropertyManager(void) const
Returns a pointer to the property manager object.
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
FGPropeller models a propeller given the tabular data for Ct (thrust) and Cp (power),...
Main namespace for the JSBSim Flight Dynamics Model.
constexpr double NMtoftpound
Models an electric brushless DC motor or more appropriately permanent magnet synchronous motor.