LAB Task 03B
Required pre-reading:
Task Description:
LAB03
Voltage Gain
Instructions:
1.
Complete the following for the Software Specification:
a. Define the problem – on paper
b. Plan the problem solution (using a flowchart OR pseudocode) – on paper
c. Create a program in Pelles C called LAB03B and use the source code
structure used in the LAB01 Task section (i.e. 3 comment lines with program
name, your details, and date).
d. Test and debug the program
2.
Upload your program (as described in LAB01) onto the Moodle site.
3.
To challenge yourself, complete the Challenge part to obtain full marks for the LAB
task. This additional code has to be uploaded onto MOODLE under LabTask3
(challenge).
Software Specification:
The magnitude of the gain of an active low-pass filter using an op-amp is given by:
1
Voltage Gain =
2πfRC
The gain can also be indicated in decibels (dB) using: Gain(dB) = 20 log(Voltage Gain)
Write program in which the user enters a Frequency, Resistance and Capacitance for
the circuit and then determines the gain voltage and the gain in decibels. Note the units
required for the inputs and the outputs:
Write a C program to implement the following program:
Sample:
INPUT:
======
Enter frequency (kHz) : 1
Enter resistance (kOhm): 2
Enter capacitance (uF) : 3
OUTPUT:
=======
Gain voltage: 26.526 mV
Gain in DB : -31.527 dB
Press any key to continue...
Use the sample run as a reference to see what the spacing for the text, headings and
values should be. You should have exactly the same layout as the sample run to
determine if you understand the printf and scanf statements. Assume PI = 3.14159
Hints:
1. Note the number of decimal spaces in the answer - %??f
2. Before you can apply the formula in the program, you have to convert all the variables
to the correct units.
Challenge:
As an extra challenge, add the following to the existing program:
•
Change the output Gain Voltage to be displayed in kV.
•
Why is the result now displayed incorrectly as 0.000? Fix the code for the output to
display a valid result in kV.