EGR 224/RC Analysis

From PrattWiki
Revision as of 14:58, 9 June 2020 by DukeEgr93 (talk | contribs) (Created page with "The following page provides some supplemental information for the '''RC Analysis''' lab for EGR 224L. It has been updated for Summer, 2020. == Element Values ==...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The following page provides some supplemental information for the RC Analysis lab for EGR 224L. It has been updated for Summer, 2020.

Element Values

Take the number attached to your NetID (use 0 if no number), calculate that number modulo 8 (i.e. the remainder after dividing by the largest whole number of 8's), and add 1. Use the resistor and capacitor values based on that number:

  • Resistances:
    • 1: 2.2 k\(\Omega\)
    • 2, 3: 4.7 k\(\Omega\)
    • 4, 5: 10 k\(\Omega\)
    • 6: 15 k\(\Omega\)
    • 7, 8: 22 k\(\Omega\)
  • Capacitances
    • 1, 3: 22 \(\mu\)F
    • 2, 5: 10 \(\mu\)F
    • 4, 6, 8: 4.7 \(\mu\)F
    • 7: 2.2 \(\mu\)F

Tinkercad

Use a small breadboard, a function generator (not a power supply), a resistor, a capacitor, and whatever wires you need to model the circuit.

  • Put in three oscilloscopes - one to show the total voltage across the RC circuit, one to show just the voltage across the capacitor, and one to show just the voltage across the resistor. Change the time scale of the scopes so that the time per division is approximately equal to the time constant $$\tau=RC$$ of your circuit.
  • Set the function generator to make a square wave with an amplitude of 2.5 V, a DC Offset of 1.25 V, and a frequency equal to $$f=\frac{1}{8\tau}$$ where again $$\tau=RC$$ for your circuit. This will make a wave that is "on" for four time constants and then "off" for four time constants. Take a screen shot of your simulation in action.
  • Note that the scopes are not triggered in sync - the time axes for each are shifted and generally centered where a wave is equal to half its maximum amplitude and rising. Given that, we will not be able to use Tinkercad to get phase information but you can at least get an idea about amplitude.
  • Set the function generator to generate a sinusoid instead of a rectangular pulse. Note that the amplitudes of the voltages across the resistor and capacitor are just about equal. This is because $$f=\frac{1}{8\tau}$$ is very close to the cutoff frequency $$f_{co}=\frac{\omega_{co}}{2\pi}=\frac{1}{2\pi\tau}$$. At exactly the cutoff frequency, we would expect the amplitude of both signals to be $$\frac{1}{sqrt{2}}$$ of the total amplitude.
  • Change the frequency of the function generator to 10 times its current value (that is $$f=\frac{1.25}{\tau}$$) and change the time per division to $$\tau/10$$. Take a screen shot of this simulation as well. Carefully note the voltage ranges on the oscilloscopes.

Multisim

Maple

Python / MATLAB

Plotting

For your plots, the total voltage should be a solid (dark) red line, the capacitor voltage should be a dash-dot (dark) blue line, and the resistor voltage should be a dashed (dark) green line. Here are some examples of how to do that in Maple, (less efficiently) in all versions of MATLAB, more efficiently in newer versions of MATLAB, and in Python, that shows plotting \(t^2\), \(t\), and \(t^2-t\). Note that you will need to add code for the axis labels and titles.

Maple

plot([t^2, t, t^2-t], t = 0 .. 3, linestyle = [1, 4, 3], legend = ['Total', 'vC', 'vR'])

All MATLAB

The following set the line widths to 1 for each plot and then sets the color based on a value for red, green, and blue -- these need to be between 0 and 1 for each component. [0.5 0 0] is thus dark red, [0 0 0.5] is dark blue, and [0 0.5 0] is dark green. These need to be darker than MATLAB's defaults because, for example, the default green is too light.

Time = linspace(0, 3, 100);
plot(Time, Time.^2,      'k-',  'LineW', 1, 'Color', [0.5 0 0])
hold on
plot(Time, Time,         'k-.', 'LineW', 1, 'Color', [0 0 0.5])
plot(Time, Time.^2-Time, 'k--', 'LineW', 1, 'Color', [0 0.5 0])
hold off
legend('Total', 'v_{C}', 'v_{R}', 'location', 'best')

Newer MATLAB

For MATLAB 2014b or newer, there is a more efficient way to use the plot object to do the same work:

Time = linspace(0, 3, 100);
p=plot(Time, Time.^2, 'k-', Time, Time, 'k-.', Time, Time.^2-Time, 'k--');
p(1).Color = [0.5 0 0]; p(1).LineWidth = 1;
p(2).Color = [0 0 0.5]; p(2).LineWidth = 1;
p(3).Color = [0 0.5 0]; p(3).LineWidth = 1;
legend('Total', 'v_{C}', 'v_{R}', 'location', 'best')

The p object has information about each of the items that were plotted; you can then set them individually rather than having to have multiple plot commands. Note that Duke's UNIX system has MATLAB 2014a (so close!) so this will not work as yet on that system.

Python

Python's default colors are darker, so the code:

import numpy as np
import matplotlib.pyplot as plt

time = np.linspace(0, 3, 100)
fig, ax = plt.subplots(num=1)
fig.clf()
fig, ax = plt.subplots(num=1)

ax.plot(time, time**2, 'k-', linewidth=1, color=[0.5, 0, 0])
ax.plot(time, time, 'k-.', linewidth=1, color=[0, 0, 0.5])
ax.plot(time, time**2 - time, 'k--', linewidth=1, color=[0, 0.5, 0])
ax.legend(['Total', '$v_{C}$', '$v_{R}$'], loc='best')

could be simplified a little to be:

import numpy as np
import matplotlib.pyplot as plt

time = np.linspace(0, 3, 100)
fig, ax = plt.subplots(num=1)
fig.clf()
fig, ax = plt.subplots(num=1)

ax.plot(time, time**2, 'r-', linewidth=1)
ax.plot(time, time, 'b-.', linewidth=1)
ax.plot(time, time**2 - time, 'g--', linewidth=1)
ax.legend(['Total', '$v_{C}$', '$v_{R}$'], loc='best')

to use the format string versus the color kwarg.