Question
Write a C++ program for a specialized laboratory voltmeter that calculates and displays the RMS voltage for waveforms of any shape. Assume that the circuitry
Write a C++ program for a specialized laboratory voltmeter that calculates and displays the RMS voltage for waveforms of any shape. Assume that the circuitry that converts the analog waveform to digital, stores the voltage in an array every 15 degrees. Exactly one full cycle, no more or less, is stored in the array. The program should use one function to calculate the RMS voltage and a second to display the results. A maximum of three decimal places should be displayed.
Since the waveform can be any shape (square, triangular, sine), you must calculate the RMS voltage by first squaring all the values in the array, then finding the mean (average), and then taking the square root of the mean. It is incorrect to find the RMS voltage using the formula:
V RMS = V Peak / ?2
as this is valid only for sine waves and the voltmeter should measure correctly for all waveforms.
Test your program by populating the array, first with the voltages for a symmetric square wave with 50% duty cycle (positive and negative amplitudes are equal) and then a sine wave.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started