Anda di halaman 1dari 68

..

2003

681.3.06
..
: . - : . , 2003. - 67 c.

MATLAB SIMULINK.

MATHCAD SIMULINK.
,
.
SIMULINK


.
,

200600.


.................................................................................................... 4
1 MATLAB 6................... 5
1.1 MatLab 6............................................................ 5
1.2 Simulink ............................................................. 6
1.3 ............................ 9
2 SIMULINK .............................................. 11
2.1 NCD ............................................................................................... 11
2.2 .................................................. 12
2.2.1 .......................................................................... 12
2.2.2 ..... 13
2.2.3 .......................................... 16
2.2.4 ................................................ 19
2.2.5 S- 20
2.2.6 ......................................... 26
2.2.7 ......................................................................... 30
2.3 Simulink........................................................ 33
3
................................................................................................... 38
4
............................................................................................... 48
. 64
. . 65



,
SCADA- .
, ,
SCADA-c - ,

.
, ,
,
,
, .


.
MathCAD,
MatLab
Simulink,
.

,
, ,
.
,
,
,
.

.


.
( ) .
,

.
4

1 MATLAB 6
1.1 MatLab 6
MatLab 6
,
:
- 600 ;
- ,
(Command Window),
(Command History), (Workspace Browser)
(Array Editor);
- ,
,
;
-
LAPACK;
- FFTW ( )

();
- ;
- ,
;
- :
, ;
- Camera
OpenGL;
- Java- Java MatLab;
- ,
;
- (, ,
)
;
- MatLab Visual Studio,
, Microsoft Visual Studio,
6

++ MatLab- ();
- , Visual Source
Safe;
- ( )
MatLab;
- (Instrument
Control ToolBox) ,
(GPIB, HP-IB, IEEE-488) VXI
VXI - GPIB ( Windows Sun Solaris)
RS-232, RS-422, RS-485 ( Linux), , VISA (Virtual Instruments
Systems Application - );
- , ,
Simulink 4 Real Time
Workshop 4;
- , , DOORS.
MATLAB 6.0
Simulink 4 . .1.2
.
:
-
;
- (Model Browser, Windows
95/98/Me/ 2000/NT4);
- ;
- - (
) Windows, Unix ;
- Finder .

1.2 Simulink 4
Simulink 100 ,
.
:
, , , , , ,
7

, .
Simulink
.
,
, . ,
,
, , , ,
, -, ,
, , , ,
.
.

,
, .
:
-

Simulink;
- Product, Multiplication, Gain Math Function
;
- u Demux
;
- Reshape ;
- Probe ,
;
- Bitwise Logical Operator ( )
,
;
- Look-Up Table ( );
- Polynomial
;
- Simulink
MatLab;
- Simulink Explorer
Simulink;
- Configurable Subsystems (
);
8

- ;
- S, S- (
Real-Time Workshop 4.0 ( )) [S-
,
Simulink-. Simulink S-
, Ada (
Simulink 4.0/Real Workshop 4.0, Real Workshop
Ada Coder), Fortran MatLab. S-
, Simulink -
. S- ,
,
. , , ,
MatLab+Simulink+Real Workshop+Real Time Windows Target
. Simulink

( S- MatLab);
- S-, ADA (
Real Time Workshop Ada Coder);
- Stateflow - , ;
Stateflow Coder ;
- run-time MatLab MatLab, , , MatLab;
- Embedded Target
,
,
.
, VxWorks/Tornado ( UNIX,
Windows MatLab), Real Time Windows Target; Lynx Embedded
OSEK Target, , DOS Target
Intel386 (
Watcom /++ DOS4GW.exe
DOS Windows).
MatLab (Stand-Alone) ;

- Target
CAN, ,
;
- web-, Target,

Internet (Microsoft Explorer 4.0 Netscape Navigator 4.5
).
, (MATLAB 6.0 +
Simulink 4.0 + Stateflow 4.0 + ...) ,
,
.

1.3

.
,
.

(
, ,
).
MatLab
, MathCAD, Maple Mathematica.

. , MatLab Notebook - Word
95/97/2000 MatLab ,
, .
, ,
.
(, MathCAD
MathCAD). ,
. MatLab 6

Microsoft PowerPoint.
10

MatLab
- (Toolbox).

, -
, .
.
MatLab ,

( ) Maple V Release 5.
Symbolic Math Toolbox Extended Symbolic Math Toolbox,
MatLab
.
MatLab
Simulink,
, .
-
,
Simulink


.
Symbolic Math
Simulink MatLab .
, , , MathCAD
Maple
MatLab, MatLab
.
, , .

11

2 SIMULINK
2.1 NCD
MatLab Nonlinear Control
Design (NCD), Simulink
NCD Blockset ( 2.1), ,
, , NCD Outport.
-
. NCD
S-
.

2.1 NCD Outport


NCD Outport ,
2.2. ,
, ,
.
,
,
. ,
.
-
, Simulink.
12

2.2 NCD Outport


2.2
2.2.1
,
.

, , . , -
-
.

2.3.
2.3 :


(2.1)

13

2.3

(2.2)
: -, - -.
, - ,
. -
, . ,
.

, -
- .

2.2.2
,

. -


, .

( ),
:
(2.3)

14

.
p
(2.2)
-

(2.4)
(2.3) :
(2.5)

;

.
(2.5)
-1, 0,

, :

Ro Rp Io Ip 1

,
I

R
+
R

I
0
o p
o p

(2.6)

Rp

Ip

Ro

2
2
Ro + Io

Io
2

Ro + Io

(2.7)

(2.8)

- :
W( p) K ,

-.
, R K , I 0 , (2.7), -

Ro1(m, )
2

Ro1(m, ) + Io1(m, )

(2.9)

MathCAD:
m := 0.221 ;
15

:= 0 , 0.001.. 0.35 ;

p( ) := (i m) p
Wo1( ) := 1.75

exp(10 p ( ))
40 p ( ) + 1

Ro1( ) := Re(Wo1( ))

( i m) ;

;
Io1( ) := Im(Wo1( ))
;
2

Ao1( ) := Ro1( ) + Io1( ) (2.9);

F( ) := if (Io1( ) 0 , argW
( o1( )) , 2 + argW
( o1( )))

- ;
Ro1( )
R( ) :=
Ao1( )
( K);

F( ) := + F( )

(2.3)
( - -);
K( ) := R( ) .

- 2.4.
, F ( )

K ( )

0 -

2.48 .

-
W

16

2.48

(2.10)

2.4 -
2.2.3

( 2.3) ,
2.5.

2.5
-

, ..
W ( p) W ( p) Wo ( p) ,
(2.11)
W ( p) ;
W ( p) ;

17

Wo ( p)

0.96
30 p + 1

20 p

.

Wo1( p) W( p)
W( p)
(2.12)
1 + W ( p) W ( p) .
o1

(2.12) (2.11), :
Wo1( p) Wp( p)

W( p)

1 + Wo1( p) Wp( p)

Wo( p) .

(2.13)


. -

K2 +

Wp ( p)

K2

K2 p + K2

(2.14)

K2 K2 , ,
-.

K2 ( i m) + K2

Wop ( m , )

( i m)

(2.15)


Wop ( m , )

K2

K m

( m2 + 1)

K2

( m2 + 1)

(2.16)

(2.8) (2.16)
I

Iop

R + I

K2

( m2 + 1)

(2.17)

K2

I
2
R + I

(
2

m + 1

.
(2.7) (2.16) :
Rop

R + I

K2

K2 m

( m2 + 1)

(2.18)

(2.19)

K2

R
2

R + I

18

K2 m

( m2 + 1)

(2.20)

-,

K2
f ( K2 ) .
, (2.13)

MathCAD:
0.96
1.75
20 p( )
10 p( )
e
e
2.48
30 p( ) + 1
40 p( ) + 1
W( ) :=
1.75
10 p( )
e
2.48
1+
40 p( ) + 1

m := 0.221 ;

:= 0,0.001.. 0.1 ;
p ( ) := ( i m) p ( i m) ;
R ( ) := Re ( W ( ) )

;
I ( ) := Im (W ( ) )
;
2

A ( ) := ( R ( ) ) + ( I ( ) ) ;
R ( ) :=

I ( ) :=

R ( )
A ( )

I ( )
A ( )

-;

K2 ( ) := I ( ) m + 1 -;
K2 ( ) := m I ( ) R ( ) -.


2.6.

19

K2 ( ) 0.05

0.1

0.15

1.5

0.5

0.5

1.5

K2 ( )

2.6
:

K2 ( )

0.973 ;

0.04
K2( )

0.04498.

2.2.4


,
,
.
, 2.7.
2.7

.
,
,

Wo ( p) 1 e

W ( p)

).

, 2.7

Wo ( p) e

20

y ( p)

( p)

(2.21)

2.7
,

, . .
:
yc
( p)

(2.22)

Wo ( p) .

2.7
yc ( p) y ( p) + y ( p) ,
yc ( p)
( p)

W ( p) + Wo ( p) e

(2.23)

(2.24)

(2.25)

(2.22) (2.24),
Wo ( p)

W ( p) + Wo ( p) e

,
W ( p)

Wo ( p) 1 e

).

(2.26)

2.2.5 S-

21


, ,
- .
, ,
.
Simulink S- .
,
Simulink
. S-
.
Simulink. Continious
Transfer Fcn (
) . ,
, 2.8.
Numerator MatLab

(
s); Denominator

.
, 2.9.

2.8 Transfer Fcn

22

2.9 Transfer Fcn


,
,
.
,
( ) Flip Name
, .
, , ,
-.
, , ,
.
, -
Continious Transport Delay (
). ( 2.10).
Time delay ( ) ,
, Initial input ( )

. , 20 .

23

2.10 Transport Delay


Sum () Math ( 2.11).

2.11 Sum
Icon shape round ()
rectangular (). List of signs ( )
,
.
Constant Sources
.
2.12.

24

2.12 Constant
Constant value
, . , .
, S-,
Simulink Extras Additional
Linear. PID Controller (-). 2.13 ,

2.13 PID-Controller

(Proportional), (Integral)
(Derivative) .
Scope .

-. ,
.
.
25

-
, .
S-, 2.14.

1.75

0.96

10

40s+1

20

30s+1

0.96
30s+1
1

0.96
20

30s+1
2

PID
-

PID
-

2.14 Simulink-
. 2.2.2- 2.2.3.
300 ,
ode 45.
Start Simulation.
Ready
. Scope,
" ", , 2.15.
;
.
, ,
( Scope " ").
2.16.

26

2.15 " "

2.16 " "


2.16 ,
( 8 %),

.
,
27

,
MatLab.

2.2.6


Scope.
,
- , ,
Word, .
Scope Properties (
). Properties ()
Data history,
2.17.

2.17 Data history Properties


.
Save data to workspace ( ).
Variable name ( ) , , y,
Scope
. Format
Structure with time ( ).
MatLab ,
S- ( Cascade1) simplot
(y), y,
Scope, Figure No.1, .
28

2.18. ,
, ,
,
..
Figure Properties, Axes Properties
Edit , 2.18.

2.18 Figure No.1


,
Style () ( 2.19). Edit properties
for ( ) ,
. Style (Axis line width)
. Color
.
(, ..).
.
,
2.20.

29


.fig,
, , MatLab.
MatLab :
saveas(gcf,'Process.fig'),

Process , .

2.19 Style Property Editor


, ,
Word, Copy figure Edit
, Word
Word. 2.21
.
MatLab
, , .

30

2.20

2.21 , Word
2.2.7

S-

(. 2.14) .
31

,
S-. , ,
Transfer Fcn ( ) ,
, S-

Transport Delay ( ).
.
Simulink
10 .
Edit Create Subsystem.
, Subsystem.
Subsystem , 2.22.
, ,
In1 Out1. -
. .
S- , 2.23.

2.22 Subsystem

20.
( 2.24). 1, 2, 20
( 2.25).
.

32

0.96

20

30s+1

0.96
30s+1
1
0.96
20

30s+1
2

PID
-

PID
-

2.23 S-

2.24
.
.
- S-
2.26. .
, .

33

2.25

PID

PID

2.26 S-
2.3 Simulink

.2.2

,
.
,
34

.

, ,
.

.
Simulink
. NCD Outport NCD
Blockset. , ,
MatLab .
NCD Outport
Simulink- ( 2.26).
- NCD Outport
, 2.27.

NCD
OutPort 1

NCD Outport

PID

PID

2.27 - NCD Outport


NCD Outport ,
2.28. ,
, , .
, Simulink ,
, Simulation parameters
Simulation .

.
Simulink .
35

, .
(-
- ),
,

MatLab.

2.28 NCD Outport


2.29 2.30
.
Optimization NCD Outport
Paramerters , 2.31.
Tuneable Variables .
MatLab
MatLab. :
>> Kp=1; K2p=1; K2i=0.001;

36

2.29 -

2.30 -

2.31

37

Start Optimization
NCD Outport. MatLab
Optimization Converged Successfully (
). NCD Outport ( 2.32)
. ,
.
,
, 2.34.

2.32 NCD Outport

2.33 NCD Outport


38

,

MatLab .
.

2.34 NCD Outport

( 2.34)
. MatLab
>> [Kp K2p K2i] ,

:
ans=
1.3867

1.2347

0.0426


NCD Outport ,
. , , ,

- ..
,
S-.
.
Simulink
39

, ,
.

NCD Outport.
,
.


.

3.1.

1 , 2 ( ), 3 ,
4 () , 5 ,
6 , 7 , 8 ,
9
3.1

, 1,
2.
3, ,
40

.
,
, 4,
. 5
,
6,
7 8.

,
. , ,
.
, ,
, .
, (
)
; ,
.
.
,
,
.

.
, , .
510.

80000
, ,
.
,
410-3 ,
, ,
.
:
I

k1 P

(3.1)

I ( 200 );
;
41

k1 .
(k1 = (0.40.5)10-14).

: -,

, -,
,
.
:

.
:
-
;
-
;
- ,
.
:
U

I I
I

(3.2)

U ;
I ;
I , ();
K (k 6.3103).
()

.
U

k2 U

(3.3)

U ;
k2 (k2 103).
,
.

.
42

:
d
T U + U
dt

k U

(3.4)

U ();
;
k .
=
0.1...2 . -5

W ( p)

11.5
0.1 p + 1

(3.5)


, .

, .
,
:
T

d
N + N
dt

k U

(3.6)

( 0.1 );
N , /;
k .
, , -11, -12
:

W ( p)

1.9
2

0.2 p + p

(3.7)



k3 k4, ,
- ,
,
. ,
.

43

Simulink - ,
. -
.
,

. ,

, .

( 3.2) (3.2).
,
.
(3.2) .
.
Simulink
,
.

-K-

f(u)

3.2
3.3 "" .

In1

In2

Out1

3.3 -
3.4
.

44

x' = Ax+Bu
y = Cx+Du

-K-

-K

1.9
0.2s 2 +s

-
-
-

11.5
0.1s+1

-K-

In1

-K-

Out1
In2

3.4 A

3.5 k = +0.001


. k = +0.001 ,
3.5.
45

( 3.5)
, , 13%,
4 .
k
= -0.001 3.6.

3.6 k = -0.001

()

( 3.7).
,
, .
(
), .
: U
, ,
U , .

46

3.7
,
,
,
.
, , ,
,
b, .
.

. ,
()
,
.
,
.
.
(. 3.7)
, , b.
+
,
.
,

. , ,
47

,

. ,
,
,
.
,
,
.

, 3.8.

x' = Ax+Bu
y = Cx+Du

-K-

-K-

1.9
0.2s 2 +s

-K-

-K-

-
-

3.8
k = +0.001
, 3.9.
(. 3.8) , 2
,
( 3.10),
( 3.11),
200% .

48

1.14
1.12
1.1
1.08
1.06
1.04
1.02
1
0.98
0.96

10
,

12

14

16

18

20

3.9 k = +0.001

x' = Ax+Bu
y = Cx+Du

-K-

-K-

1.9
0.2s 2 +s

-K-

-K-

-
-

3.10 -

, (. 3.11)
, (.
3.5).
49

3.11
200%- .

()
:
- ;
- ;
- ,
;
- ;
- .

. ,
.

, ,

50

. -
4.1.

4.1 -
1 ,
. 2
,
(,
, ),
, ,
.
.

51

3
. ,
.3 ,
, (,
, ..).
4 .

, , ,

.

,
,
- (. 4.1).
5 .
,
( , ),
, ,
,
, .

,
, , ,

.

,
(.
4.2).
, - (. 4.2).
,
.
.

, 4.2, - ,
,
.
52


.
, .
, ,
4.3.
.

.

. 115, ,

1015 /(.*).

( ).

Xe

4.2

53




.
4.4.
3.

1
x' = Ax+Bu
y = Cx+Du

-K

4.3

-K-

-K

-K-

1.9
0.2s 2 +s

11.5
0.1s+1

-K

4.4

4.5.

f(u)
-K-

4.5

54


(
).
4.6.
,
.


( 4.7).
. ,
.
0
Xe0

1
Xe
2

I0

I0

Xe0

Xe

1e15

4.6

0
1

I0

(u-1)/u

f(u)

Xe0
f(u)

f(u)

1
0

f(u)

2
Xe0

3
I0

4.7

( 4.8)
, (.
4.2), ,
(. 4.7).
.
(. 4.2).

55


, .
(. 4.2).
I0,
Xe0
( 4.9 - 4.11).

(u-1)/u

f(u)

f(u)

1
Xe

I0

Xe

Xe0

2
I0
1
Xe0

4.8
-
4.9 - 4.11.

I1

I0

I2

1
I

2
I0

3
Xe0

Xe

Xe0

4.9
56

1
Xe

-K-

0.056*4.22

1
xo s

-K-

*I

1
I1

7e-24

-K2.86e-5

2
I0

I2

4.10 1
1
2

-K- 2.86e-5 1
-K 2

0.003*4.22

1
xo s

-K
*Xe

2.4e-18

1
Xe

2
-K2.07e-5

3
Xe0

4.11 1
- (. 4.2),

Simulink.
- ,

.

, , .
57

(. 4.2).
, 1,
k = +0.001.
4.12.

4.12 k = +0.001


, ,
( 4.13, 4.14).
, -
, , -
.
, , , ,

.
,
, ,
, , ,

( 4.15).
500
. Step time
500. 4.15.
58

4.13

4.14
, ,

,
.
.
( )
59

( 4.15),
.
8.88% , 10,23
. ,

0.8.

Xe

Xe0
I0

0
Xe0

I0

1e15

-K-
-K
1

4.15


( 4.16).

,

. Simulink.
Scope
Decimation 10,
10 . , Data history
Scope Limit data points to last.

60

MatLab. 5000
, ,
5000 . ,
Limit data points to last .

4.16

, ,
,
,

,
,
,

61

.

. :
1) :
- ;
-
(, );
-
();
-
;
- "";
2)
, .
,
, ,

( 4.17).

-5

1.25

4.17
(. 4.17)
,
, .

, , ,
, , .
62

( Switch Nonlinear Simulink)


( 4.18). Treshold ()
,
() . ,
, , ,
.

4.18 (Switch)

, ,
.

( 4.19).
Simulink. Simulink Enable Signals&Systems,
, , . ,
, Simulink, ,

.
Enable

4.19 -
- ,
.
, -
63

,
,
.
Enable
Out (
4.19 ).
( 4.20) ,
""
Output when disabled.

4.20 Out
Output when disabled
Out:
- held ()
;
- reset ()
.
, Initial output
- .
,
4.20.
- (. 4.17) .

, , ,
64

, ,
,
,
, 1.

, - .

-, 1, , ,
.
, ,
, , -
.

Xe

Step

Step1

Step2

4.21 -
""
. ,
, . ,
-
, -. ,
(. 4.21)
.
65

.
1.

,
.
,
.
2.

.
,
.

.
3.
MatLab
- (Toolbox).

, -
, . .
4.


(, MatLab+Word)
, ( MathCAD, Maple).
5.
MatLab
Simulink,
, .
- , Simulink

.
.
6.

SCADA-

.

66

1 . . MatLab. - .:
, 1993. 112 .
2 . . MatLab: C . - .: " ", 1997. - 350 .
3 . . MatLab 5 : C
. - .: " - ", 1998. - 314 .
4 . . MatLab
5.*: - 2- : C . - .: " - ", 1999. - . 1 366 ., . 2 - 304 .
5 . ., . . MatLab 5 : C
. - .: " - ", 1999. - 448 .
6 . . MatLab 5.2.
Windows: . - .: , 1999. - 288 .
7 . . MathCAD: .- .: ,
1993. - 128 .
8 . . MathCAD PLUS 6.0 PRO. - .:
, 1997. - 336 . ( )
9 . . MathCAD PLUS 7.0 PRO. - .:
, 1998. - 352 .
10 . ., . . MathCAD 7.0 ,
Internet. - .: "", 1998. - 346 .
11 MathCAD 6.0 PLUS. ,
Windows 95. / . - .: -
"", 1996. - 712 .
12 . . MathCAD PLUS 6.0 . - .:
"", 1996. - 238 .
13 . . MathCAD PLUS 7 Pro . .: "", 1998. - 384 .
14 . . MathCAD PLUS 8 Pro . .: "", 1999. - 523 .
15 . ., . . Maple.
. - .: , 1997. - 208 .
16 . . Maple V R3/R4/R5. - .:
"", 1998. - 399 .
17 . . Maple V Power Edition. - M.: "", 1998. - 240 .
67

18 . ., . ., . .
Maple. - M.: "", 1997. - 200 .
19 Heal K. M., Hausen L. M., Rickard K. M. Maple V Release 5. Learning
Guide. Springer. 1998. - 284 p.
20 Monogan M. B., Geddes K. O., Heal K. M., Labahn G., Vorkoetter S. M.
Maple V Release 5. Programming Guide. Springer. 1998. - 380 p.

68