タイトルの通り。
カレントディレクトリに以下のIM.hを作成
#define _USE_MATH_DEFINES
#include <math.h>
class IM {
public:
IM(std::string name,
double r1, double r2,
double x1, double x2) {
m_name = name;
m_r1 = r1;
m_r2 = r2;
m_x1 = x1;
m_x2 = x2;
m_s = 0.0;
m_P = 0.0;
m_N = 0.0;
m_V = 0.0;
m_f = 0.0;
m_p = 0;
}
~IM() {
}
void setPrimaryVoltage(double V) {
m_V = V;
}
void setFraquency(double f) {
m_f = f;
}
void setMotorPole(int p) {
m_p = p;
}
void setSlip(double s) {
m_s = s;
}
void setMotorOutput(double P) {
m_P = P;
}
void setRPM(double N) {
m_N = N;
}
double getTorque() {
return m_P / (2 * M_PI * m_N / 60);
}
double getSyncSpeed() {
return 120 * m_f / m_p;
}
double getPrimaryCurrent() {
double Z, R, X;
R = m_r1 + m_r2 / m_s;
X = m_x1 + m_x2;
Z = sqrt(std::pow(R, 2) + std::pow(X, 2));
return m_V / (sqrt(3) * Z);
}
private:
std::string m_name;
double m_r1;
double m_r2;
double m_x1;
double m_x2;
double m_s;
double m_P;
double m_N;
double m_V;
double m_f;
int m_p;
};
して以下のmain.cppを作れば動く。
#include <iostream>
#include "IM.h"
int main() {
//std::string name, double r1, double r2, double x1, double x2
IM motor1("MOTOR1", 0.1, 0.15, 0.3, 0.4);
motor1.setSlip(0.05);
motor1.setMotorOutput(15000);
motor1.setRPM(1440);
motor1.setPrimaryVoltage(200);
motor1.setFraquency(50);
motor1.setMotorPole(4);
std::cout << "Ns -> " << motor1.getSyncSpeed() << std::endl;
// std::cout << "T -> " << motor1.getTorque() << std::endl;
// std::cout << "I -> " << motor1.getPrimaryCurrent() << std::endl;
return 0;
}
実行結果
Ns -> 1500
コメント