1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
//joe
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
//defining constants
const double D = .004; // N/rad/s vicous friction
const double C = .003; // N * m coulombic friction
double calcTor (double& V, double& omega, double& K, double& R, double D, double C);
double calcPow( double calcTor, double& omega);
double const PI = acos(-1);
int main(){
//defining variables
double V = 0;//volts
double K = 0;//N*m /Amp motor constant
double R = 0; //Ohms resistance
double RPM = 0;
double omega = (RPM * PI)/30;//rad/s
//input values
cout << "Input applied voltage(V) \n";
cin >> V;
cout << "Input Motor Constant \n" ;
cin >> K;
cout << "Input Resistance(Ohms) \n";
cin >> R;
cout <<"Cody Brown \n" <<"Applied Voltage (Volts): " << V << endl << "Motor Constant(N*m/Amp or Volts/rad/s): " << K << endl;
cout << "Motor Resistance(Ohms); " << R << endl;
cout << "RPM Torque(Nm) Power(W) \n";
//for loop to output values for the motor
for(RPM = 0; calcTor (V, omega, K, R, D, C) < 0; RPM = (RPM+100)){
cout << RPM << " " << calcTor(V ,omega ,K ,R ,D ,C) << " " << calcPow( calcTor(V ,omega ,K ,R ,D ,C), omega) << endl;
}
system ("Pause");
return 0;
}
//Calculating Torque
double calcTor (double& V, double& omega, double& K, double& R, double D, double C) {
double calcTor = 0;
calcTor = (((V - omega * K)/R) * K - (D * omega) - C);
return calcTor;
}
//Calculating Power
double calcPow( double calcTor, double& omega){
double calcPow = 0;
calcPow = calcTor * omega;
return calcPow;
}
|