0% found this document useful (0 votes)
8 views6 pages

ECE 2305 - Programming Project 01

The document outlines a programming project for EE 2305 focused on creating a C++ program to simulate a simple RC circuit, calculating current and voltage based on user-input time values. It includes details on the circuit's components, formulas for current and voltage, and instructions for documenting the program with a description, flowchart, source code, test results, and tabulated data. The project requires the use of constants for voltage, resistance, and capacitance, and the results must be verified against expected outputs.

Uploaded by

Nl Fishing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

ECE 2305 - Programming Project 01

The document outlines a programming project for EE 2305 focused on creating a C++ program to simulate a simple RC circuit, calculating current and voltage based on user-input time values. It includes details on the circuit's components, formulas for current and voltage, and instructions for documenting the program with a description, flowchart, source code, test results, and tabulated data. The project requires the use of constants for voltage, resistance, and capacitance, and the results must be verified against expected outputs.

Uploaded by

Nl Fishing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

EE 2305 – Introduction to C Programming

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 𝑅

𝑉𝐷𝐶 𝑖(𝑡) 𝐶 𝑣(𝑡)

Figure 1: Simple RC Circuit.

After the switch is thrown at time 𝑡 = 0, the current in the circuit is given by the formula

𝑉𝐷𝐶 𝑡
𝑖 (𝑡 ) = exp (− ) (𝐴𝑚𝑝𝑠, 𝑡 ≥ 0)
𝑅 𝑅𝐶

and the voltage across the capacitor is given by the formula

𝑡
𝑣(𝑡) = 𝑉𝐷𝐶 [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 𝑣(𝑡).

The exp() function call requires the <cmath> library.

Let the values of the constants be

𝑉𝐷𝐶 = 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).

Table I: Current and Voltage in an RC Circuit

Time (𝑡) (μS) Current, 𝑖(𝑡) (mA) Voltage, 𝑣(𝑡) (V)

0 0.01 0

0.1 0.00367879 6.32121

0.2 0.00135335 8.64665

0.5 6.73795e-05 9.93262

1.0 4.53999e-07 9.99955

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.

Establish constants and


equations

Ask for input

Convert micro seconds to seconds

Plug converted input into


equations

Output current
and voltage

3
C. Source Code
Insert the C++ Source Code into the document.

D. Program Test Results:


Insert a screen image of the program output that demonstrates the operation of the program.

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.

Table I: Current and Voltage in an RC Circuit

Time (𝑡) (μS) Current, 𝑖(𝑡) (mA) Voltage, 𝑣(𝑡) (V)

0 0.01 0

0.1 0.00367879 6.32121

0.2 0.00135335 8.64665

0.5 6.73795e-05 9.93262

1.0 4.53999e-07 9.99955

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.

You might also like