In AC circuit analysis the general forms of the equation for

In AC circuit analysis, the general forms of the equation for the variation in voltage versus time is given by v(t) = V_m sin (omega t + theta), where V_m is the Peak value of the voltage theta is the phase angle in degrees Omega = 2 pi f is the angular velocity in radians/sec corresponding to the frequency f in Hz. Using the four-step development method, write a C++ program that prompts the user for the values of V_m, theta, f varies the time variable in equal steps from t = 0 to t = 2/f for N (100) values calculates instantaneous voltages v(t) and saves them in an array, V[k] computes the RMS value of the voltage using V_RMS = squareroot 1/N Sigma^N-1_k=0 V^2 [K] displays the value of V_RMS with two places of decimal accuracy Demonstrate that your program works by using the following two cases at a minimum. If you code using STL vector class, perform input data validation, and/or additional test cases, you will earn bonus credit.

Solution

// C++ code determine Vrms

#include <iostream>
#include <string.h>
#include <fstream>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <vector>

# define M_PI 3.14159265358979323846 /* pi */

using namespace std;


int main()
{
int N = 100;
vector<double> Vt;
double Vm, angle, frequency,omega, radian;
double Vrms = 0.0;

cout << \"Enter Vm: \";
cin >> Vm;

cout << \"Enter angle in degrees: \";
cin >> angle;

cout << \"Enter frequency: \";
cin >> frequency;

double step = 2/(frequency*N);
double v;

radian = angle*M_PI/180;
omega = 2*M_PI*frequency;

for (double t = 0; t <= 2/frequency; t=t+step)
{
v = Vm*sin(omega*t +radian);
Vt.push_back(v);
}

for (int i = 0; i < Vt.size(); ++i)
{
Vrms = Vrms + Vt[i]*Vt[i];
}

Vrms = sqrt(Vrms/N);

cout << \"Vrms: \" << Vrms << endl;

return 0;
}


/*
output:

Enter Vm: 100
Enter angle in degrees: 37
Enter frequency: 5
Vrms: 70.7107


Enter Vm: 75
Enter angle in degrees: 43
Enter frequency: 0.8
Vrms: 53.2791

*/

 In AC circuit analysis, the general forms of the equation for the variation in voltage versus time is given by v(t) = V_m sin (omega t + theta), where V_m is t
 In AC circuit analysis, the general forms of the equation for the variation in voltage versus time is given by v(t) = V_m sin (omega t + theta), where V_m is t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site