Control System Design using Maple
Maplesoft, a division of Waterloo Maple Inc., 2004
Introduction
This worksheet demonstrates the use of Maple's LinearAlgebra package to model an inverted pendulum on a cart and create a controller for the system.
The following Maple techniques are highlighted:
Modeling a system
Analyzing the model
Developing and simulating a controller
Animating the results
Introduction to Control System Design
Computer-Aided Control Systems Design tools make extensive use of algorithms from linear algebra. The LinearAlgebra package in Maple, which combines Maple's state-of-the-art symbolics with NAG's fast and efficient numerics, allows for seamless transition through all the phases of system design.
Control Theory - study of dynamical systems with the intention of causing the output to conform to a desired reference value.
Feedback Control - measures the output and uses this information to influence its value.
Examples of Feedback Control Systems
automobile cruise control
airplane auto-pilots
space-telescopes
computer disk-drive read heads
room temperature control
inverted pendulum on a cart - standard introductory control theory example, which demonstrates basic concepts easily.
Initialization
1. Initial Study of the System
Study the system to be controlled.
Understand the dynamic requirements.
Select sensors and actuators.
Inverted pendulum on a cart
sensors - measure the angular displacement of the pendulum and the cart displacement .
actuator - motor which moves the cart.
dynamic requirement - the system must return to its original equilibrium position when disturbances are applied.
2. Model the System
Apply physical laws (i.e. Newton's laws of motion in the case of mechanical systems) to obtain a mathematical model of the system. This is usually a system of ordinary differential equations (although can be pde's as well).
= counter-clockwise angular displacement from upright position
= angular velocity
= position of cart
= velocity of cart
= horizontal force applied to the cart
= half-length of pendulum
= vertical (downward) force exerted on the cart by the pendulum
= horizontal force exerted on the pendulum by the cart
Let and to simplify notation.
Let = position of center of mass of pendulum
The acceleration of the center of mass is then calculated as
Apply F=ma in the horizontal (x-direction) to the pendulum.
Apply F=ma in the direction perpendicular to the pendulum.
Apply F=ma in the horizontal direction to the cart gives:
Apply to the pendulum, where is the sum of all moments about the pendulum's
center of mass, is the pendulumn's moment of inertia, and is its angular acceleration.
The moment of inertia is given by:
The final nonlinear model is
3. Simplify the Model
Create a linearized version of the model. Although this is only valid in a small interval about an equilibrium point, this range of validity is extended by the use of feedback controllers.
In our example, the linearized model is only a good approximation of the system when the pendulum is close to the upright position. However, with a good feedback controller in place the pendulum can go well beyond this range and still be adequately controlled.
Time Domain Representations of Linear Systems
The State-Space Description of a Linear Time-Invariant (LTI) System is given by
where
is a vector (of length ) representing the input signals to the system.
is a vector (of length ) representing the output signals of the system.
is a vector (of length ) representing the internal states of the system.
is an x matrix
Note: if we have a Single-Input, Single-Output (SISO) system.
If neither is 1, we have a Multi-Input, Multi-Output (MIMO) system.
The solution to the state-space equations is given by
where is a linear operator.
Note: this type of integral is called a convolution integral.
We can't solve the integral because we don't know what is (these functions are disturbances to the system which we can be quite arbitrary). Instead, we design a controller which for work well for a class of (bounded) functions , and then simulate the controller for specific values u(t), (i.e. a step or impulse function).
Our nonlinear model is of the form
Verify that the pendulum/cart at rest in the inverted position is an equilibrium point.
Set up the state-vector
Assign values to the parameters
Linearize the equations by computing Jacobians.
Since we are interested only in x and theta as the output variables, we have
Frequency Domain Representations of Linear Systems
Taking Laplace Transforms of the state-space representation yields the Frequency Domain Representation of the system.
where is a ( matrix) rational function, called the Transfer Function.
Working in the frequency domain is convenient, since the differential equations have been turned into algebraic ones, and the convolution operator turns into simple multiplication.
Also many control systems have input/output signals that are sinusoidal and thus transfer functions can be obtained directly from experimental data (this is known as system identification).
4. Analyze the Model
A system is internally stable if the real parts of the eigenvalues of are in the left half-plane (LHP),
i.e. . This keeps the matrix exponential bounded.
A system is input-output stable if the poles of the transfer function are in the LHP.
Roughly speaking, a system is controllable if it can obtain any desired state by an appropriate choice of input signal. A system is observable if given any input and output signals, you can uniquely determine the state of the system. Controllability and observability (and the less strict forms stabilizability and detectability) play a central role in control theory. For example, a controllable and observable state-space representation is a minimal realization (having the smallest number of states) of the transfer function. In this case, the eigenvalues of A are equivalent to the poles of the transfer function.
Maple Procedures to compute Controllability and Observability Matrices
Since the controllability and observability matrices have full rank, the system is controllable and observable.
The eigenvalues of A are
The poles of the transfer function are
The eigenvalues are equal to the poles of the transfer function since the system is controllable and observable. Since there is an eigenvalue in the left half plane the system is unstable.
5. Decide on Performance Specifications
We intend to design a controller that will maintain or create stability in the system while at the same time meeting certain performance criteria. For example we may specify a controller that will track a certain type of input signal, such as a step function, to within a specified error range. Or perhaps we require an optimal controller that will cover a more broad class of bounded inputs.
6. Design a Controller
The choice of controller depends on the performance specifications. Some typical controllers include
Proportional-Integral-Derivative (PID) Controllers
these are controllers of the form
(it is not possible to implement an electronic device with transfer function for the derivative term)
Phase Lead Compensators
these are controllers of the form where .
Phase Lag Compensators
Linear Quadratic Regulators (LQR)
these are optimal controllers which minimize the cost functional
and Controllers
the goal here is to produce optimal controllers in appropriate normed spaces.
A Maple LQR routine
Specify the weights on the input variables.
7. Simulate the Controlled System
Compute the performance of the design, using the original nonlinear model. This step is repeated with different input signals and if the necessary the controller is re-designed until the performance criteria are met.
Specify disturbance to the system as initial conditions to the model.
Plot the angular displacement of the pendulum with respect to time.
Plot the cart displacement with respect to time.
Note that the pendulum returns to its upright position and the cart returns to its initial position, as was intended by the design of the controller.
8. Implement the Controller
Once an appropriate controller has been designed, it is implemented on the real system (or sometimes first as a prototype).
Maple animation
Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material.. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.