Вы находитесь на странице: 1из 5

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. (Well review decibels a little later.) Lets 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. Lets look at each of these cases in the following sections.

Case 1: Given the Mathematical model of the system, construct a Bode Plot Once youve 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, lets consider a second order system with the following transfer function:
1 s + 9.81
2

H (s) =

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, lets specify the range of frequencies were interested in, using the logspace command (similar to the linspace command). Well 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. Ill 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 Ill 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, Im going to simulate the experimental data as follows. First, Ill load the frequency array:
EDU freq = logspace(-1,2,1000); EDU

Remember youll load in actual data from your experiment! Next Ill construct the data points that correspond to a second order system with the transfer function used in the Case 1 example. Ill 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;

Lets 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 Ive taken the log of the mag data, Ill 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 wed expect.

Question:

Why is the greatest magnitude equal to 5 db in Figure 1, and almost 40 db in Figure 2? Theyre the same system, arent they?

Вам также может понравиться