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;
145 if (Current >= ZeroTorqueCurrent)
146 Torque = (Current - ZeroTorqueCurrent) / Kv * WattperRPMtoftpound;
147 if (Current<=-ZeroTorqueCurrent)
148 Torque = (Current + ZeroTorqueCurrent) / Kv * WattperRPMtoftpound;
151 double EnginePower = ((2 * M_PI) * max(RPM, 0.0001) * Torque) / 60;
153 LoadThrusterInputs();
154 Thruster->Calculate(EnginePower);
161string FGBrushLessDCMotor::GetEngineLabels(
const string& delimiter)
163 std::ostringstream buf;
165 buf << Name <<
" HP (engine " << EngineNumber <<
")" << delimiter
166 << Thruster->GetThrusterLabels(EngineNumber, delimiter);
173string FGBrushLessDCMotor::GetEngineValues(
const string& delimiter)
175 std::ostringstream buf;
177 buf << HP << delimiter
178 << Thruster->GetThrusterValues(EngineNumber, delimiter);
203void FGBrushLessDCMotor::Debug(
int from)
205 if (debug_lvl <= 0)
return;
209 FGLogging log(LogLevel::DEBUG);
210 log <<
"\n Engine Name: " << Name <<
"\n";
211 log <<
" Power Watts: " << PowerWatts <<
"\n";
212 log <<
" Speed Factor: " << Kv <<
"\n";
213 log <<
" Coil Resistance: " << CoilResistance <<
"\n";
214 log <<
" NoLoad Current: " << ZeroTorqueCurrent <<
"\n";
217 if (debug_lvl & 2 ) {
218 FGLogging log(LogLevel::DEBUG);
219 if (from == 0) log <<
"Instantiated: FGBrushLessDCMotor\n";
220 if (from == 1) log <<
"Destroyed: FGBrushLessDCMotor\n";
222 if (debug_lvl & 4 ) {
224 if (debug_lvl & 8 ) {
226 if (debug_lvl & 16) {
228 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.
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.