ECE 2305 - Programming Project 01
ECE 2305 - Programming Project 01
Programming Project 01
Simple RC Circuit
Program Features: Sequential structure, variables and constants, data input and output,
mathematical operators, function calls.
The electrical circuit shown in Figure 1 is called an RC circuit because it contains a resistance (R)
and a capacitance (C). The behavior of the resistance is to resist the flow of electrical current in
the closed loop. The behavior of the capacitance is to store electrical charge.
𝑡=0 𝑅
After the switch is thrown at time 𝑡 = 0, the current in the circuit is given by the formula
𝑉𝐷𝐶 𝑡
𝑖 (𝑡 ) = exp (− ) (𝐴𝑚𝑝𝑠, 𝑡 ≥ 0)
𝑅 𝑅𝐶
𝑡
𝑣(𝑡) = 𝑉𝐷𝐶 [1 − exp (− )] (𝑉𝑜𝑙𝑡𝑠, 𝑡 ≥ 0)
𝑅𝐶
Write a C++ program that defines 𝑉𝐷𝐶 (voltage in Volts), 𝑅 (resistance in Ω), and 𝐶 (capacitance
in Farads) as constants (using the const keyword) and allows the user to input different values
of 𝑡 (time in Seconds). The program shall then calculate values for 𝑖(𝑡) and 𝑣(𝑡).
𝑉𝐷𝐶 = 10 Volts
𝑅 = 10 kΩ (kilo-ohms, × 103 , or × 1000)
𝐶 = 100 pF (pico-Farads, × 10−12 , or × 0.000000000001)
Write the program to prompt the user to input a time t in micro-seconds (μS, × 10−6 , or
× 0.000001, using the cin function). Convert the time to seconds to perform the calculation.
1
Run the program using the values of 𝑡 shown in the table below. Use the results of the program to
fill in the table. The program shall report the current in milliamps (mA, × 10−3 , or × 0.001) and
the voltage in volts (V).
0 0.01 0
2.0 2.06115e-11 10
5.0 1.92875e-24 10
To document your program, create a Word document and include all of the following sections in
the document.
A. Program Description:
Write a short description of the purpose of the program. Include a description of the inputs and
the outputs. Describe the basic program structure (branching, looping, etc.).
This program imitates the behavior of a simple RC circuit. When the user inputs a time, it will
produce the current and voltage of the circuit.
2
B. Program Flowchart:
Draw a flowchart of the program using the Word graphics shapes. Include each section of the
program in the flowchart.
Output current
and voltage
3
C. Source Code
Insert the C++ Source Code into the document.
4
5
E. Tabulated Data.
Collect the data and insert the values in the chart shown above. Verify that the program
produces the correct results.
0 0.01 0
2.0 2.06115e-11 10
5.0 1.92875e-24 10
Save the document as a PDF file and submit the PDF document to Blackboard.