Log Incomplete Response Experimental testing: Is a system really first-order? Suppose we run an experiment to acquire a step response of a system, and the result looks like Fig. 1. We suspect the system may be first-order, we estimate the time constant from the 63.2% mark, and we use this time constant to mathematically model the system and predict its behavior. ym t Fig. 1: Experimental step response (from System Dynamics by Doebelin). In the following discussion, we develop a method for determining how close such a system is to being truly first-order, and if it is, determining a best estimate of its time constant using all the experimental data, not just the one data point at the 63.2% mark. Step response Suppose we apply a step input u to a system and we measure the output ym and time t so that we have a set of n+1 points for ym as follows: Taking the loge of both sides yields y − y ss t = − . ln m τ y − yss 142 40 43 4 (5) Z (t ) Time t t(0) t(1) Output ym ym(0) ym(1) … … t(n) ym(n) The model of a first-order system is τ y& + y = Gu (t ), (1) where τ is the time constant and G is the static gain. The solution to this ODE (with a step input of magnitude A) is given by − t y (t ) = y ss + ( y 0 − y ss )e τ , (2) where yss = GA. If the system is first order, then the experimental data ought to satisfy y m (t ) = y ss + ( y 0 − y ss )e − t τ (3) Here’s how we check. We manipulate (3) to obtain t − ym − y ss τ =e (4) y0 − y ss and we designate the left-hand side Z, called the logarithm of the incomplete-response, y − y ss . Z (t ) = ln m (6) y0 − yss We compute Z(t) from the experimental data. The ideal Z is a linear function of t with a slope of −1/τ. Procedure: Given experimental step response data ym, estimate the time constant (τest) from the 63.2% point. From the experimental data, extract the first 4τest values of t and ym. Use (6) to compute Z(t). Plot Z(t), and perform a linear curve fit. Fig. 2 shows a representative plot. The closer a linear curve fits the data, the closer the system is to being first order with a time constant τ equal to the negative inverse of the slope of the fitted curve. Conversely, if the plot of Z is clearly not a straight line, then the system is not first order and (1) is not a good model. Z(t) t Fig. 2: Curve-fit to a plot of Z(t) (from System Dynamics by Doebelin). IC response A similar approach can be used when we have experimental data from an initial-condition response (or an impulse response). Suppose we give a system an initial condition y0 and measure the output ym and time t so that we have a set of n+1 points for ym as follows: Time t t(0) t(1) Output ym ym(0) ym(1) … … t(n) ym(n) The model of a first-order system is τ y& + y = 0, (7) where τ is the time constant. The response is given by y (t ) = y0 e − t τ (8) If the experimental system is first order, then the experimental data ought to satisfy y m (t ) = y 0 e − t τ (9) Following a procedure like the one for the step response, we get an expression for Z given by y (t ) Z (t ) = ln m . (10) y0 Again, compute Z(t) from the experimental data and compare it to the ideal Z(t) = (−t/τ). Again, the ideal Z is a linear function of t with a slope of −1/τ. Procedure: Given experimental IC-response ym, estimate the time constant (τest) from the 63.2% point. Extract the first 4τest values of t and ym from the experimental data. Use (10) to compute the log incomplete-response Z(t), plot Z(t), and perform a linear curve fit. Figure 2 shows a representative plot. The closer a linear curve fits the data, the closer the system is to being first order with a time constant τ equal to the negative inverse of the slope of the fitted curve. Conversely, if the plot of Z is clearly not a straight line, then the system is not first order and (7) is not a good model. Name_____________________________ Return to CM __________ Name_____________________________ Lesson 19 Exercise Problem 1 For the step-response data given below, compute and plot the log incomplete response Z(t). Plot a linear curve-fit and determine the time constant. Time (s) 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 ym (in) 0.00 0.97 1.79 2.35 2.83 3.15 3.37 3.53 3.73 3.82 3.91 3.98 4.03 4.06 4.06 4.09 4.13 4.14 4.13 Procedure • • • • • • • Create a Matlab m-file for this exercise. Assign the data in the table to a time vector t and a displacement vector y. Plot y(t) as individual data points. Do not “connect the dots.” Use subplot(211). Estimate y0 and yss. Assign them to variables in your m-file. Compute and plot Z(t) as individual data points. The Matlab function for the natural logarithm is log. Use subplot(212). Perform a linear least-squares curve fit for Z(t). Matlab functions for doing this are described below. Plot the linear curve fit as a line on the same graph as Z. Determine the time constant from the slope of Z. Attach your plots, properly labeled, to this worksheet and turn it in at the end of the period. Question Is the system first-order? Discuss how you might quantify your answer. Polynomial curve-fitting in Matlab Given vectors t and x(t) and an integer value for n, the polyfit command, e.g., producing xfit , the fitted curve. To plot both on the same graph, use, e.g., p = polyfit(t,x,n) plot(t,x,’o’,t,xfit,’-’) computes the coefficients of a polynomial p(t) of order n that fits the data x(t) such that xfit (t ) = p1t n + p2t n −1 + ... + pnt + pn +1 . The polyval command, e.g., xfit = polyval(p,t) evaluates the polynomial p at the values of t, A linear least-squares curve fit is first-order, that is, n = 1. Thus, for a linear curve-fit, the polyfit command produces the vector p = [p1 p2] such that xfit (t ) = p1t + p 2 . It follows that p1 is the slope of the curve and p2 is the intercept. Lesson 19 Exercise Problem 2 Consider the step response and the log incomplete response plot shown in Fig. 1. Step response (in) 4 3 2 1 0 0 5 Time (s) 10 (a) Step response of unknown system. Log-incomplete-response Z(t) Possible first-order step response 5 0 Z(t) -0.2 -0.4 linear fit to Z(t) -0.6 -0.8 -1 0 5 Time (s) 10 (b) Log-incomplete response. Fig. 1: Example of a log incomplete response plot for a system that is not first-order. Question Explain why we can conclude the system that produced this response is not 1st-order even though at first glance it appears it might be 1st-order. Question Suppose a system with the transfer function given below, when subjected to a unit step input, produces the response shown in Fig. 1(a). Rewrite the transfer function in standard form and explain why Fig. 1(a) has the appearance it does. Transfer function: 8 .4 (s + 1)(s + 2)