0% found this document useful (0 votes)
52 views20 pages

HC Laboratory Handout Simulink

The document outlines a laboratory handout for a 2DOF Helicopter Control experiment using Matlab/Simulink, detailing the aim, procedure, and theoretical background necessary for conducting the experiment. It includes instructions for manual control, data collection, and designing PID controllers for pitch and yaw stabilization over three lab sessions. The document emphasizes the importance of feedback control and parameter estimation in stabilizing the helicopter's motion.

Uploaded by

davidyount30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views20 pages

HC Laboratory Handout Simulink

The document outlines a laboratory handout for a 2DOF Helicopter Control experiment using Matlab/Simulink, detailing the aim, procedure, and theoretical background necessary for conducting the experiment. It includes instructions for manual control, data collection, and designing PID controllers for pitch and yaw stabilization over three lab sessions. The document emphasizes the importance of feedback control and parameter estimation in stabilizing the helicopter's motion.

Uploaded by

davidyount30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

2DOF Helicopter Control (MAE175a)

Laboratory Handout using Matlab/Simulink Software


January 13, 2025
Prof. R.A. de Callafon, Dept. of MAE, UCSD
TA: Nicolas Herard email: [email protected]

Contents
1 Aim and Procedure of Experiment 2
1.1 Aim of experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Laboratory procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Background Theory on Modeling 12


2.1 Rigid body dynamics of 2DOF helicopter model . . . . . . . . . . . . . . . . 12
2.2 Parameter estimation for 2DOF helicopter model . . . . . . . . . . . . . . . 14

3 Control Design 15
3.1 PID control via sequential loop shaping . . . . . . . . . . . . . . . . . . . . . 15
3.2 State feedback control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Decoupling State feedback control . . . . . . . . . . . . . . . . . . . . . . . . 19

4 Laboratory Report 19
1 Aim and Procedure of Experiment
1.1 Aim of experiment
The two degree of freedom (2DOF) helicopter system created by Quanser is a (rigid) heli-
copter model mounted on a fixed base with two propellers that are driven by DC motors.
The front or “pitch” propeller controls the elevation of the helicopter nose about the pitch
axis. The back or “yaw” propeller controls the side to side motions of the helicopter about
the yaw axis. The pitch and yaw motion require control to stabilize the motion of the 2DOF
helicopter model and for control purposes, the pitch and yaw angles are measured using
high-resolution encoders. The pitch encoder and motor signals are transmitted via a slip
ring, allowing free yaw motion, but the pitch motion is limited by the base support.

The aim of this control experiment is to stabilize the the 2DOF motion
of the helicopter model and track pitch and yaw reference signals by
applying controlled signals to the propellers.

Step-wise changes in pitch and yaw propeller motors will be used to estimate parameters
of the dynamic model of the helicopter. Feedback control of measured or observed pitch
and yaw angles will be used to stabilize the 2DOF motion of the helicopter. The control is
inherently multivariable, requiring feedback and control of both pitch and yaw, and dynamic
interactions between the pitch and yaw dynamics must be taken into account during the
control design.

1.2 Laboratory procedure


The 2DOF Helicopter Control (HC) experiment is completed within 3 laboratory sessions.

Session 1: manual control and data collection for parameter estimation


During the first laboratory session the 2DOF helicopter is controlled manually (open-loop)
via a simply joystick control to appreciate the difficulty to control this multivariable system
by hand and to collect data for the estimation of parameters of the dynamic helicopter model.
Lab Session 1 starts by familiarizing yourself with the Matlab/Simulink software used for
experiments and controller implementation for the 2DOF Helicopter Model.

• Copy all Matlab/Simulink files from the public MAE 175 Helicopter folder on the
desktop (or the contents of simulink_tools.zip on canvas) to your personal MATLAB
folder (e.g. <your username> (\\acsnf4.ucsd.edu\...) or H:\MATLAB. The copied
MAE 175 Helicopter folder should now consists of the sub-folders Courseware Resources
and Technical Resources.
• Browse to the just copied personal MATLAB folder, most likely given by the name:
H:\MATLAB\MAE 175 Helicopter\Courseware Resources\Advanced Applications\Software
and click on the q_heli_2d_open_loop.mdl Simulink model to start Matlab and
Simulink in the correct folder.

2
• You should now see a Quanser 2 DOF Helicopter: Open-loop Analysis Simulink
diagram that will run the 2 DOF helicopter in open-loop via the joy stick.
• You may only have to do this once. Either use the CTRL+e keys or click on the
Hardware Setting button from the Simulink model to open the Configuration Pa-
rameters window and click on the Code Generation tab. Under the System target
file option, click browse and look for the quarc_win64.tlc file. Click the apply
button and OK button to confirm.

Subsequently, for open-loop (joy-stick) control, the following steps must be followed in the
lab.

• Make sure the Quanser amplifier (big black box) and the Quanser Q2 USB (QUARC
or little black box on top of the amplifier) are turned on.
• Open the Matlab setup script setup_lab_heli_2d.m by a double click
• Run the Matlab setup script setup_lab_heli_2d.m via a click on the green run arrow
on top of editor screen.
Running the script file ensures everything is configured properly. For example, the
parameters K_JOYSTICK_V_X and K_JOYSTICK_V_Y control the rate at which a voltage
command is generated, whereas the JOYSTICK_X_DZ and JOYSTICK_Y_DZ specify the
dead-zone for the joystick.
• Switch back to Quanser 2 DOF Helicopter: Open-loop Analysis Simulink model
and click on the Scopes block and double click the theta (deg), psi (deg) scopes in
the Scopes block.
These scopes display both the desired and measured the pitch θ(t) and yaw ψ(t) angles
of the Helicopter. Additional signals such as the voltages Vp (t) and Vy (t) respectively
being applied to the pitch and yaw motors and (estimated) angular pitch velocity ·θ(t)
and angular yaw velocity ψ̇(t) can also be visualized and saved/logged.
• To enable data logging, make sure to click on the Configuration Properties (gear
icon) button, selected the Logging tab and enable Log Data to WorkSpace and en-
able Limit data points to last to 50000 points to save the last (approximate) 30
seconds of data of your experiment. You can change the variable Name to something
more meaningful, other than ScopeData. For example, use Theta for theta angle and
Psi for the psi angle.
Keep in mind:
– Any logged data by the scopes gets (over)written on the Matlab workspace (mem-
ory), every time you restart the experiment.
– Do not choose variable names that overwrite important existing parameters al-
ready on the workspace, as that may cause your Simulink run to fail.

3
• To start the 2D Helicopter with a Matlab/Simulink (real-time) run, click on any of the
small green arrows in the theta (deg), psi (deg) scopes. When correctly configured
by the above steps, Simulink should respond with a build, deploy and running the
model on the ‘DefaultHardwareBoard’ commands in the status bar of the Diag-
nostic Viewer sub-window.
• Grab the joy stick and start moving it around to stabilize the 2D Helicopter. Moving
the joy stick towards/away changes the pitch motor voltage and therefore pitch. Moving
the joy stick left/right will change the yaw motor voltage and therefore the yew. angle.
Hint: use small movements, as larger/fast movements is likely to destabilize the 2DOF
Helicopter model.
• To stop the run of 2D Helicopter with Matlab/Simulink, click on any of the small red
stop buttons in the theta (deg), psi (deg) scopes. You can now plot the last 50000
point of data you have logged (with Matlab’s plot command) or save the data (with
Matlab’s save command) after the stop of the Simulink model (at the end of your
experiment).

A few notes on collecting data:

• During this lab section, have each student perform a stabilization of the 2DOF Heli-
copter and record the data of the pitch θ(t) and yaw ψ(t) angles. In particular, each
students should try to change the pitch angle +5 degrees up and −5 degrees down,
while trying to keep the yaw angle the same. So the Pitch Amplitude changes ±5
degrees with a Frequency to 0.05Hz (every 20 seconds) and see if you can track the
desired pitch angle changes of ±5 degrees, while maintaining a steady yaw angle. Visa
versa, each student should try to change the yaw angle +90 degrees and −90 degrees,
while trying to keep the pitch angle the same.
• Perform the control of the 2DOF Helicopter by visually looking at the helicopter and
by not looking at the 2DOF helicopter, and only looking at the pitch θ(t) and yaw ψ(t)
angles displayed on the screen. Explain why it is more difficult to control the 2DOF
Helicopter by only looking at the angle signals on the screen.
• Once you are able to stabilize the 2DOF helicopter, also perform data collection of step
response data for parameter estimation by applying a step input on the pitch motor
voltage Vp (t) and logging Vp (t), the pitch θ(t) and yaw ψ(t) angle. Similarly, perform
data collection of step response data for parameter estimation by applying a step input
on the yaw motor voltage Vy (t) and logging Vp (t), the pitch θ(t) and yaw ψ(t) angles.
• Get an initial start with the Matlab script file maelab.m and parameters.m to simulate
the dynamics and open-loop step response of the 2DOF helicopter and the design of
feedback controllers.

4
Session 2: automatic control via sequential loop closing
During the second laboratory session you will design separate pitch and yaw proportional-
integral-derivative (PID) controllers via sequential loop-closing to stabilize the system. This
is done in two steps:
1. PID Pitch control with fixed proportional Yaw control
We start of by first keeping the yaw control a simple proportional controller and then
designing, implementing and testing a PID controller for the pitch direction.
2. PID Pitch control with updated PID Yaw control
Once the PID controller for the pitch direction is settled (designed and tested), we now
update the fixed proportional Yaw control to a PID controller.
The step response data obtained in Lab Session 1 can be used to perform the estimation
of the parameters of the dynamic model of the helicopter as explained in the lecture notes
on the 2DOF Helicopter Control Experiment and included in this handout at equation (3).
Make sure to validate the model by comparing a simulation of the angular velocities with
measured angular velocities. Once the model is validated, Pitch and Yaw control can be
designed.
The first step of PID Pitch control with fixed proportional Yaw control starts with Design
of PID Pitch control with fixed proportional Yaw control.
• Make sure you have the parameters for your 2DOF Helicopter Model updated in the
file parameters.m provided to you.
• Open Matlab and run the maelab.m script provided to you, which will read the model
parameters from parameters.m. Choose the (menu) option Design PITCH PID control
(YAW control fixed) and choose a yaw PID controller with simply Kp = 1, Kd = 0 and
Ki = 0 (making the Yaw control simply a proportional controller).
• Following the sequential loop shaping procedure, design a pitch PID controller that is
able to stabilize the pitch motion of the 2DOF helicopter. Understand/motivate your
design for your report and simulate your controller with the other menu options of the
maelab.m script.
• Make note of the numerical values of the proportional gain Kp = Kp_P , the derivative
gain Kd = Kd_P and the integral gain Ki = Ki_P of the PID pitch control, as they will
used later for implementation.

After the design, the first step of PID Pitch control with fixed proportional Yaw control fol-
lows with implementation and testing of PID Pitch control with fixed proportional Yaw
control.
• Browse to your personal MATLAB folder, most likely given by the folder name:
H:\MATLAB\MAE 175 Helicopter\Courseware Resources\Advanced Applications\Software
and click on the q_heli_2d_ff_lqr_i.mdl Simulink model to start Matlab and Simulink
in the correct folder.

5
• You should now see a Quanser 2 DOF Helicopter: Closed-loop Actual and
Simulated System Simulink diagram that will run the 2 DOF helicopter in closed-
loop via automatic computer control.

– Make sure the Program = 1/Joystick = 2 block constant is set to 1 in order


to generate the desired pitch and yaw angles from Simulink.
– Make sure the LQR = 1/LQR +i = 2/Pitch open-loop = 2/Yaw open-
loop = 3 block constant is set to 2 to ensure the 2DOF Helicopter Model can be
controlled by a (multivariabe) PID control.
– By default, the reference pitch angle is initially set to -30.0 degrees. In the De-
sired Angle from Program block, set the Amplitude: Pitch (deg) to 5 and
the Pitch: Constant (deg) to 0.

• You may only have to do this once. Either use the CTRL+e keys or click on the
Hardware Setting button from the Simulink model to open the Configuration Pa-
rameters window and click on the Code Generation tab. Under the System target
file option, click browse and look for the quarc_win64.tlc file. Click the apply
button and OK button to confirm.
• Make sure the Quanser amplifier (big black box) and the Quanser Q2 USB (QUARC
or little black box on top of the amplifier) are turned on.
• Open the Matlab setup script setup_lab_heli_2d.m by a double click.
• Edit the Matlab setup script setup_lab_heli_2d.m by adding the following additional
lines at the end of the file:

Ki = [Kp_P 0 Kd_P 0 Ki_P 0


0 1 0 0 0 0]

where Kp_P is the proportional gain, Kd_P is the derivative gainand Ki_P is the integral
gain of the PID pitch control designed earlier. The value Ki(2,2) = 1 implements the
fixed proportional Yaw control. The additional lines at the end of the file ensures that
indeed a PID Pitch control with fixed proportional Yaw control is implemented.
• Save and run the Matlab setup script setup_lab_heli_2d.m via a click on the green
run arrow on top of editor screen.
• Switch back to Quanser 2 DOF Helicopter: Closed-loop Actual and Simulated
System Simulink model and click on the Scopes block and double click the theta
(deg), psi (deg) scopes in the Scopes block.
These scopes display both the desired and measured the pitch θ(t) and yaw ψ(t) angles
of the Helicopter. Additional signals such as the voltages Vp (t) and Vy (t) respectively
being applied to the pitch and yaw motors and (estimated) angular pitch velocity ·θ(t)
and angular yaw velocity ψ̇(t) can also be visualized and saved/logged.

6
• To enable data logging, make sure to click on the Configuration Properties (gear
icon) button, selected the Logging tab and enable Log Data to WorkSpace and en-
able Limit data points to last to 50000 points to save the last (approximate) 30
seconds of data of your experiment. You can change the variable Name to something
more meaningful, other than ScopeData. For example, use Theta for theta angle and
Psi for the psi angle.
Keep in mind:
– Any logged data by the scopes gets (over)written on the Matlab workspace (mem-
ory), every time you restart the experiment.
– Do not choose variable names that overwrite important existing parameters al-
ready on the workspace, as that may cause your Simulink run to fail.
• To start the 2D Helicopter with a Matlab/Simulink (real-time) run, click on any of the
small green arrows in the theta (deg), psi (deg) scopes. When correctly configured
by the above steps, Simulink should respond with a build, deploy and running the
model on the ‘DefaultHardwareBoard’ commands in the status bar of the Diag-
nostic Viewer sub-window.
• To verify your pitch PID control is working, see if the pitch angle θ(t) track the desired
pitch reference in the pitch angle (theta) scope.
• In the Desired Angle from Program block, gradually increase the Pitch: Constant
(deg) i.e., increment by steps of 2 degrees. The helicopter should be tracking this ref-
erence position about its horizontal.
• To stop the run of 2D Helicopter with Matlab/Simulink, click on any of the small red
stop buttons in the theta (deg), psi (deg) scopes. You can now plot the last 50000
point of data you have logged (with Matlab’s plot command) or save the data (with
Matlab’s save command) after the stop of the Simulink model (at the end of your
experiment).

The second step of PID Pitch control with updated PID Yaw control starts again with a
design of a PID Pitch control with updated PID Yaw control.

• Make sure you have the parameters for your 2DOF Helicopter Model updated in the
file parameters.m provided to you.
• Open Matlab and run the maelab.m script provided to you. Choose the (menu) option
Design YAW PID control (PITCH control fixed) and choose the Kp , Kd and Ki variable
of the pitch PID controller designed earlier.
• Following the sequential loop shaping procedure, design a yaw PID controller that
is able to stabilize the yaw motion and track desired yaw angles changes of +/- 20
degrees. Understand/motivate your design for your report
• Simulate your controller with the other menu options of the maelab.m script.

7
• Make note of the numerical values of the proportional gain Kp = Kp_Y , the derivative
gain Kd = Kd_Y and the integral gain Ki = Ki_Y of the PID yaw control, as they will
used later for implementation.

After the design, the second step of PID Pitch control with updated PID Yaw control is fol-
lowed by the implementation and testing of a PID Pitch control with updated PID Yaw
control.

• Browse to your personal MATLAB folder, most likely given by the folder name:
H:\MATLAB\MAE 175 Helicopter\Courseware Resources\Advanced Applications\Software
and click on the q_heli_2d_ff_lqr_i.mdl Simulink model to start Matlab and Simulink
in the correct folder.
• You should now see a Quanser 2 DOF Helicopter: Closed-loop Actual and
Simulated System Simulink diagram that will run the 2 DOF helicopter in closed-
loop via automatic computer control.

– Make sure the Program = 1/Joystick = 2 block constant is set to 1 in order


to generate the desired pitch and yaw angles from Simulink.
– Make sure the LQR = 1/LQR +i = 2/Pitch open-loop = 2/Yaw open-
loop = 3 block constant is set to 2 to ensure the 2DOF Helicopter Model can be
controlled by a (multivariabe) PID control.
– By default, the reference pitch angle is initially set to -30.0 degrees. In the De-
sired Angle from Program block, set the Amplitude: Pitch (deg) to 5 and
the Pitch: Constant (deg) to 0.

• You may only have to do this once. Either use the CTRL+e keys or click on the
Hardware Setting button from the Simulink model to open the Configuration Pa-
rameters window and click on the Code Generation tab. Under the System target
file option, click browse and look for the quarc_win64.tlc file. Click the apply
button and OK button to confirm.
• Make sure the Quanser amplifier (big black box) and the Quanser Q2 USB (QUARC
or little black box on top of the amplifier) are turned on.
• Open the Matlab setup script setup_lab_heli_2d.m by a double click.
• Edit the Matlab setup script setup_lab_heli_2d.m by adding the following additional
lines at the end of the file

Ki = [Kp_P 0 Kd_P 0 Ki_P 0


0 Kp_Y 0 Kd_Y 0 Ki_Y]

8
where Kp_P is the proportional gain, Kd_P is the derivative gainand Ki_P is the integral
gain of the original PID pitch control and Kp_Y is the proportional gain, Kd_Y is the
derivative gain and Ki_Y is the integral gain of the updated PID yaw control. The
additional lines at the end of the file ensures that indeed separate PID Pitch control
and PID Yaw control are implemented..
• Save and run the Matlab setup script setup_lab_heli_2d.m via a click on the green
run arrow on top of editor screen.
• Switch back to Quanser 2 DOF Helicopter: Closed-loop Actual and Simulated
System Simulink model and click on the Scopes block and double click the theta
(deg), psi (deg) scopes in the Scopes block.
These scopes display both the desired and measured the pitch θ(t) and yaw ψ(t) angles
of the Helicopter. Additional signals such as the voltages Vp (t) and Vy (t) respectively
being applied to the pitch and yaw motors and (estimated) angular pitch velocity ·θ(t)
and angular yaw velocity ψ̇(t) can also be visualized and saved/logged.
• To enable data logging, make sure to click on the Configuration Properties (gear
icon) button, selected the Logging tab and enable Log Data to WorkSpace and en-
able Limit data points to last to 50000 points to save the last (approximate) 30
seconds of data of your experiment. You can change the variable Name to something
more meaningful, other than ScopeData. For example, use Theta for theta angle and
Psi for the psi angle.
Keep in mind:
– Any logged data by the scopes gets (over)written on the Matlab workspace (mem-
ory), every time you restart the experiment.
– Do not choose variable names that overwrite important existing parameters al-
ready on the workspace, as that may cause your Simulink run to fail.
• To start the 2D Helicopter with a Matlab/Simulink (real-time) run, click on any of the
small green arrows in the theta (deg), psi (deg) scopes. When correctly configured
by the above steps, Simulink should respond with a build, deploy and running the
model on the ‘DefaultHardwareBoard’ commands in the status bar of the Diag-
nostic Viewer sub-window.
• To verify your pitch PID and yaw PID control is working, see if the pitch angle θ(t)
and yaw angle ψ(t) track the desired pitch reference in the pitch angle (theta) scope.
• In the Desired Angle from Program block, gradually increase the Pitch: Constant
(deg) or Yaw: Constant (deg) to see if the helicopter tracks these reference posi-
tions.
• To stop the run of 2D Helicopter with Matlab/Simulink, click on any of the small red
stop buttons in the theta (deg), psi (deg) scopes. You can now plot the last 50000
point of data you have logged (with Matlab’s plot command) or save the data (with
Matlab’s save command) after the stop of the Simulink model (at the end of your
experiment).

9
Session 3: state feedback and decoupling control
In the third laboratory session the separate PID controllers are expanded to multivariable
PID controllers as a final multivariable control design based on state feedback. During this
last laboratory session the following steps can be followed.

• Browse to your personal MATLAB folder, most likely given by the folder name:
H:\MATLAB\MAE 175 Helicopter\Courseware Resources\Advanced Applications\Software
and click on the q_heli_2d_ff_lqr_i.mdl Simulink model to start Matlab and Simulink
in the correct folder.
• You should now see a Quanser 2 DOF Helicopter: Closed-loop Actual and
Simulated System Simulink diagram that will run the 2 DOF helicopter in closed-
loop via automatic computer control.

– Make sure the Program = 1/Joystick = 2 block constant is set to 1 in order


to generate the desired pitch and yaw angles from Simulink.
– Make sure the LQR = 1/LQR +i = 2/Pitch open-loop = 2/Yaw open-
loop = 3 block constant is set to 2 to ensure the 2DOF Helicopter Model can be
controlled by a (multivariabe) PID control.
– By default, the reference pitch angle is initially set to -30.0 degrees. In the De-
sired Angle from Program block, set the Amplitude: Pitch (deg) to 5 and
the Pitch: Constant (deg) to 0.

• You may only have to do this once. Either use the CTRL+e keys or click on the
Hardware Setting button from the Simulink model to open the Configuration Pa-
rameters window and click on the Code Generation tab. Under the System target
file option, click browse and look for the quarc_win64.tlc file. Click the apply
button and OK button to confirm.
• Make sure the Quanser amplifier (big black box) and the Quanser Q2 USB (QUARC
or little black box on top of the amplifier) are turned on.
• Open the Matlab setup script setup_lab_heli_2d.m by a double click.
• Remove any additional lines at the end of the file hat wee introduced during Lab
Section 2.
• Instead, modify the default values for the diagonal matrix Q and Qi given on line 74
and 85 the Matlab setup script setup_lab_heli_2d.m. When changing these values,
recall what importance and effect they have on the finally computed state feedback
gains.
• Save and run the Matlab setup script setup_lab_heli_2d.m via a click on the green
run arrow on top of editor screen. Inspect the values of the computed state feedback
gains K (without integrator) and Ki (with integrator) produced by the Matlab setup
script setup_lab_heli_2d.m, keeping in mind that:

10
– The first 2 rows in K refer to the multivariable “proportional” part of your mul-
tivariable controller as it will used in the feedback of the pitch angle θ(t) and yaw
angle ψ(t).
– The second 2 rows in K refer to the multivariable “derivative” part of your mul-
tivariable controller as it will used in the feedback of the derivative pitch angle
d
dt
θ(t) and derivative yaw angle dtd ψ(t).
– The third 2 rows in K refer to the multivariable “integral” part of your multi-
variable
R controller as it will used in
R the feedback of the integrated pitch angle
θ(τ )dτ and integrated yaw angle ψ(τ )dτ .

• Switch back to Quanser 2 DOF Helicopter: Closed-loop Actual and Simulated


System Simulink model and click on the Scopes block and double click the theta
(deg), psi (deg) scopes in the Scopes block.
These scopes display both the desired and measured the pitch θ(t) and yaw ψ(t) angles
of the Helicopter. Additional signals such as the voltages Vp (t) and Vy (t) respectively
being applied to the pitch and yaw motors and (estimated) angular pitch velocity ·θ(t)
and angular yaw velocity ψ̇(t) can also be visualized and saved/logged.
• To enable data logging, make sure to click on the Configuration Properties (gear
icon) button, selected the Logging tab and enable Log Data to WorkSpace and en-
able Limit data points to last to 50000 points to save the last (approximate) 30
seconds of data of your experiment. You can change the variable Name to something
more meaningful, other than ScopeData. For example, use Theta for theta angle and
Psi for the psi angle.
Keep in mind:
– Any logged data by the scopes gets (over)written on the Matlab workspace (mem-
ory), every time you restart the experiment.
– Do not choose variable names that overwrite important existing parameters al-
ready on the workspace, as that may cause your Simulink run to fail.
• To start the 2D Helicopter with a Matlab/Simulink (real-time) run, click on any of the
small green arrows in the theta (deg), psi (deg) scopes. When correctly configured
by the above steps, Simulink should respond with a build, deploy and running the
model on the ‘DefaultHardwareBoard’ commands in the status bar of the Diag-
nostic Viewer sub-window.
• To verify your pitch PID and yaw PID control is working, see if the pitch angle θ(t)
and yaw angle ψ(t) track the desired pitch reference in the pitch angle (theta) scope.
• In the Desired Angle from Program block, gradually increase the Pitch: Constant
(deg) or Yaw: Constant (deg) to see if the helicopter tracks these reference posi-
tions.
• To stop the run of 2D Helicopter with Matlab/Simulink, click on any of the small red
stop buttons in the theta (deg), psi (deg) scopes. You can now plot the last 50000

11
point of data you have logged (with Matlab’s plot command) or save the data (with
Matlab’s save command) after the stop of the Simulink model (at the end of your
experiment).

To further improve the state feedback control design, one is encourage to include the decou-
pling effect to reduce the effect of (dynamic) coupling between the yaw and pitch motion
of the 2DOF helicopter model. The computation and design of a decoupling state feedback
control algorithm is explained in more detail in the lecture notes on the 2DOF Helicopter
Control Experiment and the design procedure is as follows

• Open Matlab and run the maelab.m script provided to you. Choose the (menu) option
Design decoupling multivariable (state feedback) control.
• Choose (similar/same) values of the diagonal elements of the state weighting matrix
Q as used in the Linear Quadratic Regulator (LQR) problem for the (non-decoupling)
multivariable state feedback control to compute the optimal state feedback gain K.
• Again inspect the numerical values of the matrix K computed and displayed to you,
keeping in mind the multivariable “proportional”, “‘derivative” and “integral” gains
of your multivariable state feedback controller. Specifically, compare the computed
K computed here for decoupling state feedback with the K computed earlier for the
(non-decoupling) state feedback and comment on the differences.
• Always simulate your controller with the other menu options of the maelab.m script.

Replace the computed Ki produced by the Matlab setup script setup_lab_heli_2d.m


by the computed Klqr produced by the maelab.m script. One can alternate between the
design produced by the Matlab setup script setup_lab_heli_2d.m or by script maelab.m
for a comparison.

2 Background Theory on Modeling


2.1 Rigid body dynamics of 2DOF helicopter model
The free-body diagram of the 2 DOF Helicopter is illustrated in Figure 1. For modeling
the rigid body dynamics, the following conventions are used in the free body diagram of
Figure 1:

• The helicopter is horizontal when the pitch angle θ equals θ = 0.


• The pitch angle θ(t) increases positively, e.g. dtd θ(t) > 0, when the body rotates in
the counter-clockwise (CCW) direction along the pitch axis (nose of helicopter moves
upwards).
• The yaw angle ψ(t) increases positively, e.g. dtd ψ(t) > 0, when the body rotates in the
clockwise (CW) direction along the yaw axis.

12
• A positive pitch thrust force Fp creates a positive pitch moment oriented in the counter-
clockwise (CCW) direction along the pitch axis.
• A positive yaw thrust force Fy creates a positive yaw moment oriented in the clockwise
(CW) direction along the yaw axis.

Figure 1: Free body diagram of 2DOF helicopter model.

The Cartesian coordinates of the center-of-mass are expressed relative to the base coor-
dinate system. The nonlinear equations of motion of the 2 DOF Helicopter can be linearized
around the zero pitch angle position leading to a set of coupled first order differential equa-
tions. With the thrust forces Fp (t) and Fy (t) combined as a multivariable input
 
Fp (t)
u(t) =
Fy (t)

and the pitch and yaw angles combined as a multivariable output


 
θ(t)
y(t) =
ψ(t)

the set of coupled first order differential equations can be written in a standard state space
model format
d
dt
x(t) = Ax(t) + Bu(t)
y(t) = Cx(t) + Du(t)
where the state vector x(t) is comprised of the pitch and yaw angular positions and velocities
 
θ(t)
 ψ(t) 
x(t) = 
 d θ(t) 
 (1)
dt
d
dt
ψ(t)

13
and the state space matrices are given by
   
0 0 1 0 0 0
 0 0 0 1   0 0 
A =  0 0 − JBTpp , B =  Kpp Kpy 
   
 0   JT p JT p 
0 0 0 − JBTyy Kyp Kyy (2)
JT y JT y
   
1 0 0 0 0 0
C = , D =
0 1 0 0 0 0

where
2
JT p = Jp + mh lcm
2 (3)
JT y = Jy + mh lcm
are the (total) pitch and yaw inertia of the 2DOF helicopter model formulated around the
rotation point at a distance of lcm from the Center Of Gravity (COG) of the 2DOF helicopter
model.
With the (multivariable) state space model, also the (multivariable) transfer function of
the 2DOF helicopter model can be computed via a Laplace transform, leading to

S(s) = D + C(sI4×4 − A)−1 B

For the state space model given in (4) it can be shown to lead to a (multivariable) transfer
function S(s) of the format
 app apy 
 " Kpp Kpy #
bp = JBTpp

 (s + bp )s (s + bp )s  app apy JT p JT p
S(s) =  ayp ayy , = Kyp Kyy , (4)
ayp ayy JT y JT y
by = JBTyy
(s + by )s (s + by )s

displaying the relatively simple dynamics of the rigid body motion of the 2DOF helicopter
model, but also the (multivariable) coupling between the pitch and yaw dynamics.

2.2 Parameter estimation for 2DOF helicopter model


Temporarily changing the output y(t) to the angular velocities
 
θ̇(t)
y(t) =
ψ̇(t)

allows us to write a (multivariable) transfer function P (s) with y(s) = P (s)u(s) where
P (s) = s · S(s) and where P (s) is given by
 app apy 
 (s + bp ) (s + bp ) 
P (s) =  ayp ayy  (5)
(s + by ) (s + by )

14
It illustrates that all transfer functions in P (s) are simple first order systems in which the
relevant parameters are given by
 " Kpp Kpy #
bp = JBTpp

app apy JT p JT p
= Kyp Kyy , (6)
ayp ayy J JTy
by = JBy
Ty Ty

   
θ̇(s) Fp (s)
Considering y(s) = , u(s) = and y(s) = P (s)u(s), then a unit step input
ψ̇(s) Fy (s)
Fp (t) = 1, t ≥ 0 on the pitch motor leads to output:
app
· 1 − e−bp t

θ̇(t) =
bp
ayp
· 1 − e−by t

ψ̇(t) =
by

that can be computed via inverse Laplace transform. From this analysis it is clear that the
relevant parameters in (6) can easily be estimated by inspecting the step response data, as
app
• angular pitch velocity θ̇(t) will settle at: limt→∞ θ̇(t) = bp
.
ayp
• angular yaw velocity ψ̇(t) will settle at: limt→∞ ψ̇(t) = by
.

d
• rate of change of θ̇(t) at t = 0: dt
θ̇(t) = app .
t=0

d
• rate of change of ψ̇(t) at t = 0: dt
ψ̇(t) = ayp .
t=0

Inspection of the step response data in the case of a unit step inputs on both the pitch
motor Fp (t) = 1, t ≥ 0 and the yaw motor Fy (t) = 1, t ≥ 0 is summarized in Figure 2 to
illustrate the estimation of the relevant parameters of the helicopter model.

3 Control Design
3.1 PID control via sequential loop shaping
It is clear from the analysis in the previous section and the Bode plot given in Figure ??
that the 2DOF helicopter model is a multivariable system with marginally (un)stable rigid
body and thrust dynamics (integrator) and coupling between the pitch and thrust dynamics.
With the multivariable dynamics described by
    
θ(s) Gpp (s) Gpy (s) Vp (s)
= (7)
ψ(s) Gyp (s) Gyy (s) Vy (s)

the transfer function Gpy (s) captures the yaw-to-pitch dynamics, while Gyp (s) models the
pitch-to-yaw dynamics.

15
Figure 2: Illustration of estimation of relevant parameters for 2DOF helicopter model.

It is possible to design two separate controllers Cp (s) and Cy (s) respectively for the pitch
and yaw direction using only pitch and yaw feedback signals

Vp (s) = Cp (s)[rp (s) − θ(s)]


(8)
Vy (s) = Cy (s)[ry (s) − ψ(s)]

where rp and ry refer to the pitch and yaw reference signals respectively. It can be observed
that the controller in (8) is basically a diagonal controller
    
Vp (s) Cp (s) 0 rp (s) − θ(s)
=
Vy (s) 0 Cy (s) ry (s) − ψ(s)

simplifying the design of the control. Note though, that a diagonal controller does not
necessarily decouple the dynamics of G(s) and care must be given to the dynamic coupling
between pitch and yaw motion of the 2DOF helicopter model during the design.
For the stabilization of the marginally (un)stable rigid body and thrust dynamics of the
2DOF helicopter model, the pitch feedback controller Cp (s) and yaw feedback controller
Cy (s) can be designed as PID controllers of the format

Ki 50s
C(s) = Kp + + Kd
s s + 50
50s
where s+50 is used to approximate the dynamics of a “pure” differentiator s. To pick the PID
controller variables Kp , Ki and Kd , care must be given to the dynamic coupling between the
pitch and yaw dynamics. With sequential loop closing the PID controllers Cp (s) and Cy (s)
can be designed by:

• First fix one of the controllers Cp (s) or Cy (s) (pitch or yaw) with a zero reference.

16
• With the initial controller in place, compute the equivalent closed-loop transfer function
T (s) that incorporates the coupling between the pitch and thrust dynamics.
Assuming the yaw controller Cy (s) is fixed, application of Vy (s) = −Cy (s)ψ(s)] to the
multivariable dynamics given in (7) leads to

Gyp (s)
ψ(s) = Gyp (s)Vp (s) − Gyy (s)Cy (s)ψ(s) ⇒ ψ(s) = Vp (s)
1 + Gyy (s)Cy (s)
and
 
Gpy (s)Cy (s)Gyp (s)
θ(s) = Gpp (s)Vp (s) + Gpy (s)Vy (s) ⇒ θ(s) = Gpp (s) − Vp (s)
1 + Gyy (s)Cy (s)
| {z }
T (s)

• Using the equivalent closed-loop transfer function T (s), design the other controller to
ensure stability and performance.
With the yaw controller Cy (s) fixed, the pitch feedback controller must be designed
using
Gpy (s)Cy (s)Gyp (s)
T (s) = Gpp (s) −
1 + Gyy (s)Cy (s)
and it clear that T (s) = Gpp (s) if either the yaw-to-pitch dynamics Gpy (s) or the pitch-
to-yaw dynamics Gyp (s) is zero. If not, the pitch feedback controller is designed, taking
into account the coupling dynamics in the equivalent closed-loop transfer function T (s).

Due to the subsequent steps in closing each feedback loop, the procedure is referred to
as sequential loop closing. The computation of the equivalent closed-loop transfer function
T (s) and the design of PID controllers using Frequency Domain loop shaping can be done
with the Matlab script maelab.m provided to you. A typical figure created by the Matlab
script maelab.m during Frequency Domain loop shaping design of the pitch PID controller
is given in Figure 3.
The Frequency Domain loop shaping window given in Figure 3 show the Bode plot (am-
plitude top left, phase bottom left) of the equivalent transfer function T (s) in blue dotted
lines. In the same figure, also the Bode plot of the PID controller C(s) is shown in red
dotted lines and the resulting Bode plot of the loop transfer function T (s)C(s). Phase and
amplitude margins can be observed from these figures, while the Nyquist stability criterion
can also be evaluated by inspecting if the Nyquist contour of T (s)C(s) encircle the point
-1 in the top right figure of the window. Finally, the bottom right figure shows the result-
ing closed-loop transfer function from reference to output signal to observe any resonance
behavior and performance of the feedback system for tracking.

3.2 State feedback control


The separate pitch and yaw PID feedback controllers are decoupled controllers and do not
explicitly try to minimize any dynamic coupling between pitch and yaw motion. State
feedback control uses the measured states in pitch and yaw direction (position and velocities)

17
Magnitude Loop Transfer Nyquist contour Loop Transfer
5
10 4

2
0
10

magnitude

imag
0
−5
10
T*C −2
T
C
−10
10 −4
−2 −1 0 1 −4 −2 0 2 4
10 10 10 10
frequency [Hz] real

Phase Loop Transfer Magnitude closed−loop PITCH control


5
100 10

0
phase [deg]

magnitude
−100
0
10
−200

−300
closed loop stable
−5
−400 10
−2 −1 0 1 −2 −1 0 1
10 10 10 10 10 10 10 10
frequency [Hz] frequency [Hz]

Figure 3: Frequency Domain loop shaping window of the pitch controller.

and the states of additional integrators in the controller (for Integral action) to compute two
simultaneous control signals for pitch and yaw control.
The state feedback controller is defined as
 
Vp (s)
u(t) = , u(t) = K(rz (t) − z(t))
Vy (s)

where K is a 2 × 6 state feedback gain matrix and z(t) is the 6 dimensional state vector

θ(t)
 
 ψ(t) 
d
θ(t)
 
z(t) = 
 dt 
d
R dt ψ(t)

 
R θ(τ )dτ
 
ψ(τ )dτ

that includes the state variables defined earlier in (1), augmented with the integral of the
pitch angle θ(t) and the integral of the yaw angle ψ(t) to include Integral action in the state
feedback controller. Similarly, rz (t) is a 6 dimensional reference for the state vector to allow
for tracking of pitch and yaw angle reference signals.
The optimal values of the 2 × 6 state feedback gain matrix
 
k11 k12 k13 k14 k15 k16
K=
k21 k22 k23 k24 k25 k26

18
is computed by solving a Linear Quadratic Regulator (LQR) problem that minimizes
Z ∞
z(τ )T Qz(τ ) + u(τ )T Ru(τ )dτ (9)
τ =0

as a function of a state weighting matrix Q and input weighting matrix R. Elegantly, the
solution to (9) can be solved as a linear matrix equation and gives the optimal values of the
state feedback gain matrix K as a function of the weighting matrices Q and R. Computation
of K as a function of Q and R is provided as a LabView Virtual Instrument (VI) that can be
run to compute the numerical values of K and implement the multivariable state feedback
controller on the 2DOF Helicopter model.

3.3 Decoupling State feedback control


It is clear from the rigid body dynamics model in (4) that the rigid body transfer functions
have the same poles in each “row” of the multivariable transfer function. That property can
be exploited to formulate a constant 2 × 2 “input” weighting matrix W such that
    
S11 (s) S12 (s) W11 W12 S̄11 (s) 0
S(s) · W = =
S21 (s) S22 (s) W21 W22 0 S̄22 (s)

In fact, the choice    


W11 W12 ayy −apy
W = =
W21 W22 −ayp app
will exactly accomplish that task, as
 a a ayp apy 
pp yy
− 0  
 (s + bp )s (s + by )s S̄11 (s) 0
S(s) · W =  =

app ayy ayp apy 0 S̄22 (s)
0 −
(s + by )s (s + bp )s

Note that the zero-valued off-diagonal transfer functions in S(s)W completely eliminate
any cross-talk or dynamic coupling between yaw and pitch motion for the 2DOF helicopter
model.
Hence, instead of designing a state feedback controller (or PID feedback controllers for
that matter) for the dynamic system G(s), we opt to design that same controller for the
dynamic system G(s)W that is (ideally) decoupled. The input weighting matrix W will
then simply be incorporated in the “output” of the controller to implement the decoupling
effect, resulting in a multivariable (decoupling) feedback controller.

4 Laboratory Report
By the end of the 2DOF helicopter control experiment you should have a working multivari-
able controller that outperforms any manual control. The results of your laboratory work
have to be reported in a coherent written report. The report will be graded on the layout
and the contents that should (at least) contain the following items:

19
• Parameter estimation results for the helicopter model based on step response data.
• Design procedure for PD, PID (or state feedback) controllers on the basis of a dynamic
model of the helicopter model.
• Implementation of feedback controllers and comparing closed-loop dynamic experi-
ments with closed-loop dynamic model simulations.
• Sensitivity (robustness) analysis by (closed-loop) experiments that examine settling
time and overshoot variations due to changes in parameters of the helicopter model

— end of laboratory handout —

20

You might also like