Survey

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Transcript

Creating a Bode Plot ME 4231: Motion Control Laboratory By Frank Kelso / Spring Semester, 2003 Matlab provides some very useful functions that make it simple to look at the steady state frequency response of a linear, time-invariant (LTI) system. The traditional method controls engineers use to look at frequency response is a “Bode Plot.” Bode plots have the magnitude of the system response on the y axis, and the excitation frequency on the x axis. The graph is a log-log plot, and the magnitude of the response is converted into units of decibels. (We’ll review decibels a little later.) Let’s consider two possible cases where you might want to construct a Bode plot: 1. You have constructed a simple mathematical model of your system, and want to create a plot of its frequency response. 2. You have obtained experimental data that documents the frequency response of a system, and you would like to construct a Bode plot from the data. Let’s look at each of these cases in the following sections. Case 1: Given the Mathematical model of the system, construct a Bode Plot Once you’ve derived the mathematical model and determined the transfer function of a dynamic system, Matlab provides two functions that facilitate plotting the frequency response. The two functions are “tf”, used to specify the transfer function, and “bode”, used to generate the Bode plot. As an example, let’s consider a second order system with the following transfer function: 1 H ( s) 1 s 9.81 2 We can use the “tf” command to specify the system transfer function, as follows: EDU» sys = tf( [1], [1 0 9.81] ) Transfer function: 1 ---------s^2 + 9.81 EDU» Notice that tf accepts two arguments: the coefficients of the numerator polynomial, and the coefficients of the denominator polynomial. Next, let’s specify the range of frequencies we’re interested in, using the logspace command (similar to the linspace command). We’ll create a row vector of 100 points ranging from 10-1 to 102, as follows. EDU» freq = logspace(-1,2,100); EDU» Finally, the bode command is used to generate the Bode plot. EDU» bode(sys,freq) EDU» This results in the following plot: Figure 1: Frequency Response (Bode) Plot The traditional units used on Bode plots are decibels (db), which is an archaic set of units originally used in the field of acoustics. Their use is traditional. To express a magnitude M in units of decibels, Mdb = 20 log10( M ) From the plot of the magnitude of the response shown above in Figure 1, I can see that Mdb is equal to about -20 at low frequencies. To “decode” the actual magnitude M, then, I can calculate M = 10Mdb/20 = 10-1 = 0.1 At higher frequencies the magnitude of the response drops at a rate of 40 db per decade. This is characteristic of a second order system. Case 2: Constructing a Bode Plot from Experimental Data Suppose I wanted to characterize the frequency response of a motor (Lab #6). I can do this by running a sine wave command voltage to the motor at a very low frequency, and then measuring the amplitude of the angular displacement of the motor. I’ll store the frequency in the first element of the freq array, and the corresponding motor amplitude in the first element of the mag array. Then I’ll increase the frequency a little, and repeat the experiment. This second frequency is stored in freq(2), and the corresponding magnitude in mag(2). The complete experiment collects data at many frequencies, and stores the results in the two arrays. Plotting the two arrays (magnitude mag versus frequency freq) provides a graphical picture of the frequency response of the motor. To verify that I can create a Bode plot from these two arrays, I’m going to simulate the experimental data as follows. First, I’ll load the frequency array: EDU» freq = logspace(-1,2,1000); EDU» Remember – you’ll load in actual data from your experiment! Next I’ll construct the data points that correspond to a second order system with the transfer function used in the Case 1 example. I’ll do that in two steps: first calculating the magnitude of the denominator, then taking the reciprocal. You should verify for yourself that this is in fact the correct calculation for the magnitude of H(j). EDU» mag =abs( 9.81-(freq.^2) ); EDU» mag = 1./mag; Let’s pretend that these two arrays contain experimental data. The question before us now is, “How can we construct a Bode plot of the data?” By definition, I must first convert the mag array to units of decibels, as follows. EDU» magdb = 20*log10(mag); Since I’ve taken the log of the mag data, I’ll create my log-log Bode plot using the semilogX plotting function, not the loglog plot function. This is shown below. EDU» semilogx(freq,magdb); EDU» grid on The resulting graph is shown below. Notice that I used the “grid on” command to superimpose a grid. Figure 2: Bode Plot from “Experimental” Data As you can see, the graph is essentially the same as the graph produced in the case 1 example, as we’d expect. Question: Why is the greatest magnitude equal to 5 db in Figure 1, and almost 40 db in Figure 2? They’re the same system, aren’t they?