You are on page 1of 212

. ..

IEC 61131-3 1820

.00540-01 33 01

213

. .
.00540-01
2012

.. . .. . . .
2
.00540-01 33 01



Beremiz. ,
, ,
, .
.
IEC 61131-3 .
, .

Beremiz
Windows Linux,
IEC 61131-3.
.
3
.00540-01 33 01

1. ................................................................7

2. ................................................................................................8

3. . . .................................................9

4. ...................................................................................11

5. Beremiz .........................................................13

5.1. .................................................................................................13

5.2. .........................................................................................................15

5.2.1. ......................................................................................................15

5.2.2. .............................16

5.3. ...................................................................................................................18

5.3.1. ...........................................................................19

5.3.2. ...............................................................................22

5.3.3. , ................................22

5.4. ............................................................................23

5.5. .................................................................................................26

5.5.1. ....................................................................30

5.5.2. ......................................................................................................31

5.6. ST IL .................................................................................32

5.7. FBD, SFC, LD .............................................33

5.7.1. FBD ...........................................................................................................33

5.7.2. LD .............................................................................................................39

5.7.3. SFC............................................................................................................44

5.8. .......................................................................................58

5.9. ...............................................................................58
4
.00540-01 33 01

5.9.1. .........................................................................................................59

5.9.2. ..................................................................................60

5.9.3. ............................................................................................................60

5.9.4. .................................................................................................................................61

5.9.5. ............................................................................................................................62

5.10. .............................................................................................62

5.11. ..............................................65

5.12. ...........................................................................................................66

5.13. ...............................................................................................67

5.14. ...................................................................................................................68

5.15. ..........................69

6. ...............................................................................71

6.1. ............................................................................................................71

6.1.1. ............................................................................................71

6.1.2. ................................................................................................................73

6.1.3. ............................................................................74

6.1.4. .............................................................................................75

6.2. ..........................................................................................76

6.2.1. -..................................................................................76

6.2.2. - ..........................................................................77

6.3. ..........................................................................................77

6.3.1. - ..................................................................................77

6.3.2. - .............................................................................79

6.4. TCP ......................................................................................................81

6.4.1. TCP ....................82

6.4.2. TCP ...................................84

6.5. .............86
5
.00540-01 33 01

7. ..............................................................................................................89

7.1. ...................................................................................................89

7.2. ..............................................................................................................90

7.2.1. .....................................................................................91

7.2.2. ...............................92

7.2.3. ...............................................................................................................93

7.3. ........................................................................................................94

7.3.1. ...........................................................................................................................95

7.3.2. .............................................................................................................................100

7.3.3. .....................................................................................................105

7.4. ....................................................................................................107

7.5. ................................................................................................................................110

7.5.1. ...................................................................................110

7.5.2. ..........................................................................................111

7.6. .....................................................................................................................115

8. , ............119

8.1. ..............................................................................119

8.2. ......................120

8.3. ..............................................................................................122

8.4. FBD ....................................................................................................124

8.5. LD ...................................................................................................126

8.6. SFC ..................................................................................................127

8.7. ......................................................................129

9. .....................................................................131

9.1. ............................................................................................................131

9.2. .............................................................................................................131

9.3. .......................................................................................132
6
.00540-01 33 01

9.4. .......................................................................133

9.4.1. -..............................................................................133

9.4.2. TCP ................................................................136

9.5. ................................................................................138

9.5.1. , SFC .....................................................139

9.5.2. , ST ........................................................148

9.6. ...................................................................................151

9.7. .................................................................................................................154

9.8. ...........................155

9.9. ....................................................................................160

1. Beremiz ...............................................................................................164

2. ...........................168

3. ST ..............................................................................................180

4. IL ...............................................................................................189

5. FBD ...........................................................................................192

6. LD..............................................................................................197

7. SFC ............................................................................................203

.................................................................................................211
7
.00540-01 33 01

1.

Beremiz
IEC 61131-3
SPARC. ,
Structured Text ( ST) Instruction List ( IL),
Function Block Diagram ( FBD), Ladder Diagram ( LD), Sequential Function
Chart ( SFC).

Beremiz
1000 ( 32-, 64-
), 1 Windows XP/Vista/7.
( 17), , (
, ).
Beremiz Windows Linux.
Python, C, C++
. Beremiz,
Python ().
Beremiz DVD .
Windows Linux 1.
8
.00540-01 33 01

2.

Beremiz
.
,
( ).

.
:
IEC 61131-3;
IEC 61131-3;
GCC .
,
.
9
.00540-01 33 01

3. . .

Beremiz
. 1. , (
) (ST, IL) /
(FBD, SFC, LD) IEC 61131-3, .
XML .
:
1) < >.st, ST,
,
C;
2) : config.c config.h, POUS.h, POUS.c ,
( C)
;
3) plc_common_main.c plc_debugger.c
( SPARC)
Beremiz ;
4) ,
;
5) ( so),
C .
C , , UNIX-
, , .
, Beremiz,
.

(. . 1):
;
,
;
;
.
10
.00540-01 33 01


IEC- MatIEC
61131-3 IEC C

GCC Sparc
ANSI-C


-

IEC





/





Sparc

. 1 Beremiz
11
.00540-01 33 01

4.

IEC 61131-3 61131 (


EN 61131),
.
IEC 61131-3 ,
,
IEC 61131-3
, :
IEC 61131-3;
;
C;
;
;
;
.
/,
.
,
,
.
( )
so-,
.
,
Beremiz,
, .
(, ,
), , , ,
( ) ,
. .
, ,
.
12
.00540-01 33 01

, :
, .
, ,
. .

IEC 61131-3.
, ,
( ).
,
, (
- ).
.
, ,
, () .

.
, ,
() . , , ,
: .
,
: , , ,
.
13
.00540-01 33 01

5. BEREMIZ

Beremiz :
;
;
;
;
;
;
;
ST IL;
FBD, SFC, LD;
;
;
;
;
;
;
.
Beremiz .

5.1.

(. . 2) :
;
;
;
.

. 2
14
.00540-01 33 01

, ,
.
( ) .
:
(CTRL + N);
(CTRL + O);
,
;
(CTRL + S);
,
(CTRL + SHIFT + S);
(,
, ..) (CTRL + W);
, (CTRL + SHIFT + W);

, (CTRL + ALT + P);

(CTRL + SHIFT + P);
(CTRL + P);
Beremiz (CTRL+ Q).
IEC
61131-3 :
(CTRL + Z);
(CTRL + Y);
() () (CTRL
+ X);
() ()
(CTRL + C);
()
(CTRL + V);
(CTRL + SHIFT + F);
:
;
;
15
.00540-01 33 01

;
;
;
(. . 6);
(CTRL +
A);
, (. .
5.3).
IEC-61131
:
(CTRL + R);
(CTRL + K);
, ;
Beremiz
.

.

5.2.


Beremiz. ,
: , .
. ,
, .
IEC 61131-3 (. . 5.7).

5.2.1.

, . 3.

. 3
1.
16
.00540-01 33 01





()
()
()
()

()

5.2.2.

, ,
, ,
( (. . 5.12.)),
.
. 4.

. 4
17
.00540-01 33 01

,
, 2.

2

( )
build,
,
build,


URI,
(. 5.5)


(. .
IEC 5.5.1) ST LD,
C
,
,





,
,
.
. 5 ,
. ,
18
.00540-01 33 01

,
.

. 5

,

(. . 6).

. 6

, ,
(. . 5.12).
, , .

5.3.

Beremiz (. .
7) , .

. 7
:
;
19
.00540-01 33 01

(, )
;
;
.
, .
.

5.3.1.

+ (. . 8),
, .

. 8

, .. ,
,
(. . 9).
20
.00540-01 33 01

. 9

:
;
;
.
, , ,
. ,
,
. (.
. 10) IEC 61131-3 (IL, ST, LD, FBD, SFC),
.

. 10

, (. . 11),
.
21
.00540-01 33 01

. 11

, , ,
.

. , , (. .
12).
, .

. 12


:
;
, ST IL;
, FBD, SFC, LD;
;
;
.

.
22
.00540-01 33 01

5.3.2.


,
(. . 13)

. 13

5.3.3. ,

,
.
(. . 14),
, .

. 14

(
) , (. . 15):
23
.00540-01 33 01

. 15


(. . 16).

. 16

,
, (, ,
).

5.4.

(. . 17)
, ,
.
24
.00540-01 33 01

. 17

:
,
;
: , , , /, ,
, ;
, (
IEC 61131-3), (
, , , )
( );
,
( . 7.1.4);
;
, (
) ;
.
,
, ,
.
, .
, . 18:

. 18
25
.00540-01 33 01

(. . 19),
.. ,
.
OK .

. 19 ,

. ,
,
Assignment to CONSTANT variables is not be allowed
.
. ,
.
3.

(, , /,
, , ) (
). (.
. 20).
26
.00540-01 33 01

. 20

,
, IEC 61131-3,
,
IEC 61131-3 . .

3 ,









( . 6)





5.5.

(. . 21) ,
.
27
.00540-01 33 01

. 21

,
, . :
, .
(. . 22) :
URI () ,
.
, . 8;

(. . 6);
: Python_Library
SVGUI_Library;

;
(
), ;
CFLAGS ;
28
.00540-01 33 01

(
), ;
LDFLAGS ;
CygwinPath , UNIX- Cygwin,
.

. 22

,
4.

4

IEC
(. . 5.5.1),
, ST

,


(. . 5.5.2)
29
.00540-01 33 01

(. . 23) : , ,
, .

. 23

(. . 24) : , URL- ,
, .

. 24

(. . 25)
FBD, LD SFC.

. 25
30
.00540-01 33 01

, . 26,
Beremiz .
Beremiz ,
,
. , ,
. beremiz/locale.

. 26

ST
, , 4
.

5.5.1.

(. . 27) ,
ST, ,
.

. 27 ST
31
.00540-01 33 01


(. 4).

5.5.2.

(. . 28) (),
.

. 28

,
. 5.

5








32
.00540-01 33 01

.
, ,
.

5.6. ST IL

ST IL (. . 29)
ST IL.

. 29 ST IL

:
, , ..
;
, ,
.. ST C , ;
: ,
..
Ctrl + <
>.
, ST
3, IL 4.
33
.00540-01 33 01

5.7. FBD, SFC, LD


, FBD, SFC LD.

5.7.1. FBD

FBD : ,
. FBD ,
(. . 30).

. 30 FBD

FBD (
6).

6 FBD

,



,

,






34
.00540-01 33 01


FBD .
.

FBD .
, : , , ,
(. . 31).

. 31 FBD

5.7.1.1.

,
(. . 32).

. 32
35
.00540-01 33 01


(, , ..).

EN/ENO, 5.
OK. ,
. 5.7.1.5.
( ),

(. . 31).
,
(. . 5.11),
(Drag&Drop) FBD.

5.7.1.2.


(Drag&Drop) , . 33,
FBD .

. 33

(. . 34),
.
36
.00540-01 33 01

. 34


(, , /).

5.7.1.3.

,
, .

.

, , .

(. . 35).

. 35 FBD
37
.00540-01 33 01

:
, ,
. . 36 .

. 36 FBD

MAX OUT ,
RESULT IN1 MIN. MAX
, MIN
. , , .

5.7.1.4.

FBD ( , )
.
(. . 37)
.

. 37

OK (. . 38).
38
.00540-01 33 01

. 38 FBD

5.7.1.5.


. :
,
, .
. 39, : 1 SUB; 2
MUL; 3 ADD.

. 39 , ()

.
. 40.
39
.00540-01 33 01

. 40


.
. 41.

. 41 ,

FBD,
5.

5.7.2. LD

LD (- )
. LD
: , , . ,
FBD, .
40
.00540-01 33 01

LD ,
(. . 42) LD.

. 42 LD

FBD
LD, FBD, ..
. 7 . ,
FBD, 6.

7 LD






LD (. . 43),
LD , FBD.

. 43 LD
41
.00540-01 33 01

5.7.2.1.

, ,
(. . 44).
:
: ;
.

. 44

. 45 :
.

. 45 LD

5.7.2.2.

LD
(. . 46).
42
.00540-01 33 01

. 46

:
;
;
;
.
, ,
. ,
BOOL.
Drag&Drop
BOOL : ,
/, , , .
( #) ,

(. . 47).

. 47
43
.00540-01 33 01

5.7.2.3.

LD
(. . 48).

. 48

:
;
;
;
;
;
.
, ,
. , ,
BOOL.
Drag&Drop ,
(. . 49).

. 49
44
.00540-01 33 01

LD,
6.

5.7.3. SFC

SFC : , , , ,
, . SFC ,
.
SFC ,
(. . 50).

. 50 SFC

8 . ,
FBD LD ( ) ,
6 7 .

8 SFC













45
.00540-01 33 01

8 SFC.

5.7.3.1.

.
(. . 51).

. 51 SFC

IEC 61131-3, SFC ,


SFC-
(. . 52).

. 52 SFC

, (. . 53).

. 53
46
.00540-01 33 01

, ,
(. . 54):
;
;
.

. 54 SFC

.
, , . ,
OK, (.
. 55).

. 55 SFC

5.7.3.2.

SFC , (.
. 56).
47
.00540-01 33 01

. 56 SFC

.
:
;
;
.
(. . 57)
, ,
SFC.
SFC.

. 57

(. . 58),
ST.
48
.00540-01 33 01

. 58 , ST

, ,
: f3 f4 INT .
(. . 58):
f3 = f4
.
0 FALSE, TRUE.
(. . 59),
FBD LD.

. 59 IEC
61131-3

, ,
, ,
FBD LD . ,
49
.00540-01 33 01

BOOL. , . 60 ,
LD LD.

. 60 SFC , LD

5.7.3.3.


(. . 61).

. 61

.
:
;
;
: , , ;
;
.
50
.00540-01 33 01

, ,
. (. .
62).

. 62 SFC

,
9.

9 SFC

D (
) ,
L
,
N ,
P ,
S SFC

R ,
DS ,

SL ,
SD ,

51
.00540-01 33 01


, 9.
,
. ,
,
, SFC (. . 63).

. 63


SFC.

(. . 64), .

. 64

,
0, 0.0, FALSE .
52
.00540-01 33 01

, 1, 1.0, TRUE
.
0, 0.0, FALSE , .
,
ST , , (. . 65).

. 65

, ;,
.

.
(. . 66).

. 66 step2 ,

5.7.3.4.

,
(. . 67).
53
.00540-01 33 01

. 67

:
;
;
;
.
,
(
) , (
)
. 68 .

. 68 SFC ,

. 69.
54
.00540-01 33 01

. 69 SFC ,

. 70 .

. 70 SFC ,

5.7.3.5.

SFC GOTO
.
SFC , (. . 71),
, SFC
.
55
.00540-01 33 01

. 71

( ).
OK. SFC ,
(. . 72). ,
, .

. 72 secondStep firstStep

IEC 61131-3,
.

5.7.3.6.

,
, SFC
. SFC
(. 5.3) (. . 73).
56
.00540-01 33 01

. 73 SFC

(. . 74).
, .

. 74

, ,
(. . 75).

. 75

SFC (. . 76)
.
57
.00540-01 33 01

. 76 SFC

,
, SFC,
(. . 77).

. 77

( )
(ST, IL, FBD, LD), .
(. . 78).

. 78

,
, ,
58
.00540-01 33 01

(. . 77).
.
SFC,
7.

5.8.

(. . 79) ,
,
.

. 79


,
. ,
, ,
.

5.9.

(. . 80)
.
59
.00540-01 33 01

. 80

,
:
;
(
);
;
;
, ,
.

5.9.1.

(. . 81),
.

. 81

(,
typedef C) .
60
.00540-01 33 01

5.9.2.

,

(. . 82), .. ,
.

. 82 ,

5.9.3.

(. . 83),
, ,
.

. 83

, , ,
, 10.

10
61
.00540-01 33 01

5.9.4.

(. . 84) ,
, , .

. 84

:
< >..< >
62
.00540-01 33 01

5.9.5.

(. . 85),
.
, .

. 85


.
,
, IEC 61131-3.
Beremiz.

5.10.

(. . 86)
Beremiz .

. 86
63
.00540-01 33 01

, ,
(. . 5.8), ,
. . 87 ,
globalValue
program0 program1:

. 87

, ,
( ) , ,
. 88:

. 88
64
.00540-01 33 01

,
,
. . 89
program0, 6 .

. 89

,
, (. . 90).

. 90

, .
, ,
11.
11
65
.00540-01 33 01

, ,
(FBD, LD SFC), ,
(. . 8).
, (. .
5.14).
.
. 8.

5.11.

(. . 91), ,
Beremiz.
, ,
.

. 91
66
.00540-01 33 01

: ,
, , ,
, , , ,
, , Python SVGUI.
,
. ,
, .. .

(Drag&Drop)
: , .
.
2.

5.12.

, (. . 92), ,
Beremiz.

. 92

:
ST C ;
;
;

.
67
.00540-01 33 01

, Beremiz
(MatIEC C )
. ,
(. . 93).

. 93

5.13.

(.
. 94). (. 5.1)
(. 5.2).

. 94

: ,
, ,
68
.00540-01 33 01

. ,
. . 95 ValueH.

. 95

.
.

5.14.

Beremiz (. . 96).

. 96
69
.00540-01 33 01

.
, ,
, .
(. . 5.10).


(. . 97) .

. 97

(. . 98).

. 98

,
.
,
, .

5.15.

(. . 99) ,
(. . 5.10)
(. 11).
70
.00540-01 33 01

. 99

:
, ;
;
, .
.
12:

12


, ..
.
: x 1.0


.
71
.00540-01 33 01

6.

6.1.

Beremiz ,
, ( , )
( ), (IEC 61131-3),
.
. :
Beremiz
, Python;
, C
.

, .
Beremiz.

6.1.1.

. 5.3, , ,
(. . 100).

. 100
72
.00540-01 33 01

: -, -, -, -
, TCP . .
Beremiz (.
. 101).

. 101 Beremiz

, ,
. . 102 mdo-0 mavts-0,
: - -.

. 102


.
73
.00540-01 33 01

6.1.2.


,
. . 103
mdo-0 ( -).

. 103 -

.
, .
. :
;
;
CFLAGS LDFLAGS , ,
, ( ),
.
, ,
, , mdo-0-1 (. . 104).
74
.00540-01 33 01

. 104

.
. 6.1.3.

6.1.3.

, .
. 105 .

. 105

:
< >.x,
< >
Beremiz,
;
x , ,
.
,
. 106, , .
75
.00540-01 33 01

. 106

,
, .

6.1.4.

:
< %>< >< ><
>< .>< >
I
Q .
.
13.
.

13

BOOL X
SINT, USINT, STRING, BYTE B
INT, UINT, WORD, WSTRING W
DINT, UDINT, REAL, DWORD D
LINT, ULINT, LREAL, LWORD L

, , ( BOOL)
1 0.x : %IX0.1.
Beremiz
():
1) 0 ( 0), , %QD0.0
;
2) ( 1, 3, 5 ..)

, %ID1.5;
76
.00540-01 33 01

3) 0 ( 2, 4, 6)
,
%QD1.6.
: 2*n-1 , 2*n
, n . ,
%ID1.5 3- , %ID1.6 3- .
Beremiz
. . 6.5
.

6.2.

6.2.1. -

- 16 (. . 107), :
COM ;
.

. 107 -
.
(mdv0_condition) .
. , mdv0_signal2
77
.00540-01 33 01

. mdv0_condition4
4 . 0.

6.2.2. -

- 16 (. . 108)
:
COM ;
.
.
,
. , .

. 108 -

6.3.

6.3.1. -

(. . 109)
.
78
.00540-01 33 01

:
COM ;
;
;
.

. 109 -
, .
.
:
, ,
, ;
,
;
79
.00540-01 33 01

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

. 110

6.3.2. -

- .
. 111.
:
COM ;
;
80
.00540-01 33 01

;
.

. 111

, .
.
:
;
, ,
, ;
;
81
.00540-01 33 01

6.4. TCP

TCP (
) (
) . TCP
, (. . 112)
(LDFLAGS):
-L. -ltcpsrv -L. ltagsmanager

. 112 TCP

, .. TCP
libtcpsrv.so libtagsmanager.so,
. TCP (. . 113)
:
, ;
/ , ,
IEC 61131-3;
/ ,
(, ), , (
).
82
.00540-01 33 01

. 113 TCP

6.4.1. TCP

TCP
. -, ,
, .
(. 5.3) (. 5.1).
, ( )
.
(. 3) . (. .
114) mdo-0 (-)
, .

. 114
83
.00540-01 33 01


. (. . 115),
TCP .

. 115 mdo-0 (-)

TCP .
(. . 116).

. 116 ,

, .

(. . 117).
84
.00540-01 33 01

. 117 TCP

TCP (. .
118).

. 118 mdo-0 (-) TCP


( )
( ) , ..
, .
TCP .

6.4.2. TCP

TCP ,
.
85
.00540-01 33 01

: DINT, LINT, REAL, LREAL.


3 ST.
(. . 119).

. 119 TCP

, (.
. 120).

. 120 TCP

None, ,
. ,
86
.00540-01 33 01

tcp_in, input (.. ) REAL (),


TCP (. . 121).

. 121 tcp_in TCP

6.5.


, . 6.1.4.
. ,
. (. 5.4) ,

, (. . 122).

. 122
87
.00540-01 33 01

(.
. 123), .

, .

. 123

OK,
(. . 124).

. 124

Beremiz ,
.
(. 3), (. . 125).
88
.00540-01 33 01

. 125

,
.
(. . 126).

. 126

,
( ,
) , .
89
.00540-01 33 01

7.

Beremiz,
.

7.1.

(. . 127),
.

. 127

(. . 128), ,
.

. 128
90
.00540-01 33 01

.
, .
:
beremiz.xml XML
Beremiz ;
plc.xml XML :
, , , ,
IEC 61131-3;
;
build, ST C ,
.

7.2.

, ,
, ,
.
( ) ,
, Unnamed, . 129:

. 129
91
.00540-01 33 01

7.2.1.


,
.
, . 130,
globalValue 10, (.
3).

. 130



,
, . . 131
program0 globalValue , INT
ST.

. 131

. 132 program1 globalValue


ST.
92
.00540-01 33 01

. 132

, globalValue
: program0 program1.

7.2.2.


( ), ..
. :
URI ,
. . 133 .

. 133
, URI :
93
.00540-01 33 01

PYRO://<IP- >:<>
IP
(
). 3000.
, Sparc,
SPARC.

7.2.3.

,
.
(. . 134),
.

. 134

,
.
.
, ,
(, ),
IEC 61131-3.
94
.00540-01 33 01

7.3.

(, , )
,
, .
(. . 135).

. 135

:
;
;
.
, , ,
. ,
,
. (.
. 136) IEC 61131-3 (IL, ST, LD, FBD, SFC),
.

. 136
95
.00540-01 33 01

7.3.1.

, FBD.
:
globalValue globalLevel, globalValue 10.0,
globalLevel 100, globalLevel 50.
,
, (. . 137):

. 137

(. . 138) FBD OK.

. 138
96
.00540-01 33 01


(. . 139) : globalValue REAL,
globalLevel INT, .

. 139

,
(. . 140), . 7.2.1.

. 140

FBD.
: GT SEL. GT
.
2 20 ( 2)
OUT. IN1 IN2, OUT TRUE,
FALSE.
SEL
. G, IN0, IN1
OUT. G 0 ( FALSE), OUT
IN0. G 1 ( TRUE), OUT
IN1.
97
.00540-01 33 01


(Drag&Drop)
FBD (. . 141):

. 141 FBD

, , globalValue globalLevel
FBD . (. . 5.7.1.2),
# ,
FBD (Drag&Drop).
(. . 142).

. 142 FBD
globalValue IN1 GT.
globalValue OUT SEL,
98
.00540-01 33 01

globalValue FBD
, .
143:

. 143

globalValue OUT SEL


OUT GT G SEL (. . 144).

. 144 FBD

3 ,
IN2 GT IN0 IN1 SEL.
99
.00540-01 33 01

FBD (. 6)
(. . 145) 10.0.
OK.

. 145 FBD

IN2 GT, . 146:

. 146

50 100 IN0
IN1 SEL (. . 147).
100
.00540-01 33 01

. 147 , FBD

, globalValue 10.0,
OUT GT TRUE, SEL
True OUT IN1, .. 100.

7.3.2.

,
.
, (. . 148):

. 148
101
.00540-01 33 01


GetStatus ST IEC 61131-3
(. . 149). SFC
.

. 149


STRING (. . 150).

. 150

value (
) ST
, . 151:
102
.00540-01 33 01

. 151

CASEOF
value. 3 , Error.
FBD
in_value out_status,
. 152:

. 152 FBD


GetStatus
( ) (Drag&Drop)
FBD program0 (. . 153).
103
.00540-01 33 01

. 153 FBD


FBD (. . 154).

. 154 FBD

out_status
GetStatus, (
FBD )
(. . 155).
104
.00540-01 33 01

. 155 FBD

in_value out_status , ,
GetStatus (. . 156).

. 156 FBD


out_status in_value. ,
in_value 5 ( ),
, ,
.
105
.00540-01 33 01

7.3.3.


. .
,
RectParams (. . 157),
.

. 157

,
IEC 61131-3, SFC. . 158
ST.

. 158 ST
106
.00540-01 33 01

. ,
width height INT.
: area perimeter
INT.
ST.
(. . 5.11)
. . 159
RectParams FBD .

. 159 FBD

width width, height 40.


, ,
area perimeter. ,
(. . 160), ,
.

. 160
107
.00540-01 33 01

. 161.

. 161

7.4.


.
, (program0),
ST, : - -.
(. . 162):

. 162 -

- -, ,
. 163:
108
.00540-01 33 01

. 163

program0 ,
, . ..
,
(. 3) .
mdo-0.
, , . 164:

. 164 mdo-0

mdv-0 .
(. . 165).
109
.00540-01 33 01

. 165 mdv-0

, , .

(. . 166).

. 166

, .
ST , . 167:
110
.00540-01 33 01

. 167

, mdv0_singnal1
mdv0_singnal2, - ( mdv0) TRUE,
- md0_signal2 md0_signal3 TRUE,
FALSE. - mdv0_signal3 FALSE,
- md0_signal1 TRUE, FALSE.

7.5.

IEC 61131-3, ,
. ,
.
, Beremiz .

7.5.1.


(. . 7.2.1) (. . 168)
, (. 3).
111
.00540-01 33 01

. 168


. , . 169,
, program0
, , .

. 169

ST
.

7.5.2.


,
.
(
), (
) ( , . . 170):
112
.00540-01 33 01


, ;

TRUE BOOL,
, , .

. 170

,
, .
... (. . 171).

. 171

(. .
172), , , , , ,
.

. 172
113
.00540-01 33 01

OK
(. . 173).

. 173


BOOL, (. . 7.2.1),
(. . 7.5.1). . 174 globalFlag,
.

. 174 BOOL

, ,
, TRUE.
,
0. ,
114
.00540-01 33 01

,
(. . 5.12).
, .
.

. ,
: program0 program1 (. . 175).

. 175 ,

,
(. . 176).

. 176

,
(. . 177).
115
.00540-01 33 01

. 177

,
(. . 5.12).

7.6.


(. . 178) ,
program0.

. 178
116
.00540-01 33 01

INT 11 .
, MyArrayType (. . 179)
OK.

. 179


MyArrayType (. . 5.9).
INT, . 180:

. 180

(. 10)
(. . 181) .
117
.00540-01 33 01

. 181

MyArrayType
,
(. . 182).

. 182

temp_value out_value INT


. , . 183, ST, mas,
, .
temp_value 10:
temp_value := 10;
mas ( 0)
temp_value:
mas[0] := temp_value;
mas 20:
118
.00540-01 33 01

mas[1] := 20;
mas:
out_value := mas[0];
.

. 183 ST
119
.00540-01 33 01

8. ,


( ),
.
,
(. . 5.2.2).
( ,
). , ,
, , . , ,
, , , ..
, ( ).


Beremiz.
Beremiz :
, ,
(. . 5.14);

;
(. . 5.15).
,
.

8.1.

Beremiz,
, Python: Beremiz_service.py.
,
(. 13):
$ python Beremiz_service.py

, , 13.
120
.00540-01 33 01

13 Beremiz

-i IP , 127.0.0.1 (localhost)
-p , 3000
-h
-a (0 , 1 ),
0
-x / (0 , 1 ),
0
-t / web- Twisted (0
, 1 ), 0. web-

, : http://<ip- >:<8009>. 8009
.

Beremiz
, .
, Beremiz_service.py.
,
, .

8.2.

Beremiz ,
. (. . 5.5)
URI- :
PYRO://<IP->:< >
. 184 URI PYRO://192.168.23.226
(. 2),
.
121
.00540-01 33 01

. 184

,
(. . 185).

. 185

:
Empty ;
Started ;
Stopped , .
122
.00540-01 33 01

,
(. 2) ,
. (
, ), . 186:

. 186 ,

8.3.


, Beremiz
, .
(. . 5.10) , . 187,
(. . 5.14):

. 187

(.
. 188).
123
.00540-01 33 01

. 188

,

(. . 189) .

. 189

, . 190.

. 190

, ,
(. . 191).
124
.00540-01 33 01

. 191

, (. . 192)
:

. 192

(.. ),
(. .
193):

. 193

, .

8.4. FBD

,
,
125
.00540-01 33 01

. . 5.10,
( . 194 )
, ,
.

. 194

FBD
( ,
) ,
(. . 195).

. 195 FBD

.
,
,
.
126
.00540-01 33 01

8.5. LD

LD FBD .
(. . 196),
.

. 196 LD

(. . 197), BOOL: TRUE


ON, FALSE OFF.

. 197 LD

, , IN2 (. . 198),
TRUE OUT1 TRUE, ..
IN1 IN2.
127
.00540-01 33 01

. 198 LD

8.6. SFC

SFC FBD LD.


(. . 199),
.

. 199 SFC

. 200 , ( ,
) TRUE firstStep.
128
.00540-01 33 01

. 200 SFC

TRUE ,
. . 201, .. firstStep ,
, , ( ),
, count 1:
count := count + 1;
.

. 201 SFC
129
.00540-01 33 01

N, ,
.

8.7.

Beremiz
. ,
(.
11) , . 202:

. 202

(. . 203)
, .

. 203

,
.
130
.00540-01 33 01

, . 203,
. 204:

. 204 ST

, value ,
, ST.
131
.00540-01 33 01

9.

9.1.

, , (
SPARC): TCP ,
SFC ST, .
, , 3- 4-
TCP
.

9.2.

,
. 205:

. 205

, ,
. (. . 206)
resource1.
132
.00540-01 33 01

. 206

9.3.

,
. Python_Library
SVGUI_Library. Sparc. URI
IP PYRO,
Beremiz (. . 8.1):
PYRO://192.168.23.226:3000
, , . 207.
133
.00540-01 33 01

. 207

9.4.

, ,
, ( , ) ,
.
. : - TCP .

9.4.1. -

- (.
. 208).
134
.00540-01 33 01

. 208 -

- (. . 209) ,
, :
COM : COM1;
: 1.

. 209 -

3- 4- ,
-, , TCP
135
.00540-01 33 01

. .
,
. 210 :

. 210

mdv0_signal3 mdv0_signal4
(. . 211).

. 211 TCP ,

, ,
. 212.
136
.00540-01 33 01

. 212

TCP .

9.4.2. TCP

TCP
- (. . 213).

. 213 TCP

TCP (. . 6.4),
LDFLAGS:
-L. -ltcpsrv -L. ltagsmanager
, ,
, .. tcp_out1 tcp_out2 (.
. 214):
137
.00540-01 33 01

. 214 TCP

output, .. DINT.
- .

-: mdv_signal4 mdv_signal3 (. . 215):

. 215

TCP ,
. 216.
138
.00540-01 33 01

. 216

TCP .
, , . 217:

. 217

,
.

9.5.

, SFC, ST
TCP -.
139
.00540-01 33 01

9.5.1. , SFC

, +
(. . 218).

. 218

SFC OK (. .
219).

. 219 SFC

, .
BOOL
flagStart flagFinish, .
220.
140
.00540-01 33 01

. 220 SFC

mdv0_signal1
mdv0_signal2 (
) (. . 221).

. 221 BOOL

program0
BOOL, mdv0_signal1 mdv0_signal2
(. . 222).
141
.00540-01 33 01

. 222 BOOL -

SFC .
.
(. . 223) .

. 223

mainStep (. . 224).

. 224
142
.00540-01 33 01

, , SFC
(. . 225):

. 225 SFC

initStep mainStep.

(. . 226) flagStart.
OK.

. 226

, , initStep mainStep
. SFC , . 227:
143
.00540-01 33 01

. 227 SFC

,
(. . 228)

. 228


mainStep (. . 229).
144
.00540-01 33 01

. 229 SFC

flagFinish
,
, . 230.

. 230 SFC
145
.00540-01 33 01


initStep.
(. . 231).

. 231 SFC

SFC
, . 232:

. 232 SFC
146
.00540-01 33 01

mainStep .
value (. . 233).

. 233 value program0


tcp_out1.
value
, . 234:

. 234 TCP
147
.00540-01 33 01

, N
(. 9), (. . 235),
, :
value := value + 1;

. 235

, , ,
(. . 236).

. 236 SFC
148
.00540-01 33 01

SFC , ,
. ()
-, .. flagStart
flagFinish, -.
.

9.5.2. , ST


, (. . 237).

. 237

,
ST (. . 238) OK.

. 238 , ST
149
.00540-01 33 01

, . 239.

. 239

, ST,
sig5 BOOL.
- mdv0_signal5,
5, . 240.

. 240 -
150
.00540-01 33 01

DINT,
tcp_out2 TCP (. . 6.4.2).
mdv0_signal5 (. . 241).

. 241 TCP

,
, . 242:

. 242 program1

.
ST : sig5 TRUE, .. 1,
151
.00540-01 33 01

out 10, , sig5


FALSE, .. 0, out 20, . 243.

. 243 ST

, ,
.

9.6.

,
, , . 244.

. 244

(. . 245).
152
.00540-01 33 01

. 245

,
500 , 1000 .
( )
,
(. . 246).

. 246

(. 247) 500
OK.
153
.00540-01 33 01

. 247

, 1
. , , . 248:

. 248

: instance1 instance2.
, .
(
program0 program1), ( task1 task2),
(. . 249).

. 249

, , . 250:
154
.00540-01 33 01

. 250


, , ,
.

9.7.

(. 2).
. 251 :

. 251
155
.00540-01 33 01

,
, . . 252 ,
.

. 252

-, , ,
UNIX- Cygwin.
,
. .

9.8.

. 9,
Beremiz
(. . 8.1), Beremiz_service.py.
, , IP-
192.168.23.226 3000.
PYRO://192.168.23.226:3000 (. . 9.3), . 253:
156
.00540-01 33 01

. 253

(. 2)
. . 254 :

. 254

, . 255:
157
.00540-01 33 01

. 255

Empty ,
.
(. 2), . 256
:

. 256


, . 257:
158
.00540-01 33 01

. 257


(. 2), . 258 :

. 258


, . 259:
159
.00540-01 33 01

. 259


(. 2), . 260 :

. 260

,
. 261:
160
.00540-01 33 01

. 261

9.9.

,
resource1. ,
resource: instance1 program0 instance2 program1.
, . 262
instance1:

. 262

, FBD , ,
. 263:
161
.00540-01 33 01

. 263 FBD

, . 264
, value :

. 264 value

value 0, .. .
, mainStep .
, - 1- TRUE, .. flagStart,
. flagStart TRUE
SFC . SFC
flagStart
, . 265.
162
.00540-01 33 01

. 265 SFC

BOOL
True. OK, . 266.

. 266 True

, flagStart SFC TRUE,


mainStep (. . 267).
163
.00540-01 33 01

. 267 SFC

, ,
. . ,
, value 500
, .. program0 , 500
(. . 9.6).
164
.00540-01 33 01

BEREMIZ
Beremiz Windows 7
Beremiz Windows
:
Python 2.7 (wxPython-
2.8, twisted, simplejson, Pyro, numpy, nevow);
UNIX- Cygwin c Windows
SPARC.
Python UNIX- Cygwin
BeremizProject DVD . :
1) BeremizProject ;
2) python BeremizProject, , C;
3) python

Python
Python
.
(. . 1.1).

. 1.1 Windows 7
165
.00540-01 33 01

(. . 1.2):

. 1.2 Windows 7

,
(. . 1.3).

. 1.3 Windows 7
166
.00540-01 33 01

Path (. . 1.4)
.

. 1.4 Windows 7

, ,
, C:\Python (. 1.5).

. 1.5 Windows

, OK, .
: "<
python >\pythonw.exe" "< Beremiz>\beremiz\Beremiz.py".
167
.00540-01 33 01

Beremiz Debian/Ubuntu
Debian/Ubuntu
Python. :
$ sudo apt-get install python-wxgtk2.8 pyro mercurial
$ sudo apt-get install build-essential bison flex python-numpy python-
nevow
MatIEC:
$ cd ~/BeremizProject/matiec
$ ./configure
$ Make
, Beremiz
Debian/Ubuntu.
beremiz:
$ python Beremiz.py

:
$ python Beremiz_service.py
168
.00540-01 33 01


,

, ,
IEC 61131-3.
. ,
.


SR-
SR-,
S (Set). Q1 "1", S1 "1".
, S1 "0". Q1 "0",
R "1". S1 R "1" ,
S1 Q1 "1". ,
Q1 "0".

RS-
RS-,
R (Reset). Q1 "1", S "1".
, S "0". Q1 "0",
R1 "1". S R1 "1" ,
R1 Q1 "0". ,
Q1 "0".

SEMA
, ,
.
169
.00540-01 33 01

R_TRIG
,
. Q
"1", "0" "1" CLK . "1"
( ); "0".

F_TRIG
,
.
Q "1", "1" "0" CLK .
"1" ;
"0".

CTU
. "1"
R "0" CV . "0" "1"
CU CV 1. CV >= PV, Q "1".
:
. .
CU, RESET Q BOOL, PV CV WORD.
CU ( FALSE TRUE) CV 1.
Q TRUE, PV. CV
0 RESET = TRUE.

CTD
. "1"
LD PV CV . "0"
"1" CD CV 1.
CV <= 0, Q "1".
:
. .

CTUD
170
.00540-01 33 01

. "1"
R "0" CV . "1" LD
PV CV . "0" "1" CU
CV 1. "0" "1" CD CV
1.
"1" R LD, R .
CV >= PV, QU "1".
CV <= 0, QD "1".
:
,
. .

TP

. IN "1", Q
"1", (ET).
PT, Q "0" ( IN).
/, IN "0".
PT, IN .
PT, IN "0", /, Q
"0".

TON
.
, 0 1 1
.
IN "1", (ET).
PT, Q "1". IN "0", Q "0",
/. IN "0" ,
PT,
/, Q "0".

TOF
171
.00540-01 33 01

.
, 1 0 0
.
IN "1", Q "1".
IN "0", (ET).
PT, Q "0".
IN "1", Q "1",
/.
IN "1" , PT,
/, Q "0".


RTC

, ,
, ..
PDT (Preset DT) .
PDT. Q (BOOL) EN. CDT (Current DT)
.

INTEGRAL
XIN .

DERIVATIVE
XOUT
XIN.

PID --
,
.
- , ,
, ,
.
HYSTERESIS
172
.00540-01 33 01


, XIN1 XIN2 ( REAL
).


,
IEC 61131-3, .


ABS
OUT IN.

SQRT
OUT IN.

LN
OUT IN.

LOG 10
OUT 10 IN.

EXP
OUT , IN.

SIN
OUT IN.

COS
OUT IN.

TAN
OUT IN.

ASIN
OUT IN.
173
.00540-01 33 01

ACOS
OUT IN.

ATAN
OUT IN.


ADD
OUT IN1 IN2.

MUL
OUT IN1 IN2.

SUB
OUT IN1 IN2.

DIV
OUT IN1 IN2.

MOD
OUT IN1 IN2.

EXPT
OUT IN1 IN2.

MOVE
OUT IN.


ADD_TIME TIME
174
.00540-01 33 01

IN(k) TIME
OUT TIME. IN(n) - 2 20. 2.

ADD_TOD_TIME TOD TIME


IN1 TOD (TIME_OF_DAY)
IN2 TIME. OUT TIME_OF_DAY.

ADD_DT_TIME TIME DT
ADD_DT_TIME ( TIME)
( DT) ( DT).
( T) DT#1990-01-01-00:00:00.000
DT#2089-12-31-23:59:59.999.
.
,
(BR) "0".

.

MULTIME TIME
IN1 TIME IN2
ANY_NUM OUT TIME.

SUB_TIME TIME
IN1 TIME IN2
TIME OUT TIME.

SUB_DATE_DATE DATE
IN1 DATE IN2
DATE OUT TIME.

SUB_TOD_TIME TOD TIME


IN1 TOD (TIME_OF_DAY)
IN2 TIME OUT TIME_OF_DAY.
175
.00540-01 33 01

SUB_DT_TIME DT TIME
( TIME) (
DT) ( DT).
( T) DT#1990-01-01-00:00:00.000 DT#2089-12-
31-23:59:59.999. .
,
(BR) "0".

.

DIVTIME TIME
IN1 TIME IN2
ANY_NUM OUT TIME.


SHL
OUT IN N
.

SHR
OUT IN N
.

ROR
OUT IN N .

ROL
OUT IN N .


AND

IN1INn.
176
.00540-01 33 01

OR

IN1INn.

XOR

IN1INn.

NOT

IN.


SEL
OUT IN1 IN2
G. G = 0, OUT 1, OUT X2.

MAX
OUT IN1 IN2.

MIN
OUT IN1 IN2.

LIMIT
OUT IN,
MX OUT MX, IN MN OUT
MN.

MUX ( 1 N)
OUT IN(K), K.
IN(n) 2 20. 2.


177
.00540-01 33 01

GT
OUT True,
: (IN1 > IN2) & (IN2 > IN3) & (INn-1 > INn),
OUT False. IN(n) 2 20. 2.

GE
OUT True,
: (IN1 >= IN2) & (IN2 >= IN3) & (INn-1 >= INn),
OUT False. IN(n) 2 20.
2.

EQ
OUT True,
: (IN1 = IN2) & (IN2 = IN3) & (INn-1 = INn),
OUT False. IN(n) 2 20. 2.

LT
OUT True,
: (IN1 < IN2) & (IN2 < IN3) & (INn-1 < INn),
OUT False. IN(n) 2 20. 2.

LE
OUT True,
: (IN1 <= IN2) & (IN2 <= IN3) & (INn-1 <= INn),
OUT False. IN(n) 2 20.
2.

NE
OUT True,
: (IN1 <> IN2) & (IN2 <> IN3) & (INn-1 <> INn),
OUT False. IN(n) - 2 20.
2.
178
.00540-01 33 01

STRING
LEN
OUT IN.
.

LEFT
OUT IN L . L ,
STRING, . L = 0
. L
, . IN
.

RIGHT
OUT IN L . L ,
STRING, . L = 0
. L
, . IN
.

MID
OUT IN L-, P.
L (P1) STRING,
, P- .
(P , P / L )
. IN
.

CONCAT STRING
OUT () IN1 IN2.

CONCAT_DAT_TOD ()
OUT DT DATE
TOD, IN1 IN2.
179
.00540-01 33 01

INSERT STRING
OUT IN1, IN2,
P. P ,
. P , ,
. P , .
IN1 IN2
.

DELETE STRING
OUT IN1, L ,
P. L / P P , ,
. L P , ,
. L / P ,
. IN
.

REPLACE STRING
OUT IN1, , P,
L IN2. L ,
. P , , 1-
(). P ,
. L / P , .
IN1 IN2
.

FIND STRING
OUT , IN2
IN1. , .
, . IN1 IN2
.
180
.00540-01 33 01

ST
ST
ST (Structured Text) ,
Pascal. ,
. ,
, SFC. IEC 61131-3
.
, .
ST , Pascal:
[variable] := [value];
. .
, , ,
, .


IEC 61131-3, ST ,
. : SINT (char), USINT
(unsigned char), INT (short int), UINT (unsigned int), DINT (long), UDINT (unsigned long), LINT (64
), ULINT (64 ). : REAL (float), LREAL (double).
BYTE, WORD, DWORD, LWORD
8, 16, 32 64 . ST .
. :
a.3 := 1; (* 3 a *)
BOOL TRUE FALSE.
BOOL . STRING ,
. .
:
strA := strB;
(. 2,
STRING).
IEC (TIME),
(TOD), (DATE) (DT).
181
.00540-01 33 01

3.1 , .

3.1 IEC 61131-3


()
BOOL, SINT, INT, DINT, LINT 0
USINT, UINT, UDINT, ULINT 0
BYTE, WORD, DWORD, LWORD 0
REAL, LREAL 0.0
TIME T#0S
DATE D#0001-01-01
TIME_OF_DAY TOD#00:00:00
DATE_AND_TIME DT#0001-01-01-00:00:00
STRING ( )

, .
. :
str1: STRING := Hello world;

, .. .
3.2.

3.2 IEC 61131-3


ANY
ANY_BIT ANY_NUM ANY_DATE
TIME
BOOL ANY_INT ANY_REAL
STRING
BYTE DATE
INT UINT
WORD TIME_OF_DAY
SINT USINT REAL
DWORD DATE_AND_TIME
DINT UDINT LREAL
LWORD
LINT ULINT


ST :
182
.00540-01 33 01

;
() ;
;
;
IF ELSEIF ELSE;
FOR;
WHILE;
REPAET UNTIL;
CASE.

. (
) .


:
+ ;
- ;
* ;
/ ;
mod .
3.4 ( ,
).

()
:
OR () ;
AND () ;
XOR () ;
NOT () .


:
= ;
<> ;
183
.00540-01 33 01

> ;
>= ;
< ;
<= .
BOOL.


:=.
(
). ( )
. .
3.4 .

3.4

1
, 2
, 3
OR 4
AND, XOR 5
NOT 6
7
8

IF ELSEIF ELSE

. , :
;
.
IF-ELSEIF-ELSE :
IF <boolean expression> THEN <statement list>
[ELSEIF <boolean expression> THEN <statement list>]
[ELSE <statement list>]
END_IF;
:
184
.00540-01 33 01

IF Var <> 0
THEN Var := 1
ELSEIF Var > 0
THEN Var := 0;
ELSE Var := 10;
END_IF;
, .. IF ..
:
IF Var > 10 THEN
IF Var < Var2 + 1
THEN Var := 10;
ELSE Var := 0;
END_IF;
END_IF;

FOR
.
:
FOR <Control Variable> := <expression1> TO <expression2>
[BY <expression3>] DO
<statement list>
END_FOR;
, <Control Variable>, <expression1>
<expression3> INT. ,
<expression2>. :
FOR i := 1 TO 10 BY 2 DO
k := k * 2;
END_FOR;
BY ( i
2 ). BY ,
1. :
FOR i := 1 TO k / 2 DO
var := var + k;
k := k 1;
END_FOR;
, IF CASE.
( ) EXIT. :
FOR i := 1 TO 10 BY 2 DO
k := k * 2;
185
.00540-01 33 01

IF k > 20 THEN
EXIT;
END_IF;
END_FOR;
1: <expression1> <expression3>
, ,
. :
01: k := 10;
02: FOR I := 1 TO k / 2 DO
03: k := 20;
04: END_FOR;
3 k,
. 2: ,

. :
01: FOR I := 1 TO 5 DO
02: I := 55;
03: END_FOR;
I 1, 2 55,
I 2 .

WHILE
. ,
WHILE TRUE. :
WHILE <Boolean-Expression> DO
<Statement List>
END_WHILE;
<Boolean-Expression> .
, <Boolean-Expression> FALSE. :
k := 10;
WHILE k > 0 DO
i := I + k;
k := k 1;
END_WHILE;
, IF CASE.
EXIT (.
FOR).
186
.00540-01 33 01

REPEAT UNTIL
. ,
UNTIL FALSE. :
, UNTIL .
:
REPEAT
<Statement List>
UNTIL <Boolean Expression>;
END_REPEAT;
:
k := 10;
REPEAT
i := i + k;
k := k 1;
UNTIL k = 0;
END_REPEAT;
, IF CASE.
EXIT (.
FOR).

CASE
.
:
CASE <Expression> OF
CASE_ELEMENT {CASE_ELEMENT}
[ELSE <Statement List>]
END_CASE;
CASE_ELEMENT , .
.
BEGIN_VAL .. END_VAL.
<Expression> CASE_ELEMENT,
ELSE. ELSE ,
.
<Expression> . :
01: CASE k OF
02: 1:
03: k := k * 10;
187
.00540-01 33 01

04: 2..5:
05: k := k * 5;
06: i := 0;
07: 6, 9..20:
08: k := k 1;
09: ELSE
10: k := 0;
11: i := 1;
12: END_CASE;
4 . k
[2, 5], 5 6.
7 . 8 , k
6 [9, 20].
10 11 , k < 1, 6 < k < 9, k > 20 (
ELSE).
:
CASE ;
.
3.5
CASE.
, CASE,
, IF CASE.

3.5 CASE

01: CASE k OF 01: CASE k OF
02: 1: 02: 1:
03: k := k * 10; 03: k := k * 10;
04: 2..5: 04: 2..5:
05: k := k * 5; 05: k := k * 5;
06: i := 0; 06: i := 0;
07: 5, 9..20: 07: 6, 9..20:
08: k := k 1; 08: k := k 1;
09: ELSE 09: ELSE
10: k := 0; 10: k := 0;
11: i := 1; 11: i := 1;
12: END_CASE; 12: END_CASE;
188
.00540-01 33 01

4 7
01: CASE k OF 01: CASE k OF
02: 1: 02: 1:
03: k := k * 10; 03: k := k * 10;
04: 2..5: 04: 2..5:
05: k := k * 5; 05: k := k * 5;
06: i := 0; 06: i := 0;
07: 6, 20..9: 07: 6, 9..20:
08: k := k 1; 08: k := k 1;
09: ELSE 09: ELSE
10: k := 0; 10: k := 0;
11: i := 1; 11: i := 1;
12: END_CASE; 12: END_CASE;
7
.

ST
.
189
.00540-01 33 01

IL
IL
IL (Instruction List) ,
Assembler, .
, ,
SFC. IL
. IL
.


IL, Assembler,
. ,

. 4.1 IL.

4.1 IL

LD
LDN
ST
STN
S TRUE,
R FALSE,
AND
ANDN
OR
ORN
XOR
XORN
NOT
ADD ,
190
.00540-01 33 01

SUB ,
MUL ,
DIV ,
GT (>(greater than)).
(TRUE FALSE)
GE (>=greater than or
equal)). (TRUE FALSE)
EQ (=(equal)).
(TRUE FALSE)
NE (<>(not equal).
(TRUE FALSE)
LE (<=(less than or equal
to)). (TRUE FALSE)
LT (<(less than)).
(TRUE FALSE)
JMP
JMPC , TRUE
JMPCN , FALSE
CAL
CALC ,
TRUE
CALCN ,
FALSE
RET POU
RETC POU ,
TRUE
RETCN POU ,
FALSE

IL
. 4.1 IL,
C = A AND NOT B:
191
.00540-01 33 01

. 4.1 IL

LD A ,
. ANDN
, .
ST C .
192
.00540-01 33 01

FBD
FBD
FBD (Function Block Diagram) ,
.
.
.
, . .
, 2. FBD
, ,
, FBD
, - .


IEC 61131-3, FBD : , ,
.
, /. . 5.1 :
in_var, out_var /
in_out_var.

. 5.1 FBD

. 5.2.
(IN1 IN2), (OUT).
193
.00540-01 33 01

. 5.2 FBD

, , . 5.3,
(S1 R), (Q1).

. 5.3 FBD

,
.
,
, /
, .

.

. 5.4 ,

()
: EN () ENO ().
. 5.5.
194
.00540-01 33 01

. 5.5 EN/ENO

EN/ENO EN
, , , .
ENO 0. EN 1,
, , .
ENO 1.
, ENO
0.
EN = 1, EN/ENO.

, . 5.6:

. 5.6 FBD

: .

. . 5.7 , OUT
BOOL_TO_INT IN2 ADD:

. 5.7 FBD
195
.00540-01 33 01

FBD
. 5.8 FBD , :
SR0, AND, TP0.

. 5.8 FBD

SR0 SR-.
S1, R1 Q1, EN ENO,
SR0. Q1 IN1 AND,
. IN2 BOOL BOOL#1,
. OUT AND IN
TP0, . PT TIME,
T#5s, 5 .
enabled True
S1_IN True, SR0 . OUT
AND True Q1 SR0 True.
, OUT True IN TP0
True ET (. . 5.9).

. 5.9 FBD
196
.00540-01 33 01

PT Q TP0
True. ET PT, .. 5 Q
False (. . 5.10).

. 5.10 FBD

IN TP0 FALSE, ET
T#0s.
197
.00540-01 33 01

LD
LD
LD (Ladder Diagram) , -
( - : , ,
.)
. LD :
( ),
, . . 6.1
LD ()
().

. 6.1 LD () ()

, , .
, ,
.
LD
, .
.
LD-
. , ,
( ). , ,
.
198
.00540-01 33 01


LD .
, ,
. ,
ON OFF,
TRUE FALSE. ( BOOL).
TRUE, .
("OFF").
,
. ,
.
. |/|
"ON", FALSE.
LD :
;
;
;
;
;
Set/Reset- (/);
;
;
EN.


LD-,
. AND-

.
.
(. . 6.2) ,
TRUE. ,
FALSE.
199
.00540-01 33 01

. 6.2

(. . 6.3) ,
FALSE. ,
TRUE.

. 6.3

(. 6.4)
TRUE, FALSE
TRUE, TRUE. , FALSE.

. 6.4

(. . 6.5)
TRUE, True False,
True . , FALSE.

. 6.5


200
.00540-01 33 01

LD-,
.
.
(. . 6.6)
.

. 6.6

(. . 6.7) .

. FALSE,
FALSE,
TRUE.

. 6.7

(. . 6.8) .
TRUE,
TRUE, .
.

. 6.8

(. . 6.9) .
FALSE,
201
.00540-01 33 01

TRUE, .
.

. 6.9

(. . 6.10)
. BOOL
TRUE , FALSE TRUE.

. 6.10

(. . 6.11)
. BOOL
TRUE , TRUE FALSE.

. 6.11

,
,
, .


. ,
, ( ).
202
.00540-01 33 01

LD
:
C = A AND NOT B
LD BOOL.
A ( ).
, , , .
A, B,
C. (. . 6.12),
, LD, :
C = A AND NOT B

. 6.12 LD , C = A AND NOT B


203
.00540-01 33 01

SFC
SFC
SFC (Sequential Function Chart)
, IEC 61131-3. SFC
.
SFC , ,
. SFC
,
.

SFC
SFC : (
), , , .
, SFC,
. , , . ,
, .
.
, .
, .
, , , ,
.
SFC .


SFC , .
(. . 7.1).

. 7.1 SFC
204
.00540-01 33 01

3 .
. ,

.
, (.
. 7.2).

. 7.2 step2 step3, tr2_3

SFC (,
), .


.
, ,
. , ,
ST , :
(i<= 100) AND b
.
. 7.3 Step3 Step5
transition4.
205
.00540-01 33 01

. 7.3 Step3 Step5 transition4

transition4 ,
SFC
. , , ST:
:= (flag = True AND level > 10);
. 7.4 Step6 Step7 :
level > 10

. 7.4 Step6 Step7 level > 10

. 7.5 Step8 Step9


AND FBD:
206
.00540-01 33 01

. 7.5 step8 step9, FBD

,
.


, , ,
, . . 7.6 evaluateStep
.

. 7.6 evaluateStep , 3

,
() . .
.
( . 7.6 action0 action1).
. ,
, . ,
6.
.
207
.00540-01 33 01


.
. ,
. ,
. ,
. . 7.7 SFC ,
.

. 7.7 SFC ,

init transition4,
step1, transition2.



. . ,
, .
, ,
. SFC
. 7.8 :
208
.00540-01 33 01

. 7.8 SFC

,
. SFC ,
. SFC
. 7.9 :

. 7.9 SFC

,
. .
SFC . 7.10
:
209
.00540-01 33 01

. 7.10 SFC


. , .
SFC . 7.11
:

. 7.11 SFC

SFC
. 7.12 SFC initStep,
firstStep secondStep 3 .
210
.00540-01 33 01

startFlag BOOL
. firstStep secondStep LD
, BOOL: in1 in2.
, in1 in2 TRUE. secondStep
initStep , value -100.
firstStep count 1.
secondStep value 10.

. 7.12 SFC
211
.00540-01 33 01

1. - :

"SPAR", "".
2. -. .467 444.013 PC/104
microPC. .687264.013
3. -. .468353.152 - . -
.687265.055
4. -. .468353.153 .
.687264.015
5. . . 468154.001 - . .687264.014
6. -. . 468154.002
. .687264.016
7.
SPARC, .
IEC
61131-3. . .00540-01 12 01
212
.00540-01 33 01

()
- - - - -
(
)
.