Control Tutorials for MATLAB and Simulink (2024)

Related Tutorial Links

  • Digital Control Intro
  • Discrete Poles
  • Sampling Activity

Related External Links

Key MATLAB commands used in this tutorial are: ss , c2d , rank , ctrb , dlqr , lsim , stairs

Contents

  • Discrete state-space
  • Controllability
  • Control design via pole placement
  • Adding precompensation

In this page, we will consider the digital version of the aircraft pitch control problem. A sampled-data version of the airplance pitch dynamics can be obtained from the continuous model, as we will describe. In this example we will apply state-space techniques to design the controller.

From the Aircraft Pitch: System Modeling page, the continous-time state-space model of the aircraft pitch dynamics was derived as

(1)Control Tutorials for MATLAB and Simulink (1)

(2)Control Tutorials for MATLAB and Simulink (2)

where the input is elevator deflection angle Control Tutorials for MATLAB and Simulink (3) and the output is the aircraft pitch angle Control Tutorials for MATLAB and Simulink (4).

For a step reference of 0.2 radians, the design criteria are the following.

  • Overshoot less than 10%
  • Rise time less than 2 seconds
  • Settling time less than 10 seconds
  • Steady-state error less than 2%

Discrete state-space

The first step in the design of a digital control system is to generate a sampled-data model of the plant. MATLAB can be used to generate this model from a continuous-time model using the c2d command. The c2d command requires three arguments: a system model, the sampling time (Ts) and the type of hold circuit. In this example we will assume a zero-order hold (zoh) circuit. Refer to the Introduction: Digital Controller Design page, for further details.

In choosing a sample time, note that it is desired that the sampling frequency be fast compared to the dynamics of the system in order that the sampled output of the system captures the system's full behavior, that is, so that significant inter-sample behavior isn't missed. One measure of a system's "speed" is its closed-loop bandwidth. A good rule of thumb is that the sampling frequency be at least 30 times larger than the closed-loop bandwidth frequency which can be determined from the closed-loop Bode plot.

From the closed-loop Bode plot, the bandwidth frequency can be determined to be approximately 2 rad/sec (0.32 Hz). You may verify this yourself. Thus, to be sure we have a small enough sampling time, we will use a sampling time of 1/100 sec/sample. Now we are ready to use the c2d function. Enter the following commands in an m-file. Running this m-file in the MATLAB command window gives you the following four matrices representing the sampled-data state-space model.

A = [-0.313 56.7 0; -0.0139 -0.426 0; 0 56.7 0];B = [0.232; 0.0203; 0];C = [0 0 1];D = [0];sys_ss = ss(A,B,C,D);Ts = 1/100;sys_d = c2d(sys_ss,Ts,'zoh')
sys_d = A = x1 x2 x3 x1 0.9968 0.5649 0 x2 -0.0001385 0.9957 0 x3 -3.931e-05 0.5658 1 B = u1 x1 0.002374 x2 0.0002024 x3 5.744e-05 C = x1 x2 x3 y1 0 0 1 D = u1 y1 0 Sample time: 0.01 secondsDiscrete-time state-space model.

Now we have obtained the discrete-time state-space model shown below.

Control Tutorials for MATLAB and Simulink (5)

Control Tutorials for MATLAB and Simulink (6)

Controllability

As was the case in the continuous case, before we can design our controller we must verify the controllability of the system. For the system to be completely state controllable the controllability matrix must have rank Control Tutorials for MATLAB and Simulink (7) where the rank of a matrix is the number of linearly independent rows (or columns). The controllability matrix of a discrete-time system has the same form as a continous-time system.

(3)Control Tutorials for MATLAB and Simulink (8)

Since our controllability matrix is 3x3, its rank must be 3. The MATLAB command rank can calculate the rank of a matrix for you. Adding the following additional commands to your m-file and running in the MATLAB command window will produce the following output.

co = ctrb(sys_d);Controllability = rank(co)
Controllability = 3

Therefore, our system is completely state controllable since the controllability matrix has rank 3.

Control design via pole placement

The schematic of a discrete full-state feedback control system is shown below, where Control Tutorials for MATLAB and Simulink (9) is the delay operator (not the aircraft's pitch rate Control Tutorials for MATLAB and Simulink (10)). Note that it is assumed that Control Tutorials for MATLAB and Simulink (11) = 0.

Control Tutorials for MATLAB and Simulink (12)

where

  • Control Tutorials for MATLAB and Simulink (13) = control gain matrix
  • Control Tutorials for MATLAB and Simulink (14) = Control Tutorials for MATLAB and Simulink (15) = state vector
  • Control Tutorials for MATLAB and Simulink (16) = reference (Control Tutorials for MATLAB and Simulink (17))
  • Control Tutorials for MATLAB and Simulink (18) = Control Tutorials for MATLAB and Simulink (19) = control input (Control Tutorials for MATLAB and Simulink (20))
  • Control Tutorials for MATLAB and Simulink (21) = output (Control Tutorials for MATLAB and Simulink (22))

Referring back to the state-space equations at the top of the page, we see that substituting the state-feedback law Control Tutorials for MATLAB and Simulink (23) for Control Tutorials for MATLAB and Simulink (24) leads to the following where we will assume that all of the state variables are measured.

(4)Control Tutorials for MATLAB and Simulink (25)

(5)Control Tutorials for MATLAB and Simulink (26)

In the continuous Aircraft Pitch: State-Space Methods for Controller Design page, the Linear Quadratic Regulator (LQR) method was used to find the control matrix (Control Tutorials for MATLAB and Simulink (27)). In this digital version, we will use the discrete version of the same LQR method. This type of control technique optimally balances the system error and the control effort based on a cost that the designer specifies that defines the relative importance of minimizing errors and minimimizing control effort. In the case of the regulator problem, it is assumed that the reference is zero. Therefore, in this case the magnitude of the error is equal to the magnitude of the state. Please consult your control textbook for details. To use this LQR method, we need to define two parameters: the state-cost weighted matrix (Control Tutorials for MATLAB and Simulink (28)) and the control weighted matrix (Control Tutorials for MATLAB and Simulink (29)). For simplicity, we will choose the control weighted matrix equal to 1 (Control Tutorials for MATLAB and Simulink (30) = 1), and the state-cost matrix (Control Tutorials for MATLAB and Simulink (31)) equal to Control Tutorials for MATLAB and Simulink (32). Employing the vector Control Tutorials for MATLAB and Simulink (33) from the output equation means that we will only consider those states in the output in defining our cost. In this case, Control Tutorials for MATLAB and Simulink (34) is the only state variable in the output. The weighting factor (Control Tutorials for MATLAB and Simulink (35)) will be chosen by trial and error in order to modify the step response to achieve our given requirements. In this case, Control Tutorials for MATLAB and Simulink (36) is a scalar since we have a single input system.

Now we are ready to find the control matrix (Control Tutorials for MATLAB and Simulink (37)) employing the MATLAB command dlqr which is the dicrete-time version of the lqr command. We will choose a weighting factor Control Tutorials for MATLAB and Simulink (38) equal to 50, as determined in the continuous Aircraft Pitch: State-Space Methods for Controller Design page, Add the following commands to your m-file and run it in the MATLAB command window. Note that in the following we are overwriting the values of the state-space matrices Control Tutorials for MATLAB and Simulink (39), Control Tutorials for MATLAB and Simulink (40), Control Tutorials for MATLAB and Simulink (41), and Control Tutorials for MATLAB and Simulink (42) with their discrete-time equivalents using the model derived with the c2d command above.

A = sys_d.a;B = sys_d.b;C = sys_d.c;D = sys_d.d;p = 50;Q = p*C'*CR = 1;[K] = dlqr(A,B,Q,R)
Q = 0 0 0 0 0 0 0 0 50K = -0.6436 168.3611 6.9555

Note the structure of the weighting matrix Control Tutorials for MATLAB and Simulink (43) and the resulting gain matrix Control Tutorials for MATLAB and Simulink (44). Referring to the closed-loop state equations given above assuming a control law with non-zero reference, Control Tutorials for MATLAB and Simulink (45), we can then generate the closed-loop step response by adding the following commands to your m-file and running it in the MATLAB command window. The stairstep response shown below should then be generated.

time = 0:0.01:10;theta_des = 0.2*ones(size(time));sys_cl = ss(A-B*K,B,C,D,Ts);[y,t] = lsim(sys_cl,theta_des);stairs(t,y)xlabel('time (sec)');ylabel('pitch angle (rad)');title('Closed-Loop Step Response: DLQR');

Control Tutorials for MATLAB and Simulink (46)

Examination of the above demonstrates that the rise time, overshoot, and settling time are satisfactory. However, there is a large steady-state error. One way to correct this is by introducing a precompensator (Control Tutorials for MATLAB and Simulink (47)) to scale the overall output.

Adding precompensation

Unlike other design methods, the full-state feedback system does not compare the output to the reference; instead, it compares all states multiplied by the control matrix (Control Tutorials for MATLAB and Simulink (48)) to the reference (see the schematic shown below). Thus, we should not expect the output to equal the commanded reference. To obtain the desired output, we can scale the reference input so that the output does equal the reference in steady state. This can be done by introducing a precompensator scaling factor called Control Tutorials for MATLAB and Simulink (49). The basic schematic of our state-feedback system with scaling factor (Control Tutorials for MATLAB and Simulink (50)) is shown below.

Control Tutorials for MATLAB and Simulink (51)

Unfortunately, we can not use our user-defined function rscale.m to find Control Tutorials for MATLAB and Simulink (52) because it is only defined for continuous systems. We can, however, find the correct scaling by trial and error. After several trials, it was found that Control Tutorials for MATLAB and Simulink (53) equal to 6.95 provided a satisfactory response. Modify your m-file as shown below. Running your m-file at the MATLAB command line will then generate the stairstep response shown below.

Nbar = 6.95;sys_cl = ss(A-B*K,B*Nbar,C,D,Ts);[y,t] = lsim(sys_cl,theta_des);stairs(t,y)xlabel('time (sec)');ylabel('pitch angle (rad)');title('Closed-Loop Step Response: DLQR with Precompensation');

Control Tutorials for MATLAB and Simulink (54)

From this plot, we see that the Control Tutorials for MATLAB and Simulink (55) factor eliminates the steady-state error. Now all design requirements are satisfied.


Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)
Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 5329

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.