ECE210 Honors Python Section Assignment 4 (Due Nov 30) 1 Introduction This lab will go over RC and RL time constants as well as LC resonance. You will write functions for combining impedances in series and in parallel as well as plotting magnitude and phase of some simple impedances. 2 Plot R, L, and C In this part of the lab, you will plot the magnitude and phase of an individual resistor, capacitor, and inductor. Create a logarithmically-spaced vector containing frequencies between 10 and 10000 kHz using the logspace function. (Read the documentation for logspace.) Choose an appropriate number of points. Create variables containing the values of the three basic components: R = 1000 # Ohms C = 10**-5 # Farads L = 1 # Henries A capacitor has the input impedance given by the following equation Z(s) = 1 sC (1) where s = σ + jω, the Laplace frequency variable. We will be interested in the behavior along the jω axis. An example of the magnitude plot is shown in Figure 1. SUBMIT: 1. Plots of magnitude and phase for the capacitor, inductor, and resistor. 2. Your code. You may consolidate your code and figures in a LibreOffice Writer document to make printing simpler. 1 Figure 1: Example plot of a 10µF capacitor impedance. 3 Create Callable Functions The following code show example functions. The first function square takes a single argument x and returns the square of it. The function body starts after the colon and contains everything that is indented. def square(x): return x**2 def plot_stuff(x, y, label=’Default’): plot(x, y, label=label) legend(loc=’best’) The plot stuff function takes two arguments and a keyword argument. It creates a plot of x and y and adds a legend. You will create two functions for combining impedances, one in series and another in parallel. These functions will take two arguments z1 and z2 and return the proper value. SUBMIT: 1. Your source code for plot stuff, and the series and parallel combination of impedances. 2 4 Task III: Plotting RC, RL and RLC circuits You will create a function called plot mag phase which takes three arguments, f (frequency), Z (complex impedance), and label (label). This will be used many times during this task for displaying different circuits. Each of the figures should contain the magnitude and the phase in separate subplots. You may find the loglog and semilogy functions useful for plotting these values. Choose appropriate labels for each set of plot lines. For example, "L+C" and "L||C" can denote series and parallel respectively. An example is shown in Figure 2. Figure 2: Example plot of a series and parallel LC impedance. RC circuits On the same figure, generate a plot containing both a series and parallel combination of a resistor and a capacitor. RL circuits On the same figure, generate a plot containing both a series and parallel combination of a resistor and an inductor. 3 RLC circuits On the same figure, generate a plot containing all components in series and all in parallel. You may need to nest calls to ser and par to combine the three components together. Questions 1. What is the phase angle of a capacitor, a resistor, and an inductor, all separately? 2. Compute the time constants for the RC and RL circuits. How do these constants to the magnitude and phase graphs of the RC and RL impedances, respectively? 3. Compute the resonsant frequency for the RLC circuit. How does it relate to the graphs of the magnitude and phase? 4. How can you determine capacitance or inductance regions from the phase information? SUBMIT: 1. Plots of RC, RL, and RLC circuits in series and parallel, both the magnitude and phase. 2. Answers to the questions. 3. Your code. You may consolidate your code and figures in a LibreOffice Writer document to make printing simpler. 4