This example shows how to robustly tune a PID controller for an uncertain mass-spring-damper system modeled in Simulink.
Simulink Model of Mass-Spring-Damper System
The mass-spring-damper depicted in Figure 1 is modeled by the second-order differential equation
where
is the force applied to the mass and
is the horizontal position of the mass.



Figure 1: Mass-Spring-Damper System.
This system is modeled in Simulink as follows:

We can use a PID controller to generate the effort
needed to change the position
. Tuning this PID controller is easy when the physical parameters
are known exactly. However this is rarely the case in practice, due to a number of factors including imprecise measurements, manufacturing tolerances, changes in operating conditions, and wear and tear. This example shows how to take such uncertainty into account during tuning to maintain high performance within the range of expected values for
.




Uncertainty Modeling
The Simulink model uses the "most probable" or "nominal" values of
:

Use the "uncertain real" (
ureal
) object to model the range of values that each parameter may take. Here the uncertainty is specified as a percentage deviation from the nominal value.Nominal Tuning
First tune the PID controller for the nominal parameter values. Here we use two simple design requirements:
- Position
should track a step change with a 1 second response time
- Filter coefficient
in PID controller should not exceed 100.
These requirements are expressed as tuning goals:
Create an
slTuner
interface for tuning the "Controller" block in the Simulink model, and use systune
to tune the PID gains and best meet the two requirements.
Use
getIOTransfer
to view the closed-loop step response.
The nominal response meets the response time requirement and looks good. But how robust is it to variations of
?

Robustness Analysis
To answer this question, use the "block substitution" feature of
by the uncertain values
slTuner
to create an uncertain closed-loop model of the mass-spring-damper system. Block substitution lets you specify the linearization of a particular block in a Simulink model. Here we use this to replace the crisp values of 
um,uc,uk
defined above.
To assess the robustness of the nominal tuning, apply the tuned PID gains to the (untuned) uncertain model
UST0
and simulate the "uncertain" closed-loop response.
The
in the specified uncertainty range. Observe the significant performance degradation for some parameter combinations, with poorly damped oscillations and a long settling time.
step
plot shows the closed-loop response with the nominally tuned PID for 20 randomly selected values of 
Robust Tuning
To improve the robustness of the PID controller, re-tune it using the uncertain closed-loop model
UST0
rather than the nominal closed-loop model ST0
. Due to the presence of ureal
components in the model, systune
automatically tries to maximize performance over the entireuncertainty range. This amounts to minimizing the worst-case value of the "soft" tuning goals Req1
and Req2
.
The robust performance is only slightly worse than the nominal performance, but the same uncertain closed-loop simulation shows a significant improvement over the nominal design.

This is confirmed by plotting the worst-case gain from
to
as a function of frequency. Note the attenuated resonance near 1 rad/s.



A comparison of the two PID controllers shows similar behaviors except for one key difference. The nominally tuned PID excessively relies on "cancelling" (notching out) the plant resonance, which is not a robust strategy in the presence of uncertainty on the resonance frequency.

For further insight, plot the performance index (maximum value of the "soft" tuning goals
for the nominal damping
. Use the "varying parameter" feature of
values covering their uncertainty ranges.
Req1,Req2
) as a function of the uncertain parameters 

slTuner
to create an array of closed-loop models over a grid of 

This plot shows that the nominal tuning is very sensitive to changes in mass
or spring stiffness
, while the robust tuning is essentially insensitive to these parameters. To complete the design, use


writeBlockValue
to apply the robust PID gains to the Simulink model and proceed with further validation in Simulink.
Your style is so unique in comparison to other people I've read stuff from.
ReplyDeleteThank you for posting when you've got the opportunity, Guess I'll
just bookmark this blog.