PSPICE tutorial: Frequency response In this tutorial, we will look at frequency response simulations. Before starting, you should make sure that you have the pre-requisite PSPICE skills introduced in the first EE 201 PSPICE tutorial, located at: http://tuttle.merc.iastate.edu/ee230/spice/ pspice_DC.pdf. In particular, you should know how to start the program, set up a new project, add parts libraries, place and edit parts for the circuit, wire together the parts to form the circuit, add the ground connection, set up a DC simulation profile, run the simulation, and observe the results. Also, if you have read the RC and RL transient tutorial ( http://tuttle.merc.iastate.edu/ ee230/spice/pspice_transient.pdf ), you should be familiar with probes and making plots, skills that are used again in this tutorial. Now we would like to do an AC sweep analysis, meaning that we would like to see how the voltages and currents in the circuit change with frequency. The graphs generated by the simulation will be identical in nature to the frequency response plots calculated in class. A transient simulation requires requires a few changes from the Bias Point (DC) analysis carried in the introductory tutorial. 1. In setting up the simulation profile, we will choose a “AC Sweep/Noise” analysis, in which a frequency range is specified. The complex voltages and currents in the circuit will be calculated over a range frequencies, which will specify. 2. We need to use an AC voltage or current source. We can specify the amplitude of the source. Most typically, we will use a voltage source with an amplitude of 1 V. 3. We use probes to generate the frequency response plots, which show up in separate windows. Build the circuit As described in the “pspice_DC” tutorial, launch the PSPICE program and start a new, blank “Analog or Mixed A/D” project. (Give the project whatever name you like and have it stored in a convenient place.) If you haven’t done it previously, add the “ANALOG” and “SOURCE” libraries. (The analog library contains the basic components, resistors, capacitors, capacitors, etc. and the source library contains all the sources.) From the source library, choose the “VAC” source, as shown below, and place it in the drawing window. 1 From the analog library, add a resistor and a capacitor to the drawing window. Add a ground a connection, and then wire the parts together, as shown below. Change the capacitor value to 47 nF (47n in PSPICE terminology) and the resistor to 2.2 kΩ. That amplitude of the source can remain at the default value of 1 V. You can change the component labels to whatever you like. We should recognize this is as a simple 1st-order lowpass circuit with cutoff frequency of fc = (2πR1C1)–1 = 1540 Hz. 2 Set up the Simulation profile Set up a new simulation profile. (Give it whatever name you like.) From the pop-up menu, choose the “AC Sweep/Noise” analysis type. You can choose the range of frequencies for which the circuit will be simulated. For this example, we will sweep over several orders of magnitude, so choose the “Logarithmic” Sweep Type. Enter the start frequency (10 Hz), stop frequency (1 MHz) and how many points per decade (10). (The more points used, the longer the computation will take.) Add probes and run the simulation PSPICE calculates all of the complex node voltages and branch currents at each frequency. We use probes to indicate which voltages or currents should be graphed in the frequency response plot. For now, choose the single voltage probe from the toolbar at the top and place it on the node between the resistor and capacitor. (Recall that the single probe will calculate the voltage at that node with respect to ground.) Note that the probes are initially gray in color – they will change colors after the simulation has been run. Once the probe is in place, run the simulation by clicking on the “run” button at the top. 3 The plot If the simulation runs successfully, a plot window will open. Initially, it may be hidden behind the drawing window – click the flashing icon in the tray at the bottom to bring the plot to the front. The plot should show the frequency response of the magnitude of the output voltage, with a linear voltage axis. Of course, we generally prefer use a Bode plot to display the magnitude information. There are two ways to have the voltage expressed in decibels. (Comment: We know that decibels are used to express ratios of voltages, currents, or powers, and that the frequency response plot should be a graph of the magnitude of the transfer function, |T| = |vo/vs|, and not of the output voltage alone. However, by choosing the magnitude of the input voltage to be 1 V, the magnitude of the output voltage is numerically the same as the magnitude of the transfer function. With |vs| =1, making a Bode plot of the magnitude of the output voltage gives us the same graph as a Bode plot of the transfer function.) The first way to get decibels is to change the probe. Back in the circuit diagram, select the voltage problem and delete it. Then choose a dB probe from the PSPICE menu item (Pspice>markers->advanced->dB magnitude of voltage), and place it on the node between the capacitor and resistor. 4 Run the simulation again, and voila – we have a Bode plot. 5 We can use the same technique to plot the phase. From the PSPICE menu, choose a phase probe (Pspice->markers->advanced->phase of voltage) and place it on the same node. Run the simulation again, and the plot now shows the phase as a function of frequency. (The units on the vertical axis are “d” for degrees.) If we wanted, we could put both probes on simultaneously and then both traces would show up in the same plot. However, this can be a bit confusing since only one axis scale is shown. It is probably more clear to keep the traces in separate plots. 6 The other way to make a Bode plot is done from within the plotting view. First, go back to the circuit window, delete all the probes, and run the simulation again. All the voltages are currents are calculated, but since there are no probes, there graph will be blank when you bring up the plotting window. However, you can add a trace (or traces) using the “Trace->Add Trace...” menu item (or the Add Trace icon on the toolbar), which brings up the dialog shown below. On the left-hand side are all of the node voltages, branches, and powers that were calculated in the simulation. On the right are various that can be used in making plots. For example, to plot the output voltage in decibels, we would choose the decibel function on the right and then the capacitor voltage on the left. [V(C1:2) is the upper node of the capacitor. The notation is a bit vague, and sometimes you have to use a bit of trial-and-error to get the correct node or branch.] The expression to be plotted is displayed at the bottom: DB(V(C1:2)). Click OK and the the trace is added to the plot – it looks exactly like the Bode plot obtained using the decibels probe. (Commentary: This approach of defining a trace from scratch also gives you a way to display the magnitude of the transfer function in a rigorously correct manner. Define the trace expression as DB(V(C1:2)/V(VS:+)), giving the ratio of the output to input voltages, expressed in dB. 7 Cursors It is difficult to be accurate when trying to read values off a log-log plot, and we might might like know a reasonably precise value for the corner frequency. We can use the cursor function to find the values of specific x-y (frequency-voltage or frequency-phase) points on the curve. In the plotting window, turn on the cursor using the menu item (Trace->cursor->display) or click on the “Toggle cursor” icon in the toolbar. A cursor (X-Y crosshairs) are added to the graph. You can move the cursor around using the mouse or the arrow keys, and the numerical values off current cursor location are shown in the box in the lower left of the window. Moving the cursor until the magnitude is down by 3 dB from the maximum gives the corner frequency. In this case, we see that the corner frequency is 1540 Hz, as expected. Note that the cursor can only display values at frequencies that were included in the simulation, so the exact corner frequency (where the output is exactly -3.000 dB) probably will not show up. We have to choose the closest point. If we need more accuracy, we should go to the simulation set up and add more points. 8 A third-order filter Shown below, without commentary, are the images for a third-order RC filter simulation. The calculation time for this is only a few milliseconds longer that the first order case. Think about how long it would take you to find the transfer function by hand! 9 A Sallen-Key filter Shown below, without commentary, are the images for a second-order Sallen-Key filter simulation. This might be familiar from lab. 10