Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,131 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,781 people online right now. Registration is fast and FREE... Join Now!




Resonant Frequency Calculation

 
Reply to this topicStart new topic

Resonant Frequency Calculation

ayad
26 Feb, 2007 - 03:08 AM
Post #1

New D.I.C Head
*

Joined: 22 Feb, 2007
Posts: 3


My Contributions
Can someone show me how to cancel enter Y to do an other calculation on this program then can you show me how to calculate the resonant frequency
The resonant frequency is when XL-Xc = 0
thank you

CODE


#include<iostream>
using namespace std;
#define pi 3.142
#include <math.h>
#include <iomanip>

void ShowTitle();
void GetData();
void DoCalcs_ShowResults();

double capacitor=0;
double inductor=0;
double resistor=0;
double frequency=0;
double impedance=0;
double reactance=0;
double phase_angle=0;

char letter = 'Y';
void main()
{
    
    cout<<"\nFunprog 1 A modular program using Global values"<<endl;
    
    do
    {
        
        ShowTitle();
        GetData();
        DoCalcs_ShowResults();
        cout<<"\n\npress Y then Enter to do another calculation,"<<"\n\n\t\tOR";
        cout<<"\n\npress any other key then Enter to terminate";
        cin>>letter;
    }
    while(letter == 'Y' || letter == 'Y');
}


void ShowTitle()
{
    cout<<"\n R/C/L Series circuit calculation"<<endl;
}

void GetData()
{
    cout<<"\nEnter Capacitor value in micro farads:";
    cin>>capacitor;
    cout<<"\nEnter Resistor value in ohms:";
    cin>>resistor;
    cout<<"\nEnter inductor value in henrys:";
    cin>>inductor;

    cout<< setw(10) << "\n\n\t\t\tReactance (ohms)\tImpedance (ohms)\tPhase Angle(Deg)\n"<<endl;
}

void DoCalcs_ShowResults()
{
    for(frequency=10;frequency<=100;frequency+=10);
    {
        cout<<setw(10) << setiosflags(ios::fixed) << setprecision(0)<<"\n For Frequency = "<<frequency<<"HZ";
        reactance = 1000000/(2*pi*frequency*capacitor)+(2*pi*frequency*inductor);
        impedance = sqrt (pow(resistor,2) + pow(reactance,2));
        phase_angle = atan(reactance / resistor)*(180/pi);
        cout<<"\t" <<setw(10) << setiosflags(ios::fixed) << setprecision(2)<<reactance;
        cout<<"\t" <<setw(10) <<setiosflags(ios::fixed) << setprecision(2)<<impedance;
        cout<<"\t" <<setw(10) <<setiosflags(ios::fixed) << setprecision(2)<<phase_angle;
        cout<<"\n";
    }

}

User is offlineProfile CardPM
+Quote Post

horace
RE: Resonant Frequency Calculation
26 Feb, 2007 - 04:05 AM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 4 times
Dream Kudos: 50
My Contributions
you while should be
CODE

while(letter == 'Y' || letter == 'y');

you had two capital Y

if I remember correctly the resonant frequency is f=1/(2*PI*sqrt(L*C))
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:21PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month