0% found this document useful (0 votes)
16 views8 pages

MATLAB RC Circuit Capacitor Simulation

The assignment focuses on simulating the charging and discharging behavior of capacitors in an RC circuit using MATLAB, analyzing different capacitance values (1µF, 10µF, 100µF) and input frequencies (1Hz, 10Hz). The results demonstrate how the time constant τ affects the capacitor's response, with lower capacitance and frequency leading to sharper voltage changes, while higher values result in slower, smoothed responses. The findings emphasize the capacitor's role as a low-pass filter and the importance of capacitance and frequency in circuit design.

Uploaded by

Gold Qwerty
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)
16 views8 pages

MATLAB RC Circuit Capacitor Simulation

The assignment focuses on simulating the charging and discharging behavior of capacitors in an RC circuit using MATLAB, analyzing different capacitance values (1µF, 10µF, 100µF) and input frequencies (1Hz, 10Hz). The results demonstrate how the time constant τ affects the capacitor's response, with lower capacitance and frequency leading to sharper voltage changes, while higher values result in slower, smoothed responses. The findings emphasize the capacitor's role as a low-pass filter and the importance of capacitance and frequency in circuit design.

Uploaded by

Gold Qwerty
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

MATLAB Assignment: Simulating Capacitor Charging and Discharging in an RC

Circuit

GROUP NUMBER: 2

NAME OF MEMBERS:
SAMSON, SHAINA S.
MONTECILLO, JULIA DAWN C.
CUTAMORA, CLIFFORD
GERONA, GREGORY IAN
NARAL, ANDRICH JAROD A.

DATE: 05/07/2025

Objective

To simulate and analyze the voltage across capacitors of varying capacitance values (1F, 10F,
and 100F) in an RC circuit when subjected to square wave inputs at frequencies of 1Hz and
10Hz.

Materials

• MATLAB software
• Basic understanding of RC circuits and exponential charging/discharging behavior

Background

In an RC circuit, the voltage across the capacitor during charging and discharg ing follows an
exponential behavior characterized by the time constant τ :

τ=R×C

Where:
• R is the resistance in ohms ()
• C is the capacitance in farads (F)
• τ is the time constant in seconds (s)
The voltage across the capacitor during charging is given by: VC (t) = Vmax(1 −
e−t/τ )

And during discharging: Where:


VC (t) = V0e−t/τ 1

• Vmax is the maximum voltage applied


• V0 is the initial voltage across the capacitor
• t is the time elapsed
Understanding how different capacitance values and input frequencies affect the charging
and discharging behavior is crucial in designing circuits with desired timing characteristics.

Instructions

1. Define Circuit Parameters


• Resistance: R = 10 kΩ
• Capacitance values: C = {1 µF, 10 µF, 100 µF}
• Input voltage amplitude: Vmax = 5 V
• Input frequencies: f = {1 Hz, 10 Hz}

2. Generate Square Wave Input


• For each frequency, generate a square wave using MATLAB’s square function.
• Duration: Simulate for at least 5 periods.
• Choose an appropriate time step to accurately capture the waveform.

3. Simulate Capacitor Voltage


• For each combination of capacitance and frequency:
– Calculate τ = R × C
– Simulate VC (t) by solving the differential equation or using the analytical expression.
– Numerical solvers like ode45 can be used if desired.

4. Plot Results
• For each simulation, plot both the input square wave and the resulting capacitor voltage.
• Label axes and include legends.

5. Analyze and Compare


• Observe how capacitor voltage responds to different capacitance values and frequencies.
• Note charging/discharging rates and their relation to the time constant τ .

6. Document Observations
• Create a summary table of observations for each scenario. • Discuss behavioral
changes due to varying capacitance and frequency.

Expected Deliverables

• MATLAB scripts or functions used in the simulation


• Plots showing input and capacitor voltage for each case
• A summary table of observations
• A brief discussion or conclusion based on results

Tips

• Use a fine time resolution to capture the exponential behavior accurately. • Adjust solver

options for stiff equations if necessary.

• Utilize MATLAB’s plotting tools to make clear and informative visualiza tions.
MATLAB scripts or functions used in the simulation:
Plots showing input and capacitor voltage for each case :

Analyze and Compare:

The voltage response of a capacitor in an RC circuit is significantly influenced by both


the capacitance value and the input frequency, with the time constant τ=R×C playing a central
role in this behavior. The time constant determines how quickly the capacitor charges or
discharges in response to a square wave input. By examining different capacitance values (1
µF, 10 µF, and 100 µF) and frequencies (1 Hz and 10 Hz), we can observe how the charging
and discharging rates vary and how they are intrinsically related to the time constant.

Capacitance of 1 µF (τ = 0.01 s)​


​ With a capacitance of 1 µF, the time constant is relatively small. This results in rapid
charging and discharging of the capacitor.

●​ At 1 Hz: The period of the square wave is 1 second, much longer than the time constant.
The capacitor has ample time to charge and discharge fully within each half-cycle. As a
result, the voltage response follows the square wave almost perfectly, with sharp
transitions.​

●​ At 10 Hz: The period of the square wave is 0.1 seconds, which is still much larger than
the time constant. Therefore, the capacitor charges and discharges fully within each
cycle, and the voltage response continues to track the input with only minor lag.​
​ In this case, the capacitor’s charging and discharging rates are fast enough to
match the input signal, meaning that the time constant is small compared to the signal
period. This results in sharp voltage transitions and near-perfect tracking of the square
wave.

Capacitance of 10 µF (τ = 0.1 s)​


For a capacitance of 10 µF, the time constant increases to 0.1 seconds, leading to slower
charging and discharging rates.

●​ At 1 Hz: With a signal period of 1 second, which is much larger than the time constant,
the capacitor still charges and discharges fairly well during each half-cycle. However, the
voltage response starts to become smoother with some delay, as the capacitor no longer
reaches the full voltage immediately. The charging and discharging rates are slower
compared to the 1 µF case, leading to more gradual voltage transitions.​

●​ At 10 Hz: The signal period is now 0.1 seconds, which is equal to the time constant. In
this scenario, the capacitor can charge to only about 63% of the full voltage before the
input switches. This results in a smoother, more rounded waveform compared to the
sharp transitions seen at lower capacitance. The charging and discharging rates are
slower in this case, meaning the capacitor struggles to follow higher frequency inputs.
The voltage response shows increased lag and smoothing, highlighting that the time
constant is now more comparable to the signal period.

Capacitance of 100 µF (τ = 1 s)​


With a capacitance of 100 µF, the time constant becomes large (1 second), resulting in very
slow charging and discharging rates.

●​ At 1 Hz: With the signal period equal to the time constant, the capacitor charges to
about 63% of the full voltage before the input switches. The transitions are slow and
significantly curved, indicating a delayed response to the square wave. The capacitor
cannot fully follow the input signal in each cycle, and the voltage response shows
substantial smoothing.​

●​ At 10 Hz: The signal period is only 0.1 seconds, which is much smaller than the time
constant. As a result, the capacitor barely responds to the input signal. The voltage
remains almost constant, unable to charge or discharge meaningfully within each cycle.
The response is extremely slow, with little to no change before the input flips again.​
The large time constant results in an even slower charging and discharging rate, and the
capacitor acts as a low-pass filter, effectively removing high-frequency components from
the input signal. At this point, the capacitor’s charging and discharging behavior is
extremely sluggish, and it cannot keep up with high-frequency changes.​
Capacitance and Time Constant: As capacitance increases, the time constant τ=R×C
becomes larger, which means slower charging and discharging rates. This slows down the
capacitor’s response to the input signal, particularly at higher frequencies.​

Frequency Effects: When the signal frequency is much lower than the time constant, the
capacitor has sufficient time to charge and discharge fully within each cycle, producing sharp
transitions and near-perfect tracking of the square wave. However, as the frequency increases
and approaches or exceeds the time constant, the capacitor’s ability to follow the signal
diminishes, leading to slower, smoothed voltage transitions.​

Charging/Discharging Rates: The charging and discharging rates are directly related to the
time constant. A small τ results in fast charging and discharging, allowing the capacitor to track
the input signal effectively. Conversely, a larger τ results in slower charging and discharging,
with the capacitor lagging behind the input signal, especially at higher frequencies.

Summary Table of Observations:

Capacitance Frequenc Time Constant Behavioral Changes


y (τ = RC)

1 µF 1 Hz 0.01 s In MATLAB, we observed that the capacitor


voltage closely tracked the square wave
input. The response was very fast—charging
and discharging were almost immediate, and
the voltage reached nearly 5V and dropped
back to 0V in each cycle.

1 µF 10 Hz 0.01 s The capacitor still responded quickly, but due


to the shorter period of the input, we noticed
a slight delay in the voltage curve. It didn’t
fully reach 5V before the wave flipped again,
which caused a small rounding at the top and
bottom of the waveform.

10 µF 1 Hz 0.1 s In this case, the voltage across the capacitor


rose and fell more gradually. It still managed
to charge and discharge almost fully, but the
transitions weren’t as sharp. The MATLAB
plot showed noticeably curved edges instead
of straight lines.
10 µF 10 Hz 0.1 s The simulation showed that the capacitor
couldn't keep up with the fast input. The
voltage didn't have enough time to reach high
or low values before switching again, so the
waveform appeared smoothed out,
resembling a rounded triangle wave.

100 µF 1 Hz 1.0 s With this high capacitance, MATLAB clearly


showed a sluggish response. The voltage
curve barely reached halfway to 5V before
the input switched again. It was charging and
discharging too slowly, which created a
heavy lag in the output.

100 µF 10 Hz 1.0 s This was the slowest case we simulated. The


capacitor voltage remained almost flat in the
MATLAB plot. It barely reacted to the fast
switching input at all, acting like a low-pass
filter that smoothed out the square wave into
nearly a straight line.

Conclusion:

The capacitor's voltage behavior is significantly influenced by both capacitance and input
frequency. Low capacitance and low frequency result in sharp, responsive voltage changes that
closely follow the input waveform. As either capacitance increases or frequency rises, the
capacitor begins to lag, introducing curvature and smoothing to the waveform. High capacitance
combined with high frequency results in extreme filtering, where the output barely changes in
response to the input. This analysis highlights the capacitor's role as a low-pass filter and
demonstrates how its response can be tuned by varying its capacitance and the signal
frequency.

You might also like