Notas sobre regulación automática - Área de Ingeniería de Sistemas
Transcription
Notas sobre regulación automática - Área de Ingeniería de Sistemas
Notas sobre regulación automática: Estudia el comportamiento dinámico de un sistema frente a órdenes de mando o perturbaciones. • • • • • • Sistema: conjunto de componentes interactuantes. La interacción de los componentes en el sistema genera señales observables. Las señales observables que son de nuestro interés son usualmente denominadas salidas del sistema y las denotaremos con y. El sistema está también afectado por estímulos externos. Las señales externas que pueden ser manipuladas son usualmente llamadas entradas, que denotamos con u, mientras que las que no pueden ser manipuladas son llamadas perturbaciones (z). Las perturbaciones suelen dividirse en aquellas que pueden medirse directamente y aquellas que se ponen en evidencia sólo a través de su influencia en las salidas. Los sistemas no necesariamente están restringidos a sistemas físicos. Pueden ser biológicos, económicos, computacionales, informáticos, sociales, etc. La teoría clásica de control estudia el comportamiento dinámico del sistema a partir de las relaciones existentes entre las variables de entrada y las de salida. Los sistemas físicos son representados para su estudio por modelos integrados por componentes ideales, cuyo comportamiento pueda ser definido mediante expresiones matemáticas. 1 Sistemas en lazo cerrado: DEFINICIÓN Y CARACTERÍSTICAS Los sistemas de control realimentados se denominan también sistemas de control de lazo cerrado. En la práctica, los términos control realimentado y control en lazo cerrado se usan indistintamente. En un sistema de control en lazo cerrado, se alimenta al controlador la señal de error de actuación, que es la diferencia entre la señal de entrada y la salida de realimentación (que puede ser la señal de salida misma o una función de la señal de salida y sus derivadas o/y integrales) a fin de reducir el error y llevar la salida del sistema a un valor conveniente. El término control en lazo cerrado siempre implica el uso de una acción de control realimentando para reducir el error del sistema. ELEMENTOS BÁSICOS 1. Elemento de comparación: Este elemento compara el valor requerido o de referencia de la variable por controlar con el valor medido de lo que se obtiene a la salida, y produce una señal de error la cual indica la diferencia del valor obtenido a la salida y el valor requerido. 2. Elemento de control: Este elemento decide qué acción tomar cuando se recibe una señal de error. 3. Elemento de corrección: Este elemento se utiliza para producir un cambio en el proceso al eliminar el error. 4. Elemento de proceso: El proceso o planta, es el sistema dónde se va a controlar la variable. 5. Elemento de medición: Este elemento produce una señal relacionada con la condición de la variable controlada, y proporciona la señal de realimentación al elemento de comparación para determinar si hay o no error. 2 Sistemas en lazo abierto: DEFINICIÓN Y CARACTERÍSTICAS Son los sistemas en los cuales la salida no afecta la acción de control. En un sistema en lazo abierto no se mide la salida ni se realimenta para compararla con la entrada. En cualquier sistema de control en lazo abierto, la salida no se compara con la entrada de referencia. Por tanto a cada entrada de referencia le corresponde una condición operativa fija; como resultado, la precisión del sistema depende de la calibración. Ante la presencia de perturbaciones, un sistema de control en lazo abierto no realiza la tarea deseada. En la práctica, el control en lazo abierto sólo se utiliza si se conoce la relación entre la entrada y la salida y si no hay perturbaciones internas ni externas. Es evidente que estos sistemas no son de control realimentado. ELEMENTOS BÁSICOS 1. Elemento de control: Este elemento determina qué acción se va a tomar dada una entrada al sistema de control. 2. Elemento de corrección: Este elemento responde a la entrada que viene del elemento de control e inicia la acción para producir el cambio en la variable controlada al valor requerido. 3. Proceso: El proceso o planta en el sistema en el que se va a controlar la variable. 3 Sistemas lineales Un sistema con una entrada x(t) y una salida y(t), es lineal si entre la entrada y sus primeras n derivadas y la salida y sus m primeras derivadas es posible establecer una relación funcional de tipo ecuación lineal diferencial invariable en el tiempo. Un sistema es lineal si verifica el Principio de Superposición, tanto para entradas como para condiciones iniciales. Si para una entrada x(t) la salida es y(t), y para una entrada v(t), la salida es w(t), entonces si se aplica una entrada Ax(t)+Bv(t) (con A y B ctes), la salida será Ay(t)+BW(t). Un sistema que no verifica el principio de Superposición se denomina no lineal . 4 Transformada de Laplace Definición y características: La transformada de Laplace es un método que transforma una ecuación diferencial en una ecuación algebraica más fácil de resolver. F(t): una función del tiempo t tal que f(t) = 0 para t<0 S: una variable compleja S= + jw L: un símbolo operativo que indica que la cantidad a la que antecede se va a transformar mediante la integral de Laplace. F(s): transformada de Laplace La transformada de Laplace se obtiene mediante: El proceso inverso de encontrar la función del tiempo f(t) a partir de la transformada de Laplace F(s) se denomina transformada inversa de Laplace. 5 Tabla de transformadas: 6 7 8 9 FdT de un sistema realimentado: Sabiendo que la FdT de un sistema es: Y ( s) W ( s) = Y ( s ) = W ( s ) X ( s ) = G ( S ) [ X ( S ) H ( s )Y ( s ) ] X ( s) Y (s) G( s) = W (s) = Y ( s ) [1 + G ( s ) H ( s ) ] = G ( s ) X ( s ) X (s) 1 + G( s) H (s ) Ejemplo: Uso del comando TF Ejemplo: FdT con el comando tf(num,den) Tenemos tres sistemas (sys1, sys2, sys3) con las siguientes Fdts, vamos a introducirlas usando el comando tf(num,den) %-----------------------------------------------------------------------% REG.AUTOMATICA Y MATLAB % En este ejemplo introduciremos las Fdts de los sistemas sys1, sys2, sys 3 % mediante el comando tf(num,den) %-----------------------------------------------------------------------%Definicion del sistema sys1: num=[1 1]; % Aqui se define la variable vector del numerador den=[1 2]; % y del denominador. sys1=tf(num,den); % Creacion del sistema sys1 %Definicion del sistema sys2,mediante una sola linea: sys2=tf([1 2 3],[1 4 5 6]); %Definicion del sistema sys3: num=[3 0 0]; % Atencion con los ceros den=[2 6 3]; sys3=tf(num,den); % Visualizacion de las Fdts sys1 sys2 sys3 10 Sistemas realimentados en MATLAB: Matlab dispone de un comando para crear sistemas realimentados a partir de dos sistemas LTI (sys1 y sys), la sintaxis básica es la siguiente: >>w=feedback(sys1,sys2) El sistema resulante w tiene como entrada u y como salida y. Por defecto Matlab asume una realimentación negativa, para aplicar una realimentación positiva la sintaxis es: >>w=feedback(sys1,sys2,+1) Ejemplo: Un servomecanismo de posición está compuesto por: un detector formado por dos potenciómetros que dan 10V/rad, un amplificador de ganancia K variable de 0 a 10, un motor de corriente continua cuya función de transferencia velocidad eje/tensión inducido se aproxima por Km/(1+0.1s) y un sistema reductor de velocidad d erelación 1/50. Determinar: a) Diagrama de bloques del sistema. b) La función de transferencia c/ r (pos. eje salida/ pos. eje referencia). c) La respuesta ante un escalón unitario de entrada para valores de K=10 y Km=25 Diagrama de bloques: r ( rad ) 10 Vr (V ) (V ) K Va (V ) Vc (V ) Km 1 + 0.1 s m 1 ( rad s ) 1 50 c 1 ( rad s ) 1 s 10 Análisis temporal de sistemas lineales Una vez ya se conoce el modelo atemático del sistema, ya estamos en disposición de analizar el comportamiento dinámico del sistema. Para ello se utilizan señales de entrada o excitación sencillas y con transformada de Laplace. El análisis se puede realizar en el dominio del tiempo o la frecuencia. 11 c ( rad ) En ese tema trataremos el análisis en el dominio del tiempo. Primero veremos una clasificación del análisis temporal según la señal de excitación, aquí daremos a conocer las principales funciones para analizar el comportamiento de un sistema. Posteriormente nos centraremos en la respuesta de los sistemas de primer y segundo orden para una entrada tipo escalón unitario. Aquí veremos la mayoría de características que puede tener una respuesta. 12 13 14 15 Sistemas de primer orden: 16 17 18 Ejemplo: Respuesta escalón unitario con MATLAB Tenemos dos sistemas con las siguientes funciones de transferencia: sys1: sys2: . Realizar con MATLAB una gráfica donde veamos la respuesta de los dos sistemas ante un escalón unitario con un tiempo de simulación de 30s. También representar en la misma gráfica, la función escalón unitario. %---------------------------------------------------------------------%REG.AUTOMATICA Y MATLAB %En este ejemplo veremos el uso del comando step %---------------------------------------------------------------------%Definicion de los sistemas: sys1=tf([1],[1 0.5 1]); sys2=tf([1],[1 0.5 4]); %Representacion de la respuesta: t=0:0.01:30; %Respuesta hasta los 30 s. step(sys1,'r', sys2,'g',t);%Representacion en la misma grafica %Aplicaremos rejilla y pondremos un titulo con text: grid text(5, 1.4,'Respuesta de dos sistemas','FontSize',13); 19 20 21 PID Tutorial Introduction The three-term controller The characteristics of P, I, and D controllers Example Problem Open-loop step response Proportional control Proportional-Derivative control Proportional-Integral control Proportional-Integral-Derivative control General tips for designing a PID controller Key Matlab Commands used in this tutorial are: step cloop ote: Matlab commands from the control system toolbox are highlighted in red. Introduction This tutorial will show you the characteristics of the each of proportional (P), the integral (I), and the derivative (D) controls, and how to use them to obtain a desired response. In this tutorial, we will consider the following unity feedback system: 22 Plant: A system to be controlled Controller: Provides the excitation for the plant; Designed to control the overall system behavior The three-term controller The transfer function of the PID controller looks like the following: • • • Kp = Proportional gain KI = Integral gain Kd = Derivative gain First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown above. The variable (e) represents the tracking error, the difference between the desired input value (R) and the actual output (Y). This error signal (e) will be sent to the PID controller, and the controller computes both the derivative and the integral of this error signal. The signal (u) just past the controller is now equal to the proportional gain (Kp) times the magnitude of the error plus the integral gain (Ki) times the integral of the error plus the derivative gain (Kd) times the derivative of the error. This signal (u) will be sent to the plant, and the new output (Y) will be obtained. This new output (Y) will be sent back to the sensor again to find the new error signal (e). The controller takes this new error signal and computes its derivative and its integral again. This process goes on and on. The characteristics of P, I, and D controllers A proportional controller (Kp) will have the effect of reducing the rise time and will reduce ,but never eliminate, the steady-state error. An integral control (Ki) will have the effect of eliminating the steadystate error, but it may make the transient response worse. A derivative control (Kd) will have the effect of increasing the stability of the system, reducing the overshoot, and improving the transient response. Effects of each of controllers Kp, Kd, and Ki on a closed-loop system are summarized in the table shown below. CL RESPO SE RISE TIME OVERSHOOT SETTLI G TIME S-S ERROR Kp Decrease Increase Small Change Decrease Ki Decrease Increase Increase Eliminate Kd Small Change Decrease Decrease Small Change 23 Note that these correlations may not be exactly accurate, because Kp, Ki, and Kd are dependent of each other. In fact, changing one of these variables can change the effect of the other two. For this reason, the table should only be used as a reference when you are determining the values for Ki, Kp and Kd. Example Problem Suppose we have a simple mass, spring, and damper problem. The modeling equation of this system is Taking the Laplace transform of the modeling equation The transfer function between the displacement X(s) and the input F(s) then becomes Let • • • • M = 1kg b = 10 N.s/m k = 20 N/m F(s) = 1 Plug these values into the above transfer function The goal of this problem is to show you how each of Kp, Ki and Kd contributes to obtain • • • Fast rise time Minimum overshoot No steady-state error 24 Open-loop step response Let's first view the open-loop step response. Create a new m-file and add in the following code: num=1; den=[1 10 20]; step(num,den) Running this m-file in the Matlab command window should give you the plot shown below. The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output to an unit step input. This corresponds to the steady-state error of 0.95, quite large indeed. Furthermore, the rise time is about one second, and the settling time is about 1.5 seconds. Let's design a controller that will reduce the rise time, reduce the settling time, and eliminates the steady-state error. Proportional control From the table shown above, we see that the proportional controller (Kp) reduces the rise time, increases the overshoot, and reduces the steady-state error. The closed-loop transfer function of the above system with a proportional controller is: Let the proportional gain (Kp) equals 300 and change the m-file to the following: Kp=300; num=[Kp]; den=[1 10 20+Kp]; t=0:0.01:2; step(num,den,t) Running this m-file in the Matlab command window should gives you the following plot. 25 ote: The Matlab function called cloop can be used to obtain a closed-loop transfer function directly from the open-loop transfer function (instead of obtaining closed-loop transfer function by hand). The following m-file uses the cloop command that should give you the identical plot as the one shown above. num=1; den=[1 10 20]; Kp=300; [numCL,denCL]=cloop(Kp*num,den); t=0:0.01:2; step(numCL, denCL,t) The above plot shows that the proportional controller reduced both the rise time and the steadystate error, increased the overshoot, and decreased the settling time by small amount. Proportional-Derivative control Now, let's take a look at a PD control. From the table shown above, we see that the derivative controller (Kd) reduces both the overshoot and the settling time. The closed-loop transfer function of the given system with a PD controller is: Let Kp equals to 300 as before and let Kd equals 10. Enter the following commands into an mfile and run it in the Matlab command window. Kp=300; Kd=10; num=[Kd Kp]; den=[1 10+Kd 20+Kp]; t=0:0.01:2; step(num,den,t) 26 This plot shows that the derivative controller reduced both the overshoot and the settling time, and had small effect on the rise time and the steady-state error. Proportional-Integral control Before going into a PID control, let's take a look at a PI control. From the table, we see that an integral controller (Ki) decreases the rise time, increases both the overshoot and the settling time, and eliminates the steady-state error. For the given system, the closed-loop transfer function with a PI control is: Let's reduce the Kp to 30, and let Ki equals to 70. Create an new m-file and enter the following commands. Kp=30; Ki=70; num=[Kp Ki]; den=[1 10 20+Kp Ki]; t=0:0.01:2; step(num,den,t) Run this m-file in the Matlab command window, and you should get the following plot. 27 We have reduced the proportional gain (Kp) because the integral controller also reduces the rise time and increases the overshoot as the proportional controller does (double effect). The above response shows that the integral controller eliminated the steady-state error. Proportional-Integral-Derivative control Now, let's take a look at a PID controller. The closed-loop transfer function of the given system with a PID controller is: After several trial and error runs, the gains Kp=350, Ki=300, and Kd=50 provided the desired response. To confirm, enter the following commands to an m-file and run it in the command window. You should get the following step response. Kp=350; Ki=300; Kd=50; num=[Kd Kp Ki]; den=[1 10+Kd 20+Kp Ki]; t=0:0.01:2; step(num,den,t) 28 Now, we have obtained the system with no overshoot, fast rise time, and no steady-state error. General tips for designing a PID controller When you are designing a PID controller for a given system, follow the steps shown below to obtain a desired response. 1. 2. 3. 4. 5. Obtain an open-loop response and determine what needs to be improved Add a proportional control to improve the rise time Add a derivative control to improve the overshoot Add an integral control to eliminate the steady-state error Adjust each of Kp, Ki, and Kd until you obtain a desired overall response. You can always refer to the table shown in this "PID Tutorial" page to find out which controller controls what characteristics. Lastly, please keep in mind that you do not need to implement all three controllers (proportional, derivative, and integral) into a single system, if not necessary. For example, if a PI controller gives a good enough response (like the above example), then you don't need to implement derivative controller to the system. Keep the controller as simple as possible. Example: DC Motor Speed Modeling Physical setup and system equations Design requirements Matlab representation and open-loop response Physical setup and system equations Photo courtesy: Pope Electric Motors Pty Limited A common actuator in control systems is the DC motor. It directly provides rotary motion and, coupled with wheels or drums and cables, can provide transitional motion. The electric circuit of the armature 29 and the free body diagram of the rotor are shown in the following figure: For this example, we will assume the following values for the physical parameters. These values were derived by experiment from an actual motor in Carnegie Mellon's undergraduate controls lab. * moment of inertia of the rotor (J) = 0.01 kg.m^2/s^2 * damping ratio of the mechanical system (b) = 0.1 Nms * electromotive force constant (K=Ke=Kt) = 0.01 Nm/Amp * electric resistance (R) = 1 ohm * electric inductance (L) = 0.5 H * input (V): Source Voltage * output (theta): position of shaft * The rotor and shaft are assumed to be rigid The motor torque, T, is related to the armature current, i, by a constant factor Kt. The back emf, e, is related to the rotational velocity by the following equations: In SI units (which we will use), Kt (armature constant) is equal to Ke (motor constant). From the figure above we can write the following equations based on Newton's law combined with Kirchhoff's law: 1. Transfer Function Using Laplace Transforms, the above modeling equations can be expressed in terms of s. By eliminating I(s) we can get the following open-loop transfer function, where the rotational speed is the output and the voltage is the input. 30 2. State-Space In the state-space form, the equations above can be expressed by choosing the rotational speed and electric current as the state variables and the voltage as an input. The output is chosen to be the rotational speed. Design requirements First, our uncompensated motor can only rotate at 0.1 rad/sec with an input voltage of 1 Volt (this will be demonstrated later when the open-loop response is simulated). Since the most basic requirement of a motor is that it should rotate at the desired speed, the steady-state error of the motor speed should be less than 1%. The other performance requirement is that the motor must accelerate to its steady-state speed as soon as it turns on. In this case, we want it to have a settling time of 2 seconds. Since a speed faster than the reference may damage the equipment, we want to have an overshoot of less than 5%. If we simulate the reference input (r) by an unit step input, then the motor speed output should have: • • • Settling time less than 2 seconds Overshoot less than 5% Steady-state error less than 1% Matlab representation and open-loop response 1. Transfer Function We can represent the above transfer function into Matlab by defining the numerator and denominator matrices as follows: Create a new m-file and enter the following commands: J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; Now let's see how the original open-loop system performs. Add the following commands onto the end of the m-file and run it in the Matlab command window: 31 step(num,den,0:0.1:3) title('Step Response for the Open Loop System') You should get the following plot: From the plot we see that when 1 volt is applied to the system, the motor can only achieve a maximum speed of 0.1 rad/sec, ten times smaller than our desired speed. Also, it takes the motor 3 seconds to reach its steady-state speed; this does not satisfy our 2 seconds settling time criterion. 2. State-Space We can also represent the system using the state-space equations. Try the following commands in a new m-file. J=0.01; b=0.1; K=0.01; R=1; L=0.5; A=[-b/J K/J -K/L -R/L]; B=[0 1/L]; C=[1 0]; D=0; step(A, B, C, D) Run this m-file in the Matlab command window, and you should get the same output as the one shown above. Example: PID Design Method for DC Motor Speed Control Proportional control PID control Tuning the gains From the main problem, the dynamic equations and the open-loop transfer function of the DC Motor are: 32 and the system schematic looks like: For the original problem setup and the derivation of the above equations, please refer to the Modeling a DC Motor page. With a 1 rad/sec step input, the design criteria are: • • • Settling time less than 2 seconds Overshoot less than 5% Steady-stage error less than 1% Now let's design a PID controller and add it into the system. First create a new m-file and type in the following commands (refer to the Modeling page for the details of getting these commands). J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; Recall that the transfer function for a PID controller is: Proportional control Let's first try using a proportional controller with a gain of 100. Add the following code to the end of your m-file: Kp=100; numa=Kp*num; dena=den; 33 To determine the closed-loop transfer function, we use the cloop command. Add the following line to your m-file: [numac,denac]=cloop(numa,dena); Note that numac and denac are the numerator and the denominator of the overall closed-loop transfer function. Now let's see how the step response looks, add the following to the end of your m-file, and run it in the command window: t=0:0.01:5; step(numac,denac,t) title('Step response with Proportion Control') You should get the following plot: PID control From the plot above we see that both the steady-state error and the overshoot are too large. Recall from the PID tutorial page that adding an integral term will eliminate the steady-state error and a derivative term will reduce the overshoot. Let's try a PID controller with small Ki and Kd. Change your m-file so it looks like the following. Running this new m-file gives you the following plot. J=0.01; b=0.1; K=0.01; R=1; L=0.5; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)]; Kp=100; Ki=1; Kd=1; numc=[Kd, Kp, Ki]; denc=[1 0]; numa=conv(num,numc); dena=conv(den,denc); 34 [numac,denac]=cloop(numa,dena); step(numac,denac) title('PID Control with small Ki and Kd') Tuning the gains Now the settling time is too long. Let's increase Ki to reduce the settling time. Go back to your m-file and change Ki to 200. Rerun the file and you should get the plot like this: Now we see that the response is much faster than before, but the large Ki has worsened the transient response (big overshoot). Let's increase Kd to reduce the overshoot. Go back to the m-file and change Kd to 10. Rerun it and you should get this plot: 35 So now we know that if we use a PID controller with Kp=100, Ki=200, Kd=10, all of our design requirements will be satisfied. Example: Modeling a Cruise Control System Physical setup and system equations Design requirements Matlab representation Open-loop response Closed-loop transfer function Physical setup and system equations The model of the cruise control system is relatively simple. If the inertia of the wheels is neglected, and it is assumed that friction (which is proportional to the car's speed) is what is opposing the motion of the car, then the problem is reduced to the simple mass and damper system shown below. 36 Using Newton's law, modeling equations for this system becomes: where u is the force from the engine. For this example, let's assume that m = 1000kg b = 50Nsec/m u = 500N Design requirements The next step in modeling this system is to come up with some design criteria. When the engine gives a 500 Newton force, the car will reach a maximum velocity of 10 m/s (22 mph). An automobile should be able to accelerate up to that speed in less than 5 seconds. Since this is only a cruise control system, a 10% overshoot on the velocity will not do much damage. A 2% steady-state error is also acceptable for the same reason. Keeping the above in mind, we have proposed the following design criteria for this problem: Rise time < 5 sec Overshoot < 10% Steady state error < 2% Matlab representation 1. Transfer Function To find the transfer function of the above system, we need to take the Laplace transform of the modeling equations (1). When finding the transfer function, zero initial conditions must be assumed. Laplace transforms of the two equations are shown below. Since our output is the velocity, let's substitute V(s) in terms of Y(s) The transfer function of the system becomes To solve this problem using Matlab, copy the following commands into an new m-file: 37 m=1000; b=50; u=500; num=[1]; den=[m b]; These commands will later be used to find the open-loop response of the system to a step input. But before getting into that, let's take a look at another representation, the state-space. 2. State-Space We can rewrite the first-order modeling equation (1) as the state-space model. To use Matlab to solve this problem, create an new m-file and copy the following commands: m b u A B C D = = = = = = = 1000; 50; 500; [-b/m]; [1/m]; [1]; 0; ote: It is possible to convert from the state-space representation to the transfer function or vise versa using Matlab. To learn more about the conversion, click Conversion Open-loop response Now let's see how the open-loop system responds to a step input. Add the following command onto the end of the m-file written for the tranfer function (the m-file with num and den matrices) and run it in the Matlab command window: step (u*num,den) You should get the following plot: To use the m-file written for the state-space (the m-file with A, B, C, D matrices), add the following command at the end of the m-file and run it in the Matlab command window: step (A,u*B,C,D) 38 You should get the same plot as the one shown above. From the plot, we see that the vehicle takes more than 100 seconds to reach the steady-state speed of 10 m/s. This does not satisfy our rise time criterion of less than 5 seconds. Closed-loop transfer function To solve this problem, a unity feedback controller will be added to improve the system performance. The figure shown below is the block diagram of a typical unity feedback system. The transfer function in the plant is the transfer function derived above {Y(s)/U(s)=1/ms+b}. The controller will to be designed to satisfy all design criteria. Four different methods to design the controller are listed at the bottom of this page. You may choose on PID, Root-locus, Frequency response, or Statespace. Example: Solution to the Cruise Control Problem Using PID control Proportional control PI control PID control The transfer function for this cruise control problem is the following, • • • • m = 1000 b = 50 U(s) = 10 Y(s) = velocity output and the block diagram of an typical unity feedback system is shown below. The design criteria for this problem are: 39 Rise time < 5 sec Overshoot < 10% Steady state error < 2% To see the original problem setup, see Cruise Control Modeling page. Recall from the PID tutorial page, the transfer function of a PID controller is Let's first take a look at the proportional control. Proportional control The first thing to do in this problem is to find a closed-loop transfer function with a proportional control (Kp) added. By reducing the block diagram, the closed-loop transfer function with a proportional controller becomes: Recall from the PID tutorial page, a proportional controller (Kp) decreases the rise time. This is what we need, if you refer to the Cruise Control Modeling page. For now, let Kp equals 100 and see what happens to the response. Create an new m-file and enter the following commands. kp=100; m=1000; b=50; u=10; num=[kp]; den=[m b+kp]; t=0:0.1:20; step(u*num,den,t) axis([0 20 0 10]) Running this m-file in the Matlab command window should give you the following step response. 40 ote: You can use the Matlab command cloop to find the closed-loop response directly from the open-loop transfer function. If you choose to do so, change the m-file to the following and run it in the command window. You should get the same plot as the one shown above. kp=100; m=1000; b=50; u=10; num=[1]; den=[m b]; [numc,denc]=cloop(kp*num,den,-1); t = 0:0.1:20; step (u*numc,denc,t) axis([0 20 0 10]) As you can see from the plot, both the steady-state error and the rise time do not satisfy our design criteria. You can increase the proportional gain (Kp) to improve the system output. Change the existing m-file so that Kp equal 10000 and rerun it in the Matlab command window. You should see the following plot. The steady-state error has dropped to near zero and the rise time has decreased to less than 0.5 second. However, this response is unrealistic because a real cruise control system generally can not change the speed of the vehicle from 0 to 10 m/s in less than 0.5 second. The solution to this problem is to choose a proportional gain (Kp) that will give a reasonable rise time, and add an integral controller to eliminate the steady-state error. PI control The closed-loop transfer function of this cruise control system with a PI controller is: Recall from the PID tutrial page, an addition of an integral controller to the system eliminates the steadystate error. For now, let Kp equals 600 and Ki equals 1 and see what happens to the response. Change your m-file to the following. kp = 600; 41 ki = 1; m=1000; b=50; u=10; num=[kp ki]; den=[m b+kp ki]; t=0:0.1:20; step(u*num,den,t) axis([0 20 0 10]) ote: If you choose to obtain the closed-loop response directly from the open-loop transfer function, enter the following commands instead of the ones shown above: kp=600; ki=1; m=1000; b=50; u=10; num=[1]; den=[m b]; num1=[kp ki]; den1=[1 0]; num2=conv(num,num1); den2=conv(den,den1); [numc,denc]=cloop(num2,den2,-1); t=0:0.1:20; step(u*numc,denc,t) axis([0 20 0 10]) Whichever the m-file you run, you should get the following output: Now adjust both the proportional gain (Kp) and the integral gain (Ki) to obtain the desired response. When you adjust the integral gain (Ki), we suggest you to start with a small value since large (Ki) most likely unstabilize the response. With Kp equals 800 and Ki equals 40, the step response will look like the following: 42 As you can see, this step response meets all design criteria. PID control For this particular example, no implementation of a derivative controller was needed to obtain a required output. However, you might want to see how to work with a PID control for the future reference. The closed-loop transfer function for this cruise control system with a PID controller is. Let Kp equals 1, Ki equals 1, and Kd equals 1 and enter the following commands into an new m-file. kp=1; ki=1; kd=1; m=1000; b=50; u=10; num=[kd kp ki]; den=[m+kd b+kp ki]; t=0:0.1:20; step(u*num,den,t) axis([0 20 0 10]) Running this m-file should give you the step response of the system with PID controller. Adjust all of Kp, Kd, and Ki until you obtain satisfactory results. We will leave this as an exercise for you to work on. Suggestion: Usually choosing appropriate gains require trial and error processes. The best way to attack this tedious process is to adjust one variable (Kp, Kd, or Ki) at a time and observe how changing one variable influences the system output. The characteristics of Kp, Kd, and Ki are summarized in the PID Tutorial page. 43 Orígenes de estas notas: - Ingeniería de Sistemas y Automática; Universidad de Oviedo; Página web de la asignatura Regulación Automática; http://isa.uniovi.es/docencia/rameuitig/ - Carnegie Mellon - University of Michigan; Control Tutorials for MatLab; http://www.engin.umich.edu/group/ctm/index.html - E.U. d’Enginyeria Tècnica Industrial de Barcelona; Regulación Automática con MatLab; http://usuarios.lycos.es/automatica/ 44