• Nie Znaleziono Wyników

To get familiar with the methodology of control systems simulations in Mathematica, methods for results visualization and analysis.

N/A
N/A
Protected

Academic year: 2021

Share "To get familiar with the methodology of control systems simulations in Mathematica, methods for results visualization and analysis."

Copied!
4
0
0

Pełen tekst

(1)

Scientific & Engineering Programming

II Year Electronics and Computer Engineering, FoE, WUST

Laboratory Class 7 – Control systems in Mathematica

The scope

To get familiar with the methodology of control systems simulations in Mathematica, methods for results visualization and analysis.

Prerequisites

Before the classes you should know, how to:

• model simple physical systems,

• represent and define differential equations,

• solve numerically differential equations,

• visualize functions being the differential equations solutions,

• visualize the results on animations.

Tasks

Read carefully the tasks preliminaries. Analyze the to dos. Choose the task more suitable for you.

1. Controlling the Inverted Pendulum with Moving Vertically Base

Preliminaries

Differential equations, describing the dynamical behavior of a depicted below inverted pen- dulum of the length l and the mass m, with a moving vertically base,

x y

θ y

m

l

x

m

m

y

has a form

l ¨ θ = g sin θ − c ˙ θ + sin θ ¨ y, (1) where θ denotes the angle, the pendulum link makes with the vertical, y is the base offset, c viscous damping coefficient, and g stands for the gravitational acceleration. The dot operator means a time derivative ˙  =

ddt

.

1

(2)

Scientific & Engineering Programming, LC7, II Year ECE, FoE, WUST 2

y

d

CONT PLANT y

u

Figure 1: Open loop control scheme

Let’s assume, the pendulum base is moving in a oscillatory way, described by the equation

y(t) = A sin(ωt), (2)

where A is the oscillations amplitude and ω their frequency. Introduction of the oscillatory base (2) into the system (1) allows to control its behavior exploiting the idea of an open loop (feedforward) control scheme, illustrated in Figure 1. In the figure PLANT stands for the object to be controlled, y is its output, and u its input. CONT is a controller, which on the base of desired system behavior tries to generate the control input u, causing the system to behave as desired. In the case of the analyzed inverted pendulum with a moving vertically base, the role of the input u plays the second derivative of the base position ¨ y, and the angle θ is taken as the output y. The oscillator takes the role of the controller. Changing its oscillations frequency and amplitude one can control the behavior of the pendulum and decide, which equilibrium the pendulum stabilizes at.

To dos

For the described system do the following:

(a) Prepare the Mathematica model of the inverted pendulum with a moving vertically base (1):

i. define a function which returns the pendulum base position, ii. define a function which returns the mass m position, iii. define the differential equation 1.

Analyze the model behavior for an initial θ value equal to 0

and 0.2, and the steady base (y=0). Plot the joint angle as a function of time. Animate the pendulum movement.

Investigate the influence of the dumping coefficient on the pendulum behavior.

(b) Equip the pendulum with the oscillator (2):

i. define the rule which introduces the controller (2), ii. apply the defined rule to the system.

Examine the correctness of the provided solution.

(c) Simulate the system behavior for both the initial values with different values of oscil- lations amplitude and frequency. Try

A = 0.2, ω = 4; A = 0.2, ω = 40; A = 0.2, ω = 400; A = 0.02, ω = 400; A = 0.002, ω = 400; A = 0.002, ω = 4000. Try to derive some conclusions about the influence of the oscillator amplitude and its frequency on the system behavior

§

.

An inverted pendulum with such a base is know as Kapitza’s pendulum.

For the practical purposes you can observe also the pendulum behavior for the initial value very close to 0 (i.e. 10−4.)

With the pendulum length l = 1 and the dumping coefficient c = 0.2.

§Do not forget to change the animation speed if necessary, to observe the actual system behavior

(3)

Scientific & Engineering Programming, LC7, II Year ECE, FoE, WUST 3

2. Controlling the Double Pendulum

Preliminaries

Differential equations, being the dynamical model of a presented during the lecture and depicted below double pendulum,

x y

θ

1

y

1

l

1

x

1

x

2

y

2

l

2

θ

2

m

2

m

1

consisting of two masses m

1

and m

2

, attached by rigid massless links of lengths l

1

and l

2

, can be simplified to a form

( m

12

l

12

θ ¨

1

+ m

2

l

1

l

2

θ ¨

2

cos(θ

1

− θ

2

) + m

2

l

1

l

2

θ ˙

22

sin(θ

1

− θ

2

) + gm

12

l

1

sin θ

1

= u

1

m

2

l

22

θ ¨

2

+ m

2

l

1

l

2

θ ¨

1

cos(θ

1

− θ

2

) − m

2

l

1

l

2

θ ˙

21

sin(θ

1

− θ

2

) + gm

2

l

2

sin θ

2

= u

2

, (3)

where θ

1

, θ

2

denote the angles, the links make with the vertical, u

1

, u

2

describe the external, control torques applied at the pendulum joints, m

12

= m

1

+ m

2

, and g stands for the gravitational acceleration. The dot operator stands for a time derivative ˙  =

ddt

. The equations (3) can be rewritten in a general, vector form

Q(q)¨ q + B(q, ˙ q) = u, (4)

where the vectors q =

θθ1

2

, u = (

uu12

), and the matrix Q(q) and the vector B(q, ˙ q) are expressed as follows:

Q(q) =

 m

12

l

21

m

2

l

1

l

2

cos(θ

1

− θ

2

) m

2

l

1

l

2

cos(θ

1

− θ

2

) m

2

l

22

 ,

B(q, ˙ q) =  m

2

l

1

l

2

θ ˙

22

sin(θ

1

− θ

2

) + gm

12

l

1

sin θ

1

−m

2

l

1

l

2

θ ˙

12

sin(θ

1

− θ

2

) + gm

2

l

2

sin θ

2

 .

To control the position of the double pendulum end, which is a function of the link angles θ

1

and θ

2

x

2

y

2



=

 l

1

sin θ

1

+ l

2

sin θ

2

−l

1

cos θ

1

− l

2

sin θ

2



and has a form of the vector output

y = k(q)

with y = (

xy22

), one can apply the idea of a closed loop feedback linearization, illustrated in Figure 2. In the figure PLANT stands for the object to be controlled, y is its output, and u its input. LIN is a linearizing block, which makes the compound system with the input v and the output y to be linear. PD is just a linear PD controller, providing a control loop feedback,

The system equations in this form, together with all the accompanying matrices and vectors are defined in the Mathematica notebook file, provided on the course web page in the laboratory classes table.

(4)

Scientific & Engineering Programming, LC7, II Year ECE, FoE, WUST 4

v y

LIN PLANT

u

PD y

d

Figure 2: Linearizing closed loop control scheme

allowing the output y to follow a desired value y

d

. In the case of the double pendulum the LIN module has to realize the relation

k

u = −D

−1

(q)P (q, ˙ q) + D

−1

(q)v, (5) with D(q) = J (q)Q

−1

(q), P (q, ˙ q) = ˙ J (q) ˙ q − J (q)Q

−1

(q)B(q, ˙ q), J (q) =

∂k(q)∂q

. The PD controller follows the well known rule of control, described by

∗∗

v = ¨ y

d

− K

1

( ˙ y − ˙ y

d

) − K

0

(y − y

d

), (6) with diagonal gain matrices K

0

, K

1

, containing nonnegative elements.

To dos

For the described system do the following:

(a) Compare the double pendulum vector equations (4) and their matrix Q and vector B with these introduced in the provided file – put the attention to the equations structure.

(b) Simulate the system behavior for the initial condition θ

1

(0) = P i/2, θ

2

(0) = ˙ θ

1

(0) = θ ˙

2

(0) = 0, and the controls u = (

uu12

) equal to zero. Plot the joint angles as a function of time. Animate the pendulum movement.

(c) Set the pendulum parameters l

1

= l

2

= m

1

= m

2

= 1. Try the controls (

uu12

) = (

50

), (

uu12

) = (

150

), (

uu12

) = (

200

), (

uu12

) = (

05

).

(d) Analyze the way, the linearizing module equations (5) are introduced in the provided file.

(e) Simulate the linearized system behavior (with the input v) for the initial condition θ

1

(0) = P i/2, θ

2

(0) = ˙ θ

1

(0) = ˙ θ

2

(0) = 0, and the controls

††

(

vv12

) = (

00

), (

vv12

) =

−0.010

, (

vv12

) = (

0.010

), (

vv12

) = (

0.010

), (

vv12

) =

−0.1 cos t0

, (

vv12

) = (

0.1 sin t0

). Try to interpret the meaning of the controls v

1

, v

2

.

(f) Repeat the simulation for the last value of controls v with the nonzero initial joint speed θ ˙

1

(0) = −0.1. With this initial speed try the control (

vv12

) =

−0.1 cos t0.1 sin t

.

(g) Analyze the way, the control loop (6) is defined in the provided file. Apply the defined control rules to the linearized system. Analyze the control system behavior for an exemplary desired trajectory y

d

(t) =

0.3+0.3 cos t

0.5+0.3 sin t

 (the parametric equation of a circle).

Add to the animation the desired and actual trajectories (y

d

and y.)

(h) Analyze the control system behavior for different values of the gains, different initial conditions. Change the desired trajectory. What happens when the desired trajectory (part of it) is located outside the region, which the pendulum end can reach?

kThe formula together with the matrices is included in the Mathematica notebook file, provided on the course web page in the laboratory classes table.

∗∗Also included in the Mathematica notebook file, provided on the course web page in the laboratory classes table.

††In the cases when the NDSolve function doesn’t give the solution for the whole time domain you’ve specified, visualize just the part which has been obtained. Try to explain, why no the whole solution was obtained.

Cytaty

Powiązane dokumenty

(d) Find the probability that this adult is allergic to nuts and the liquid turns

The composants of an indecomposable metric con- tinuum X are pairwise disjoint, continuum connected, first category, dense F σ -subsets of X1. Mazurkiewicz [8] proved that

Using the Newton’s laws write the differential equation of a harmonic oscillator of the mass m, which is a system that, when displaced from its equilibrium position, experiences

Stack-losses of ammonia Y were measured in course of 21 days of operation of a plant for the oxidation of ammonia (NH3) to nitric acid (HNO 3 )... Discuss the obtained

As mentioned in Section 5, the plan is to apply Theorem 3.1 to equations of the form (3.2) defined by certain minimal forms L ∈ L(T ).. Since we must apply transformations to the

By means of the Riemann boundary value problems, we give an algebraic method to obtain all solutions of equation (∗) in closed form.. Algebraic characterizations of integral

In this paper, we associate field-oriented control with a powerful nonlinear robust flux observer for an induction motor to show the improvement made by this observer compared with

We deal with its justification and its place in the degree, skills and objectives, program and content, activities (individual practical work, optional seminars, preparation