聯系方式

您當前位置:首頁 >> Matlab編程Matlab編程

日期:2019-05-29 11:06

Inverted Pendulum Laboratory Experiment

Part I - Introduction

This experiment aims to demonstrate the design of a stabilizing controller for an inverted pendulum

by means of a linear control law. In implementing such a control system the following

topics will be covered.

Modeling the dynamics of an inverted pendulum using the Euler-Lagrange equation.

Obtaining a linear state-space representation of the system.

Creating a Simulink model to simulate the non-linear behaviour of the pendulum.

Designing a state-feedback control law that improves damping for the pendulum in the

downward position and balances it at its vertical upward position.

Implementing the control law on the Quanser SRV02 + SIP (Single Inverted Pendulum)

plant and evaluating its performance.

The non-linear model is obtained using classical Lagrangian mechanics. The Lagrangian function,

L(·, ·), is defined as

L(q(t), q˙(t)) = T(q(t), q˙(t)) V (q(t)) , (1)

where T and V are the kinetic and potential energies of the mechanical system, respectively and

(q, q˙) are the generalized coordinates.

The dynamics of the system can, then, be obtained through the Euler-Lagrange equation

dtLq˙(t, q(t), q˙(t)) Lq(t, q(t), q˙(t)) = τ , (2)

where Ly denotes the partial derivative of the function L with respect to the variable y, and

τ describes the non-conservative forces applied to the system with respect to the generalized

coordinates, q.

1

Part II - Derivation of the model

For the considered pendulum, the generalized coordinates, q(t), are taken to be the vector

(θ(t), α(t)) representing the angles of the rotary arm and of the pendulum, respectively, see

Figure 1.

The kinetic energy of the pendulum is given by (all parameters are defined in Table 2)

where τm is the motor torque applied at the load gear, Barm is the viscous friction force, Bp the

damping coefficient of the pendulum and kθ and kα are the constant coefficients of the static

friction terms acting on the shaft and the pendulum respectively. Since the pendulum is not

actuated, the only force acting on the link is the damping. Considering the dynamics of the

motor, the motor torque is expressed as

The control variable is taken to be the motor voltage Vm.

The model is derived considering (0, 0) as the downward position and (0, π) as the upward position.

The non-linear model is given by

Figure 1: Kinematics of a single inverted pendulum system.

Q1) Show that the mechanical model can be expressed as in (7) and (8) using the EulerLagrange

equation (2) and considering equations (3)-(6).

Q2) Rewrite the system of differential equations derived in Q1) in the matrix form (9).

Q3) Design a simulink model describing the non-linear model given by (7) and (8) assuming

τm ≡ 0, in order to simulate the unforced response of the pendulum. This model will be

used to estimate the values of the parameters kθ and kα.

a) To estimate the value of the parameter kα let the real pendulum oscilate freely from a

small initial angle (between 3o and +3o) and adjust the value of kα in your simulink

model to match the observed oscilation of the pendulum to the theoretical one of

your model.

b) In the control block, add a constant term as shown in Figure 2. We can estimate the

value of the parameter kθ, by finding the greatest constant torque for which the shaft

remains stationary. (Ensure that the initial value is very small.)

Part III - Linear System Analysis

Q1) (a) Linearize the model (9) in the downward position, (θ, α) = (0, 0).

(b) Repeat the procedure for the upward position, (θ, α) = (0, π).

Q2) Obtain the state space representation of the linearized models derived in Q1), defining the

Figure 2: Modified Control Block.

[x1(t), x2(t), x3(t), x4(t)]T = [θ(t), α(t),

˙θ(t), α˙(t)]T and [x1(t), x2(t), x3(t), x4(t)]T = [θ(t), α(t)?

π, ˙θ(t), α˙(t)]T

for the downward and upward positions, respectively.

(HINTS: (i) Get an expression for q¨(t) and transform the two second-order differential

equations into a system of four first-order differential equations. (ii) Since static friction

is small, it can be ignored in the derivation of the linearised model.)

Part IV - System Analysis

For this section consider the linearized state space models ˙x(t) = Ax(t)+Bu(t) obtained in Part

III.

Q1) Evaluate the expression for the matrices A, B (see Table 2 for the parameter values). Assess

the stability of the linearized systems associated to both the upward and downward

configurations.

Q2) Check controllability of the linearized systems.

Part V - Controller design and implementation

The aim of the controller is to stabilize the equilibrium point of the pendulum in the upward

configuration and improve the damping of the pendulum in the downward. Assuming that all

the states are measurable, the stabilization of the upward and downward equilibria of the pendulum

is achieved through the implementation of a linear static state feedback law, K, of the

form u = K(xd x) where xd is the desired reference input and x the actual state vector.

Q1) If the pair (A, B) is controllable assign the poles to a location of your choice that improves

damping for the downward position and stabilises the upward. Scientifically support your

4

answer. By using pole placement, obtain a pair of control laws corresponding to the poles

you have chosen and comment on their success.

Q2) Compare and contrast your ‘guess’ with the pair of LQR control laws resulting from the

and Rdown = 10, Rup = 100.

Part V - Matlab and Simulink

The Simulink model, Figure 3, is used to control the SRV02 pendulum using the QuaRC software.

The closed-loop system comprises the plant (System) and the controller.

SRV02 Inverted Pendulum: Balance Control

Figure 3: Closed-loop diagram.

The System block, Figure 4, contains the QuaRC sub-blocks required to communicate with the

DC motor and encoders of the actual system (SRV02-ET+ROTPEN-E), the swing-up controller

and a filter block (High-Gain Observer) that calculates the unmeasured states of the system.

As far as this experiment is concerned, all the blocks together make up the plant and, therefore,

the block is not to be tampered with.

The Set point block can be used to adjust the reference input to the system; it is initially set

to a square wave of frequency 0.2Hz. The amplitude of the reference signal can be entered in

degrees in the Amplitude block.

The Swing-up switch can be used to alternate between manual and automatic swing up. In

the OFF position, the user must manually swing the pendulum to the vertical position, where

the controller takes over. In the ON position, a separate energy-based controller swings the

5

pendulum up.

The Stabilize switch allows selection between upward and downward stabilization. Because of

the way the angle of the pendulum is read, it is necessary to set it to the correct position

otherwise the controller will not function correctly.

Figure 4: Description of the System block.

In Lab Procedure

The MATLAB control toolbox can be used to create a state space representation of the system

and to design the static controller K. The state space representation can be obtained by

executing sys = ss(A,B,C,D). The matrices A and B are as calculated in Part IV, Q1) and.

Verify your answer to Part IV, Q2) by generating the controllability matrix using the ctrb command

and checking its rank.

Verify the control laws, obtained earlier, using the place command (for both upward and downward

setups). Note that MATLAB uses ?K for the control law.

The first task is to implement the controller for the downward position. Ensure that you have

the correct value for K before attempting to run the model. The variable K is passed into the

Simulink model. Open and run the configuration file ‘setup.m’. This sets all the pendulum

parameters to the correct values; then open the model file ‘q rotpen bal.mdl’.

Set the Stabilize down/up switch to the down position and the Swing-Up ON/OFF to

OFF.

6

Click on QuaRC → Build.

Press the ‘Connect to target’ button on the Simulink toolbar. The experiment is ready

to run, by clicking the ‘Play’ button. You can always interrupt the simulation by clicking

‘Stop’ on the toolbar.

NOTE: KEEP YOUR DISTANCE. THE SWING CAN BE VIOLENT!

Q1) Set K = 0. This will simulate the open loop response of the system. Connect and run the

experiment. Using the scopes (in Scopes block) plot a graph of α(t) showing the undamped

oscillations. Now, set k to its downward position value. Repeat, plotting a graph for α(t).

Compare the two results.

Q2) Stop the simulation and change the amplitude of the reference signal in the Set point

block to 40 degrees. What do you expect to observe? Comment on the response of the

pendulum.

Q3) Repeat Q2 using K = [0.3, ?1.36, 0.28, 0.17]. Plot graphs of α(t) and θ(t) showing the

ideal and actual responses. Can you explain the shape of the wave form for θ(t) Repeat

the experiment using K = [0.6, 1.36, 0.28, 0.17], [1, 1.36, 0.28, 0.17] and experiment

changing the square wave reference to a sine. Does the controller follow the reference?

Comment on your results.

NOTE: You need to gently perturb manually the pendulum to observe the damped response.

Q4) Set K to the corresponding controller for the up position and the amplitude in the Set

pointblock to zero. Ensure that the Stabilize switch is set to the up position. Run the

model and manually rotate the pendulum counter-clockwise to the up position. At the top

of its trajectory, the controller should take over keeping the pendulum vertical. If your

controller works (stabilizes the pendulum), stop and enable the automatic swing. Recompile

and run your design. The pendulum should now swing to its vertical position before

your controller takes over.

Q5) While the controller is running, change the reference signal to a 30 degree sinewave with

frequency 0.2Hz. Plot graphs of α(t) and θ(t) showing the ideal and actual responses.

Q6) Try increasing the frequency to 2Hz in steps and comment on the robustness of your

controller. Repeat using a square wave.

7

Appendix

Table 1 lists and describes the various files supplied for the experiment.

Table 1: List of MATLAB files

File Name Description

config srv02.m Returns the configuration-based SRV02 model specification

Rm, Kt

, Km, Kg, ηg and ηm and the sensor calibration

constants.

setup.m The main MATLAB scripts that sets the SRV02 motor and

sensor parameters, the SRV02 configuration-dependent

model parameters, and the SIP sensor parameters. Run this

file only to setup the laboratory.

Table 2: Parameter description and values

Symbol Description Value

Rm Motor armature resistance 2.6 ?

Kt Motor torque constant 7.68e-3 N · m/A

ηm Motor efficiency 0.69

Km Back-emf constant 7.68e-3 V /(rad/s)

Kg High-gear total gearbox ratio 70

ηg Gearbox efficiency 0.9

mp Mass of the pendulum 0.127 Kg

lp Distance from pivot to center of gravity 0.1556 m

Jp Pendulum moment of inertia 0.0012 Kg · m2

Jarm Rotary arm moment of inertia 0.002 Kg · m2

Bp Damping coefficient of the pendulum 0.0024 N · m · s/rad

Barm Viscous friction force 0.0024 N · m · s/rad

r Length of the rotary arm 0.2159 m

g Gravitational constant 9.81 m/s2

8


版權所有:留學生編程輔導網 2018 All Rights Reserved 聯系方式:QQ:99515681 電子信箱:[email protected]
免責聲明:本站部分內容從網絡整理而來,只供參考!如有版權問題可聯系本站刪除。

体彩22选5开奖走势图百度