experiment 6: state space control for the two degrees of ... experiment 6.pdf · values into matlab...
TRANSCRIPT
Experiment 6: State Space Control for the Two Degrees
of Freedom Helicopter
Charles Tytler
AAE 364L
Thursday 1:30pm
Group 1
April 16, 2009
TA: Dzung Du
Introduction: In this lab an error feedback and a state feedback controller are designed for the 2 Degree-of-
Freedom Helicopter, each controlling both pitch and yaw. These are calculated for the Pre-Lab section of
the lab.
In experimentation, the controllers from the Pre-Lab are modified for improvement based on
actual response of the helicopter. Pitch and yaw control are tested individually and both are tested with
a pulse input and sinusoidal input. For each test, the response of the pitch and yaw of the helicopter are
recorded as well as the motor voltage. From the analysis of both controllers with pulse and sine wave
inputs, the superior controller will be selected.
After the better controller is selected, this lab will observe the effectiveness of the controller
with human control. This is done by controlling the pitch and yaw of the helicopter with a joystick,
attempting to follow a given path.
Finally, the controller designed in this lab will be compared to a PID controller for the same
system designed in a previous lab.
Procedure:
Table 1: Definition of Variables
Symbol Definition
θ Pitch angle ψ Yaw angle Rc Horizontal distance from center of mass to pivot point h Vertical distance from center of mass to pivot point l Distance from front propeller axis to pivot point L Total length of the helicopter x Distance from the small mass to pivot point
mh Mass of the helicopter without the small mass ms Small mass added to helicopter m Total mass of the helicopter
mmotors Mass of the pitch and yaw propellers, propeller shields, and motors mb Mass moving about the pitch axis Jp Moment of inertia of the helicopter relative to the pitch axis Jy Moment of inertia of the helicopter relative to the yaw axis
Jshaft Moment of inertia of metal shaft about yaw axis at end point cp Coefficient of viscous friction corresponding to the pitch axis (Bp) cy Coefficient of viscous friction corresponding to the yaw axis (By) vp Input voltage to the pitch or front motor vy Input voltage to the yaw or back motor vpe Pitch equilibrium voltage vye Yaw equilibrium voltage x Column vector of state variables
xd Desired states inputted into system
𝒙 Error between x and xd
Ai 6x6 Coefficient matrix
Bi 6x2 Coefficient matrix
W 6x2 Coefficient matrix
Ki Matrix of controller gains
Schematics:
Figure 1: Two Degrees of Freedom Helicopter is comprised of two motor driven propellers located about a pivot point which allows movement in the pitch and yaw directions only.
Figure 2: Free body diagram of 2DOF Helicopter Model
Procedure of Experiments:
Error-feedback Controller:
1. Run MATLAB file ‘setup_heli_LQR_parameters.m’ 2. Input Ki values into MATLAB and load Simulink model ‘Heli_LQR.mdl’ 3. Open plots for Pitch, Yaw, and Voltage 4. Set a pitch input as a square wave with a gain of 20º, and no yaw input 5. Run test for 90 seconds, and analyze response 6. Set a yaw input as a square wave with a gain of 30º, and no pitch input 7. Run test for 90 seconds, and analyze response 8. Iterate through steps 4 through 7 while modifying Ki values to find best Ki 9. Record plots for best Ki 10. Repeat process for sine wave inputs instead of square wave
State-feedback Controller:
1. Run MATLAB file ‘setup_heli_LQR_parameters.m’ 2. Input Ki values into MATLAB and load Simulink model ‘Heli_LQR2.mdl’ 3. Open plots for Pitch, Yaw, and Voltage 4. Set a pitch input as a square wave with a gain of 20º, and no yaw input 5. Run test for 90 seconds, and analyze response 6. Set a yaw input as a square wave with a gain of 30º, and no pitch input 7. Run test for 90 seconds, and analyze response 8. Iterate through steps 4 through 7 while modifying Ki values to find best Ki 9. Record plots for best Ki 10. Repeat process for sine wave inputs instead of square wave
Closed Loop Flight Testing
1. Load Simulink model ‘Heli_LQR.mdl’ or ‘Heli_LQR2.mdl’ depending on controller used 2. Set helicopter to joystick control 3. As a desired path, set a sine wave generator for pitch with gain 20º in WinCon 4. Run WinCon and try to control the helicopter to follow the sine wave displayed in the plot with
the joystick 5. Repeat for yaw, with sine wave gain at 30º
Results: State Feedback gain:
𝐾𝑖 = 19.1910 4.5532 12.7446 2.1746 19.1256 3.9180
−0.2160 36.5945 −2.0065 24.3332 −3.0349 24.6911
Pitch Pulse Step Response:
Metric Value
Rise Time 1.68 sec
Overshoot 7.08%
Settling Time 7.86 sec
Steady State Error 0.08º
Yaw Pulse Step Response:
Metric Value
Rise Time 0.95 sec
Overshoot 76.51%
Settling Time 8.05 sec
Steady State Error 0.95º (positive angle) and 6.44º (negative angle)
Analysis:
Equations of Motion The equations of motion for the two degree of freedom helicopter are expressed as
(1.1)
These equations can be linearized for level flight to
(1.2)
where the equilibrium voltages are given as
(1.3)
State Variable Form We can convert these equations into state variable form, using the following state variables:
(2.1)
By using the state variables in (2.1), we can rewrite (1.2) in state variable form as:
(2.2)
The state equations take the form of 𝑥 = 𝐴𝑥 + 𝐵𝑣, where A, B, and ν are defined as:
(2.3)
In order to adjust θ and ψ values to match their desired input values, θd and ψd, integral control must be
introduced to the system, producing two new state variables:
(2.4)
Adding the new state variables to our system produces a new form,
, (2.5)
where Ai, Bi, and W are given by
(2.6)
Controller Design
Error Feedback
To design a controller using state feedback, we create a vector xd to represent desired input,
, (3.1)
and the error between x and xd will be defined as
(3.2)
We will create a controller K that will convert the 6 state matrix into a 2x6 matrix, by
(3.3)
Plugging this new ν into equation (2.5), we arrive at
(3.4)
With this, the controller can be designed using the LQR or pole-placement methods.
(3.5)
State Feedback
To design a state-feedback controller, use the state feedback 𝑣 = −𝐾𝑥 instead of 𝑣 = −𝐾𝑥 . Then, the
state variable system becomes
(3.6)
It is important to note that when using state-feedback, we will include the feed forward term:
(3.7)
The error feedback method will result in a controller with a fast rise time, but significant
overshoot. The state feedback method will provide a controller with a slower rise time and no
overshoot. The settling time for the two is nearly the same, so the choice to use one or the other would
most likely depend on the importance of overshoot. So if you have a system that cannot afford
overshoot, then the state feedback method would be your best choice. However, if response time is
most important, than error feedback would most likely be ideal.
Error Feedback Controller and State Feedback Controller Implementation Two controllers were designed, one using the error feedback method and the other using the
state feedback method. Both were implemented in the Helicopter system and tested with pitch pulse
and yaw pulse inputs. The results for the pitch and yaw response is seen below in Figure 3 and Figure 4,
respectively.
Figure 3: Pitch Pulse Response of Helicopter for Error Feedback and State Feedback Controllers
Figure 4: Yaw Pulse Response of Helicopter for Error Feedback and State Feedback Controllers
The two controllers designed both follow the pulse input well, but the state feedback designed
controller performs slightly better. The state feedback controller provides response that has a quicker
settling time as well as a lower overshoot than the error feedback controller for both pitch and yaw. The
one disadvantage is its steady state error for yaw at negative angles, where it shows an error of about 6º
when trying to reach a -30º input. However, the controller is still better than the one designed with
error feedback, which has an overshoot of 40º when the -30º input is given. Whether the overshoot or
the steady state error is of larger concern depends on the intended use of the system, but for the
general case, the state feedback controller will be used because of its superior performance in settling
time and overshoot for both inputs.
State Feedback Controller Analysis The state feedback controller was tested with Pitch Pulse, Yaw Pulse, Pitch Sinusoid, and Yaw
Sinusoid inputs, and its pitch, yaw, and voltage response were all recorded. Figure 5 to Figure 16 show
the plotted results of these tests.
Figure 5: Pitch Response of Helicopter with Pitch Pulse Input
Figure 6: Yaw Response of Helicopter with Pitch Pulse Input
Figure 7: Voltage Response of Helicopter with Pitch Pulse Input
Figure 8: Pitch Response of Helicopter with Yaw Pulse Input
Figure 9: Yaw Response of Helicopter with Yaw Pulse Input
Figure 10: Voltage Response of Helicopter with Yaw Pulse Input
Figure 11: Pitch Response of Helicopter with Sinusoidal Pitch Input
Figure 12: Yaw Response of Helicopter with Sinusoidal Pitch Input
Figure 13: Voltage Response of Helicopter with Sinusoidal Pitch Input
Figure 14: Pitch Response of Helicopter with Sinusoidal Yaw Input
Figure 15: Yaw Response of Helicopter with Sinusoidal Yaw Input
Figure 16: Voltage Response of Helicopter with Sinusoidal Yaw Input
Voltage Saturation
The voltage applied to the motors stayed within its limits and thus no saturation was
experienced in the system. If there was saturation, a maximum would have been reached and
maintained in the plot when the commanded voltage exceeded the capability of the motor. This would
not make the system unstable, but it would diminish the responsiveness. When the commanded voltage
is higher than the motor’s maximum, the motor will only be able to output at its maximum voltage; this
means that the system will not have the rise time the controller expects and will thus not reach the full
potential of the controller. For such a case, the controller should be modified to remain within the
bounds of the motor’s capabilities in order to have the most efficient system.
Controller Performance
The controller designed works well for the pitch of the helicopter, but could use more
improvement for the yaw. The results section shows the step response characteristics for the pitch and
yaw controllers calculated with the MATLAB function stepinfo.m. The characteristics seen in the two
tables show that the settling time for both are nearly equal, at 7.86s and 8.05s for the pitch and yaw,
respectively. The two controllers achieve this differently though. The yaw controller has a quick rise time
of 0.95s but with a large overshoot of 76.51%. The pitch controller uses a slower response, with a 1.68s
rise time, but very little overshoot, only 7.08%.
The piloting of a helicopter will not have many step inputs however, but will normally use more
gradual adjustments throughout flight. Therefore, a better test for the controllers would be a ramp
input, since it would more closely simulate actual use of the system. The ramp response of the system
can be seen in Figure 11 for pitch and Figure 15 for yaw. To analyze the response, Figure 17 below shows
the error for pitch and yaw when responding to the ramp input used for Figure 9 and Figure 15,
respectively.
Figure 17: Error in Ramp Response for a) Pitch; b) Yaw
The pitch controller responded fairly well to the sinusoidal input. It experienced difficulties in
matching the climbing and descent of the pitch angle; the peaks of the error plot for pitch show the
error in descent, it would reach a maximum deviation from the path of 4º. The controller had greater
difficulty with climbing, where it would deviate as much as -7º, seen in Figure 17 at times t = 30, 60, and
90. This is not unusual since climbing requires the motor to supply a force to overcome gravity, whereas
descent just requires a controlled decrease in motor force and angle. The yaw response was not as good
as the pitch response, due to the steady state error problems witnessed in the step response. When
responding to a sine wave input, the controller would hold at -23º instead of moving all the way down to
-30º. This is shown in Figure 15 and Figure 17 in the time periods t = 33-45s and t = 83-95s.
Human Control
The State Feedback Controller was tested with human control by setting the helicopter to
respond to a joystick input. With the state feedback controller implemented, the response matches the
joystick well; after a little practice it is not difficult at all to follow a desired path. If the controller were
not installed, the pilot would need to input a series of on/off commands for the voltage to hold a
desired pitch or yaw. The manual control required for level flight is not intuitive if the human is
controlling the voltage. The controller allows joystick position to correlate to helicopter position, where
if a certain angle on the joystick is held, a certain angle for pitch of the helicopter is also held.
Need for Integrators
When the joystick is used, the need for integrators in the system really shows. With a joystick,
the idea is that a human user may input an angle with the joystick, and the helicopter will move to that
angle and maintain it. This is where the integrators in the controller are important, since they reduce the
steady state error in the control. This allows the helicopter to match the inputs, so if an input of a pitch
at 20º is provided, the helicopter will move to 20º and match that input. The margin of error off from
20º will depend on how well the controller is designed. Integrators accomplish this by increasing the
equation type such that it eliminates steady state error for higher order inputs. An example is a Type 1
system can be controlled to have zero steady state error for a ramp input by introducing an integrator,
raising the system to a Type 2 system.
State Feedback Controller versus PID Controller
The controller design process for the state feedback provides a more sophisticated approach
compared to that for the PID controller. The PID controller identifies the transfer function for the entire
system to be controlled then adjusts three gains to create the desired output. With state feedback each
state of the system is taken into account for control. This allows more specific controller design, when
the LQR method is used, the different states can be weighted. For the Two Degrees of Freedom
Helicopter system, there are 6 states taken into account per motor for controller design. The PID
controller has only 3 variables per motor to adjust, grouping together certain characteristics. So for fine
tuning of a controller, the state feedback method is preferred since it allows much more specific
adjustments than the PID method.
In Figure 18 the State Feedback Controller is compared to a PID controller designed for the
helicopter in another lab.
Figure 18: Comparison of State Feedback and PID Controllers with: a) Pitch Pulse Response; b) Yaw Pulse Response
The State Feedback controller far exceeds the PID controller’s performance. The overshoot is
much less as well as the settling time. The one weakness of the State Feedback controller is the steady
state error with the yaw, however with the PID controller it does not even reach its settling point with
the pulse input for yaw. Also, if more time were spent on the State Feedback controller design, the
steady state error could be reduced by using smaller gains.
Conclusion: The impact of the controller as a whole was seen by piloting the helicopter with closed loop and
open loop flight. Flying accurately without a controller is nearly impossible, and when the goal of a
vehicle is to serve the purposes of the pilot, the controls must be made as easy as possible. The PID
controller transforms an awkward voltage input to a control system that directly relates the movement
of the joystick to the maneuverings of the vehicle. This is a much more intuitive control system for a
human, and thus makes flight control much easier for a pilot to learn and perform.