Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How is the info not relevant? Ask instead of just stating. Your job in this proj

ID: 3779414 • Letter: H

Question

How is the info not relevant? Ask instead of just stating.

Your job in this project is to design a C++ program to assist students in the design of the filter circuit, data collection, and analysis for the low pass filter.

Design: User supplies a value for the critical frequency (the frequency that defines the edge of the filter’s passband). The low pass filter requires a resistor (units: kilo-ohm) and capacitor (units: micro-Farad). The program should ask the user for a value for the capacitor but should allow a default value for the capacitor as C = 0.01µF. The following equation is used to determine the necessary value for the resistor based on the critical frequency, fc, and C.

These three values should be stored in the struct.

Experiment: Once the program has performed the design steps, it is time for use during the experiment. During the experiment, students will test the circuit at frequencies sufficiently above and below the critical frequency. Twenty to forty data points are needed for a sufficiently useful plot of the results. The user must be able to tell the program how many data points will be used and to select the frequencies. During the test, input voltage is set to a constant peak-to-peak voltage value, such as 10Vp-p, and the peak-to-peak output voltage is measured at each of the frequencies. The program should use arrays to organize the data and, for each frequency, calculate the filter gain in decibels, Av,dB, using the following formula.

The base-10 logarithmic function is in with the syntax: log10(num) where num must be declared as a double variable type.

Additionally, the program should calculate the theoretical gain in dB for each frequency using the following formula for ease of comparison between experimental result and theoretical result.

The program should provide a way to output the information to a screen and to a text file that could be used to upload the information in to Excel for plotting. It is possible to get C++ to plot the results of gain versus frequency but not required for this problem statement. A sample data set is provided below for a low pass filter with a design critical frequency of 3.0kHz and C = 0.01µF.

R 2m fcC

Explanation / Answer

Please cpoy the code in .cpp file and compile using g++ filename.cpp and then do ./a.out now you will be promted for mentioned details. Please refer to comment in code. want the output in text file.

Suppose all your input is in file input.txt and then exeucte your program like this ./a.out < input.txt > output.txt

all your output will be stored in output.txt.

Program:

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define muf .000001
#define KHz 1000
#define pi 3.142857
typedef struct filterCircuit{
   double Fc; // critical frequency
   double C; // capacitor
   double R; // resistance
}filterCircuit;

int main()
{
   filterCircuit fcircuit;
   int n;
   fcircuit.C = .01;
   cout<< "Please enter the Critical Frequency in KHz(Fc) : ";
   cin >> fcircuit.Fc;
   cout<< " Please enter the Capcitor value in micro farad (C) : ";
   cin >> fcircuit.C;
   cout << "Calculation Resistance ... "<<endl;
   fcircuit.R = 1.0 / (2 * pi * fcircuit.Fc * KHz * fcircuit.C * muf * 1000); // multiplied by 1000 to covert in kilo ohm
   cout << "Resistance : " << fcircuit.R <<" Kilo ohm" << endl;
   cout << "Enter the number of data set to use: ";
   cin >> n;
   double inputVoltage = 10;
   cout << "Input Voltage is set to : " << inputVoltage << endl;
   cout << "Enter " << n << " measured voltage : " << endl;
   double measuredVoltage[n];
   double filtergain[n];
   for(int i = 0;i < n;i++){
       cin >> measuredVoltage[i];
       filtergain[i] = 20 * log10(measuredVoltage[i] / inputVoltage);
   }
   double theoreticalgain = (double) 1.0 / sqrt(1 + pow(2*pi * fcircuit.Fc * fcircuit.R * fcircuit.C, 2));
   cout << "Data to be ploted: ";
   cout << "InputVoltage MeasuredVoltage TheoreticalGain"<<endl;
   for(int i = 0;i < n;i++){
       cout<< inputVoltage <<" "<<filtergain[i] <<" "<<theoreticalgain<<endl;
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote