| Contents | Index |
| On this page… |
|---|
Creating Improved Controllers for the Stewart Platform Designing a New PID Controller Trimming and Linearizing the Platform Motion |
Note Before working through this study, consult the control design preliminary, About Controllers and Plants, and work through the first control design study, Analyzing Controllers preceding. This study builds on the results and concepts of the latter. In addition to Simulink and the SimMechanics product, this study use these products: |
This second control design case study begins by showing you how to create and optimize a new PID controller. It starts with the creation of a new PID controller ab initio, locates a steady state and linearizes the platform's motion about this equilibrium, and adjusts the linearized platform dynamics to optimize the new PID controller. The study ends by introducing multivariable synthesis as a step beyond PID control, implementing a more complex and realistic multivariable controller and comparing its performance with the new PID controller.
Note This section requires Control System Toolbox. Saving intermediate model versions and workspace values is recommended. |
The PID controller gains set by the initialization script are preoptimized. The preceding case study, Analyzing Controllers, uses these gain values as examples.
In the rest of this study, you follow a more realistic scenario where the gains are not initially known and you use control design tools in the MATLAB environment to create and optimize a filtered PID controller.
Make an initial guess for the integrator (I) gain Ki with dimensional analysis. Ki has dimensions force/length/time.
An initial guess for the force is one-sixth the weight of the platform and legs.
An initial guess for the length is range of vertical motion in the reference trajectory.
An initial guess for 1/time is the natural frequency, π/2π = 0.5 Hz.
Thus an initial guess for the integrator gain is
Ki = 0.5*9.8*(top_mass/6+(upper_leg_mass+lower_leg_mass))/0.3 Ki = 7.1680e+003
The initialization script sets the workspace variable initCondI to the value needed to put the platform in a symmetric equilibrium in the initial state. With a new Ki value, you need to recalibrate this initial condition.
initCondI = ... (upper_leg_mass+lower_leg_mass+(top_mass*1.3/6))*9.81/Ki initCondI = 0.6839
Start by turning off the PID controller and applying a constant force to the platform.
Right-click the controller subsystem. Select Block Choice > Null Controller.
Right-click Null Controller again. Select Link Options > Go To Library Block.
The configurable subsystem library mech_stewart_controller opens.
Under Edit, select Unlock Library. Open the Null Controller template subsystem.
In the subsystem, between the Gain and Force (Output) blocks, insert an Integrator block.

Open the Integrator dialog. For Initial condition, enter Ki*initCondI. Click OK.
Close Null Controller. Save and close the mech_stewart_controller library.
At the command line, enter Ki*initCondI.
This is your first guess for the controller force in one leg: the product of your PID integrator (I) gain guess and your controller initial state guess.
Now observe the effect of this constant force on the platform.
In the Leg Reference Trajectory subsystem, set the Trajectory Switch position to down.
Open the Scope and start the simulation. The control force is less than the platform weight. The platform accelerates downward.
Note This section requires Control System Toolbox and Simulink Control Design. Saving intermediate model versions and workspace values is recommended. |
A critical step in control design is to understand the response of a plant being controlled to small disturbances in its motion [5]. This step requires
Trimming the platform, or finding an operating point. This is a time trajectory satisfying certain prior conditions that you specify.
Here you search for the simple, useful operating point of symmetric equilibrium, where the platform does not move.
Linearizing the platform motion about the operating point.
You save the results of the linearization to use in the next section, Improving the New PID Controller.
As described in Trimming and Linearizing Through Inverse Dynamics, you can trim SimMechanics models in many ways. Control System Toolbox and Simulink Control Design provide linear analysis tools richer and more powerful than what Simulink and SimMechanics software alone offer.
Now set up the model for trimming. In Trimming mode, the model's mechanical states are the 40 constraints that reduce the 52 free (forward dynamics) states to the 12 independent states.
Make sure the model observes these settings.
Keep the controller subsystem Block Choice set to Null Controller and the derivative type to Filtered Derivative.
Keep the Trajectory Switch down (static trajectory) in the Leg Reference Trajectory subsystem.
Reset the SimMechanics analysis mode to trimming.
Open the Plant subsystem. Double-click the orange Machine Environment block. Locate the Parameters tab.
For Analysis mode, change the pull-down menu to Trimming. Click OK and close the subsystem.
Observe the trimming output blocks that have appeared in the upper left of the main model.
![]()
Next, locate an operating point for the Stewart platform plant.
Select linearization points in your model as follows. Right-click, in turn, on each of the Simulink signal lines defining the input and output of the Plant subsystem:
Leg Forces (input)
Pos (output)
On each signal line's right-click menu, under Linearization Points, select
Both Input Point and Open Loop for the input line
Both Output Point and Open Loop for the output line
Choosing the open-loop property for these signals breaks the feedback loop from controller to plant back to controller. The plant instead takes a given set of externally imposed controller forces.
Then, from the model menu bar, select Tools > Control Design > Linear Analysis. The Control and Estimation Tools Manager window opens.
To the left of the Manager window, select the Operating Points node. Then, to the right, select the Compute Operating Points tab. Click the Sync with Model button at the bottom of the tab.

The default subtab is States. The Steady State check boxes are selected by default. This choice searches for a plant operating point where the platform is at rest relative to its initial configuration.
Examine the states by scrolling down in the States window.
There are six states associated with the null controller Integrator block.
Clear the Steady State check boxes for these states. The trimming will not hold the controller signal as fixed.
Below these six are twelve states associated with the Transfer Fcn blocks in the Filtered Derivative subsystem.
Free them from being fixed by clearing their Steady State check boxes. Make their values (0) known by selecting their Known check boxes.
The rest of the states are associated with the positions and velocities of the Stewart platform leg joints. Only six of these states are independent. The others are constrained. Leave their settings as the defaults.
Move to the Outputs subtab. Under Output Specifications, select the Known check box (the topmost check box in that column). This action specifies all outputs, the state deviations from the desired operating point. There are 40 states (constraints) in Trimming mode.
The output values are specified in the Value column. The values are all zero, indicating that all constraints on states (the specifications of the operating point) must be satisfied within tolerance.

From the Manager window menu bar, select Tools > Options. The Options window opens. Select the Operating Point Search tab.
In the Optimization Method area, select Nonlinear least squares in the Optimization Method menu.
Leave the other defaults. Click OK. The Options window closes.
Back in the Control and Estimation Tools Manager, click the Compute Operating Points button at the bottom of the Compute Operating Points tab.
The Computation Results subtab indicates the progress of the trimming. When finished, it should indicate that the operating point specifications were successfully met.
In the Operating Points node to the left, a new Operating Point subnode appears, Operating Point, containing the results of this trimming.
Examine and save the operating point results.
Click Operating Point. Look at the States and Outputs tabs.
Under Outputs, the Desired dx values (if not marked N/A) are zero. For the mechanical states (constraints), the Actual dx values (deviations from the requested operating point) are zero within tolerance.
This is not true for the Controller states, which you did not require to vanish. The Filtered Derivative states are all zero.
Save this operating point by right-clicking Operating Point and selecting Export. Except for the name, leave the defaults.
For Variable Name, enter oppoint_PLANT. Click OK.
You now have a workspace object (opcond.OperatingPoint class) called oppoint_PLANT representing the plant holding still at the start of simulation (t=0). Retain this object for later use.
Examine its states by entering
oppoint_PLANT % List plant states at t=0
Reset the controller initial condition to the new operating point.
initCondI = oppoint_PLANT.States(1).x(1);
Now switch the model back to Forward Dynamics mode. The mechanical states are now the 52 tree states corresponding to the uncut joint primitives.
Open the Plant subsystem, then its orange Machine Environment block. Locate the Parameters tab.
In the Analysis mode pull-down menu, select Forward Dynamics. Click OK and close the subsystem.
Then linearize the plant motion about the operating point you specified in earlier. Return to the Control and Estimation Tools Manager.
Select Tools > Options. In the Options dialog, select the Linearization State Ordering tab.
Click the Sync with Model button at the bottom, then click OK.
Now select the Linearization Task node to left, then the Operating Points tab. Select the Operating Point called Operating Point.
At the bottom of the tab, make sure the Plot linear analysis result in a check box is selected. Then choose a plot type in the pull-down menu. For example, pick Bode response plot.
Then click the Linearize Model button. The LTI Viewer opens with a large family of Bode response plots.
For later reference, you can choose other response plot types by right-clicking on one of the plots and, under Plot Type, selecting a different plot, such as Bode, Step, or Impulse. (You do not need to go back to Linearization and relinearize the model.)
This plant linearization started with six inputs (the leg forces) and 12 outputs (six leg positions and six leg velocities). The LTI Viewer displays 6 x 12 = 72 response plots. To view one plot individually,
Right-click any one of the 72 plots and select I/O Selector. The I/O Selector dialog opens.
This dialog lets you to choose any response of one output relative to one input. To see that plot in the LTI Viewer, click the corresponding black dot.
Each plot shows how one of the outputs (a position or velocity) responds to the application of a small force in one of the input channels. Different plot types (impulse, step, Bode, etc.) yield different aspects of the response.
Export the results of your linearization.
Choose your model and give it a unique name (call it sys) under Export As.
Click Export to Workspace. The model is saved as an LTI object. The variable class is ss, the canonical state space form used by Simulink.
Retain this LTI object for the next section, where you use it to improve the PID controller.
You can apply these results to other controllers (see Synthesizing a Robust, Multichannel Controller following), as well as choose other operating points.
Note This section requires Control System Toolbox and Simulink Control Design. Saving intermediate model versions and workspace values is recommended. To proceed with this section, you need to have completed the preceding section, Trimming and Linearizing the Platform Motion. |
In this section, you use the linearization results to create a controller to better match the plant. This information allows you to convert open-loop information about the controller and plant into closed-loop behavior of the coupled system.
A PID controller acts as the same controller on each of the platform legs. You can improve the controller's response to each leg's motion by working with the diagonal components of the plant response. These components represent a leg's motion response to the force acting on that leg. This control design paradigm is single-in, single-out (SISO). By symmetry, designing the PID settings with one of the leg's control behavior optimizes them for the other five.
The SISO approach ignores coupling between the legs. The last section of this study, Synthesizing a Robust, Multichannel Controller following, tackles multichannel coupling to achieve a more accurate controller design.
From the preceding section, Trimming and Linearizing the Platform Motion, you should have these saved in your workspace:
Linearized plant model as an LTI object (ss class) called sys
Controller initial condition initCondI reset to the operating point
Useful intermediate model versions and workspace variable MAT-files
Throughout this section, keep the derivative block as Filtered Derivative and the PID controller as biproper.
Many of the mechanical states in sys are constrained. Remove them with the sminreal command. This reduction works with the structure of the sys, rather than (like minreal) with the numerical properties of sys.
G = sminreal(sys); % Structural reduction of linearized sys
G now represents the reduced linearized plant.
One way to get a feel for the effect of PID feedback control on the Stewart platform's motion is to vary the gains, frequency cutoff, and force saturation systematically, while holding fixed the reference trajectory and the platform initial conditions.
The larger Kd is relative to Kp and Ki, the more sensitive the controller is to immediate changes in the reference signal. (The same is true of Kp relative to Ki.) The derivative term emphasizes rapid change. On the other hand, if Kd is small, the controller is more sluggish in response. The Ki term emphasizes memory of motion errors past. A fundamental tradeoff of control design is
A more responsive PID controller is also less stable against high-frequency (short time-scale) disturbances such as noise.
A more stable controller is less responsive to feedback.
For large filtering constant A, the biproper transfer function c(s) behaves at small s almost exactly like the improper C(s). But as you reduce A, c(s) behaves less like C(s). In the time domain, for smaller A, the controller c(s) shows more transient deviation from the pure derivative behavior of C(s).
The PID controller also depends on the force saturation limit, set in the workspace by force_act_max. Making the force saturation limit too small means that the controller cannot actuate the legs sufficiently to make them keep up with the reference trajectory signal. The platform motion moves toward instability with a lower force saturation limit. Too low a limit eventually yields motion that is unacceptably extreme or completely unstable. Up to a point, you can compensate for a lower force saturation limit by making the controller more responsive.
A better way to optimize the PID controller is to analyze the open- and closed-loop machine response with the SISO design tool.
Open the SISO Design Tool by entering
sisotool(G(1,1)); % SISO design tool for first leg-leg pair
The design tool opens with a unity controller (compensator), C(s) = 1. Use the Help menu for more information about the design tool, including how to interpret the plot symbols.
The Root Locus Editor to the left shows the closed-loop CG/(1+CG) response, the s-plane poles, zeros, and root-loci. The Open-Loop Bode Editor to the right shows the open-loop CG plant response, including poles and zeros.
The closed-loop response has eight poles, four on the left-half and four on the right-half of the s-plane, the latter indicating instability. The open-loop Bode plot displays the gain and phase margins.
SISO Design Tool with Stewart Platform Plant at Rest and Unity Controller

To design a biproper PID controller, add two zeros and two poles and adjust the overall gain. Observe these general rules for the poles and zeros:
The numerator coefficients, including the overall gain, must be positive. The easiest way to ensure this is for both zeros to have negative real parts.
One pole must occur at zero. This corresponds to the integrator (I) part.
The other pole must have negative real part.
To implement,
Select Compensators > Edit > C. The Edit Compensator C dialog opens. Add poles and zeros. Click OK. The dialog closes.
In the root-locus plot, you can move controller and closed-loop poles and zeros around by dragging them with your mouse. As you move closed-loop poles, you also change the overall controller gain. Be sure to leave the initially stable closed-loop poles in the left half-plane.
In the Bode editor, you can move open-loop (controller) poles and zeroes by dragging them. You can also change the gain and phase margins.
The SISO design tool controller form is κ(1+αs)(1+βs)/s(1+γ]s). The overall control gain κ is Ki in this form.
For Ki, use the value of your first guess found previously in Designing a New PID Controller.
To optimize your controller, change its response to suppress undesirable and enhance desirable feedback. The objectives, typical in control problems, are a high-gain response at low frequencies to achieve tracking performance and a diminishing response at high frequencies to limit the controller's sensitivity to plant variations and noise.
The platform motions have low bandwidth, typically only a few Hertz (Hz). The system should have strong response up to a few Hz (ω = about 10 rad/s), then falling response for higher frequencies.
One controller pole must always remain at zero. Five system poles have positive (unstable) real parts, a result of the first leg coupling to the other five. You cannot eliminate these in a SISO analysis.
Improve the controller by
Making the nonzero controller pole more negative. This increases A and increases the phase margin while decreasing the gain margin.
Improving transient response by adjusting the controller zeros.
Lowering the gain margin by raising the overall Bode response. This increases the overall controller gain κ = Ki.

Once you have a satisfactory controller, you can export the new optimized biproper control law to the workspace and analyze it there to redefine the filtered PID controller parameters Ki, Kp, Kd, and A.
Export the modified compensator from the SISO design tool.
cBiproperOpt is a zero-pole-gain form (LTI object of class zpk). For example,
cBiproperOpt
Zero/pole/gain:
6171074.4994 (s+15.51) (s+0.08378)
----------------------------------
s (s+400)Extract the biproper PID controller parameters by inverting the zeros s±, poles, and gain K. The standard zero-pole-gain form is
c(s) = K(s - s+)(s - s-)/s(s+A) = [(Kp + AKd)*s2 + (Ki + AKp)*s + AKi]/s(s + A)
A = the negative of the biproper nonzero pole
The gains are:
Ki = Ks+s- , Kp = -[K(s+ + s-) + Ki]/A , Kd = (K - Kp)/A
Reset your workspace variables accordingly.
[z,p,k] = zpkdata(cBiproperOpt) % Extract ZPK data from cBiproper
A = -p{1,1}(2) % Extract nonzero pole
Ki = k*z{1,1}(1)*z{1,1}(2)/A % Extract Ki gain
Kp = -(k*(z{1,1}(1) + z{1,1}(2)) + Ki)/A % Extract Kp gain
Kd = (k - Kp)/A % Extract Kd gainCheck that the symmetric equilibrium is stable with your new controller.
Update the diagram (Ctrl+D) and rerun the model.
A trim point is rarely exact. There is typically a small but nonzero motion error as the platform relaxes toward equilibrium.
Now test the platform motion with the moving trajectory and your new retuned biproper control law.
Restart the model. You should see reasonable motion errors and leg forces, except perhaps for an initial transient.
Capture the Motion Errors from the logged signals structure sigsOut.
pid_opt_TS = sigsOut.('Motion Errors'); % Record motion errorsNote This part of the study requires Control System Toolbox and Robust Control Toolbox. To complete this section, you need to have completed the preceding section, Improving the New PID Controller. |
The controllers you have designed so far in this and the preceding control design studies are based on classical PID techniques, where each channel is subject to the same control law and the control law is tuned one channel at a time. This approach misses the cross-coupling, the effect that the force on one platform leg has on the motion of the other legs.
In this section, you redesign the Stewart platform controller by using modern techniques that take multichannel coupling into account and implementing a robust H-infinity controller [6], [7].
From preceding sections, you should have these saved in your workspace:
Reduced state space representation G of the plant
Time series structure pid_opt_TS
Before starting,
From its right-click menu, under Block choice, switch the controller subsystem to H_inf Controller.
Make sure that the derivative subsystem remains set to Filtered Derivative and the Trajectory Switch in the Leg Reference Trajectory subsystem is set to up.
Examine the controller subsystem, which is implemented via state space.
Stewart Platform H-Infinity Controller Subsystem

Start by specifying a desired open-loop response |C*G(1,1)| and plot its singular values. For example,
Lsd = zpk([],[-1000 0],612770) % Define desired loop shape Zero/pole/gain: 612770 ---------- s (s+1000) sigma(Lsd) % Plot singular values
View the closed-loop response generated by this loop shape by entering:
step(feedback(Lsd,1)) % Feedback step response
Desired Loop Shape: Singular Values

Now create a controller using the desired loop shape and plant response:
[K_ls,CL,GAM,INFO] = loopsyn(G,Lsd); % Synthesize controller
Check the size of the controller by entering
size(K_ls) % Check size of loopsyn controller
The example controller has 48 states. It is usually impractical to implement a controller of such high order and computational intensity. So try reducing the controller to 24th order:
Kr_ls = reduce(K_ls,24); % Reduce controller order
To estimate how many states you can ignore (truncate), plot both the full and reduced singular values
sigma(K_ls,Kr_ls) % Plot singular values
Full and Reduced Loop-Synthesized Controllers: Singular Values

From the synthesized loop shape, extract the matrices needed to define the state space model used in the H_inf Controller subsystem.
[Ak,Bk,Ck,Dk] = ssdata(Kr_ls); % Extract state space model
Run the loop-synthesized controller model. Then capture the motion errors.
loopsyn_TS = sigsOut.('Motion Errors'); % Record motion errorsFinally, compare the motion error data from the two controllers:
Redesigned PID
Robust loop-synthesized
At the command line, enter:
figure
plot(pid_opt_TS.Time,pid_opt_TS.Data(1,:),'r', ...
loopsyn_TS.Time,loopsyn_TS.Data(1,:),'b')
ylabel('Motion Errors','FontSize',16)
xlabel('t (seconds)','FontSize',16)
legend('Redesigned PID Controller','Loopsyn Controller')Apart from the initial transient, the loop-synthesized controller performs better than the redesigned PID controller. In this example, the late-time robust controller motion errors are more than an order of magnitude smaller and exhibit no oscillatory "ringing."
Redesigned PID and Loop-Synthesized Control System Motion Errors

![]() | Analyzing Controllers | Generating and Simulating with Code | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |