where
This creates the state vector in Mathematica.
This sets the input and output vectors.
To obtain
The expression for the derivative contains an undesirable variable,
The replacement rule stored as sln helps to get rid of
The expression for function h is trivial.
So far we have used the built-in Mathematica functions. Now it's time to make accessible the library of functions provided in Control System Professional. This loads the application.
For most Control System Professional functions, the input state-space model must be linear. Therefore, our first task will be to linearize the model, that is, represent it in the form
This is the purpose of the function Linearize, which, given the nonlinear functions f and h and the lists of state and input variables, supplied together with values at the nominal point (the point in the vicinity of which the linearization will take place), returns the control object StateSpace[a, b, c, d], where matrices a, b, c, and d are the coefficients
This performs the linearization.
Mapping the built-in Mathematica function Factor onto components of the state-space object simplifies the result somewhat. (Here /@ is a shortcut for the Map command.)
TraditionalForm often gives a more compact representation for control objects.
Now let us design a state feedback controller that will stabilize the pendulum in a vertical position near the nominal point. One way to do this is to place the poles of the closed-loop system at some points
In this particular case, Ackermann's formula is used. The result is a matrix comprising the feedback gains.
Note that we were able to obtain a symbolic solution to this problem and thus see immediately that, for example, only the first gain depends on
To check if the pole assignment has been performed correctly, we can find the poles of the closed-loop system, that is, the eigenvalues of the matrix
This extracts the matrices from their StateSpace wrapper.
We see that the eigenvalues of the closed-loop system are indeed as required.
With Control System Professional, we can also design the state feedback using the optimal linear-quadratic (LQ) regulator. This approach is more computationally intensive, so it is advisable to work with inexact numeric input. For convenience in presenting results, we switch to the control print display. This is the particular set of numeric values (all in SI) we will use.
Here our system is numericalized.
Let
LQRegulatorGains solves the Riccati equations and returns the corresponding gain matrix.
Here are the poles our system will possess when we close the loop.
Let us make some simulations of the linearized system as well as the original, nonlinear system stabilized with one of the controllers we have designed--say the one obtained with Ackermann's formula. We start with the linearized system and compute the transient response of the system for the initial values of
Here is the list of initial conditions for θ.
This is the linearized system after the closing state feedback. The function StateFeedbackConnect is described in
To compute how the initial condition in θ decays in the absence of an input signal, we can use OutputResponse. In this particular case, the input arguments to OutputResponse are the system to be analyzed, the input signal (which is 0 for all t), the time variable t, and the initial conditions for the state variables supplied as an option. The initial value for θ is denoted as angle.
Here is the plot of the previous function for the chosen values
The case of actual nonlinear system stabilized with the linear controller is more interesting, but requires some work on our part. We note that when the control loop is closed, the input variable--the force
First we prepare the input rules. As we have only one input, there is only one rule in the list.
Recall that we store the description of our nonlinear system as sln.
Now we numericalize the rule, substitute the feedback rules, and, to convert the rule to an equation, apply the head Equal to it (@@ is the shorthand form of the Apply function). The resultant differential equation is labeled de.
This solves the differential equation with the initial conditions for every value in the list
In several graphs that follow, we show the results for
The results for θ are now presented graphically. We can see that the controller succeeds in driving the pendulum to its equilibrium position for all three initial displacements. The plot is stored as plot1.
We can also see that, once the angle θ[t] has come to zero, the derivative
Here is the plot of input force versus time.
Finally, we compare the graphs of θ for the nonlinear and linear systems and see that the only case of smallest initial displacement is treated adequately by the linear model.
The transient responses suggest that our linear feedback is not sufficiently prompt in reacting to moderate and large initial displacements
We solve the same equation for another set of initial conditions.
In the following graphs, we will plot the results for
We find that the pendulum still could be driven from
Of course, the cart in our particular model of the pendulum would not allow the pendulum to rotate in circles, but, for the sake of argument, we will assume that it would. The variations in
This is the force the motor must exert to maintain the process.
The real actuator may not be up to the task. If the maximum force the motor can provide is, say,
To model this situation, we create a clip function.
Here is how it works: everything beyond the interval from
We use clip to saturate the feedback.
This is the new differential equation for θ under the saturated feedback.
This solves it.
Finally, we plot the state response--for
|
|