Вы находитесь на странице: 1из 452

CoDeSys 2.

Copyright 1994, 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
3S - Smart Software Solutions GmbH
All rights reserved.
Copyright 2003, 2004, 2005, 2006, 2007, 2008 ( )
.
. .

Trademark
Intel is a registered trademark and 80286, 80386, 80486, Pentium are trademarks of Intel Corporation.
Microsoft, MS and MS-DOS are registered trademarks, Windows is a trademark of Microsoft Corporation.

:
3S - Smart Software Solutions GmbH
Memminger Strae 151
D-87439 Kempten
.:
+49 831 5 40 31 - 0
: +49 831 5 40 31 50
www.3s-software.com
:

21400, , . , . , 9
.:
+7 4812 38-29-31
./:
+7 4812 65-81-71
www.prolog-plc.ru
CoDeSys V2.3 . .

10.09.2008
RU 2.8, CoDeSys V2.3.9.x

CoDeSys V2.3

1-2

CODESYS ...........................................................................................1-1

1.1 CoDeSys....................................................................................................................................................... 1-1


1.2 CoDeSys.................................................................................................................... 1-1
1.3 CoDeSys............................................................. 1-3
2

CODESYS ..............................................................................................................2-1

2.1 ................................................................................................................................................... 2-1


2.2 ....................................................................................................................................... 2-8
(IL)..................................................................................................................................................... 2-9
IL..................................................................................................................................... 2-9
(ST).................................................................................................................................... 2-10
(SFC)...................................................................................... 2-17
(FBD)............................................................................................... 2-22
(CFC)....................................................................................................... 2-23
(LD).................................................................................................................................... 2-23
2.3 .................................................................................................................................... 2-25
3

..............................................................................................................3-1

3.1 ............................................................................................................................... 3-1


3.2 ............................................................................................................................................ 3-11
4

CODESYS ..............................................................4-1

4.1 .................................................................................................................................................................. 4-1


4.2 ............................................................................................................................................................... 4-3
4.3 ............................................................................................................................................... 4-19
4.4 .......................................................................................................................... 4-50
4.5 ................................................................................................................ 4-57
4.6 .................................................................................................................................. 4-64
4.7 .......................................................................................................................................................... 4-80
4.8 ........................................................................................................................................................................... 4-80
5

CODESYS .....................................................................................................................5-1

5.1 ................................................................................................................................. 5-1


5.2 .............................................................................................................................. 5-3
.................................................................................................................................. 5-3
............................................................................................... 5-11

CoDeSys V2.3

1-3

................................................................................................................................................ 5-11
5.3 .............................................................................................................................................. 5-20
................................................................................................................................. 5-20
IL............................................................................................................................................................ 5-24
ST.......................................................................................................................................................... 5-24
5.4 ......................................................................................................................................... 5-25
............................................................................................................................ 5-25
FBD ................................................................................................................................................................... 5-30
LD ...................................................................................................................................................................... 5-36
SFC ................................................................................................................................................................... 5-43
CFC................................................................................................................................................................... 5-52
6

............................................................................................................................................6-1

6.1 ............................................................................................................................................................. 6-1


6.2 , ............................................... 6-2
................................................................................................................................................ 6-3
................................................................................................................................ 6-7
................................................................................................................................ 6-8
6.3 (Alarm Configuration)..................................................................................................... 6-9
..................................................................................................................................................................................... 6-9
....................................................................................................................... 6-10
................................................................................................................................................................... 6-11
................................................................................................................................................................... 6-15
.................................................................................................................................................................... 6-16
'' (Extras): '' (Settings)........................................................................................................... 6-18
6.4 (Library Manager)............................................................................................................ 6-18
6.5 (Log)....................................................................................................................................................... 6-20
6.6 (PLC Configuration)............................................................................................................ 6-23
................................................................................................................................................................................... 6-23
................................................................................................................. 6-25
..................................................................................................................... 6-26
..................................................................................................... 6-27
/..................................................................................................................... 6-28
.................................................................................................................................................... 6-31
Profibus ....................................................................................................................... 6-32
CANopen- .................................................................................................................... 6-39
CANopen- (CANopen Slave)........................................................... 6-45
DeviceNet.................................................................................................................... 6-49
...................................................................................................................... 6-54
/ / ................................................................................ 6-54
6.7 (Task Configuration)........................................................................................................ 6-56
................................................................................................................................................................................... 6-56
................................................................................................................................... 6-57
....................................................................................................................................................... 6-59
.................................................................................................................... 6-60
6.8 (Watch and Recipe Manager) ..................................................................................... 6-62
................................................................................................................................................................................... 6-62
.............................................................................................................. 6-62
................................................................................................................. 6-64
6.9 (Sampling Trace)........................................................................................................ 6-65

CoDeSys V2.3

1-4

................................................................................................................................................................................... 6-65
.......................................................................................................................................... 6-66
........................................................................................................................ 6-67
..................................................................................................................................................... 6-68
('Extras' 'Save trace values')................................................... 6-70
('Extras' 'External Trace Configurations')................ 6-70
6.10 (Workspace)............................................................................................................................ 6-71
6.11 (Parameter Manager)................................................................................................ 6-71
.................................................................................................................................................... 6-71
. ............................................................................................................... 6-73
................................................................................................................ 6-74
............................................................................................................................ 6-76
......................................................................................................................... 6-78
................................................................................................................ 6-79
/ ...................................................................................................................... 6-80
6.12 (Target Settings)..................................................................................... 6-80
6.13 - (PLC-Browser)................................................................................................................................. 6-82
.............................................................................................................................................................. 6-82
- ...................................................................................................................................... 6-82
-............................................................................................................... 6-84
-............................................................................................................. 6-85
6.14 (Tools)............................................................................................................................................... 6-86
(Object Properties)....................................................................................... 6-86
............................................................................................................................... 6-89
...................................................................................................... 6-90
7

ENI........................................................................................................................................................7-1

7.1 ENI?................................................................................................................................................................ 7-1


7.2 ENI ............................................................................................. 7-1
7.3 ENI CoDeSys ............................................................................................. 7-2
7.4 ................................................................................................... 7-2
8

DDE ...............................................................................................................................8-1

8.1 DDE CoDeSys.......................................................................................................................................... 8-1


8.2 DDE GatewayDDE Server ................................................................................................. 8-2
9

CODESYS....................................................................................9-1

9.1 ................................................................................................................................................................................. 9-1


9.2 CoDeSys..................................................................................... 9-1
10

...............................................................................................................................10-1

A: ...............................................................................10-1
10.1 .............................................................................................................................. 10-1

CoDeSys V2.3

1-5

10.2 ............................................................................................................................................... 10-4


10.3 ................................................................................................................................................... 10-6
10.4 ............................................................................................................................................... 10-8
10.5 .........................................................................................................................................10-10
10.6 ...........................................................................................................................................10-13
10.7 ..............................................................................................................................10-14
10.8 ...................................................................................................................................................10-15
10.9 ..........................................................................................................................10-15
10.10 ................................................................................................................................10-22
: CODESYS .......................................................................................10-27
...........................................................................................................................................................................10-27
.......................................................................................................................................................................10-29
..................................................................................................................................................................................10-31
........................................................................................................................................10-32
: CODESYS ....................................................................................10-33
.....................................................................................................................................10-33
.............................................................................................................................10-34
D: CODESYS .......................................................................................10-42
Standard.lib ....................................................................................................................10-42
......................................................................................................................................................10-42
..............................................................................................................................................................10-45
..................................................................................................................................................10-47
...........................................................................................................................................................................10-49
...........................................................................................................................................................................10-51
UTIL.LIB ......................................................................................................................................................10-53
BCD ...................................................................................................................................................10-53
/ ..........................................................................................................................................................10-54
.........................................................................................................10-55
......................................................................................................................................................................10-57
...................................................................................................................................................10-60
..................................................................................................................10-62
...........................................................................................................................................10-63
AnalyzationNew.lib .................................................................................................................................10-64
CoDeSys ............................................................................................................................10-65
E: 10-66
CoDeSys:.....................................................................................................................................................10-66

CoDeSys V2.3

1-6

Standard.lib: ............................................................................................................................................10-68
Util.lib:........................................................................................................................................................10-68
F: / ......................................................10-70
...........................................................................................................................................................10-70
(cmdfile)..........................................................................................................................................10-71
G: . .................................................................................................10-79
SEQ ....................................................................................................................10-79
S5 .....................................................................................................................................10-80
S5 C 61131-3......................................................................................................10-80
H: ..................................................................................10-84
(Target Platform)...............................................................................10-84
Intel 386 ..................................................................................................................................................10-84
Motorola 68K....................................................................................................................................................................10-85
Infineon C16x ...................................................................................................................................................................10-86
ARM Power PC ............................................................................................................................................................10-87
MIPS...................................................................................................................................................................................10-88
'Hitachi SH'........................................................................................................................................................................10-89
8051 ........................................................................................................................................................10-90
Infineon 'TriCore .............................................................................................................................................................10-90
(Memory Layout)................................................................................................10-91
(General)............................................................................................................................10-92
..................................................................................................10-94
...............................................................................................................................10-95
I: .........................................................................10-98
J: ............................................................10-101
..........................................................................................................................10-101
................................................................................................................................10-101
(DUT).........................................................................................10-103
, (POU) ..........................................10-103
.............................................................................................................................10-104
K: .............................................10-105
............................................................................................................................................................10-106
...............................................................................................................................................................................10-112

CoDeSys V2.3

1-7

1 CoDeSys
1.1 CoDeSys
CoDeSys - (CoDeSys
Controllers Development System).
CoDeSys 61131-3. , (, Visual C++).

1.2 CoDeSys
?
, .
(POU Program Organization Unit)
PLC_PRG.
( main ),
(, ).
PLC_PRG, (Task Configuration). , .
POU, ,
.
(Object Organizer) .
?

.
, .
.
, ,
.
?
, .
(simulation) .
.
(PLC Configuration)
. , . , . (,

CoDeSys

Watch and Recipe Manager), ,


.

. , .
(single step),
.

, ,
, .
(Sampling Trace), .
, "". , .
CoDeSys
.
CoDeSys DDE . , OPC DDE .
CoDeSys .
(Parameter manager) .
ENI: ENI . CoDeSys , . ENI
CoDeSys, .
CoDeSys . ,
, .
CoDeSys ,
Web. .

CoDeSys V2.3

1-2

CoDeSys

1.3 CoDeSys

CoDeSys

CoDeSys_V23_RU.pdf
First Steps with CoDeSys RU.pdf

CoDeSys ()
Gateway Server

, ,
, (

)

Gateway Manual.pdf

OPC Server

OPC-Server V2.0,

OPC_20_How_to_use.pdf

CoDeSys

CoDeSys ,
CoDeSys HMI, (Target-) Web

CoDeSys_Visu_V23_RU.pdf

SoftMotion

SoftMotion

SoftMotion_Manual_V23.pdf

Standard.lib Util.lib .

CoDeSys_V23_RU.pdf
SysLibs_Overview_RU.pdf

CoDeSys

<library
name>.pdf
SoftMotion :
.
ENI Server

<SysLib-Name_RU>.pdf

SoftMotion-

ENI , , .

EniServerQuickstart.pdf
CoDeSys_V23_RU.pdf

ENI CoDeSys:
.
ENI Admin, ENI Control ENI Explorer: .
.

CoDeSys V2.3

1-3

2 CoDeSys
2.1

: POU, , , , .
.
POU (Program Organization Unit)
(POU) , . POU ().
.
POU (IL, ST, FBD, SFC, LD CFC).
CoDeSys . standard.lib.
POU POU, .

POU, (
, ). .
.
. . J.
:
FUNCTION Fct: INT;
, .
FUNCTION
END_FUNCTION. , IL,
.
, IL:

, CoDeSys

ST .
SFC .
: , CoDeSys . 61131-3, . .. .

:
IL:
LD
Fct
ST

7
2,4
Result

ST:
Result : = Fct (7, 2, 4);
FBD:

: RETAIN .
!
: :
CheckBounds,
( . ).
: CheckDivByte, CheckDivWord, CheckDivDWord CheckDivReal 0 (. DIV).
CheckRangeSigned CheckRangeUnsigned
(. ).


- POU, .
.
FUNCTION_BLOCK END_FUNCTION_BLOCK. . J.
, IL,
. MULERG , VERGL
.
:

CoDeSys V2.3

2-2

, CoDeSys


. () .
, ().
( ) , , .
, .
fubinstance FUB:
fubinstance: FUB;
.
,
.
:
fb iInl INT:
PROGRAM prog
VAR
fbinst1 : fb;
END_VAR
LD 17
ST
fbinst1.iIn1
CAL fbinst1
END_PROGRAM

. .
POU, ,
.

.

CoDeSys V2.3

2-3

, CoDeSys

. . , , , .
RETAIN, .



, :
< >.< >
:
(IL, ST) . ":=", "=>". , (Input Assistant)(<F2>) (With arguments).
:
, FBINST - , xx yy. FBINST ST
:
FBINST1(xx:= , yy=> );
-:
, - (VAR_IN_OUT) .
.
fuboinst iInOut1 VAR_IN_OUT:
VAR
fuboinst: fubo;
iVar1: int;
END_VAR
iVar1 := 2;
fuboinst (iInOut1 := iVar1);
:
fuboinst (iInOut1:=2); fuboinst .iInOut1:=2;
FUB:
ERG, QUAD.
FUB INSTANZ.
IL:

CoDeSys V2.3

2-4

, CoDeSys

ST ( , ):

FBD:

SFC .

POU, . .
. .
.
, ,
, POU.
,
.

CoDeSys V2.3

2-5

, CoDeSys

PROGRAM END_PROGRAM. . J.
:

, , (IL, ST) .
":=", "=>".
:
IL:
CAL
LD
ST

PRGexample2
PRGexample2.out_var
erg

:
CAL PRGexample2(in_var:=33, out_var=>erg )
ST:
PRGexample2;
erg := PRGexample2.out_var;
:
PRGexample2(in_var:=33, out_var=>erg );
FBD:

PLC_PRG
PLC_PRG POU, . .
(Project) - (Object Add), POU - PLC_PRG.
.

Configuration), PLC_PRG.

(Task

: POU PLC_PRG ( (Task


Configuration) ). PLC_PRG .

CoDeSys V2.3

2-6

, CoDeSys

. POU . ,
, .
, ,
.
:

Counter "out" "in". Reset


0. "out" .
:
:
<_>.<_> <_>.<_ >.
POU, , , .
:
PROGRAM PLC_PRG
VAR
Inst : Counter;
END_VAR
IL:
CAL Inst.Reset(In : = FALSE)
LD Inst.out
ST ERG
ST:
Inst.Reset(In := FALSE);
Erg := Inst.out;
FBD:

SFC ( SFC).

CoDeSys V2.3

2-7

, CoDeSys

SFC .
CoDeSys.

, :

, .
(Library manager)

(Log)
(Alarm Configuration)

(PLC Configuration) .
(Task Configuration)
(Watch and Recipe Manager)

(Target Settings)
(Workspace)
:

(Sampling Trace) - .
(Parameter Manager) -
- (PLC-Browser) -
(Tools) ,
SoftMotion ( ),
CNC CAM

, POU,
. POU , .
"standard.lib" "util.lib" .
(. (Library manager))

,
. , .
(. (Data types))

.

.
, CoDeSys
HMI Web ( ) . (. CoDeSys (Visualizations))

2.2
CoDeSys :

CoDeSys V2.3

2-8

, CoDeSys

Instruction List (IL) -


Structured Text (ST)

Sequential Function Chart (SFC)


Function Block Diagram (FBD)
Ladder Diagram (LD) -

, CoDeSys , Continuous Function Chart (CFC) .

(IL)
IL (Instruction list) , , , .
, (:).
. .
:
LD
ST
GE
JMPC
LD
EQ
STN
next:

17
lint
(* *)
5
next
idword
istruct.sdword
test

IL
IL :
:

JMP, CAL, RET:

, .

JMPC,CALC, RETC:

,
.

IL :

LD

ST

AND

N, (

OR

N, (

XOR

N, (

ADD

SUB

MUL

CoDeSys V2.3

2-9

, CoDeSys

DTV

GT

>

GE

>=

QE

NE

<>

LE

<=

LT

<

JMP

CN

CAL

CN

RET

CN

POU .

.
IL :
LD TRUE
AND
JMPC
LDN
ST ERG

(* *)
BOOL1 (* BOOL1*)
mark
(* ,
" mark"*)
BOOL2 (* BOOL2 *)
(* ERG*)

, .
:
LD
MUL
ADD
ST

2
2
3
ERG

ERG 7. , :
LD
MUL
ADD
)
ST

2
( 2
3
ERG

ERG 10.
MUL , ")".
MUL 5.

(ST)
ST , ("IFTHENELSE") (WHILEDO).
:
IF value < 7 THEN
WHILE value < 8 DO
value:=value+1;
END_WHILE;
END_IF;

CoDeSys V2.3

2-10

, CoDeSys

, .
. , ,
.

.
, ..,
.
.
ST , .

()


( )

EXPT

NOT

MOD

< , > ,<=, >=

<>

AND

XOR

OR

ST:

A := B; CV := CV+1; C := SIN (X);


FB

A := CMD_TMR.Q

RETURN

RETURN;

CoDeSys V2.3

2-11

, CoDeSys

IF

D := B*B;
IF D<0.0 THEN
C := A;
ELSIF D = 0.0 THEN
C := B;
ELSE
C := D;
END_IF

CASE

CASE INT1 OF
1: BOOL1 := TRUE;
2: BOOL2 := TRUE;
ELSE
BOOL1 := FALSE;
BOOL2
END_CASE
J := 101;
FOR I :=1 TO 100 BY 2 DO
IF ARR [I] = 70 THEN
J := I;
EXIT;
END_IF
END_FOR

FOR

WHILE

EXIT

J: =1;
WHILE J<= 100 AND ARR [J] <> 70
DO
J: = J+2;
END_WHILE
J := -1;
REPEAT
J := J+2;
UNTIL J = 101 OR ARR [J] = 70
END_REPEAT
EXIT;

REPEART


( ), , .
:
Var1 := Var2 * 10;
Var1 , Var2.
ST

. IN PT. Q .
, IL, , , :
CMD_TMR (IN := %IX5, PT := 300);
A := CMD_TMR.Q

CoDeSys V2.3

2-12

, CoDeSys

RETURN
RETURN POU, , .
IF
IF, ,
- .
:
IF <Boolean_expression1> THEN
<IF_instructions>
{ELSIF <Boolean_expression2> THEN
<ELSIF_instructions1>
.
.
.ELSIF <Boolean_expression n> THEN
<ELSIF_instructions n-1>
ELSE
<ELSE_instructions>}
END_IF;
.
< <Boolean_expression1> , <IF_Instructions> .
, . ,
ELSIF ELSE.
, , ELSE.
:
IF temp < 17
THEN
heating_on := TRUE;
ELSE
heating_on := FALSE;
END_IF
(heating) , 17 ,
.

CoDeSys V2.3

2-13

, CoDeSys

CASE
C CASE .
:
CASE <Var1> OF
<Value1>:
<Instruction 1>
<Value2>: <Instruction 2>
<Value3, Value4, Value5>:
<Instruction 3>
<Value6 .. Value10>:
<Instruction 4>
...
<Value n>:
<Instruction n>
ELSE
<ELSE instruction>
END_CASE;
CASE :

<Var1> <Value i>, <Instruction i>

<Var1>
Instruction>.

<ELSE

<Var1>,
.
, , .
:
CASE INT1 OF
1, 5: BOOL1 := TRUE;
BOOL3 := FALSE;
2: OL2 := FALSE;
BOOL3 := TRUE;
10. 20: BOOL1:= TRUE;
BOOL3 := TRUE;
ELSE
BOOL1 := NOT BOOL1;
BOOL2 := BOOL1 OR BOOL2;
END_CASE
FOR
FOR .
:
INT_Var :INT;
FOR <INT_Var> := <INIT_VALUE> TO <END_VALUE> {BY <Step size>} DO
<Instructions>
END_FOR
, , .
<Instructions> , <INT_Var> <END_VALUE>. <Instructions>, <Instructions> ,
<INIT_VALUE> <END_VALUE>.

CoDeSys V2.3

2-14

, CoDeSys

, <Instructions>, <INIT_VALUE>, <Step_


size>.
<Step_ size> .
1.
:
FOR Counter: =1 TO 5 BY 1 DO
Var1 := Var1*2;
END_FOR;
Erg:=Var1;
, Var1 1.
32.
: <END_VALUE>: <INT_VAR>. ,
SINT <END_VALUE> 127,
.

WHILE
WHILE , FOR, ,
. , , .
:
WHILE <Boolean expression>
<Instructions>
END_WHILE
<Instructions> , <Boolean_expression> TRUE.
<Boolean_expression> FALSE , <Instructions> . <Boolean_expression> FALSE,
<Instructions> .
: , . . , .

:
WHILE counter<>0 DO
Var1 := Var1*2;
ounter := ounter-1;
END_WHILE
REPEAT
REPEAT WHILE , , 1 . ,
.
:
REPEAT
<Instructions>
UNTIL <Boolean expression>
END_REPEAT
<Instructions> , <Boolean_expression> TRUE.
<Boolean_expression> TRUE , <Instructions>

CoDeSys V2.3

2-15

, CoDeSys

. <Boolean_expression> TRUE,
<Instructions> .
: , . . , .

EXIT
EXIT FOR, WHILE, REPEAT, .

CoDeSys V2.3

2-16

, CoDeSys

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

SFC POU , . 2 :
( SFC) .
( ) , .
( SFC) . .

IL ST, FBD LD, SFC.


. , . / (Extras Zoom
Action/Transition). , .
,
POU. <Enter>.
(Project Add Action). 9 .

CoDeSys V2.3

2-17

, CoDeSys


.
, .
, , "" , "" .
. , .
:

/
.
, , . , , ST
(.. (i<= 100) AND b) .
, !
SFC
(. 0, / (Extras Zoom Action/Transition)). , !
: , ; . SFCtip
SFCtipmode.


SFC POU (, ) .
, , . , , . . ,
TRUE.
, .
, , , , .
: , , .


SFC ( ).
POU,
(Extras Associate action).
, .
, , , . : -

CoDeSys V2.3

2-18

, CoDeSys

, ; S () ..
<StepName>.x, , (. ).
, , , .
, , ,
.
:

, . .
: , . , (. ).

,
.
, "Extras"
"Use IEC-Steps" Iecsfc.lib.
SFC POUs, .
("Project" "Add Action").
SFC POU :

CoDeSys V2.3

SD

DS

2-19

, CoDeSys

,
SL

L, D, SD, DS, SL ( L T#5s)


TIME ( L t_var).
: . P!

SFC
SFC ,
, . .
iecsfc.lib ( SFCStepType SFCActionType), . SFC CoDeSys.
:
: <StepName>.x <StepName>._x.
<StepName>.x . <StepName>._x
. <StepName>.x=TRUE,
. <StepName>._x=TRUE <StepName>.x=FALSE,
. <StepName>._x
<StepName>.x .
<StepName>
_<StepName>. , , ,
.
: <ActionName>.x ,
. ( <ActionName>._x -
).
(TIME):
,
.
.
<StepName>.t (<StepName>.t
).
_time<stepname>.
, "_timeStep1: TIME;"

SFC. ,
. : boolvar1:=sfc1.step1.x; step1.x - , step1 POU sfc1.
SFC
SFC .
POU.
.

CoDeSys V2.3

2-20

, CoDeSys

: SFC POU , , (.
), , "SFCError" (SFCError
TRUE ).
-:
SFCEnableLimit: BOOL. ,
SFCError. .
SFCInit: BOOL. , Init SFC . Init , , . SFCInit , .
SFCReset: BOOL. SFCInit. Init. SFCReset Init.
: 2.3.7.0, SFCReset , , .

SFCQuitError: BOOL. SFC ,


. ,
SFCError .
SFCPause: BOOL. SFC , .
SFCError: ,
. , , SFCError .
: SFCErrorStep, SFCErrorPOU, SFCQuitError, SFCErrorAnalyzation.
SFCTrans: BOOL. , .
SFCErrorStep: STRING. , ( ).
SFCErrorPOU: STRING. ,
( ).
SFCCurrentStep: STRING. .
, SFC .
SFCErrorAnalyzationTable: ARRAY [0..n] OF ExpressionResult p . , FALSE , ,
, , .
16 (),
0 15.
ExpressionResult AnalyzationNew.lib. POU, SFC.
.
. SFCError (. ).

CoDeSys V2.3

2-21

, CoDeSys

SFCTip, SFCTipMode: BOOL


SFC. SFCTipMode=TRUE,
SFCTip, TRUE. SFCTip FALSE, ,
.
:
(. ).


SFC . .
. (
), ( )
(jump). , , , .
, , .

SFC .
.
.
( )
( ) (jump).
, , .
. , , , .
(Jump)
- , jump.
, .

(FBD)
FBD . ,
, ,
.
FBD CoDeSys:

FBD 0.

CoDeSys V2.3

2-22

, CoDeSys

(CFC)
FBD , , ,
.
CFC:

CFC 0.

(LD)
- () ,
.
LD ,
- FBD. , LD
POU.
LD .
- . , ,
.
,
"ON" "OFF", .
. ,
. ("OFF").
LD :

(. " CoDeSys")

"ON" "OFF".
.
. , .

CoDeSys V2.3

2-23

, CoDeSys

, "ON",
"ON".
, , "ON", , "ON". .
. |/|
"ON", .

(),
(). . .
(ON), (OFF).
(/).
( - %QX3.0). ( (/)), .
LD
, LD .
, .
SET RESET
SET RESET. SET "S" (S).
, ( R) .
RESET R. , ( S) .
LD FBD
, LD POU.
-, ,
. , LD.
POU , , , , EN. EN , POU , EN=. POU ,
EN . POU LD FBD
.
LD EN POU:

CoDeSys V2.3

2-24

, CoDeSys

2.3
(Sampling Trace)
(Sampling Trace) , , , . 20 . 500 .

CoDeSys ,
. (Debugging)
(Project Options) (Build).

, , . .
, FBD LD - SFC - .
: CoDeSys SP 32 Bit Full , .

CoDeSys V2.3

2-25

, CoDeSys

IL: CAL, LD or JMP.

ST: .

FBD, LD: .

SFC: .

.

(Single Cycle) .
.
,
( ) ( ).
. , , ,
(Write Variable).

CoDeSys
. , (watch and Recipe manager) .
.
, , . .
, :
anarray[1] = 5
anarray[i] = 1
, ( [i + j] [I*2]).
: , : " "(Too many monitoring
variables).

CoDeSys V2.3

2-26

, CoDeSys

, , CoDeSys. ,
, .
: .

(Log)
(Log) ,
, . .

CoDeSys V2.3

2-27

3
3.1
-. - , . , . , : . .
, 61131-3, CoDeSys
CoDeSys.
POU
: CoDeSys ("File" "New").
POU. PLC_PRG.
. POU, , - .
. POU
Continuous Function Chart (CFC).
. - ("Project" "Object Add") (
) . : Sequential Function Chart (SFC)
SEQUENCE, Function Block Diagram (FBD)
TRAFFICSIGNAL - WAIT,
(IL).
TRAFFICSIGNAL?
POU TRAFFICSIGNAL .
, - ,
- ..
WAIT?
WAIT ,
.
SEQUENCE?
SEQUENCE ,
.
PL_PRG?
PLC_PRG ,
' .
"TRAFFICSIGNAL"
POU TRAFFICSIGNAL. ( VAR_INPUT END_VAR) STATUS INT. STATUS
, - , , - .

TRAFFICSIGNAL ,
RED, YELLOW GREEN. TRAFFICSIGNAL
:
TRAFFICSIGNAL, :

"TRAFFICSIGNAL"
, STATUS .
POU (body). ( 1).
. ("Insert" "Box").
AND :

AND EQ.
STATUS. 1. :

EQ. EQ. ("Insert" "Assign").


??? GREEN. :

STATUS 1, GREEN. , GREEN , STATUS 1.


TRAFFICSIGNAL .
() ("Insert" "Network (after)"). POU :

CoDeSys V2.3

3-2

TRAFFICSIGNAL:

, ,
( ). ("Insert"
"Box").
POU . , TRAFFICSIGNAL , STATUS.
standard.lib
POU WAIT POU . , ("Window" "Library Manager"). ("Insert" "Additional library"). . standard.lib .
"WAIT"
POU WAIT. , POU , TRAFFICSIGNAL. POU
TIME TIME (Boolean) ,
OK. TRUE,
.

CoDeSys V2.3

3-3

FALSE (
) ":= FALSE ".
POU TP. (IN, PT) (Q, ET). TP
:
IN FALSE, ET 0 Q FALSE. IN TRUE,
ET . ET PT,
. Q TRUE, ET PT. ET
PT, Q FALSE.
POU .
TP POU WAIT, .
ZAB ( ) TP (
VAR, END_VAR).
WAIT :

"WAIT"
:

, Q TRUE (, ),
ZAB, ZAB - , .
IN ZAB FALSE ET 0 Q FALSE.
, . -

CoDeSys V2.3

3-4

TIME PT ZAB IN:=TRUE. ZAB


, TIME Q FALSE.
Q OK
WAIT. Q FALSE, OK TRUE.
.
TRAFFICSIGNAL PLC_PRG.

WAIT

"SEQUENCE" 1
. START BOOL, TRAFFICSIGNAL1 TRAFFICSIGNAL2 INT WAIT (DELAY
, ). SEQUENCE :
SEQUENCE 1, :

SFC
SFC "Init" "Trans0" Init, , .
, .
TRAFFICSIGNAL. , Trans0 - ()("Insert" "Step transition (after)").
.
. Init "START", "DELAY.OK".
, START TRUE, - DELAY
OK TRUE, .. .
( ) Switch1, Green2, Switch2, Green1, Init, ,
. "Switch" , Green1 TRAFFICSIGNAL1 ,

CoDeSys V2.3

3-5

Green2 TRAFFICSIGNAL2 . , Init Switch1.


, :
SEQUENCE 1, :

. , . IL ( ).

Init , START .
, . ,
TRAFFICSIGNAL1 TRAFFICSIGNAL2 5.
Init:

CoDeSys V2.3

3-6

Green1 TRAFFICSIGNAL1 (STATUS:=1), TRAFFICSIGNAL2


(STATUS:=3), 5000 .
Green1:

Switch1 TRAFFICSIGNAL1 2 () , , TRAFFICSIGNAL2


4 (-). , 2000 . :
Switch1:

Green2 TRAFFICSIGNAL1 (STATUS:=3) TRAFFICSIGNAL2


(STATUS:=1). 5000 .
Green2:

Switch2 STATUS TRAFFICSIGNAL1 4 (-), ,


TRAFFICSIGNAL2 2 (). 2000 .

CoDeSys V2.3

3-7

Switch2:

.
, :
POU PLC_PRG. PLC_PRG.
AND SEQUENCE. .
( - 'Project' 'Build')
. : "0 Errors, 0 Warnings".
(Online 'Simulation mode') '' (Online 'Login'). ''
(Online 'Run').
SEQUENCE. , ,
START TRUE. PLC_PRG, . . TRUE.
('' Online 'Write values'). . .
'' (Online 'Logout').
"SEQUENCE"
. .
,
TRAFFICSIGNAL .
COUNTER INT.
SEQUENCE.
Switch1 . . .
(jump) Init.
: "Count" "Off".
( ) EXIT, TRUE DELAY.OK.
, .

CoDeSys V2.3

3-8

"SEQUENCE", :

.
Count - COUNTER 1:
Count:

EXIT1 , 7:
EXIT:

Off 5 ( ), COUNTER
0 10 .

CoDeSys V2.3

3-9

Off:

TRAFFICSIGNAL. , .
, .
PLC_PRG
SEQUENCE.
. PLC_PRG. IN (2 ) SEQUENCE. Boolean
, IEC .
- LIGHT1 LIGHT2 TRAFFICSIGNAL .
LIGHT1 LIGHT2:

6 Boolean.
PLC_PRG, (Global Variables) (Resources). IN,
START SEQUENCE TRUE, .
(Resources) (Global
Variables).
:

PLC_PRG. .
(CFC), , , .

CoDeSys V2.3

3-10

(Box).
AND SEQUENCE. SEQUENCE
.
TRAFFICSIGNAL. TRAFFICSIGNAL - , , , ,
LIGHT1 LIGHT2.
Input, IN Output,
: L1_green, L1_yellow, L1_red, L2_green, L2_yellow, L2_red.
, .
/ ( ) / .
, .
PLC_PRG:

.
TRAFFICSIGNAL
.
,
CoDeSys.

3.2
.
8. ,
.

, (Visualizations) . - ('Project' 'Object
Add').
:

CoDeSys V2.3

3-11

, Lights. Ok,
, .

:
('Insert' 'Ellipse')
2 . ,
, .
.
.
(Variables) . (Change color)
.L1_red. (Input Assistant) ( <F2>). L1_red .

(Colors). (Color)
(Inside) , , .
(Inside) (Alarm Color)
.

, , , .
, .

CoDeSys V2.3

3-12

.
('Edit' 'Copy') (<Ctrl>+<C>)
('Edit' 'Paste') (<Ctrl>+<V>). .
. , . . .
(Change Color) (Variables) :
: .L1_yellow
: .L1_green
(Colors) (Alarm color) ( ).
.
(Insert Rectangle) , . (Extras Send to back),
. .
, Online
Simulation mode( , ).
(Online Login)
(Online Run) , .
.
.
, (Edit
Copy) (Edit Paste). , (, .L1_red .L2_red), .
ON.
, , .ON
. (Change Color) (Variables). (Content) (Text) ON.

CoDeSys V2.3

3-13

ON ,
(Toggle variable) (Input) .ON.
/ .
, . . (Change Color).

.
. (Colors)
(frame) . - Contents ( Text) Light1 Light2.
Traffic Signal:

CoDeSys V2.3

3-14

4 CoDeSys
4.1

CoDeSys:

CoDeSys ( ):

.
. .
, POU, (Data types),
(Visualizations) (Resources).
CoDeSys.
, .
.
, .

,
.

. CoDeSys.

CoDeSys

.
, .
,
.
CoDeSys.
.
(. ('Project' 'Options')
(Desktop))


CoDeSys.

POUs,

(Data types),

(Visualizations)
(Resources).
.
.
:

.
. CoDeSys : , POU, .
, .
. , , .
.
CoDeSys. , .
.
.
. , .

CoDeSys V2.3

4-2

CoDeSys

<Enter > , .
(Edit Next error) (Edit Previous error)
.
(Window Messages).

CoDeSys
.
.
, . .
,
: SIM , RUN , BP- , FORCE .
, (, Line:5, Col.:11). OV . <Ins> .
X Y,
. - , . (, ).
, .
(. ('Project' 'Options') - Desktop)

: <Shift>+<F10>
, . , , .

4.2
CoDeSys (Project Options)
. .
,
.
(Workspace) (Resources).
CoDeSys.ini
CoDeSys.
:

CoDeSys.ini

CoDeSys V2.3

4-3

CoDeSys

CoDeSys.ini

(Load & Save)

(User information)

(Editor)

(Desktop)

(Colors)

(Directories)

. Common

(Log)

. Project

(Build)

(Passwords)

(Source download)

(Symbol configuration) X
(Database-connection)

(Macros)

(Load&Save)
(Load&Save):

(Create Backup) CoDeSys .bak . .asd (. )


. .
(AutoSave) CoDeSys
.asd, . , (Auto Save Interval).
CoDeSys . - (, ), . :

CoDeSys V2.3

4-4

CoDeSys

" " (Open auto save file) .


, .asl.
(Auto save before compile) .
(Ask for project info), .
(Project Project info).
(Auto Load)
CoDeSys. , CoDeSys , .
(Remind of boot project on exit): , , : "
. ?" (No boot project created since last download. Exit anyway?).
ENI (Save ENI credentials):

(Login) ENI .
(User information)
(User information):

CoDeSys V2.3

4-5

CoDeSys

(Name) (Initials),
(Company). .
, .
(Editor).
(Editor):

(Autodeclaration):
.
(Autoformat): CoDeSys
IL . :
1. .
2. .
(List components):
(Intellisense). : , . . , .
Intellisense , , .
(Declarations as tables):
. , ,
- (in_out). :
(Name), (Address), (Type), (Initial) (Commment).
(Tab-Width) . 4 . .
(Font) . , CoDeSys.

CoDeSys V2.3

4-6

CoDeSys

(Mark) ,
. (Dotted line), , (Line), , (Filled) .
(Bitvalues) ( ) (BYTE, WODR DWORD): (Binary), (Hexadecimal) (Decimal).
(, , VAR_IN_OUT) - Suppress monitoring of complex types (Array, Pointer, VAR_IN_OUT): , , , VAR_IN_OUT .
POU (Show POU symbols): , .
bmp
. : TON TON.bmp.
:

CoDeSys V2.3

4-7

CoDeSys

(DeskTop)
(DeskTop):

(Tool bar) (
).
(Status bar) .
(Online in Security mode)
(Run), (Stop), (Reset), (Toggle Breakpoint), (Single cycle),
(Write values), (Force values). ,
,
.
(Query communication parameters before login):
(Online Login) .
OK.
(Do not save communication parameters in project):
( Online Communication Parameters) .
(Show print area margins): ,
.
F4 (F4 ignores warnings): F4 , .
MDI (MDI representation): MDI CoDeSys,
. SDI .
(Communications timeout [ms]): . , ,
. : 1-10000000 .

CoDeSys V2.3

4-8

CoDeSys

(Communications timeout for download [ms]): ( , , ): , , (Download Wait Time). :


1-10000000 .
XML (XML-Encoding): XML . "ISO
8859-1". ENI, Message Interface COM Automation Interface, CoDeSys XML. Licensing Manager.
(Language): , .
: Windows 98!

(Colors)
(Colors):

CoDeSys. (Line numbers), (Current position), (Breakpoint


positions), (Set breakpoint), (Reached Positions),
(Monitoring of Bool). :

-
-
-
. -
-
Bool

CoDeSys V2.3

4-9

CoDeSys

(Directories)
(Directories):

, (Libraries),
(Configurations files) (Visualisation files).
, (Compile files) (, map- list) , (Upload files).
, <>,
.
, ;.
: , .
. , ".\libs"
'C:\programs\projects\libs',

'C:\programs\projects'.
: , "_" .

CoDeSys V2.3

4-10

CoDeSys

, (Project),
. , (General), ini
CoDeSys .
(Target) , ( .TNF).
, ( ).
CoDeSys (Project),
(Target) (Common).
, , .
(Log)
(Log):

(*.log ), , CoDeSys .
(Activate logging) .
, .
, ,
(Directory for project logs) . , <>.
.log.
, , (Oline sessions).
.
, .
(Filter) , : , , . ,
, (.
).
(Window Log).

CoDeSys V2.3

4-11

CoDeSys

(Build)
(Build):

(Debugging) . (, ). .
. .
(Replace constant) ( , ) . . , .
,
(, , ).
(Nested comments) . :
(*
a := inst.out; (* *)
b := b+1;
*)
: .
, , , .

(Create binary file of application):


, ( ).
<_>.bin.
(Actions hide programs):
. : ,
, :
, , .
: , ,
. : ,
, , .

CoDeSys V2.3

4-12

CoDeSys

LREAL REAL (Treat LREAL as REAL):


REAL LREAL . , . .
(Number of Data segments) , .
.
(Out of global data memory...), .
(Exclude objects)
(Exclude objects from build). (POU), ,
Exclude. POU .
, (Exclude unused). , , ('Exclude from build') .
(Compiler Version): . V2.3.3 (, -, ) CoDeSys, , . , (Use latest), . . , , . , (Fix).
, , :

(Macro before compile):


(Macro after compile):

, : - (file new),
- (file open), - (file close), (file save as),
- (file exit), , (project compile), - (project check), - (project build).
(Check automatically)
:

(Unused variables)
(Overlapping memory areas)
(Concurrent access)
(Multiple write access on output)

.
('Check') ('Project').
, .
, , .

CoDeSys V2.3

4-13

CoDeSys

(Passwords).
(Passwords):


.
(Password).
(Confirm Password).
Ok. "The password does not agree with the confirmation"(
), , , .
.
, , . , .
"The password is not correct"( ).
.
(Write Protection Password) .
, , . ,
CoDeSys , Cancel. , , , .
.

.
(. (File Save as)). ,
.

CoDeSys V2.3

4-14

CoDeSys

(Source download)
(Source Download):

(Extent) ,
.
(Sourcecode only) .
(All files), , , , ..
(Timing) . (Inplicit at load) "" "" ("Online" "Download"). " " (Notice at load) . "
" (Only on demand) ,
"" " " ("Online" "Sourcecode download").
, , , "" "" " " ("File" "Open" "Open project from PLC").
.
(Symbol Configuration).
( *.sym
*.sdb). , OPC DDE .
" " (Dumb symbol entries),
.
" XML " (Dump XML symbol table), XML , . < >.SYM_XML.
: (target settings)
" INI-" (Symbol config from INI file),
CoDeSys.ini , INI

CoDeSys V2.3

4-15

CoDeSys

CoDeSys.ini , INI
( " " (Configure symbol file) ).
" INI-" (Symbol config from INI file) ,
(Set object attribute),
" " (Configure symbol file).
" " (Set object attributes):

, .
POU ( )
. . :
(Export variables of object): POU . , .
(Export data entries):
.
(Export structure components): .
(Export array entries): .
(Write Access): OPC
.
POU, . , .

CoDeSys V2.3

4-16

CoDeSys

(Database-connection)
(Database-connection):

ENI .
(ENI) (Use source control (ENI)): ,
ENI. ENI . ENI Server .
.
. 'ENI'.
( (Check
in), (Get last version) ..) .
, . ('Project' 'Data Base Link')
. (Database-connection) (Properties), .
(Automatically place new Objects in the following project data base):
: (
('Project' 'Object' 'Add')), .
('Project' 'Object' 'Properties') .
:
(Project): POU , ENI configuration/Project
(Shared Objects): POU , ENI configuration/Shared

CoDeSys V2.3

4-17

CoDeSys

(Local): POU
ENI.
(Project) (Shared Objects), 'Compile files', , .
.
(Ask for type of new objects):
'' '' ('Object' 'Properties') . , .
ENI (configure ENI) ENI:
, ENI, c : (Project), (Shared Objects) 'Compile
files'. () .
( Next Wizard). ,
. ,
Login .
(Macros).
(Macros):

(), CoDeSys.
(Edit Macros).
:

CoDeSys V2.3

1.

(Name).
(New) (Macro list). .
. (. ) , .

2.

(Menu) ,
(Edit Macros). -

4-18

CoDeSys

. &. :
Ma&cro 1, Macro 1.
3. (Commands) , .
CoDeSys. , (Help) . <Ctrl><Enter>. ( )
.
4.

1-3 OK.

, <Del>. ,
(Rename).
(Edit Macros) , .
(Edit Macros).
:
.
: (Create).
(Merge project) . OK. (Save Macro library) (Save). <library name>.mac.
: (Include).
- (Open Macrolibrary), *.mac
(Open). .
: (' ' ' ' - 'Project' ' Export' ).

4.3
(File) (Project).
.
(File New)
Untitled. .
(File New from template)
. Untitled.
(File Open)
. -
, CoDeSys ,
.
( .pro)
( .lib). , (Open)
.

CoDeSys V2.3

4-19

CoDeSys

(PLC), . , (Communication parameters)


. ,
CoDeSys , , .
, (Load project from PLC),
, .
( ,
(Online - Sourcecode download).
. (Create Boot project)!)
: , , ,
. Untitled .
: , ' ' (Title )
(Project info)
.
, .

, .
CoDeSys:

ENI
. ENI, (Project objects) ENI .
(TCP/IP-, , , ,
) ( - Project name), . (Next). , , (Shared Objects).
(Finish), CoDeSys. , .
codesys.ini , -
ENI (Save ENI credentials).

(File) (Exit).
, CoDeSys
.

CoDeSys V2.3

4-20

CoDeSys

(File Close)
. , CoDeSys , .
Untitled, (File Save as).
(File Save)
: <Ctrl>+<S>
. Untitled,
(File Save as).
(File Save as)
. .
. .
(Save as):

1.5 (Project Version 1.5 (*.pro)), 2.0


(Project Version 2.0 (*.pro)), 2.1 (Project Version 2.1 (*.pro))
2.2 (Project Version 2.2 (*.pro)). , 2.3,
. CoDeSys 1.5, 2.0, 2.1
2.2.
, . POU CoDeSys, Internal library
(*.lib).
, , (External library) (*.lib). , , , .h. , POU,
. POU, CoDeSys.
, .
,
CoDeSys (Encrypted CoDeSys Projekt) (*.pro),
(Encrypted internal library) (*.lib), (Encrypted external library) (*.lib).

CoDeSys V2.3

4-21

CoDeSys

(Encryption), . .
:

. CoDeSys , .
, .
(Save as).
.
:

:

(Edit Licensing Information), (Edit license info...).
. ' CoDeSys'.
OK. ,
CoDeSys , .
. ,
,
.
/ (File Save/Mail Archive )
. , CoDeSys, zip . . , .

CoDeSys V2.3

4-22

CoDeSys

, .
, , , .
, , (Details).
, :

(Select All)
(Select None) . .
(Save).
" " (Save archive),
, .
, ,
, :
(Project File)

CoDeSys V2.3

< >.pro ( CoDeSys)

4-23

CoDeSys

(Referenced Libraries)
(Symbol Files)
(Compile
Information)

*.lib, *.obj, *.hex ( hex-)


*.sdb, *.sym (, )

*.ci (, )
*.ri ( )
<temp>.*( )

(Log
File)
INI File

*.log ( )

(Configuration files)

(Target
Files)

(Registry Entries)

, PLC (

CoDeSys.ini
, , .): *.cfg, *.con, *.eds, *.dib,*.
*.tgr ( )
*.txt ( )
Registry.reg ( , CoDeSys, Gateway PS).
:
HKEY_LOCAL_MACHINE\SOFTWARE\3S-Smart Software Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\AutomationAlliance

(Bitmap Files)

(Local Gateway)

*.bmp ( POU )
Gateway.exe, GatewayDDE.exe, GClient.dll,
GDrvBase.dll, GDrvStd.dll, GHandle.dll, GSymbol.dll,
GUtil.dll, DLL Gateway.


(Language Files)

, (*.vis, *.xml)

, (Other
Files). (Other files), :

(Add) , .
.
, . ,
(Remove). Ok,
.

CoDeSys V2.3

4-24

CoDeSys

, (Comment). , .
OK, readme.txt. , CoDeSys.
, :
(Save) .
, . < >.zip. , .
(Mail) .
, MAPI (Messaging Application
Programming Interface). . , ,
(Save) , E-mail,
, . , .

(Cancel) , .

: zip
!

(File Print)
:<Ctrl>+<P>
. . , OK.
. .
:

. (Printer Setup), . ,
. , .
(Project
Document). ,
Extras Make docuframe file .

CoDeSys V2.3

4-25

CoDeSys

(File Printer setup)


.
:

(File) .dfr, . DEFAULT.DFR.


, (Browse).
, (
(new page for each object)) (
(new page for each subobject)). (Printer Setup) .
(Edit), , . , , POU, .
:

(Insert Placeholder) 5
: (Page), POU (POU name), (File name), (Date) (Content) .
:

CoDeSys V2.3

(Page)
POU
(POU name)

{Page}

{POU name}

POU

4-26

CoDeSys


(File name)
(Date)

(Contents)

{File name}

{Date}

{Contents}

POU

C (Insert Bitmap) , . , . . (. ).
, CoDeSys ,
.
: (Show print area margins)
(Desktop) . ,
.

(File Exit)
: <Alt>+<F4>
CoDeSys. ,
, ( File Save).
(Project Build)
: <F11>
. POU, .
*.ci, . ,
(Project Clean all).
, , POU, , .
(Project-Build),
(Online-Download), (Online-Login)
Online-Login.
, (Online
Login) . , . .
(<F1>).

CoDeSys V2.3

4-27

CoDeSys

(Auto save before compile) (Load & Save), .


, (Object Organizer),
.
(Exclude from build), .
('Exclude objects')
(. 4.2 , ).
:
. , (Show Call
Tree ), (Show Cross Reference ), (Unused Variables),
(Overlapping memory areas), (Concurrent Access), (Multiple Write Access on output)
('Project' 'Check'), .

(Project Rebuild all)


(Project Build)
, . , ,
(Clean All).
. 4.2 ( ,
(Build)).
(Project-Build),
(Online-Download), (Online-Login)
Online-Login.

CoDeSys V2.3

4-28

CoDeSys

(Project Clean all)


. , ,
. .
:
, *.ri, . *.ri (Load Download-Information).

(Project Load Download-Information)


,
, . .
<project
name><target identifier>.ri . ,
,
. , , , POU
. , ,
POU.
(Project Clean all) *.ri
. (Project Load Download-Information),
.
(Project Translate into another language)
.
, CoDeSys
.
:

(Create translation file)


(Translate project)
(View translated project)

. : ' '
(Create translation file)
:

CoDeSys V2.3

4-29

CoDeSys

(Translation file) .
.tlt. *.txt EXCEL WORD, .
,
(Search).
: (Names), , POU,
(Identifiers), (Strings), (Comments),
(Visualization texts). , (Position
information) .
, . , , ,
.
:
Text Tooltip-Text.
:
*.tlt *.txt CoDeSys CoDeSys HMI. Target Web . *.vis .
(Extras Settings..)
. .
(Translate into another language) .
( Text Tooltip-Text) , # (,
#text#). . (.
).
(Position information) .
, POU , .
3 :
(None)

(First)

(All)

, , ,
.
: (All), 64- .

(Overwrite existing): .
(Target languages) ,
.
(Exclude) (Exclude libraries).
, , . ,
(Included libraries), ,
(Add). (Excluded libraries). ,
(Remove). Ok , .

CoDeSys V2.3

4-30

CoDeSys

(Add) (Add target Language).


:

. . Ok,
.
(Remove) .
OK.
,
. . ? No , Yes. Backup_of_<translation file>.xlt.
:

##TODO.

, ,
.
.
.
##. ##TODO . , ##NAME_ITEM,
##END_NAME_ITEM ( ##COMMENT_ITEM ..).
, POU ST_Visualisierung.
(English) (French) . .
:
##NAME_ITEM
[D:\CoDeSys\projects\Bspdt_22.pro::ST_Visualisierung::0]
ST_Visualisierung
##English :: ##TODO
##French :: ##TODO
##END_NAME_ITEM

CoDeSys V2.3

4-31

CoDeSys

:
##NAME_ITEM
[D:\CoDeSys\projects\Bspdt_22.pro::ST_Visualisierung::0]
ST_Visualisierung
##English :: ST_Visualization
##French :: ST_Visu
##END_NAME_ITEM
##TODO .
, .
: . .
.
: Language, Flag, , (,
) .

(Translate project)
,
(Translation file).
:

: ,
, .. .

(Target language) , , .
, OK. ,
, . , , .
(Cancel) .
, OK
: , , , . : [C:\Programs\CoDeSys\projects\visu.tlt (78)]; Translation text expected.
(Show project translated)
, , . (
(Translate Project) !)

CoDeSys V2.3

4-32

CoDeSys

(Translation file). , (Search).


(Target language) . "<Native language>"
. OK.
!
(Toggle translation).
(Switch translation)
(. 'View translated project'),
. (Toggle translation) ('Project' 'Translate').

(Project Document)
,
:

POU

: , , ,
PLC, , .
POU.
.

, .

CoDeSys V2.3

4-33

CoDeSys

, .
, . , . , , . , ,
. . <Shift>, , <Ctrl> - .
, OK.
. (File Printer setup) .
(Project Export)
CoDeSys .
.
IL, ST SFC (Common Elements format ).
POU LD FBD CoDeSys ,
. ASCII .
POU, , .
( ).
: POU FBD LD , (), .
, (Project Document). One file for each object , . Ok,
. ,
. < .exp>.
.

CoDeSys V2.3

4-34

CoDeSys

(Project Import)
.
. , , , , : Do
you want to replace it?( ?). Yes,
, . No,
("_0", "_1", ..). Yes, all No, all .
, . ,
, . , , , *
(, standart.lib*30.3.99 11:20:14). ,
: Cannot find library {<path>\}<name> <date> <time>( { \ \ \ }).
(Project Siemens Import)
POU Siemens-STEP5
STEP7.
.
(Project Compare)
.
:
:

,
,
Compare.
COMPARE.
. ( ST IL) ( FBD LD) /POU ( CFC SFC).

,
. POU, , . POU . ,
, ,
(, ) . , , .
, !
:
(Project Compare)
(Project Comparison).

CoDeSys V2.3

4-35

CoDeSys

(Project to be compared).

, .
, .
ENI ,
, .
ENI- (Compare with ENI-Project).
:
(Ignore whitespaces)
(Ignore comments)
(Ignore properties)
(Compare differences): , POU
,
( ). , , - (/,
). , .
:
0005 ( ).
( , )

OK.

CoDeSys V2.3

4-36

CoDeSys

1. :
:
Project comparison < > - < >.
, - . . POU, , , :
: ; .
: ;
.
: ; .
: .
POU (Properties changed),
. (Access right changed) ,
.
2. POU
POU, ,
POU. POU . -
( , ST,IL), (FBD, LD) (CFC, SFC).
, .

CoDeSys V2.3

4-37

CoDeSys

POU :

.., , .
.

, POU,
Extras :

(Next difference)

<F7>


(Previous difference)

<Shift><F7>


(Accept change)

<Space>


(Accept properties)

(Accept access right)


,
(, ),
,
.
. ,

.


.
( ):
.

: , .

CoDeSys V2.3

4-38

CoDeSys

(Project Merge)
. .
, .
(Project Document).
,
_1 _2 ..
(Project Project info)
. , .
:

(File name)
(Directory)
(Change date)

. :

(Title)
(Author)
(Version)
(Description)

.
(Statistics), .
POU, , .

CoDeSys V2.3

4-39

CoDeSys

(License info) , CoDeSys-


, ('File' 'Save as...'). (. CoDeSys').
(Ask for project info)
(Load & Save) ,
.
(Project Global Search)
POU, .
(.
Project Document).
.

(Global Search) .
. , ,
.
, .
,
(Edit Search).
(Message window), . , ,
.
:

CoDeSys V2.3


: (Decl) (Impl).
.
.

4-40

CoDeSys

, POU , . <F4> <Shift>+<F4>,


.
(Project Global replace)
POU, .
(Project Global
Search) (Edit Replace). , , .
.
(Project Check)
.
, .
. .
:

(Unused Variables)
(Overlapping memory areas)
(Concurrent Access)
(Multiple writes to output)

.
: .

(Unused Variables)
, , . POU ,
. : PLC_PRG(4) var1. , , .
(Overlapping memory areas)
, , AT. , var1 AT %QB21: INT var2 AT %QD5: DWORD ,
21- .
:
%QB21 is referenced by the following variables:
PLC_PRG (3): var1 AT %QB21
PLC_PRG (7): var2 AT %QD5
(Concurrent Access)
, ,
. :
%MB28 is referenced in the following tasks :

CoDeSys V2.3

4-41

CoDeSys

Task1 PLC_PRG (6): %MB28 [read-only access]


Task2 POU1.ACTION (1) %MB28 [write access]
(Multiple writes to output)
, . :
%QB24 is written to at the following locations:
PLC_PRG (3): %QB24
PLC_PRG.POU1 (8): %QB24

CoDeSys .
. . .
0 7. 0 , ..
.
. 0 , 0- .
0 , .
.
:

(User group) , ,
(Password). , :
"The password is not correct."( )
, .
(Passwords for user
group),
(Object properties Access rights).
(Project Passwords for user group)
. 0.
:

(User group)
(Password). *.

CoDeSys V2.3

4-42

CoDeSys

(Confirm password) . OK "The password does not agree with the confirmation",
, . .
, .
: , !

(Project Database)
,
(ENI) (Use source control (ENI)) (Data base-connection).
ENI:
1.

(Login) - ENI


(Data Base Login) ( , ),
:
2.
3.
4.
5.
6.
7.
8.

(Define)
(Get Latest Version)
(Check Out)
(Check In)
(Undo Check Out)
(Show differences)
(Show Version History)

, (Database Login)
.
(Data Base Login) (Project) ,
, :
9.
10.
11.
12.
13.
14.
15.
16.
17.

CoDeSys V2.3

(Multiple Define)
(Get All Latest Versions)
(Multiple Check Out)
(Multiple Check In)
(Undo Multiple Check Out)
(Project Version History)
(Label Version)
(Add Shared Objects)
(Refresh Status)

4-43

CoDeSys

:

:
.
x :
.
<R> :
.
:
( - Task configuration, - Sampling Trace, - PLC
Configuration,
- Target Settings, - Watch- and Recipe
Manager) <R> ,
.

,
(Check out) .

(Login)
'Login', ENI . . ENI (ENI Admin, User Management).

CoDeSys V2.3

4-44

CoDeSys

(Login):

(Project objects) :
(Host): ENI Server ( 'TCP/IP ' - 'Database connection').
(Project): ( (Project name)
/ - 'Database connection' / 'Project Objects').
(Credentials):
(User name) (Password).
Use as default,
.
OK .
(Shared objects). OK. (Compile files).
(Login) ,
.
: , ENI (Save ENI credentials) , (Load
& Save ).

(Define)
: ('Project' 'Project Database' 'Define').
, .
'Project' ( ) 'Shared objects' ( ) 'Local' ( ).
( )
.
(Get Latest Version)
: ('Project' 'Project Database' 'Get Latest Version')
, . (Check Out), .

CoDeSys V2.3

4-45

CoDeSys

(Check Out)
: ('Project' 'Project Database' 'Check Out')
.
'Check out object'. , . <Ctrl>+<Enter>.
,
, .
.
, .
(Check In)
: ('Project' 'Project Database' 'Check In')
. ,
.
'Check in object'. , . <Ctrl>+<Enter>.
.
(Undo Check Out)
: ('Project' 'Project Database'
'Undo Check Out ')
. . ( ) .
(Show Differences)
: ('Project' 'Project Database' 'Show
Differences')
() ,
. CoDeSys , , (. ('Project' 'Compare')).
(Show Version History)
: ('Project' 'Project Database' 'Show Version History')
, . , , :

CoDeSys V2.3

4-46

CoDeSys

:
Version: . . (label) ,
.
User: ,
Date:
Action: . : 'created' ( ),
'checked in' ( , ) 'labeled with <label>' (
).
:
Close: .
Display: CoDeSys. : "ENI: <
>/< >
Details: 'Details of Version History':
File ( ), Version (. ), Date (. ), User (. ), Comment (, ). Next Previous
'Version history of ..'.
Get latest version: CoDeSys .
Show Differences: ,
() . , .
, .
Reset version: (). , , ! .
Labels only: , .
Selection box 'Labels only': ,
. 'All'.

CoDeSys V2.3

4-47

CoDeSys

(Multiple Define)
: ('Project' 'Project Database'
'Multiple Define')
(Define) (Object Properties) . ENI (ENI-Selection), POU. ,
. POU OK.
(Get All Latest Versions)
: ('Project' 'Project Database' 'Get All Latest Versions ')
.
:
,
CoDeSys.
,
,
.
(Multiple Check Out)
: ('Project' 'Project Database' '
Multiple Check Out')
.
ENI (ENI-Selection) OK. .
(Check Out).
(Multiple Check In)
: ('Project' 'Project Database'
'Multiple Check In')
.
ENI (ENI-Selection) OK. . (Check In).
(Undo Multiple Check Out)
: ('Project' 'Project
Database' ' Undo Multiple Check Out')
.
ENI (ENI-Selection) OK. . (Undo Check Out).
(Project Version History)
: ('Project' 'Project
Database' ' Project Version History')
,
.
' <data base project name>'. (, , ) .
(Version history).

CoDeSys V2.3

4-48

CoDeSys

(Show Version History). :


1) ' ' (Reset Version) .
2) (Get latest version) , ! , CoDeSys
. : , ,
! , ,
, .
(Label Version)
: ('Project' 'Project Database' 'Label
Version')
"" (label) ,
. ' <data base project name>'
(Label) (, "Release Version") , , Comment.
OK. . .
(Version).
(Labels only)
.
(Label project <data base project name>)

(Add Shared Objects)


: ('Project' 'Project
Database' 'Add Shared Objects ')
(Shared Objects)
. (Project Objects) , () ( ) (Get (all) latest version(s))
, .
(Shared Objects) , .
(Add Shared Objects)
ENI (Browse ENI). OK .

CoDeSys V2.3

4-49

CoDeSys

' ENI (Browse ENI)

(Refresh Status)
: ('Project' 'Project Database' 'Refresh Status')
,
.

4.4
.

, (POU),
, (visualizations), (global) (variable configuration), (Sampling trace), (PLC
configuration), (Task Configuration) (Watch and Recipe
Manager). .
.
POU ,
(, ).
(VAR_GLOBAL VAR_CONFIG).
(drug&drop). , (, Object_1).

POU, ,
. .
,
.
, "" "" . (Expand node)
(Collapse node). (New Folder).
: , .

CoDeSys V2.3

4-50

CoDeSys

(New Folder)
.
, . . , ,
.
, ,
, <Shift>+<F10> .
(New Folder). :

.
.
, - .

(New Folder) , , 1 (New Folder 1).


, .
(Expand node) (Collapse node)
(Expand node) .
(Collapse node) . .
, ,
, <Shift>+<F10> .
(Project Object Delete)
: <Delete>
. . ('Edit' 'Undo').
, .
(Edit Cut) .
(Project Object Add)
:<Insert>
.
. (Global Variables), (Data
types), (Function), (Function Block) (Program)
, . (Save as template).

CoDeSys V2.3

4-51

CoDeSys

POU POU (Name of the new POU) . , .


:


POU POU, .
POU .


POU.
, POU .

. , , , POU, . ,
POU.
POU POU (,
) , POU . POU POU (Type of the POU), (Language of the POU).
POU , (Return Type).
(, , ).
(Input assistance), <F2>.
POU:

POU , OK , ,
. .
(Edit Insert) . ,
(, Righ_1).
ENI, , ( (Database-connection)), , . .
(Properties) .
(Save as template)
(Global Variables), (Data types),
(Function), (Function Block) (Program)
. (Save as template) ( ).
. .

CoDeSys V2.3

4-52

CoDeSys

(Project Object Rename)


: <>
. . , .
POU

(Project Object Convert)


POU. POU IL, FBD LD.
.
POU . , . OK,
POU POU.
, .
POU.

: .
: POU, FBD, LD (.
('Extras' 'View')).

(Project Object Copy)


.
POU . , .
(Edit Copy),
.
POU

CoDeSys V2.3

4-53

CoDeSys

(Project Object Open)


: <Enter>
POU .
, ( ).
:

.
. ,
, . (Open). .

- (Project Object Properties)


(Properties), . :
Global variable list. , , . .
(Add Object), (Global Variables) .
(Visualizations) (. CoDeSys).

CoDeSys V2.3

4-54

CoDeSys

(Use as): Web visualization Target visualization


(Target Settings), Web
Target .
(Used as): , (Master layouts):

(Visualization): .

(Visualization without Master layout):


, .

(Master layout): .
,
(as background).

ENI (. 'Project' 'Options' 'Database-connection'), 'Database-connection'.


'Local'. ( . ENI?).
(Project Object properties Access
rights)

. :

0.
:

(No Access): .
(Read Access): .
(Full Access): .

, Apply to all
, POU, , .
0.
.

CoDeSys V2.3

4-55

CoDeSys

(Project Add Action)


, .
, .
.
"". ,
"" "" .
(Expand node) (Collapse node).
(Project View Instance)
.
. , (Implementation).
OK.
: . (
.)

(Project Show Call Tree)


, . .
POU .
:

CoDeSys V2.3

4-56

CoDeSys

(Project Show Cross Reference)


, , (POU, )
. .
, "Not
up to date". ,
.
Variable(), Address() POU Name
. *. Name.
:

Get References, , .
POU, , ,
, . Scope , ; Access .
Go To ,
, . .
, Send to message window, .

4.5
CoDeSys, . Edit
.
, CoDeSys
. , <Ctrl> .
(Edit Undo)
:<Ctrl>+<Z>

CoDeSys V2.3

4-57

CoDeSys

, . , , . , POU, , , .
(Edit Redo) .
: (Undo) (Redo) .
. - ,
. , .

(Edit Redo)
:<Ctrl>+<Y>
.
: (Undo) (Redo) .
. - ,
. , .

(Edit Cut)
:

: <Ctrl>+<X> <Shift>+<Delete>

. .
,
, , (PLC Configuration).
, .
.
IL ST, .
FBD LD , .
SFC .
, (Edit
Paste). SFC () (Extras Paste parallel branch (right))
(Extras Paste after).
,
(Edit Copy).
(Edit Delete) .

(Edit Copy)
:

: <Ctrl>+<C>

, .

CoDeSys V2.3

4-58

CoDeSys

,
, , (PLC Configuration).
, .
,
(Edit Cut).
(Edit Paste)
:

: <Ctrl>+<V>

, . , .
, .
, . .
FBD LD , (Edit Paste) .
SFC
, ( ).
(Edit Delete)
: <Del>
, .
, , , (PLC Configuration).
, . , (Edit Cut).
.
(Edit Find)
:
.
. , Cancel.
.
, (Match whole word only) , (Up) (Down).
(Find next) .
. , . , , .

CoDeSys V2.3

4-59

CoDeSys

, .
CFC .
. , FBD
!

(Edit Find next)


:

: <F3>

, .
(Edit Replace)
.
.
.
. .

(Edit Input Assistant)


: <F2>
: , .
, OK. .
: .

, , , .. , (, , , POU ..).

CoDeSys V2.3

4-60

CoDeSys

With arguments, . , pr1, var_in.


: pr1(var1_in:=);
func1 var1 var2
: func1(var1,var2).
.
Structured Display.

POU, .
O.
, .
(, (Watch and Recipe Manager)) ,

CoDeSys V2.3

4-61

CoDeSys

, POU,
. ,
, , , , , , . ,
. , , Standard.
, , (Global Variables)
(Local Variables) . ,
.
, With arguments. IL ST .
,
Inst(IN:=,PT:=)

Inst TON. :

With arguments , . .
,

enumerations .
. :
, , , POU.
(
, . ),
.

CoDeSys V2.3

4-62

CoDeSys

(Watch and Recipe Manager) , .


<Shift>, , <Ctrl> - .
, (, POU), . , .
(Watch and Recipe Manager) , . , O.
(Watch and Recipe Manager) . , .
20,
A maximum of 20 variables is allowed 20 .
: (, ) .

(Edit Auto Declare)


: <Shift>+<F2>
.
, ('Project' 'Options' 'Editor' 'Autodeclaration').
(Edit Next error)
: <F4>
, .
, .
.
(Edit Previous error)
: <Shift>+<<F4>
, .
, .
.
(Edit Macros)
(. - 'Project' 'Options' 'Macros'). Process Macro, . Cancel, . .
: "<Macro>: Execution interrupted by user.
,
, .

CoDeSys V2.3

4-63

CoDeSys

4.6
. .
, .
(Online Login)
:

: <Alt>+<F8>

CoDeSys ( ) .
, (
(Project Build)). , CoDeSys .
, CoDeSys, , (Project Clean All), (Login) The program has been modified!
Should the new program be loaded? ( . ?)
, . ,
. .
(Login)

(Desktop) (Online in security mode) ,


(Details).
, , .
: .

CoDeSys V2.3

4-64

CoDeSys

:
, (Project
Clean All) (. ). ,
, Retain .
'' '' ('Online'
'Download').

. .
(Online Logout) .
:
"The selected controller profile does not match that of the target system..." ( .)
(Target settings) ( - Resources)
(Communications parameters) ''.
"Communication error. Log-out has occurred" ( . ).
, , ''
' ' ('Online' 'Communications parameters'), (
(baud rate)). Gateway , .
The program has been modified! Should the new program be loaded? ( . ?)
, CoDeSys, , .
. , .
, .
The program has been changed. Load changes? ( CHANGE) ( . ?)".
. , . ,
. ,
Load all.
(Login) (Build)
(Download) (Online Change)
Download (), Build ()
Online Change ( ), .
:
Source

CoDeSys ( *.pro, PC)

Compile
, ( *.ci, PC)
Download

( *.ri, , PC)

PLC

, ( *.prg-file, )

CoDeSys V2.3

4-65

CoDeSys

(Online change):
( ), .
:
(Online Change)
, .
( <projectname><targetidentifier>.ri), , (, '' ' ' - 'Project'
'Clean all'), Online Change . ri-
, '' '
' ('Project' 'Load download information').
. !
Retain (. '' '' - 'Online' 'Download').

CoDeSys V2.3

4-66

CoDeSys

:
, proj.pro PLC1 PLC2 ( )
. :
(1) PLC1 :
1. CoDeSys PLC1 (. / - Online/Communication
parameters) proj.pro (/, Online/Login, Download).
proj00000001.ri, .
2. proj00000001.ri, proj00000001_PLC1.ri.
proj.pro .
3. PLC1 ('' '' - 'Online' 'Run',
'' '' - 'Online' 'Logout').
(2) PLC2 :
1. CoDeSys PLC2 ( ) proj.pro. proj00000001.ri, .
2. proj00000001.ri, proj00000001_PLC2.ri.
3. PLC2 ('' '' - 'Online' 'Run',
'' '' - 'Online' 'Logout').
(3) CoDeSys:
proj.pro CoDeSys, .
(4) PLC1, PLC1:
1. PLC2, proj00000001.ri .
, proj00000001_PLC1.ri.
2 :
(a) proj00000001_PLC1.ri proj00000001.ri.
PLC1 , Change.
(b) proj00000001_PLC1.ri '' ' ' ('Project' 'Load Download Information'). .
(5) PLC2, PLC2:
, proj00000001_PLC2.ri (3)
(4).
(Online Logout)
:

: <Ctrl>+<F8>

, , . .
, Online Login.

CoDeSys V2.3

4-67

CoDeSys

(Online Download)
.
< >0000000ar.ri, , ( ).
(Project Clean all).
*.ri
.
persistent .
(Online Run)
:

: <F5>

.
, (Online Stop),
(Online
Single Cycle).
(Online Stop)
:

:<Shift>+<F8>

.
.
, (Online
Run).
(Online Reset)
. , VAR RETAIN. , ( VAR PERSISTENT).
(, 0 ).
, .
. .
'' ' ()' - 'Online' 'Reset (original)' '' ' ()' - 'Online'
'Reset (cold)'.
(Online Run).
'' ' ()' - 'Online' 'Reset (cold)'
. , (Online Reset),
RETAIN.
(Online Run).
'' ' ()' - 'Online' 'Reset (original)'
. . PERSISTENT
. , ,
.

CoDeSys V2.3

4-68

CoDeSys

: (Reset) . . .

(Online Toggle Breakpoint)


:

<F9>

.
, .
, , .
IL ST , . , - .
, .
FBD LD .
, .
SFC . , <Shift>.
, , .
, . , '' ''
('Online' 'Run'), '' ' ' ('Online' 'Step in'), '' ' '
('Online' 'Step Over').
' ' ('Breakpoint Dialog').
(Online Breakpoint Dialog)
.
.
, POU POU
(Location). (Add),
.
.
(Delete).
(Delete All) .
:
(Go to).
(Online Toggle Breakpoint).

CoDeSys V2.3

4-69

CoDeSys

(Breakpoints)

(Online Step over)


:

<F10>

. POU,
POU .
POU ( POU), (Online Step in).
POU,
.
(Step over) SFC .
(Online Step in)
<F8>
. POU
.
, .
,
(Online Step over).
(Online Single Cycle)
: <Ctrl> +<F5>

.
.
, (Online Run).
(Online Write values)
: <Ctrl> +<F7>

( , - Online Force values).

CoDeSys V2.3

4-70

CoDeSys

, .
, .
,
. : <Enter>.
Write variable <x>, .

,
. .

, a = 0<:=34>
: FBD LD, .

.
, .
/ - Online
Write/Force dialog(. ).
, (Writelist), ,
(Forcelist), (Force values).
(Write Values) :

Editing the writelist and the forcelist.

Writelist , Writelist ( (Force values) Forcelist, Writelist ).


: SFC , , , (Write values),
, . , : "a AND b" TRUE,

TRUE.
FBD, , , , ,
. (Write Values)
.
(Online Force values)
: <F7>

CoDeSys V2.3

4-71

CoDeSys

. :1. . 2. . 3. . 4. . 5. .
, (Online Release force).
Writelist, (.
- Online Write values). Writelist , .
(Force values) Writelist Forcelist. Writelist , . Forcelist .
: Forcelist (Force values) Writelist.


(Editing the writelist and the
forcelist).

: SFC , , , (Write values),


, .

FBD, , , ,
. (Write values)
.
(Online Release force)
: <Shift>+<F7>
. .
,
. .
, :
(Release force)
(Release Force)
(Editing the writelist and the forcelist)
/ (Remove Write-/Forcelist) (. )
, . <Release Force> .
:

Write variable <x> (Release Force).
<Release Force>
/ (Write/Force dialog) (Forced value).
"<Release Force>" ,
(Force values) .
(Release Force) Writelist
, / (Remove Write-/Forcelist).

CoDeSys V2.3

4-72

CoDeSys

, - Writelist ( ), Forcelist (). .


Writelist Forcelist

/ (Online Write/Force Dialog)


: <Ctrl>+<Shift>+<F7>
, (Writelist) (Forcelist). , - .
(watchlist) '' '
' ('Online' 'Write Values') (forcelist)
'' ' ' ('Online' 'Force Values').
(Writelist) (Forcelist)

Writelist '
' (Write Values). Forcelist, ' ' (Force Values).
(Prepared Value) (Forced Value) Writelist Forcelist, . , .

CoDeSys V2.3

4-73

CoDeSys

,
, Cancel.
:
(Force Values): Writelist Forcelist.
. , <Release Force>, .
.
(Write Values): Writelist .
.
(Release Force): Forcelist. Writelist
, / (Remove Write-/Forcelist),
, . .
(Online Show Call Stack)
, . POU:

POU PLC_PRG,
.
POU, .
POU (Go to), POU
.
(Online Display Flow control)

. ,
, ,
.
. IL, , . FBD LD
, , . , . , TRUE , .

CoDeSys V2.3

4-74

CoDeSys

:
1. .
,
.
2. .
3. .

(Online Simulation mode)


. , .
. . Windows.
, .
.
(/) .
: POU .
( , ) .

(Online Communication Parameters)


. ( OPC DDE
, ).
:

(gateway)





(gateway). , .
. . ,
, . (Login). , . CoDeSys Windows. ,
. . Exit (
).
, .

CoDeSys V2.3

4-75

CoDeSys

PC_local , PC_x ,
PC_ gateway. PC_PLC1 PC_PLC4 - . , .
: TCP/IP. ,
.

, ,
(TCP/IP, ..).

1.
"Communication Parameters
Gateway". "Gateway" .

Connection - . ,
(local) TCP/IP.
TCP/IP.

Address IP - , . Localhost, IP
127.0.0.1. . ,
(, : '010.107.084.050',
'10.107.84.50').
Password , .
,
. Change password.
.

CoDeSys V2.3

4-76

CoDeSys

Port

- , .
.

OK. , , Channels .
2. :
. (
"not connected"), , .
OK. .

, .
New. .

Name .
, (, localhost).
.
.
Device .
. OK,
Channels "Communication Parameters".
.
, (login). , .
.
, , (, COM1)
. , .
, , . , .
: . Remove.

CoDeSys V2.3

4-77

CoDeSys


. , , , .
Update.
.
, :

Channels .

. IP . localhost, . IP
127.0.0.1. , IP , , .
PC_PCL1 PC_PCL3
.
. , , -.
PC_PCL1 PC_PCL4. , . .
, PC_PCL1 . . PC_PCL4.

. , 3 : Name, Value Comment (, ).



Value. <>. <Enter> .
<Tab> <Shift+Tab> .
. <Up>, <Down>, <PgUp>, <PgDn >, <Ctrl+Home> () <Ctrl+End> ()
.

, "not connected" .
:

CoDeSys V2.3

4-78

CoDeSys

. ( CoDeSys) .

IP ( "ping" ).

TCP/IP , .

(Online Sourcecode download)


.
, .
Soucedownload.
(Online Create bootproject)
,
. .
. , 386 3 : default.prg,
, default.chk, , default.sts, .
Offline, . : < > .prg,
, < > .chk .
.
offline *.ri- ( ). ,
.
: - Implicit at create boot project ( Source download),
(Online Create bootproject).

(Online Write file to PLC)


. .
Open
. , .
(Read file from PLC) .
.

(Online Read file from PLC)


.
(Read file from PLC).
, .
, Save.

CoDeSys V2.3

4-79

CoDeSys

4.7
Windows. , .
, .
, . .
(Window Tile Horizontal)
, .
(Window Tile Vertical)
,
.
(Window Cascade)
.
(Window Arrange Symbols)
.
(Window Close All)
.
(Window Messages)
: <Shift>+<Esc>
, , . , .

4.8
'' '' '' ('Help' 'Contents' 'Search')
CoDeSys , .
'' (Contents) '' (Search) '' (Help)
. HTML Help Viewer (Internet Explorer V4.1 ).
'' (Contents) .
.
'' (Search) . .
. ,
.

CoDeSys V2.3

4-80

CoDeSys

-
: <F1>
<F1> , . , . , (,
) .

CoDeSys V2.3

4-81

5 CoDeSys
5.1

POU (Program Organization Units)
. ;
- . , .

CoDeSys , , . - .
' ' (Show print area margins) ' ' (Workspace). , .
, (Default.DFR). ' ' (New page for each object) ' ' (New page for each sub-object) (Documentation setup). .
: 100%.

(* *).
: (* .*). , . , IL ST .
FBD LD .
'' '' ('Insert' 'Comment'). , , .
FBD :

LD ,
'' '' ('Extras' 'Options').
CFC (Comment), .
SFC , .
(Nested comments) ,
'' '' ' ' ('Project' 'Options' 'Build').
, , .

CoDeSys

(Zoom)
: <Alt>+<Enter>
. POU. '' (Extras), POU
POU .
POU, POU.
(Open instance)
'' ' ' ('Project' 'View instance'). (<F2>) '' (Extras), .

(List components) '' (Editor)
, ,
:
"." ,
. 'Return' .
, .
'Return' .
:
"struvar." -> struct1 :

<Ctrl> + <Space Bar>,


POU , . <Enter>.
Offline
,
, (, VAR_GLOBAL), , (, RETAIN), .

CoDeSys V2.3

5-2

CoDeSys

5.2

POU, ,
, .
Windows .
<Ins>. OV .
, .
,
<Ctrl>+<F10>.

POU . , , , ,
.
, , ,
(. '' ' ' - 'File' 'New from template').

, , 61131-3. J.


POU VAR_INPUT END_VAR.
POU, .
:
VAR_INPUT
iIn1:INT
END_VAR

(* *)


POU VAR_OUTPUT
END_VAR. POU ,
, POU.

CoDeSys V2.3

5-3

CoDeSys

:
VAR_OUTPUT
iOut1:INT
END_VAR

(* *)


VAR_IN_OUT END_VAR. .
: , . :
< >.<in/out >.

:
VAR_IN_OUT
iInOut1:INT; (* *)
END_VAR

VAR END_VAR.
POU, . POU
.
:
VAR
iLoc1:INT; (* *)
END_VAR

. .
RETAIN.
, ( ) ,
('' '' - 'Online' 'Reset''). RETAIN .
(Retain) '' ' ()' ('Online' 'Reset (cold)') '' ' ()' ('Online' 'Reset (original)'),
(Persistent) .
PERSISTENT.
,
. .
PERSISTENT RETAIN .
- = , x =

VAR

VAR RETAIN

VAR PERSISTENT

VAR RETAIN
PERSISTENT
VAR PERSISTENT
RETAIN

(Reset)

CoDeSys V2.3

5-4

CoDeSys

cold)

(Reset

(Reset
origin)

(Download)

(Online Change)

:
VAR RETAIN
iRem1:INT;
END_VAR

(* *)

:
VAR RETAIN,
.
VAR RETAIN, , VAR RETAIN
.
VAR RETAIN, . ! PERSISTENT
!

,
CONSTANT. .
:
VAR CONSTANT
<>:<>:=< >
END_VAR
:
VAR CONSTANT
_iCon1:INT:=12; (* *)
END_VAR
B.

, POU,
EXTERNAL. .
POU ,
"Declaration of '<var>' does not match global declaration!"
, "Unkown global variable: '<var>'!"

CoDeSys V2.3

5-5

CoDeSys

:
VAR_EXTERNAL
iVarExt1:INT:=12;
END_VAR

(* *)


. . : VAR, VAR_CONSTANT, IF, NOT, INT.

:
<> {AT <>}:<> {:=< >};
, , .
,
. , .. Var1, VAR1 var1 . . A_BCD AB_CD . . , .
. :=.
.
.
:
iVar1:INT:=12;

(* INT, 12*)

, AT.
.
, . ,
(Variable configuration).
.
AT
, AT. ,
(, ).
, , , . , AT
, POU.
:
xCounterHeat7
AT %QX0.0:
wLightcabinetimpulse AT %IW2:
xDownload
AT %MX2.2:

CoDeSys V2.3

BOOL;
WORD;
BOOL;

5-6

CoDeSys

Byte, Word Dword, , !

(Insert Declaration keywords)


, POU. ,
.
, (Input Assistant) <F2> (Declaration).
(Insert Types)
.
<F2>.
:

(Standard types): BOOL, BYTE ..

(User Defined types): , ..

(Standard Function Blocks).

(User defined Function blocks).

CoDeSys 1131-3.

. . , ,
.
:

(, TRUE/FALSE, T#3s,%IX0.0)

(, , , )

, , .


. , <Ctrl>+<Enter>.
:

, .

B Bool

CoDeSys V2.3

BOOL

5-7

CoDeSys

I Int

INT

R Real

REAL

S String

STRING

( ) BOOL (. 1). .
, , ( 2 3).

AT ( 4).

( 4).

( 5).

:
:

A: BOOL;

AB I 2

A, B: INT := 2;

ST S 2; A string

ST:STRING(2); (* A string *)

X %MD12 R 5 Real Number

X AT %MD12: REAL := 5.0;(* Real Number*)

B!

B: BOOL;


(Autodeclaration) (Editor Options), .
.

(Class) : (VAR),
(VAR_INPUT), (VAR_OUTPUT), / (VAR_IN_OUT), (VAR_GLOBAL).
CONSTANT, RETAIN PERSISTENT, .
(Name).
(Input Assistant), BOOL ( ).
.
.

CoDeSys V2.3

5-8

CoDeSys

ARRAY, .

( . - Dim.) (Start) (End) .


(Type). (Input Assistant),

(Type).
: ARRAY [1..5, 1..3] OF INT.
(Initial Value) .
, ,
<F2>.
; := .
.
. :=
. , ,
, "" . .

Initial value .
: x:=5,field:=2,3,struct2:=(a:=2,b:=3)
(Address) ( AT)
.
<Ctrl>+<Enter>.
OK .
: '' ' '
('Edit' 'Auto Declare'). ,
Autodeclare <Shift><F2> .

.
, , .

CoDeSys V2.3

5-9

CoDeSys

, , ,
, .

(Declarations as tables) ( - Editor) , , . ,
(, ..), .
:
Name:

Address:

( AT), .

Type:

. (
)

Initial:

( :=)

Comment:

. .
:

:
(Sort by name):
Name.
(Sort by address):
Address.
(Sort by type):
Type.
(Original order): , .

(Insert New declaration)


. - , , . , , TAB
.
Name, Name, Bool Type.

CoDeSys V2.3

5-10

CoDeSys

, .
, .


.
=. ,
= 3 .
( "" " " - "Project" "View
instance").
. <Enter> , , . .

<Enter> . , .
, ,
.
. , (Online
Write values). .
(Online Force values)

(Release force). .


, .
.
, :{< >}
, .
: Ignore compiler directive <Instruction text>!
, ,
, . ,
.
,
.
CoDeSys :

{flag} ,

{bitaccess...}

{link} POU DUT

CoDeSys V2.3

5-11

CoDeSys

{parameter..}, {template...}, {instance...}

{library ...}

{nonpersistent} PERSISTENT

,
:
{flag [<flags>] [off|on]}
<flag> - :
noinit

nowatch

noread

nowrite

noread, nowrite

on
off {flag off}. .
:
:
a . b :
VAR
a : INT {flag noinit, nowatch};
b : INT {flag noinit };
END_VAR
VAR
{flag noinit, nowatch on}
a : INT;
{flag noinit on}
b : INT;
{flag off}
END_VAR

:
{flag noinit on}
VAR
a : INT;
b : INT;
END_VAR
{flag off}
VAR
{flag noinit on}
a : INT;
b : INT;
{flag off}
END_VAR

:
noread nowrite . , POU,

CoDeSys V2.3

5-12

CoDeSys

. , ,
.
:
POU , a , b :
VAR
a : INT {flag noread};
b : INT {flag noread, nowrite};
END_VAR
VAR
{ flag noread on}
a : INT;
{ flag noread, nowrite on}
b : INT;
{flag off}
END_VAR

a, b :
{ flag noread, nowrite on }
VAR
a : INT;
b : INT;
END_VAR
{flag off}
VAR
{ flag noread, nowrite on}
a : INT;
b : INT;
{flag off}
END_VAR

:
: ( POU )
a : afb;
...
FUNCTION_BLOCK afB
VAR
b : bfb {flag nowrite};
c : INT;
END_VAR
...
FUNCTION_BLOCK bfB
VAR
d : INT {flag noread};
e : INT {flag nowrite};
END_VAR

a, c .
b, e .
d .
{bitaccess...}
,
. ,
.

CoDeSys V2.3

5-13

CoDeSys

. POU.
.
.
.
:
{bitaccess <Global Constant> <Bitnumber> '<comment>'}
<Global
Constant>:

, .

<Bitnumber>:

<comment>

: ' ' - 'Replace constants' ( (Build))


!

. : CoDeSys , .

POU (, , )
(DUT) ,
. , ( ) (,
, ). POU DUT {link}
.

CoDeSys, , . .
. {library private} {library public} .
:
{library public} : .
{library private} : .
: . "(* *)" , "(* *)" .
local in3 :
{library public}(* *) {library private} (* *)
{library public}
FUNCTION afun : BOOL
VAR_INPUT
in: BOOL;
END_VAR
{library private}

CoDeSys V2.3

5-14

CoDeSys

VAR
local: BOOL;
END_VAR
{library public}
VAR_INPUT
in2: BOOL;
{library private}
in3: BOOL;
{library public}
END_VAR


(Parameter Manager).
CoDeSys .
(Networkfunctionality) .
:
, : { <>}. ,
.
, VAR_CONFIG, ,
.

, .

<name>: . , .

<key>: , .. ("Name", "Value",


"Accesslevel" ..). . , .
, (. 3, ).
<value>: , <key>. <value> , . : accessright="read only".
: , , .
.

:
1. 'Variables'
(a) :
'Variables' PROGRAM VAR_GLOBAL
:
{parameter list=<name> [ <key>=<value> <key>=<value> ... ] }
: bvar .
parlist1 ( 'Variables') bvar1, 102, 16#1200 16#2l.
VAR

CoDeSys V2.3

5-15

CoDeSys

bvar:INT{parameter list=parlist1 [name=bvar1 value=102 index=16#1200


subindex=16#1 ] };
END_VAR
() VAR_CONFIG:
'Variables' VAR_CONFIG ( ) :
{parameter list=<name> path=<path> [ <key>=<value> <key>=<value> ... ] }
<path> , , "PLC_PRG.act1.var_x"
: var_x an "varlist1",
"xvar".
VAR_CONFIG
{parameter list=varlist1 path=PLC_PRG.act1.var_x [ name=xvar ] }
END_VAR
2. 'Template'

: 'Template':
{template list=<name> [ <key>=<value> <key>=<value> ... ] }
: strvar, "stru1",
"templ1" 'Template'; "struvar1", "low":
TYPE stru :
STRUCT
ivar:INT;
strvar:STRING{template list=vorl1 [member=struvar1 accesslevel=low]
};
END_STRUCT
END_TYPE
3. ' Instance' ( )
(a) :
, 'Instance':
{instance list=<name> template=<template> baseindex=<index>
basesubindex=<subindex>
[
<key>=< > <key>=< >
...
] | [ <key>=< > <key>=< > ..
] | [ ]}<key>=<value> <key>=<value>
... ] }
"template" "ARRAY".
.
,
. :
"name" [name=<_>]
.
( ) , . .

CoDeSys V2.3

5-16

CoDeSys

, , ( "name" )! (. 1b).
"name" :

, :
< POU>_< >_< >.
: ARRVAR [1..8] INT PLC_PRG pragma. "name" , "PLC_PRG_arrvar_1" "PLC_PRG_arrvar_8".

"<>_< >"
,
<>_< >.
: ARRVAR [1..8] INT pragma. [name=xyz_1] .
"xyz_2" "xyz_8".

: "Member"; ,
.

:
1:
"arr_1" "arrinst" 'Instance'; "xname_<index number>" ( ),
, 0. Accesslevel=low
.
arr_1: ARRAY [1..8] OF INT{instance list=arrinst template=ARRAY baseindex=16#0
basesubindex=16#0 [name=xname_1 accesslevel=low ] };

1:
arr_1 1 4 , 5 8
4, "xname_5" ..
"xname_8".
,
,
:
arr_1: ARRAY [1..8] OF INT{instance list=arrinst template=ARRAY
baseindex=16#0 basesubindex=16#0 [name=aname accesslevel=high]
[name=bname] [name=cname] [name=xname accesslevel=medium]};
1: instance

CoDeSys V2.3

5-17

CoDeSys

2:
"stru1" ( a,b,c)
'Instance', "strulist_temp"; a,b,c, , "high"
, 2. , :
struvar:stru1{instance list=strulist template=strulist_templ baseindex=16#2
basesubindex=16#0 [accesslevel=high] };

2: Template

() VAR_CONFIG:
Instance'
VAR_CONFIG ( ).
, :
{instance list=<name> path=<path> template=<template> baseindex=<index>
basesubindex=<subindex>[ <key>=<value> <key>=<value> ...further keys ] }
<path> , "PLC_PRG. fb1", fb1
: VAR_CONFIG "fb1" "varinst1" "fb1_templ".
2 (baseindex), (basesubindex). "fb1var",
:
VAR_CONFIG
{instance list=varinst1 path=PLC_PRG.fb1 template=fb1_templ baseindex=16#2
basesubindex=16#0 [ name=fb1var ]}
END_VAR

CoDeSys V2.3

5-18

CoDeSys

PERSISTENT
PERSISTENT, persist.dat.
: {nonpersistent} . ,
PERSISTENT .
:
local fblevel3 .
FUNCTION_BLOCK FB_Level_2
{nonpersistent}
VAR_INPUT
bvar_in : BOOL;
END_VAR
VAR_OUTPUT
bvar_out : BOOL;
END_VAR
VAR
ivar2 : INT;
END_VAR
VAR PERSISTENT
local : INT := 33;
fblevel3 : FB_Level_3;
END_VAR

CoDeSys V2.3

5-19

CoDeSys

5.3

( IL ST) CoDeSys Windows.
. .
OV . <Ins>,
.
ST IL

,
<Ctrl> +<F10>.
:
(Insert Operator)
.
OK, .
(Insert Operand)
.
(, , ), .
OK, ( ).

CoDeSys V2.3

5-20

CoDeSys

(Insert Function)
, .
OK.
With Argument, .
(Insert Function Block)
. ,
: , .

OK.
With Arguments, .
POU c
ST IL POU -
POU.
: out1 a.
IL:
ST:

CAL afbinst(in1:=1, out1=>a)


afbinst(in1:=1, out1=>a);

POU (<F2>) 'With arguments', ST


IL . .

CoDeSys . -, .
.
, .
, .
, .
, :
. : a AND b
:=TRUE, a b .
(, a.2 ":=TRUE, a 4).
,
, .
(Extras Monitoring Options)
, . . , .

CoDeSys V2.3

5-21

CoDeSys

(Width) (Distance) . , 1 .
, ,
.


.. CoDeSys IL , . ,
, .
. . ,
, , . . , .
IL :

POU.

LD,LDN

JMP, JMPC, JMPCN

CAL, CALC, CALCN

RET, RETC, RETCN

POU

ST :

RETURN EXIT.

, (WHILE, IF,REPEAT)

POU

, ,
.

CoDeSys V2.3

5-22

CoDeSys

IL c ( )

?
, , . - ,
.

, .
( - Online Toggle Breakpoint), <F9> .

, . .
,
(Online Run).
, (Online Step
over) (Step in) . (Step over), , POU.
(Step in)
POU.

POU.

.
,
. :
-: , .
:

CoDeSys V2.3

5-23

CoDeSys

IL
, IL CoDeSys:
IL

POU ,
.
IL Windows.
CoDeSys POU :
:
CAL CTU_inst(
CU:=%IX10,
PV:=(
LD A
ADD 5
)
)
, , 2.2.1. Instruction List
(IL).
IL
(Online Display Flow control), , . IL .

ST
, ST CoDeSys

CoDeSys V2.3

5-24

CoDeSys

ST

POU ,
.
ST Windows.
ST .
, , 2.2.2. Structured Text
(ST).

5.4

SFC, LD, FBD CFC,
.
LD, FBD, CFC SFC.
(Zoom)
SFC, LD, FBD, CFC .
, , .
100%. .
100%.

CoDeSys V2.3

5-25

CoDeSys

,
25% 400%. 10%
500%.
, .

.
, , , ,
. ; .
, <Ctrl> .

LD FBD .
: , , , , , .

, . ,
, . ,
.
, (Extras Options)
()
. (Extras Options) .
maximum comment size ( 4). . (minimum
comment size) , . ,
, 2, , , . 0,
.
, , . : (Insert Comment).
.

CoDeSys V2.3

5-26

CoDeSys

LD FBD:

(Alternative Look & Feel):


.

. (Comments
per Contact) (Lines for Variable Comment)
, . (Lines for Variable text) , , .
.
:

(Networks with Linebreaks) , .


CoDeSys V2.3

5-27

CoDeSys

(Replace with Symbol after entering Address): (


): ,
( "%QB4"). ,
. , .
(Set Contact Comment to Symbol Comment):
, . (. : ) ,
(Comments per Contact). ,
, ,
!
(Show Address of Symbol): ( ):
, . (. : ).
(Show Variable Comments per Rung in Printout): ,
, , , . .
:

:
OK: , POU
.
(Apply options): ,
. . .
() (Insert Network(after)) ()
(Insert Network(before))
() (Network(after)): <Shift> +<T>
FBD LD,
() (Insert Network(after)) () (Insert
Network(before)) . , . . <Shift>, ,
.

FBD LD .
, , . , . -

CoDeSys V2.3

5-28

CoDeSys

(Step in) (Step over),


.
, . :
a AND b :=TRUE, a b . (, a.2
:=TRUE, a 4).
(Online Display Flow Control). ,
, .
, . , , . TRUE, .
, , ,
( ).

CoDeSys V2.3

5-29

CoDeSys

FBD
FBD

FBD - . ,
, ,
, .
,
<Ctrl>+<F10>.
,
0 , (Extras Options).

FBD
FBD , . .
. :
1) ( ):

2) :

CoDeSys V2.3

5-30

CoDeSys

3) , .

4) , .

5) , :

6) ( ; )

7) :


.
.
, .
.
"???". ,
.
(Insert Assign)
:

:<Ctrl>+<A>

.
(. FBD) ( 2), ( 4)
( 6). ,
, .
(F2).
(. 0 , (Extras Options)).
,
(Insert Output).
Insert Jump
:

CoDeSys V2.3

:<Ctrl>+<L>

5-31

CoDeSys

.
(. FBD) ( 2), ( 4) ( 6).
, ,
.
(Insert Return)
:

:<Ctrl>+<R>

Return.
(. FBD)
( 2), (
4), 5 ( 6).
(Insert Box)
:

:<Ctrl>+<B>

C , ,
. AND.
, AND,
(, , , ), .
, (<F2>). ,
AND, .
.
, . (
), , .
, <F2> .
POU :

( 2). POU
. POU , . POU .

( 4), POU .
POU . POU ,
.

POU ( 3) , .
, , .
, , . .

, POU .
POU , . POU , .

( 6). POU .

CoDeSys V2.3

5-32

CoDeSys

POU, , . .
POU ,
POU.
(Insert Input)
:

:<Ctrl>+<U>

. (,
ADD ).
, ( 1), (Insert Input).
: ( 3)
(Insert Input), .
???.
, .
(. 0 , (Extras Options)).
(Insert Output)
:
.
.
( 5, .
FBD) ( 4),
.
, ( 4),
.
???. , .
(. 0 , (Extras Options)).

(Extras Negate)
:

:<Ctrl>+<N>

C , , . .
( 2), .
.
, ,
, FALSE.

CoDeSys V2.3

5-33

CoDeSys

.
(Extras) Set/Reset
:
Set- Reset-. Set- S, Reset- R.
Set/Reset FBD

Set- TRUE, Reset- FALSE, ,


, TRUE. FALSE,
.
Set-, Reset-
.
(Extras View)
, LD FBD
(POU) FBD . .
(Open instance)
'' ' ' ('Project' 'Open instance'). (<F2>) '' (Extras),
.
(Cut), (Copy), (Paste)
(Delete) FBD
(Edit).
( 5), ,
, , , .
POU ( 5), , .
, , , ,
.

, . .
POU ( , ,
, ),
.
( POU), , ,
.

CoDeSys V2.3

5-34

CoDeSys

,
.
: C :
; , , ,
.
(Edit Cut). ,
(Edit Paste). .

FBD
FBD . , . , . . (Step in) (Step over),
, .
. , . .
. , , . (Online Write values). .
(Online Display Flow Control). ,
, .
, . , , . TRUE,
. .
, ,
, .

CoDeSys V2.3

5-35

CoDeSys

LD
POU LD

POU POU.
.
LD . , <Ctrl>+<F10>.
,
0 , (Extras Options).
2.2.6 Ladder Diagram(LD).
LD
, . POU, EN,
FBD. FBD.
( )

CoDeSys V2.3

5-36

CoDeSys

, .

LD :
LD
(drag&drop) (,
) LD .
(, ) ,
. .
. .

, . , . (),
.

'' ' ()' ('Insert' 'Network (before)')


:
, LD.

CoDeSys V2.3

5-37

CoDeSys

'' ' ()' ('Insert' 'Network (after)')


:
, LD.
(Insert Contact)
:

: <Ctrl>+<K>

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

(. 0 , (Extras Options)).
'' ' ' ('Insert' 'Contact (negated)')
:

: <Ctrl> + <G>

. 'Insert' 'Contact' 'Extras' 'Negate'.


(Insert Parallel Contact)
:

: <Ctrl>+<R>

, .
( 3) , ( 4), , .
.
. .
() ('Insert' 'Parallel Contact (negated)')
:

: <Ctrl> + <D>

. 'Insert' 'Parallel Contact' 'Extras' 'Negate'.


(Insert Coil)
:

: <Ctrl>+<L>

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

CoDeSys V2.3

5-38

CoDeSys

, , , ???,
, . .
. (. ,
"" "" ("Extras" 'Options')).
'' 'Set' ' ('Insert' 'Set' coil')
:

: <Ctrl> + <I>

Set , . (Insert Coil) '' (Extras) 'Set/Reset'.


'' 'Reset' ' ('Insert' 'Reset' coil')
:
Reset , . (Insert Coil) '' (Extras) 'Set/Reset'.
(Insert Function Block)
:

: <Ctrl>+<B>

, , .
( 3) ,
( 4), . AND. . , POU.
POU ,
BOOL. POU , ,
. .
(. , "" "" ("Extras" 'Options')).
POU c EN.
POU , POU
EN.
POU EN- EN (Insert
Box with EN). , , EN- , FBD. EN , . POU
, , EN-, TRUE.
EN POU . ,
POU .
, FBD , EN- . FBD.
FBD.

CoDeSys V2.3

5-39

CoDeSys

EN (Insert Box with EN)


:
, ,
EN- LD.
( 3) , ( 4). POU
AND. . .
(Insert Insert at blocks)
POU.
, , , FBD (. 5.7).
(Input) POU.
(Output) POU.
POU POU .
(Assign) .
.
'' ' ' ('Insert' 'Rising edge detection')
:
R_TRIG,
(FALSE -> TRUE) .
'' ' ' ('Insert' 'Falling edge detection')
:
F_TRIG,
(TRUE -> FALSE) .
'' ' (TON)' ('Insert' 'Timer (TON)')
:
TON, .
(Insert Jump)
, , . , , On, .
( 3) , ( 4).

CoDeSys V2.3

5-40

CoDeSys

???. .
(Insert Return)
LD
, , .
, , On,
POU.
( 3) , ( 4).
'' ' ' ('Extras' 'Paste after')
.
, ,
.
(Extras Paste below)
.
, , .
.
(Extras Paste above)
.
, , .
.
(Extras Negate)
:

: <Ctrl>+<N>

, , , POU ( 2 3).
((/) |/|). , POU , FBD.
,
. ,
False.
, ,
Off.
, .
(Extras) Set/Reset
:
, Set-.
True, On, , Off.
S.

CoDeSys V2.3

5-41

CoDeSys

, Reset-. False, On,


, Off.
R.
, Set-, Reset- .
LD
, On,
. , , On, . .
.
, ,
.

CoDeSys V2.3

5-42

CoDeSys

SFC
SFC

POU POU.
.
SFC . , <Ctrl>+<F10>. ,
, , , ,
, Offline.
Sequential Function Chart (SFC).
SFC SFC. :
SFC
SFC, .
(, , ) . , , <Shift> . .
: ,
!

- ()(Insert Step Transition (before))

CoDeSys V2.3

: : <Ctrl>+<T>

5-43

CoDeSys

, ,
.
- () (Insert Step Transition (after))
:

: <Ctrl>+<E>

, ,
.

, .
'' ''
('Edit' 'Delete') <Del>.
() (Insert Alternative Branch (right))
:

: <Ctrl>+<A>

.
. .
() (Insert Alternative Branch (left))
:
.
. .
() (Insert Parallel Branch(right))
:

: <Ctrl>+<L>

.
.
. (jump) .

(Add Label To Parallel Branch).
() (Insert Parallel Branch(left))
:

<Ctrl>+<U>

.
.
. (jump) .
(Add Label To Parallel Branch).
(Insert Jump)
:
(jump) ,
. Step.
,

CoDeSys V2.3

5-44

CoDeSys

, .
- (Insert Transition-Jump)
:

(jump) .
Step.
, .
(Insert Add Entry-Action)
.
.
E .
(Insert Add Exit-Action)
.
.
X .
() (Extras Paste Parallel Branch
(right))

. .
, SFC, .
(Extras Add label to parallel
Branch)
,
(Add Label To Parallel Branch).
, Parallel . .
Parallel Par_1_2 Ende .

CoDeSys V2.3

5-45

CoDeSys


, .
(Extras Paste after)
SFC .
, SFC.
/ (Extras Zoom Action/Transition)
: <Alt>+<Enter>

, . ,
, .
, , , ,
. : i>100 , FALSE, , TRUE!

/ (Extras Clear Action/Transition)


.
( , , ),
. , ,
, .
, - , , .
, ,
. , .
(Extras Step Attributes)
.

CoDeSys V2.3

5-46

CoDeSys

. . (Minimum
Time) . . (Maximum
Time) . ,
Time (, T#3s), Time.
(Comment) .
SFC (Sequential function chart options), (Extras Options), ,
SFC. .
, , SFC, .
, 2
10 . , , .

(Extras Time Overview)


SFC.

CoDeSys V2.3

5-47

CoDeSys

SFC POU

POU. ,
( , ). ,
. (Minimal Time) . (Maximal Time) . , OK, .
, 2 6 . 2 2
, 10 . 6 7 8 .
(Extras Options)
SFC .
SFC

6 SFC. (Height of Steps)


( 4). (Width of Step)
( 6). (Display at Step)
, : (Nothing), (Comment) (Time Limits)

CoDeSys V2.3

5-48

CoDeSys

Extras Associate Action


.
, , . N Action_1. . Input Assistant.
Object Organizer, POU (Add Action).
(Extras Use IEC-Steps)
:
( ), - -.
, SFC POU, Init .
CoDeSys.ini
CoDeSys.
SFC
. (Time Limits) (Extras Options),
.
, 8 410 . ,
7 .

(Online Toggle Breakpoint)


, , . . , , .
, .
.

CoDeSys V2.3

5-49

CoDeSys

SFC

Switch , Step10.
(Online Step over) . - :

POU, , POU, , POU. POU PLC_PRG, ;

, ;

, , POU. ;

,
.
(Online Step in) , . , , -, . .
, ,
.
: ( Change)
, !

CoDeSys V2.3

5-50

CoDeSys


1. -, - (
, ).
2. , , , , .
3. , , , , .
4. :

, .

-, SFC-.

-, .

5. , -, .
, . .
6. : True ( , ), .
:
,
(, SFC ,
SFC, . , ).

. , , CoDeSys.
: (, Bool1 AND Bool2)
.

CoDeSys V2.3

5-51

CoDeSys

CFC
CFC

, . CFC , , , , , .
, .
. ,
, ,
, , .
CFC FBD , .
.

CFC . .
.
.
1.

CoDeSys V2.3

, , , , .

5-52

CoDeSys

2.

3.

: , , , .

4.

: .

(Insert Box)
:

: <Ctrl> + <B>.

, ,
. AND.
, , , . .
, .
, , .
(Insert Input)
:

: <Ctrl> + <E>.

. ,
. .
(Insert Output)
:

CoDeSys V2.3

: <Ctrl> + <A>.

5-53

CoDeSys

. ,
. . .
(Insert Jump)
:

: <Ctrl> + <J>.

. , . (Insert Label).
(Insert Label)
:

: <Ctrl> + <L>.

. ,
. POU Return.
, (Insert
Jump).
(Insert Return)
:

: <Ctrl> + <R>.

RETURN. ,
RETURN , POU, .
(Insert Comment)
:

: <Ctrl> + <K>.

. ,
<Ctrl>+<Enter>.
(Insert Input of box)
: <Ctrl> + <U>.
. (, ADD ).
, ( 1).
(Insert In-Pin), (Insert OutPin)
:
. , POU .
(Extras Negation)
:

CoDeSys V2.3

: <Ctrl>+<N>.

5-54

CoDeSys

, , . .
, .
(Extras) Set/Reset
:

: <Ctrl>+<T>.

, .
Set S, Reset - R.

VarOut1 TRUE, VarIn1 , ,


VarIn1 .
VarOut2 FALSE, VarIn2 , ,
VarIn1 .
Set, Reset
.
(Extras) EN/ENO
:

: <Ctrl>+<I>.

( 3) EN ENO.

VarOut TRUE ADD. condition FALSE,


ADD ( , ) . ,
! VarOut AND TRUE.
, ENO.

CoDeSys V2.3

5-55

CoDeSys

X , Y . ,
.
X , 10. LT
(0) FALSE SUB(3) ADD(5). X , Y , LT(0) , X
10. Y , 1 10.
(Extras Properties)
, (VAR_INPUT CONSTANTS) . , ( 1) . CFC .
(Edit Parameters)

(VAR_INPUT CONSTANT) .
Value. <Enter>, - <Esc>.
OK .
"VAR_INPUT
CONSTANT" CFC. FBD INPUT

CoDeSys V2.3

5-56

CoDeSys

VAR_INPUT
VAR_INPUT CONSTANT. .


, ( 1).
, <Shift>
, , .
Extras Select all .

, <Shift>. : , . ,
. ,
.


(Edit Copy) (Edit Paste).

. .
E2 E1.

E1 ( 4),
, , E2 ( 3) . .
: E2,
, , E1. .
, () ()
. , .
E2 , , E1
E2, . , . ,
E2 , , .
( ).
.
, . , - . , .

CoDeSys V2.3

5-57

CoDeSys


, E1 E2:
E1 E2 ( 4) <Delete>
(Edit Delete). E1 , .
E2 , ,
. , .

E1 E2
E1 E3. E2 ( 3),
, E3 .
(Extras Connection mark)
, .
, .

. ( 3) (Extras Connection mark). ,


.
, . ,
.
1. :
, . , .
.
2. :
, 1.
, (
4) (Extras Connection mark).
/
- .
, , , .

, .

CoDeSys V2.3

5-58

CoDeSys

: . .
.
, .
(Extras Order Show order)
, .
( ).
.
(Extras Order Order
topologically)
.
. ,
.
,
.
,
. :

1, 2 3.
(Order topologically) . Var3,
, 2, AND 4, 5.
:

, ,
.

CoDeSys V2.3

5-59

CoDeSys

: (Extras Order Order one up)


.
: (Extras Order Order one down)
.
: (Extras Order Order start)
. .
: (Extras Order Order End)
.
.
(Extras Order Order everything according to data flow)
. , .
.
(Order everything according to
data flow)

CoDeSys V2.3

5-60

CoDeSys

.
, CoDeSys . , AND
, (1 2), SUB ,
ADD.
.
, Output , , . , , .
(Extras Create macro)
:
POU , . /,
. , , . In<n>, Out<n>. ,
.
Macro, . .
.
:

CoDeSys V2.3

5-61

CoDeSys

(Extras Jump into Macro)


:
POU. .
. POU. ,
. , - .

,
, .
. .
.
. .
(Extras Expand Macro)
(Create Macro).
. - , , .
: 2.1 , . CFC, .

CoDeSys V2.3

5-62

CoDeSys

(Extras Return to prior macro


level), (Return to top level)
:
, . , .
CFC
CFC. , , .
. , , 1 SINT. ,
, .
, . x y
INT.

:
y , .
SINT, INT. x y 129 . x INT, -127,
. y 129 .
CFC
:
.
. , .
, TRUE, ,
FALSE.
, TRUE,
.
.

CoDeSys V2.3

5-63

CoDeSys

, , , .
:
, , , .
:
, .
.
Breakpoints.
<F9>
(Online Toggle
breakpoint). , .
, .

Return:
Return.
POU, , POU, . Return .
:
(Step over)
. POU,
(Step in).

CoDeSys V2.3

5-64

6
6.1
(Resources) ,
:

(Global Variables) - , . , .

(Alarm configuration)
CoDeSys .

(Library Manager) , .

(Log) .

(PLC Configuration) -
.

(Watch and Recipe Manager)


.

(Task Configuration) .

(Target settings)

(Workspace) .

(Parameter Manager) ,
.

- (PLC Browser)
.

(Sampling Trace) .

(Tools) CoDeSys.

SoftMotion ( ): CNC CAM (.


SoftMotion).

(Docuframe file)
(, ..), .

6.2 ,

(Global Variables) (Resources) (. .
6.1) ( ):

(Global Variables).

(Variable Configuration).

, , .
(Global Variables) (
"+"), (Expand note). (Global Variables) , . ,
.

, .
,
(Global Variables) ("Project" "Object Add").
. VAR_ GLOBAL.
,
VAR_CONFIG.

CoDeSys V2.3

6-2


?
, ,
, . , (Network
variables) .
: ,
,
!

. , ,
"var1" PLC Configuration, ,
.

:
( - Network functionality).

( -
)
(CoDeSys )
. . ,

. , .
! . !


. '' '' '' ('Project' 'Object' 'Add').
(. . ) .
'' '' '' ('Project' 'Object'
'Properties'), .
(Name of the global variable list):
(Link to file):
(*.esp) DCF (*.dcf), , . (Filename). (Browse)
. DCF .
(Import before compile)
. (Export before compile)
.
OK .
. , '' '' '' ('Project' 'Object' 'Properties').

CoDeSys V2.3

6-3


' ' (Support network variables) , <Add network>.
, , .
, .
Connection <n> (<Network type>): .
. .
, UDP
'Connection 1 (UDP)'. ' ' (Add network)
Connection.
(Network type): . : CAN" UDP".
(Settings): :
UDP:

CoDeSys V2.3

(Use standard) (Port


1202) . (Broad-

6-4

cast/Multicast) "255 . 255 . 255 . 255", :


.
(Port): . , ! UDP ,
.
(Broadcast/Multicast address): , (, "197 . 200 . 100
. 255", IP- 197 . 200 . 100 .
x).
Win32 , Broadcast/Multicast TCP/IP PC.
UDP

CAN:
(Controller Index): CAN,
.
:
(Pack variables): (), . , .
(List identifier) (COB-ID): ,
( = 1).
. : COB-ID . ID
( 2.3.7.0).
(Read): ; ,
.
(Request on Bootup): ( '' (Read) ),
(, ), . : ' . ' (Answer Bootup requests)
! (. ).
(Write): ; :
(Transmit Checksum):
. . , ,
(. 'Use acknowledge transfer'), .

CoDeSys V2.3

6-5

(Acknowledgement): ( CAN) . , , UDP- , NetVarUdp_LIB_V23.lib.


. (Answer Bootup requests): ( '' (Write) ),
(. Request on Bootup). , (, ).
(Cyclic transmission): , (Interval) ( , T#70ms).
(Transmit on change): , . Minimum
.
(Transmit on event): ,
Variable TRUE.

: ,
, . , , .
.

.
.

. , .
, .
:
VAR_GLOBAL
(* *)
END_VAR
, .
, UDP.EXP :

CoDeSys V2.3

6-6


:
Retain variables, '' ''
('Online' 'Reset') CoDeSys. Persistent variables , (, ).
RETAIN
PERSISTENT.
:
VAR_GLOBAL RETAIN
(* *)
END_VAR
VAR_GLOBAL PERSISTENT
(* *)
END_VAR
Persistent Retain ! :
VAR_GLOBAL RETAIN PERSISTENT VAR_GLOBAL PERSISTENT RETAIN

CONSTANT.
:
VAR_GLOBAL CONSTANT
(* *)
END_VAR



. , "", .
locio %I %Q.
"*".
:
FUNCTION_BLOCK locio
VAR
loci AT %I*: BOOL := TRUE;
loco AT %Q*: BOOL;
END_VAR
Hugo tto , , :
.
PROGRAM PLC_PRG
VAR
Hugo: locio;
Otto: locio;
END_VAR
Variable
Configuration:
VAR_CONFIG

CoDeSys V2.3

6-7

PLC_PRG. Hugo.loci AT %IX1.0 : BOOL;


PLC_PRG. Hugo.loco AT %QX0.0 : BOOL;
PLC_PRG. Otto.loci AT %IX1.0 : BOOL;
PLC_PRG.Otto.loco AT %QX0.3 : BOOL;
END_VAR
( ) .
, . , . "*" Variable Configuration. , , .

" " (All Instance Paths) (Insert).
"" " " ("Insert" "All Instance Paths")
VAR_CONFIG,
. .
, . ("", " " - "Project", "Rebuild All").


, (, ), , , , . : ""
" " ("Extras" "Make Docuframe File"). . DOCUFILE.
. 3 : VAR, , , , , , ,
. .
, , .
, .

,
("Extras" "Link Docu File").

CoDeSys V2.3

6-8

, , . .
"" " " ("Extras" "Make Docuframe File")
, .
. *.txt.
, .
("Extras" "Link Docu File")
. ,
. . .
"" " " ("Extras" "Make Docuframe File").

6.3 (Alarm Configuration)

, CoDeSys, , .
CoDeSys .
'' .
,
' ' (Alarm configuration)
'' (Resources).
(alarm classes) (alarm groups). , . ( ), . , .
, 'System' .
CoDeSys Alarm table.
, .
(History), (Alarm-Events), log-
.
' ' (Alarm configuration) '' (Resources),
' ' (Alarm configuration). ,
(PLC Configuration) (Task configuration). , .

CoDeSys V2.3

6-9

"" Alarm configuration'.


, 'Alarm classes' 'System'.


CoDeSys :
(Alarm): - , ( ).
(Priority): .
- "0". - "255".
(Alarm state): / ,
: NORM - , INTO - , ACK -
, OUTOF - "" ( !).
(Sub-State): (Lo , Hi
) "" (LoLo, HiHi). : HI, HI-. , , HI-
HIHI- (
, ). HI-
.
(Acknowledgement of alarms): ,
. ,
(
). , .

CoDeSys V2.3

6-10

(Alarm Event): . . -
, .
CoDeSys (INTO, ACK, OUTOF).
CoDeSys :

, .

'Alarm table'


, , , ,
, , . .
:
' ' (Alarm classes) , .

CoDeSys V2.3

6-11

' ' (Alarm classes)

(Add) .
,
"NOACK" ( ) (Acknowledgement). (Name) (
). , (Acknowledgement).
:
NO_ACK: .
ACK_INTO: "" ( "INTO") .
ACK_OUTOF: "" ( "OUTOF") .
ACK_ALL: "" "" .
(Comment).
. (Delete)
.
<class name>:

CoDeSys V2.3

6-12

, , , .
(Possible actions) ">",
(Assigned actions).
, . ">>" . "<" . "<<"
. " ... "
: , , , , .
(Possible actions):

(Save):

(Print):


log .

!

,
Alarm saving.

Printer: ; Outputtext: (. ),
.
.

(Message):

E-Mail:

(Variable):

(Execute):

Message: ,
.

e-mail .

From: ; To: ;
Subject: ; Message: (.
); Server: smtp .
Variable: :

(<F2>): : NORM =0 INTO=1. : NORM =0, INTO =1, ACK =2, OUTOF =4;
Message (. ).
Executable file: (, notepad.exe),
"..."
; Parameter: ,
exe-).

CoDeSys .

:
'' (Message), '' (Print), 'Email' '' (Variable)
, .
<Ctrl>+<Enter>.
(placeholders):

CoDeSys V2.3

MESSAGE

,
.

DATE

(INTO).

6-13

TIME

EXPRESSION

( ), .

PRIORITY

( ).

VALUE

(. ).

TYPE

( ).

CLASS

( ).

TARGETVALUE

DEV+ DEV- (
) .

DEADBAND

( ).

ALLDEFAULT

, log
(History).

:
, :

(Message): "Temperature too high!".


:

:
, , *.vis- *.tlt. :
"#" (: "#Temperature critical !#" "TIME
/EXPRESSION: MESSAGE #current#: VALUE").
ALARMTEXT_ITEM .

(Events for actions):


, :
INTO

(Status = INTO).

ACK

(Status = ACK).

OUTOF (Status = OUT OF).


Colors/Bitmaps for class <class name> ( )

CoDeSys V2.3

6-14

,
. Foreground, Background color INTO, ACK OUTOF (. ).
.
(bitmap).


. .
. , .
. (Alarm group) .
:

(Description).
(Deactivation variable) . ( )
. .
(Add) . .
:

CoDeSys V2.3

6-15

(Expression): , (, "a + b"),


. <F2> .
(Type): .
.
DIG=0 , FALSE.
DIG=1 , TRUE.
LOLO , Alarm type
LOLO. (Deadband).
, , LOLO.
LO LOLO.
HI , Alarm type HI.
(Deadband).
, , HI.
HIHI HI.
DEV- - ;
, Alarm type DEV-. = (target value) * (deviation in %) / 100.
DEV+ + ; ,
, Alarm type DEV+. = (target value) * (deviation in %) / 100.
ROC ; , . (Rate of changes) : , (units
per).
(Class): .
. , , .
(Priority): 0-152. 0 - . .
(Message): . . OK
. (acknowledge) .
log ( ).
(Deactivation): . , '' (Deactivation variable)! (. ).


, , 'Save'.
' '
(Alarm saving):

CoDeSys V2.3

6-16

' ' (Alarm saving)

:
(Filepath): () , (Filename);
"..." .
'Alarmhandling on PLC', , .
(Filename): , .
, , ".alm". , log-. "0";
( ,
(File change event)) : 1, 2 .. (: "alarmlog0.alm", "alarmlog1.alm).
(File change event): ,
. : (Never), (Hour) ,
(Day) , (Week) , (Month) , (Variable) - , (Triggervariable), (Records) - ,
(Number of records).
.. (Delete old files after .. Hours):
, log- .
(log-file) .
, :
Date/Time
DWORD
1046963332

6.3.03

16:08:52

INTO

PLC_PRG.b

LO

1046963333

6.3.03

16:08:53

ACK

PLC_PRG.n

HIHI

:
.
-30

.
-31

35

Alarm_high

Temperature !

Warnng

Rising Temp. !

log-:
1046963332,6.3.03 16:08:52,INTO,PLC_PRG.ivar5,HIHI,,,,

CoDeSys V2.3

9.00,a_class2,0,

6-17

1046963333,6.3.03 16:08:53,INTO,PLC_PRG.ivar4,ROC,2,,,

6.00,a_class2,2,

1046963333,6.3.03 16:08:53,INTO,PLC_PRG.ivar3,DEV-,,,,

-6.00,a_class2,5,

1046963334,6.3.03 16:08:54,INTO,PLC_PRG.ivar2,LOLO,-35,,3,
1046963334,6.3.03
knowldge!

16:08:54,INTO,PLC_PRG.ivar1,HI,20,,5,

-47.00,warning,10,warning: low temperature !


47.00,a_class1,2,temperature

to

high!

'' (Extras): '' (Settings)


(Alarm configuration settings) ''
(Extras): '' (Settings) (Alarm Configuration):
/ (Category Date/Time):
. .
:
: dd'-'MM'-'yyyy -> : "12.Jan-1993"
: hh':'mm':'ss -> : "11:10:34" (24- )
(Language):
(. CoDeSys CoDeSys_Visu_V23_RU.pdf).
(*.vis *.tlt),
CoDeSys. .

(Project Translate into another language), .
xml-, . ,
CoDeSys. , !
(Online):
(Deactivate alarm evaluation in
mode): , .

.

6.4 (Library Manager)


, . U,
, U .
,
' ' (Informations about external library). ''
'' ('Extras' 'Properties').
"" " " ("Window" "Library Manager").

CoDeSys V2.3

6-18

Ac-


3 4 . , , . , , U, .
<Enter>. , .
U, U,
.
.

"standard.lib" . ,
61131-3. , ,
U (standard.lib).
POU - CoDeSys.
,
, .
. , .
, CoDeSys,
(Internal Library).
, , ( ), (External Library). "*.h".
. POU, ,
. ,
, CoDeSys.
C .

CoDeSys V2.3

6-19

, (Edit license info...) 'Edit Licensing


Informationen'. . '' ' ' ('File' 'Save as...')
CoDeSys.
("Insert" "Additional Library")
.
"*.lib".
, .
, .
,
. : standard.lib
"D:\codesys\libraries\standard".
, :
"standard.lib < >".
"D:\codesys\libraries",
: "standard\standard.lib < >".
, :
"D:\codesys\libraries\standard\standard.lib < >".
. , ,
, .
,
, ,
. . .
'License information'.

("Edit" "Delete").
'' '' ('Extras' 'Properties')
'Informations about internal ( external) library'.
, Project Info ( ). .

6.5 (Log)
- ,
. (*.log).
.
.

CoDeSys V2.3

6-20

(Window Log)
. '' (Log) .
'' (Log) . , . (Internal).

.
. , ,
Field Log.
, , :
(Category): , . 4 :
(User actions): ( )
(Internal actions): (,
(Delete Buffers) (Init Debugging)).
(Status change): (, ).

(Exception): , , .

(Description): . , . , XXX().

CoDeSys V2.3

6-21

(Info): , . , .
(System time): .
(Relative time): -
.
(Duration): .
(Log)
, (Log),
:
(Load): (*.log). .
, , .
(Save): .
, .

, .
. (Show Project Log): , . .

, (.
), <
>.log. '' (Log).
, .
- ''
(Log). , .

CoDeSys V2.3

6-22

6.6 (PLC Configuration)

(PLC Configuration)
. .
/ , . CoDeSys
, , .
() *. cfg (.
) (, *.gsd, *.eds).
, (.
- Target Settings), CoDeSys. .
*.cfg , .
, .
: *.cfg , CoDeSys !
: CoDeSys V2.2 . *.cfg. *.con. :
(old) . . *.con . , . , *.cfg (. 'Extras' 'Convert').

CoDeSys /,
CAN Profibus.
CAN:

, : 1) (PLC
Configuration), 2) CoDeSys, 3)
(PLC Configuration).
.

CoDeSys V2.3

6-23

. .
/ , (,
CAN-bus 8 ).
. .
,
CoDeSys V2.1. CoDeSys V2.1, :
CAN :
"Create all SDO's" 'CAN ' (CAN Parameters) CAN (.
0). : SDO
V2.3; , .
"" (Device-Type) 'CAN '
(CAN settings) CanDevice (. 0).
Profibus :
Profibus (. 0)
.

(PLC Configuration): CoDeSys, -.
: . -.
, . .
: -. , . . , .
.
: .
: , . - . ' ' (Automatic calculation of addresses),
. .
,
( ) . : %QB0, %IB26, %MW4.
: ,
, . :
%QW2.4.6
%QX2.4.6.10

: CAN bus VME Slot 2, CAN- Id 4 6.


:10 .

: . . .

CoDeSys V2.3

6-24


.
. , CoDeSys. .
, ''
'' ('Extras' 'Properties').
,
.
: (CAN, Profibus, I/O, .).


. .
, "", . <Enter>. ( ""), .
'' ' ' ('Insert' 'Insert element'), '' ' '
('Insert' 'Append subelement')
() ,
, , . , . .
o

'' ' ' ('Insert' 'Insert element')


, .

'' ' ' ('Insert' 'Append subelement') .


.

(
<Ctrl>+<F10>).
: ,
CoDeSys PLC
Configuration.
'' ' ' ('Extras' 'Replace element')
. .
'' ' ' ('Extras' 'Replace element').

.

(AT).
.

CoDeSys V2.3

6-25


'AT'.
.
.
/
(*.cfg) ,
'Export module' 'Import module'. , .
'Export module' .
. , XML. 'Import module',
.

.


. '' (Settings). :
(Automatic Calculation of addresses):
,
.
.
'' ' ' ('Extras' 'Calcalute addresses').
(Check for overlapping addresses):
,
.
. (Save configuration files in project): *.cfg , ,
. , . ,
. ,
.

( ),
, .

CoDeSys V2.3

6-26

'' ' ' ('Extras' 'Calculate addresses')


" " (Calculate addresses) '' (Settings) ,
'' ' ' ('Extras' 'Calculate addresses') . , .
' ' (Add configuration file)
'' (Extras)
. ()
: '' (Directories), '. ' (Configuration files).
(Select configuration file) ,
: CAN- (*.eds,*.dcf), Profibus- (*.gsd), (*.cfg ) (*.*).
. , .
, Select configuration directory. . , . OK. .
'' ' ' ('Extras' 'Standard configuration')
'' ' ' ('Extras' 'Standard configuration') , *.cfg .
: *.cfg ,
. , , !

'' '' ('Extras'


'Convert')
'' (Convert) , ,
, CoDeSys V2. 2. , 'Convert'
. : "Convert the configuration
to the new format? Attention: Undo is not possible !" ( ?
: !). Yes, . , !


. 'Hook'-DLL,
. , 'Module parameters' , DLL.

CoDeSys V2.3

6-27

(Custom Parameters):

/
/
/

/ , :
(Module id): . .
(Node id):
.
(Input address), (Output address), (Diagnostic
address): , .

CoDeSys V2.3

6-28

. ,
.
(Comment): .
Load module description: ,
. . *.cfg.
:
(Diagnostic address)
(M) . , .
DiagGetState
/ . , , CAN Profibus DP, : GetBusState, (, BusDiag.lib 3S - Smart Software Solutions).
. , :
BusState AT %MB12 : GetBusState;
, , . ,

DiagGetState. .
(masters), CoDeSys!
, DiagGetState CoDeSys .
DiagGetState:
ENABLE: BOOL;
DRIVERNAME: POINTER TO
STRING;
DEVICENUMBER:INT;

BUSMEMBERID:DWORD ;

ENABLE.
( ),
. 0,
.
, . ,
Hilscher 5 .
0.
(, CANopen - NodeID, PB-DP -
..).

DiagGetState:
READY:BOOL ;

TRUE:

STATE:INT;

READY = TRUE, STATE ,


:
-1:
(NDSTATE_INVALID_INPUTPARAM:INT;)
0:
(NDSTATE_NOTENABLED:INT;)

CoDeSys V2.3

6-29

EXTENDEDINFO:ARRAY[0..129] OF BYTE;

1:
(NDSTATE_GETDIAG_INFO:INT;)
2:
(NDSTATE_DIAGINFO_AVAILABLE:INT;)
3:
(NDSTATE_DIAGINFO_NOTAVAILABLE:INT;)
100 . , 0 2 :
Bit 0: .
Bit 1: .
Bit 2: .

DiagGetBusState:
, . , ( ) DiagGetBusState
. , ,
BusDiag.lib 3S - Smart Software Solutions GmbH.
.
STATE EXTENDEDINFO :
STATE:INT;

READY = TRUE, STATE


, :
BUSSTATE_BUSOK ( )
BUSSTATE_BUSFAULT ( )
BUSSTATE_BUSNOTCOMMUNICATING ( )
BUSSTATE_BUSSTOPPED ( )

EXTENDEDINFO:ARRAY[0..129]
OF BYTE;


. 3
:
Bit 0:
Bit 1:
Bit 2: ,
DiagGetState()

/ /

CoDeSys V2.3

6-30

, .
'value'.
(Index): .
(Name): .
(Value): ().
. ( ) .
' ' (Read Only), . ( ). -
, 'Open file' .
Default: .
Min.: ( ).
Max.: ( ).
.

. (Hook-DLL),
.

ID (Channel-Id): .
(Class): (I), (Q), (I&Q),
(I|Q). ,
'' ' ' ('Extras' 'Replace element').
(Size): [Byte].
. (Default identifier): .
. , .
(Comment): .

CoDeSys V2.3

6-31

Address: , . .

:
(Index), (Name), (Value), Default, Min., Max. 'Custom Parameters'.

,
CreateBitChannels=TRUE.
Comment.

Profibus
CoDeSys Profibus DP. profibus
(master) (slave). .
PROFIBUS DP .
, . . / .
CoDeSys gsd , . gsd- . , gsd ,
. .
DP ,
: (Base parameters), DP (DP Parameter),
(Bus parameters), (Module parameters).
DP DP , : (
): (Base
parameters), DP (DP Parameter), / (Input/Output), (User parameters), (Groups), (Module parameters).
"DP Parameter"
.
DP , ,
: (Base parameters), DP (DP Parameter),
/ (Input/Output), (Module parameters).

(Base parameters) DP : (Module ID), (Node ID), (Input address),
(Output address) .
Do not adapt address automatically: , . , .

(Module parameters) DP
: ,
DP, , . ,
/.

CoDeSys V2.3

6-32

DP
(DP parameters) ,
( , ):

(Manufacturer), (Revision), (ID),


(HW Release SW Release), GSD-

(Station address): 0 126. ,


(: DP 126 ).
.
. (Highest station address): (HSA), . , GAP ( , ).
(Auto Clear Mode): ,

"operate" "clear".
(Automatic Startup): ,
. .

GSD GSD .
(. ' DP' ') . Freeze "" . Sync Synch , .
Freeze Sync (
).

CoDeSys V2.3

6-33

DP /


(Bus parameters) .
(Use defaults), ,
(Baudrate), , , GSD
.
: !

DP

.
(Baud
rate)

GSD . , .


(Use defaults)

, . , .

Slot Time

Min.Station Delay min. TSDR (in tbit): , (min. 11 tBit)

CoDeSys V2.3

6-34

Max.Station Delay max. TSDR (in tbit): , .


Quiet Time

TQUI (in tbit): (idle), .

Target Rotation
Time

TTR (in tbit): ; ,


. .

Gap Update Factor GAP: ,


(
).
Max. Retry Limit

, , .

Min. Slave Interval , . GSD .


Poll Timeout

(Class 2 DP master) ( 1 ms).

Data Control Time . Data_Transfer_List.


Watchdog Time

(watchdog).
( 400 ms).

DP
(DP-Slaves) :
. (Module id), (Node number), (Input-),
(Output-) (Diagnostic address).
Do not adapt address automatically: , . , .
DP

DP
, ( , ):

CoDeSys V2.3

6-35

DP

Info

(Manufacturer), (Revision), (ID),


(HW Release SW Release), GSD- ,

(Standard parameter)

(Identnumber): , PNO . DP
GSD .
TSDR (Tbit*): Time Station Delay Responder: , ,
. (min. 11 TBit)
* TBit: PROFIBUS; ;
1 TBit 12MBaud=1/12.000.000 / = 83
Lock/Unlock: :
0: min.TSDR
1: ,
2: , ;
3:

(Station address) ( ' DP'), (Station


(Identification) name) - .

(Ac- . ,
tivation)
, .

Watchdog

- (Watchdog Control) , ( , 10 ms).


, .

GSD GSD .

CoDeSys V2.3

6-36

/ DP
/

DP .
- (Select), . (Delete). .
, Profibus
(Profibus Modul), , . , Profibus (Profibus Channel),
. , .
(Max. length of input data, Max. length of output data, Max. length
of in-/output data) (Max. number of modules) GSD. . , . .
( GSD ), -.
- (Delete).
(Properties) - ' '
(Module properties), . (Name),
. (Config) ( PROFIBUS) .
GSD ,
. (Symbolic
names) , .

CoDeSys V2.3

6-37

/ DP

DP
DP

, GSD-. (Parameters) .
(Value).
. Value range.
GSD- . (Symbolic names), .
(Length of user parameters).

CoDeSys V2.3

6-38

.
, (. . - Sync. - . . - Freeze) (. ' DP).
(Global Group Properties).
(), , "". /
(Group Membership)
' ' (Add slave to group) / ' ' (Remove slave from group) ( ).
, .
(. - Sync. Mode / .
- Freeze Mode). , .
DP
DP (. 0).
.
DP Profibus
Profibus , . ( ) :
, DP , /.

CANopen-
CoDeSys CANopen Draft
Standart 301. ,
- .
EDS (Electronic Data Sheet) DCF (Device Configuration
File), ( PLCCONF), CoDeSys. .
EDS CAN-, . ,
DCF, -, .
CAN .
'CAN ' (CAN Parameters). -

CoDeSys V2.3

6-39

PDO (Process Data Objects),


'. PDO' (Receive PDO) '. . PDO' (Send PDO-Mapping).
SDO (Service Data Objects) Service Data Objects.
CAN , , ' ' (Module parameters).
CoDeSys CANopen (CAN device), . EDS-, CANopen .
CANopen. CANopen for 3S Runtimesystems.pdf.
CAN-
, . (Module-Id), / (input/output addresses), (Diagnostic address), 0.
CAN- CAN-
CAN (Extras Properties).

(Baud rate).
PDO (Process Data Object) . , . COB-ID (Sync. COB-ID)
(Communication Object Identifier), ,
(Communication Cycle Period). PDO
(Sync. Window Length) .
. , (Communication Cycle Period) (Sync. Window Length) 0.
(activate): .
. (Node-Id): CAN- ().
1 127. . ( Node-Id Node number.)

CoDeSys V2.3

6-40

CAN
, (Automatic startup). ,
.
DSP301, V3.01 DSP306 (Support DSP301, V3.01 and DSP306),
CAN-Slave , ,
DSP301, V3.01 DSP306, . CAN
, , , , (Heartbeat Master[ms]).
(Heartbeat) (Node guarding),
, Master, Slave-. CAN-.
CAN-
CAN , (. 0).
CAN-, ,
, .
CAN
, . (Module-Id), / (input-/output addresses), (Diagnostic address),
6.6.5.
- PDO , (output address)
(input address) , PDO.
(diagnostic address) -
(M). .

CoDeSys V2.3

6-41

CAN- CAN-
CAN CAN-

General
ID (Node-Id): CAN- (). 1 127.
.
DCF (Write DCF),
DCF, EDS
, .
SDO (Create All SDOs), SDO , , .
(Reset node) (
), .
. (Optional device) ( )
, . , .
. (No initialization)
SDO. ( SDO .)
, SDO .
:
: , , !

CreateCommSDOs: SDO

CoDeSys V2.3

6-42

CreateMappingSDOs: SDO
CreateBasicSDOs: SDO (Nodeguarding, Sync .)
SDO . SDO
(Create All SDOs) .
(Node guard - Heartbeat):
(NodeGuarding),
(Guard Time) ( ). COB-ID (Guard COB-ID) (Communication Object Identifier).
, timeout. (Life Time Factor) , not OK.
, . , (Guard Time) (Life Time Factor)
0.
(Heartbeat Settings - Node
guarding):
(Activate Heartbeat generation) ,
(Heartbeat Consumer Time) ( ).
(Activate Heartbeat Consumer),
, . , /.
(Emergency Telegram):
COB-Id,
. , ,
.
(Info), EDS DCF . 3 : (FILE INFO), (DEVICE INFO) O PDO
(PDO INFO).
CAN-
(Available modules) . Add (Selected Modules).
Remove . PDO SDO .
PDO CAN-
. PDO (Receive PDO mapping) . PDO
(Send PDO mapping) PDO (PDO
mapping), EDS-.
PDO (Process
Data Object) >> PDO Remove. StandardDataTypes PDO.

CoDeSys V2.3

6-43

CAN-, PDO-

PDO (Insert PDO) PDO.


PDO . /
, .
, .
PDO , (Properties).
PDO Properties

PDO COB-Id (Communication Object Identifier).


PDO, , .
(Inhibit Time) PDO.
, PDO . ,
, PDO, , ,
.
CMS Priority Group - PDO . 0
7, 0.
(Transmission Type) :

- (acyclic-synchronous): PDO ,

- (cyclic-synchronous): PDO ,
. (Number of Sync) .

CoDeSys V2.3

6-44

.- RTR (synchronous-RTR only): PDO


, (Remote Transmission Request)

.- RTR (asynchronous-RTR only): PDO


(Remote Transmission Request)

.-. (asynchronous-device profile specific) .-. (asynchronous-manufacturer specific): PDO .

. (Number of Sync):
PDO .

(Event-Time):
.
(SDO)
(Service Data Object) , EDS DCF , 0x2000 0x9FFF. .
SDO

(Index), (Name), (Value) (Default). . <>. <Enter>, - <Esc>. SDO (Service Data Object) .
: , CANopen, -61131-3,
.

CANopen- (CANopen Slave)


, CoDeSys, CANopen Slave-
. CANopen Slave CanDevice.
CanDevice
EDS-. EDS-
CANopen .
CanDevice:
1.

a.
b.
c.

CoDeSys V2.3

3S_CanDrv.lib
3S_CanOpenManeger.lib
3S_CanOpenDevice.lib

6-45

. , CAN.
2.

*.cfg, ,
.
CanDevice. 3 : (Base settings), CAN (CAN settings), PDO . (Default PDO mapping).

CanDevice
(Base settings)

. (Bus identifier):
. (Name of updatetask): ,
CanDevice. .
- EDS (EDS file generation): , EDS-,
CAN-. EDS (Name of EDS file) . EDS EDS (Template of EDS file). , , EDS-, EDS_template.txt EDS (Template of EDS file).
, EDS- device_xy.eds , ,
, device_xy.eds ( .eds).
, .
,
(Browse)
CAN- CanDevice
CANopen, . . CANopen 3S CanOpen.lib, "CanOpen for 3S Runtimesystems".

CoDeSys V2.3

6-46

CAN (CAN settings)

ID (Node id) (1-127),


CANopen.
(Baud rate):
.
(Device Type): , 0x1000, . .
(Automatic startup): ,
CAN . , CanDevice .
(Nodeguarding) (Emergency
Telegram) (. CAN ).
- (Activate heartbeat generation),
CanDevice
(Heartbeat Producer Time) ( ) .
(Activate heartbeat consumer), CanDevice
, ID (Consumer ID).
(Heartbeat Consumer Time) ( )
, .

CoDeSys V2.3

6-47

PDO CanDevice
PDO (Default PDO mapping)

PDO, CanDevice. PDO- , CanDevice.


, , /.
: 0 , , . 0 . , .

(List of mappable objects):


, PDO CanDevice.
, Mapping, PDO CanDevice. PDO
. Variables Instance.
: Parameter Manager "Index range for
mappings", CanDevice !

(Objects). PDO PDO. PDO


PDO (Insert receive PDO) PDO
(Insert send PDO). PDO, , PDO
>>. PDO , (Properties).
Delete PDO .

CoDeSys V2.3

6-48

:
: PDO(COB-Id = 512+NodeId)
PLC_PRG.a

/ PLC_PRG.a.
Network functionality . .
PDO (Default PDO-Mapping) PDO.

DeviceNet
CoDeSys ,
DeviceNet (EN50325). DeviceNet , Plug & Play ( , .).
DeviceNet CAN (Controller Area Network).
.
DeviceNet CoDeSys DeviceNet-, .
(DeviceNet-Slave) .
DeviceNet- "UCMM" (Unconnected Message Manager
) .
DeviceNet CoDeSys
.
EDS (Electronic Data Sheet) ,
DeviceNet . CAN
".EDS", DeviceNet !
DeviceNet- ,
: , DeviceNet, .
(DeviceNet-Slave), , : , DeviceNet, -, .
DeviceNet-Master
DeviceNet . (Module id), .
(Node number), (Input address), (Output address)
(Diagnosis address). (. 0, -).
DeviceNet DeviceNet-Master
(Address) .
ID "ID " (Node-ID) CAN . ( Node number
!) , : 0-63, : 0.
(Baudrate [Baud]) . : 125000 ( ), 250000, 500000.

CoDeSys V2.3

6-49

DeviceNet DeviceNet-Master

DeviceNet-Master
(. 0. -). , .
DeviceNet-Slave
DeviceNet-Slave
(Input address) (Output address).
(. 0. -).
( ) .
DeviceNet DeviceNet-Slave
DeviceNet DeviceNet-Slave

:
(Address): DeviceNet-Slave . ID "Node-ID" CAN . ( Node number !) , : 0-63,
: 0.
(Device active in configuration):
, .

CoDeSys V2.3

6-50

(Info...): , EDS .
, CAN ".EDS",
DeviceNet !
(Expert...): (Extended settings). :

UCMM: (Unconnected Message Manager ). ( ), UCMM .


: Group1, Group2 Group3 ( ).
. Start
. , EDS : ID (Check vendor id), (Check device type), (Check product code), (Check product version).
- DeviceNet-Slave
,
( ). ,
.
./. (Selected I/O connection):
, -:
Poll: (Master-Slave-)
Bit Strobe: DeviceNet , . ,
.
Change of State:
. .
Cyclic: , ( ).
Multicast Poll: .
. (I/O complete): . (Inputbytes) . (Outputbytes).
'Inputs' 'Output'.

CoDeSys V2.3

6-51

- DeviceNet Slave

(Extended):
(More settings), :
(More settings), 'Cyclic'

(Expected Packet Rate): : 75 -


( ) .
(Fragmentation timeout)[]: 1600 . 8 , ,

CoDeSys V2.3

6-52

.
. 'Action on timeout error'.
(Action on timeout error):
:
Transition to time out: ( ) .
Auto delete: - .
Auto reset: , , .
'Change of state':
Lock time for sending: ( :1) ( )
, . . "0" ,
, .
Timeout[ms]: ( : 16) ,
.
Heartbeat rate[ms]: ( 250) ,
, .
'Bit Strobe':
Use output bit: , .
'Cyclic':
Interval [ms]: ,
().
Timeout [ms]: ,
.
Inputs ():
(Available connections)
(Configured input connections)
>> . << .
.
(Length of connection)
(Length in Bytes). .
. .
Outputs ():
, .
DeviceNet-Slave
EDS . - .

CoDeSys V2.3

6-53

(Obj.): ( ). EDS ( [Params], "Param<number>").


(Typ): .
(Acc.): : rw= , ro= .
., . (Min., Max.): , .
(Default)
(Value): , EDS . .

.
DeviceNet- Slave
(. 0.
-).


. TRUE, , .
(, "=12").
.
. OK.
, (.
).

/ /
(*.cfg ), ,
CoDeSys:

,
(Scan module
configuration).
offline.
. .

,
(Load module state).

CoDeSys V2.3

6-54

. () :
:

, .

.

,
(Show diagnosis messages).
. ,
CoDeSys.

CoDeSys V2.3

6-55

6.7 (Task Configuration)

PLC_PRG, . , .
- . , . . (
freewheeling ) , (,
).
, . , , ( ). .
: ,
.

.
( ). .
.
, System events (..
, , ) POU .

(Task Configuration) (Resources)
. 2 .

CoDeSys V2.3

6-56

(Task Configuration) .
(Task Configuration). , .
. .
, . (Task properties), (Program
call), (System events).
. . , 'Parameter' .

( ).


(Task Configuration). "", . <Enter>.
"". , .

. .

"" " " ("Insert " "Insert Task")


.

"" " " ("Insert" "Append Task")


.


("Insert" "Append Program Call").

. /, .
'Taskattributes' (. 'Insert Task'), 'Program Call' (. 'Insert
Program Call') 'System events'. . ( ).

, <>
.

(, ).

"" " " ("Insert" "Insert Task") "" " "


("Insert" "Append Task")
.
' ' (System events),
" " (Insert Task). , . (Task Configuration),
" " (Append Task) .
(. . ).

CoDeSys V2.3

6-57

. , ( cfg-).
:
(Name): .
<>.
(Priority) (0-31): ( 0 31 : 0 - , 31
)
:
(cyclic)
(Interval) (. ).

(freewheeling) : , - .
(triggered by event)
: , (Event).
(triggered by external event) : , (Event) .
.
:
(Interval) ( 'cyclic'): ,
. .
[ms] [s].
TIME (, "t#200ms").
(, "300").
(Event) ( 'triggered by event' 'triggered by external event'):
. ...
<F2>. Singleton Events. , ,
. , . : %MX1.1 %IB4 Singleton-Events, 2 (a b , c d, ):
VAR_GLOBAL
a AT %MX1.1: BOOL;
b AT %MX1.1: BOOL;
c AT %MB4: BOOL;
d AT %MD1: BOOL;
END_VAR

'Interval' 'Event' , . , CoDeSys SP NT V2.2 10 ms.


(Watchdog):
(-).
-,
, . .
(Activate watchdog): , ,
, '' (Time) (. ).

CoDeSys V2.3

6-58

:
CoDeSys SP 32 Bit Full .

'' (Time) (.: t#200ms): ;


, .
.
"%".
'' (Sensitivity): ,
. 1.
,
. 0, .
:
,
. "Parameters". .
"" " " ("Insert" "Insert Program Call") "" " " ("Insert" "Append Program Call")
.

" " (Insert Program Call)


, " " (Append Program
Call) .

(Program Call) , , Select .


, (,
prg(invar:=17)).
(
).


"", " " POU .
.
. , : , ,
.
POU . '
' '(System Events)
events) :

CoDeSys V2.3

' ' (System-

6-59

POU:

( )
, (Name) (Description). POU POU (called POU).
(<F2>) POU, (, "PLC_PRG" "PRG.ACT1"). POU,
Create POU. POU .
,
.
POU
. / .


. .
: SysTaskInfo.lib SysLibTime.lib . ,
, .
:

. , .
:
Idle

;
.

Running

Stop

CoDeSys V2.3

6-60

Stop on BP

Stop on Error

, : .

Stop
dog

Watch-

'Stop on Error' 'Stop Watchdog' .



' ' (Taskconfiguration) .

.
. :
.
(Min):

.
(last):

.
(Max):

(Cycle):

(Jitter):

s ( ).

(Reset) , 0.
( ) (Scaling)
[s/Pixel].
?
:

, , ..
.

, .

CoDeSys V2.3

6-61

, , .

,
.

PLC_PRG free-wheeling
.

'' (Extras):
"" " " ("Extras" "Set Debug Task")
. [DEBUG].
. , ,
.
'' ' / ' ('Extras' 'Enable / disable task')
. .
'' ' ' ('Extras' 'Callstack')
(Extras) . , . . < > (Callstack of task <task name>).
POU (: "prog_x (2)" prog_x).
. '' (Go To) POU.

6.8 (Watch and Recipe Manager)


,
:
(Write Recipe). ,
( (Read Recipe)). , , .

(Watch and Recipe Manager)
(Resources) .
.
.
.


, "" " " ("Insert" "New Watch List"). :
<POUName>.<Variable Name> [:= <Const>]

CoDeSys V2.3

6-62

POU Name ( ) . . .
.
:
PLC_PRG.Instance1.Instance2.Structure.Componentname
:

.global1.component1

Offline

: =.
(Write Recipe).
:
PLC_PRG.TIMER:= 50
PLC_PRG.TIMER 50.
"" " " ("Extras" "Write Recipe")
PLC.
: . : a, b, c struvar PLC_PRG.
a,b,c :
PLC_PRG.struvar.a:=<value>
PLC_PRG.struvar.b:=<value>
PLC_PRG.struvar.c:=<value>
. ,
ARRAY[0...6]:
PLC_PRG.arr_var[0]:=<value>
PLC_PRG.arr_var[1]:=<value>
...
fb, x,y fb_inst, PLC_PRG, :
PLC_PRG.fb_inst.x:=<value>
PLC_PRG.fb_inst.y:=<value>

CoDeSys V2.3

6-63

"" " " ("Insert" "New Watch List")


, .
"" " " ("Extras" "Rename Watch List")
.
"" " " ("Extras" "Save Watch List")
"*.wtc".
"" " " ("Extras" "Load Watch List")
, " " (Save
Watch List).


.
(, , ) "" . <Enter>. '' (Zoom) ' ' (Open instance).
""
" " ("Extras" "Monitoring Active").
.


"" " " ("Extras" "Write Recipe").
"" " " ("Extras" "Read Recipe") .
. , .

CoDeSys V2.3

6-64

"" " " ("Extras" "Monitoring Active")


.
, .
(. ) .
"" " " ("Extras" "Write Recipe")
.
"" " " ("Extras" "Read Recipe")
, , .
. ,


(Watch and Recipe Manager) , . " " (Write values) " "
(Force values). .

6.9 (Sampling Trace)

. (
). , .
20 .
500.
,
(, DWORD), . , 10 WORD, 5000 , 250 .

Trace) .

(Sampling

""
" " ("Extras" "Trace Configuration")
(, .).
" " (Start Trace) , , " " (Read Trace).
.
( ) (
*.trc XML *.mon) . *.tcf
. , .
: ,
(debug task).

CoDeSys V2.3

6-65


(Trace Configuration).
(Sampling
Trace) :
"" " " ("Extras" "Trace Configuration")
" " (Trace Configuration)

(Trace
Name).
:
(Variables) . (Input of trace variable) (
(Insert) <Enter>). , (Help Manager). , (Delete).
:
"" : (Trigger Variable).
(Trigger Variable) (
(Variables)).
. . .

CoDeSys V2.3

6-66

: (Trigger edge: positive), (Trigger Level) .


: (Trigger edge: negative) . (Both) . (None) .
- , " " (Stop Trace).
. (Trigger Position) , . , 25, 25% , 75% - . .
. (Sample Rate)
. . 0. .
:
(Single) . (Continuous) . , , (Number of samples) 35, 35
, 35 .
(Manual) .
(Save) .
" ".
(Load). .
. (Save) (Load) ,
.


,
. Extras.
"" " " ("Extras""Start Trace")
:
,
.
"" " " ("Extras" "Read Trace")
:
.
"" " " ("Extras" "Auto Read Trace")
, .

CoDeSys V2.3

6-67

"" " " ("Extras" "Stop Trace")


:
.




(Sampling Trace). : Var0, Var1 ..
, .

. ( PLC_PRG.a ). ,
. 8 .

("" " " - "Extras" "Start Trace")


("" " " - "Extras" "Read Trace" "" " " - "Extras" "Auto Read Trace"), . CoDeSys (State:) . "" " " ("Extras" "Stop Trace") .
, , .
Y . . , .
Var 0 - 20 +120.
, , , ,
(. ).
CoDeSys .

CoDeSys V2.3

6-68

"" " " ("Extras" "Cursor Mode")


.
.
. . , Var N, , .
"" " " ("Extras" "Cursor
Mode"). . .
, .
<Control>, 10 .
Shift .
(dy).
"" " " ("Extras" "Multi Channel")
. " " (Multi Channel) .
. 8
, . .
.
"" " " ("Extras" "Show grid")
, . , .
"" " Y" ("Extras" "Y Scaling")
Y .
( - Channel)
( maximum y scale minimum y scale).
(Automatic) , .
.

"" "" ("Extras" "Stretch")


:
. . .

CoDeSys V2.3

6-69

"" "" ("Extras" "Compress").


"" "" ("Extras" "Compress")
:
. , . .
"" "" ("Extras" "Stretch").

('Extras' 'Save trace values')



"*.trc".
" " (trace configuration) .
. : '' ' ' ('Extras' 'External Trace Configurations')
" " (Save Values)
"*.trc" .
, "" " " ("Extras" "Load Values").
" " (Load Values)
"*.trc". . " " (Save Values).
" ASCII " (Trace in ASCII file)
SCII . . .txt .
:
CoDeSys Trace
D: \CODESYS\PROJECTS\TRAFFICSIGNAL.PRO -
Cycle PLC_PRG.COUNTER PLC_PRG.LIGHT1
-
021
-
121

221
.....
,
, .
. . ,
, .

('Extras' 'External Trace Configurations')


XML, .

CoDeSys V2.3

6-70

" " (Save to file)



XML . : *.mon.
*.mon- ' ' (Load from file).
" " (Load from file)

(*.mon) XML.
. ,
' ' (Apply as project configuration).
*.mon ' ' (Save to file).
: '' ' '
('Extras' 'Save values').

' ' (Load from target)


, . .
' ' (Save to target)
XML
(*.mon). .
*.mon ' ' (Save to
file).
' ' (Apply as project configuration)
, '' (Trace),
. ''
(Trace) , ' ' (Load from file)
*.mon ( ).

6.10 (Workspace)
'' (Resources) (. 4.2,
- Project Options). (Workspace),
'' (Options), .

6.11 (Parameter Manager)



, (Network functionality)
(. 6.12).
-, , , CoDeSys. , fieldbus. .

CoDeSys V2.3

6-71

: (. 5.2.3)

?
:

, .

, , , , default
value ( ), access rights ( ), index, subindex, name (, , ),
.

.
.
?
.
, -, . .
. - . ,
.
, , , ,
, . , ,
.
,
. . . , .
-, ,
, , -.
CoDeSys

:
.

CoDeSys V2.3

6-72


(Network functionality):

(Support Parameter Manager)


(Parameter) (Variable), , ,
(Index range for mappings) - ( PDO CAN ).

.
(Parameter Manager) (Resources). , ,
.
:
.

CoDeSys

CoDeSys V2.3

6-73

.
, . ( )
, , .
,
( - Variables, - Parameters, - Template, - Instance,
- System Parameters).

. . .
.
<F6>
. . . offline .


:
(Variables): .
(Parameters): .
(System parameters): , .
.
(Template): , .

.
(Instance).
(Instance):
. ,
.
(Mappings):
, . , PDO CAN. Variables,
. Network functionality. PDO CAN-, Variable Instance
PDO Default PDO mapping PLC Configuration.
XML . , .

(Instance) , . ,
.
, , .

CoDeSys V2.3

6-74

(Template) , . ,
, . (Instance)
.
: Base POU , . .
(Apply), POU
. . (Instance).
(Insert missing entries), (Extras),
. , POU
.
. ARRAY
() .
(Synchronous actions) / POU, ,
.
(Instance): (Template). , ARRAY, , .
(Apply), POU .
(Base variable) ,
. .
(Base index) (Base subindex). POU
, / ( 0)
/ . , , 3, , 3000.
, 3003.
(Insert missing entries), (Extras), . , .
:
fudo a, b, c. PLC-PRG
inst1_fudo inst2_fudo.
inst1_fudo.a, inst1_fudo.b, inst1_fudo.c inst2_fudo.a,
inst2_fudo.b, inst2_fudo.c, .
(Template) c fudo_template. POU fudo. (Apply) a, b, c: (Index-offset): a:16#2, b:16#1, c:16#3. (Subindex-offset): a:16#2, b:16#3, c:16#4.

CoDeSys V2.3

6-75

(Instance).
fudo_template, inst1_fudo, 16#2300,
30 ( ). Apply a, b, c
(a:16#2302, b: 16#2301, c: 16#2303) (a:16#20, b:
16#21, c: 16#22).



: <Ins>
, (List) (Insert) (Insert new list) .
, .
:

CoDeSys V2.3

6-76

(Insert list)

( )
:
(Variables)
(Parameters)

- ,
(System parameters)
(Template)
(Instance)

(Mappings)


,
.
, PDO CAN.

OK, .
. ,
.
. , . (. 6.11.4.
).

, (Rename list) (Extras) . .
/ /
:<Ctrl>+<X>, <Ctrl>+<C>, <Ctrl>+<V>.
(Cut (Edit) (Cut list) ) ,
(Paste (Edit)
(Paste list) ). ,
.
(Copy (Edit) (Copy list)
) .

CoDeSys V2.3

6-77


:<Del>
(Delete) (Edit) (Delete list) ) .
: .


()
, .
, , .
(fade out). , .
. (Standard column width)
, . (Maximize width) , .

, (Insert) (Extras):
/ ( )
, (Insert line,
New line)

, (Line after,
New line after)

:<Ctrl>+<Enter>
(Delete line)

:<Shift>+<Del>
, , (Cut,
Copy, Paste line)

, ,

:
.
,
. , .
, <F2>.
<Enter>
.

CoDeSys V2.3

6-78

<Del>.
, .
/ (Format
Dec/Hex) (Extras).
<F6>.
:
:
(Download with program): .
(Synchronous actions): .

- , .
. ,
. ,
.



, , . , . ''
(Variable) '' (Parameters) .
:
(Login), Load with project.

Index Subindex
RefID Offset.

, (Extras):

(Delete list)


(Write list)

, , . OK.
.


(Read list)

Parameter
. 'Variables' , .

CoDeSys V2.3

6-79

, .

(Write values)

Value
. ,
. Write
value.



(Write default values)

,
Default.

(Apply values)


Value


/ (Format Dec/Hex).


.

/
'' '' ('Extras' 'Export')
, XML-.
.
*. prm.
( Project Export).
'' '' ('Extras' 'Import')
XML-. .
XML- , , , .

6.12 (Target Settings)


" " (Target Settings) "" (Resources) . , ()
, .
( '' '' - 'File' 'New') . (Target Support Packages: TSP). .
" " (Target Settings).
: TSP ,
: 'None'. . .

CoDeSys V2.3

6-80

TSP
TSP . InstallTarget, CoDeSys. .
TSP , CoDeSys , . , , , -. , TSP , , ini- -.
TSP (Target files).
,
. *.trg. ,
.
" " (Target Settings) CoDeSys.
TSP
. . *.tnf . . , .
CoDeSys. CoDeSys .
: ,
CoDeSys .


(Target Settings) . , " " (Target Settings) '' (Resources) .
, (Configuration).
, , CoDeSys
.
. .
(Hide Settings). :
1. (Target Platform).
2. (Memory Layout).
3. (General).
4. (Network functionality).
5. (Visualization).
: , !

<Default>, .

CoDeSys V2.3

6-81

6.13 - (PLC-Browser)

- - (). . . . CoDeSys ,
. ini , .
PLC-Browser (Resources) , ( 'General').
CoDeSys - (PLC Browser)

- . . . .
<Enter> . , , . .

-
- 3S, .
. ini ,
. ini .
- ini .

" " (Insert standard command) <F2>. ''
' ' ('Insert' 'Standard commands'). , .
:
<><><>

CoDeSys V2.3

6-82

.
.
: (Id) "pid":
pid.....
:
pid
Project-ID: 16#0025CFDA
: : ?<><>.
ini . .

3S PLC-Browser:

. , .

mem

Hex
1: mem <start address> <end address>
2: mem <start address>-<end address>
, ( 16#) .

memc

Hex ; mem,

memd

Hex ; mem,

reflect

( )

dpt

ppt

POU

pid

Id

pinf

tsk

IEC

startprg

stopprg

resetprg

. .

resetprgcold

resetprgorg

. ..

reload

getprgprop

getprgstat

filedir

"dir"

CoDeSys V2.3

6-83

filecopy

[from] [to]

filerename

[old] [new]

filedelete

[filename]

saveretain

(retain)

restoreretain

(retain)

setpwd


: setpwd <password> [level]
<level> "0" ( ) "1"

delpwd

(<KEYWORD>).

,
'Keyword not found'.
( ? mem"),
ini-.
.

-
, . .
s: <><>
::
%P<NAME> NAME POU, <POU-Index>,

%V<NAME> NAME , #<INDEX>:<OFFSET>, ( #<INDEX>:<OFFSET> )
%T<NAME> NAME , <VARIABLENTYP>,

%S<NAME> NAME , <SIZEOF(VAR)>,

\ % .
, : \\.
:
( .testit):
mem %V.testit
:
mem #4:52

CoDeSys V2.3

6-84

03BAAA24 00 00 00 00 CD CD CD CD ....

-
'' (Extras) - :
(History forward )

(History

backward)
.
.
(Cancel command)

(Save history list)



*.bhl. (Browser History List). (Print last command) .
.

CoDeSys V2.3

6-85

6.14 (Tools)
(Tools) (Resources) , . ( ) (shortcuts), CoDeSys . , (, Acrobat Reader notepad.exe) . - .
(Tools).
Tools

4 .
CoDeSys.
. PDF-. , "<R>" CoDeSys. , ,
PDF-.
, .

(Object Properties)
(Tools), , "".
, . CoDeSys.
, .
1. (Tool Properties):
(Tools) , ' ' (Object Properties). ' ' (Tool Properties).
. : Id , (Name of the shortcut) () ,
(Name of the executable file). (Advanced) .

CoDeSys V2.3

6-86

,
. (Directory) ,
. (Apply), .
:

(FixedCount):


(Tools). "0", .
: , "fix"
, CoDeSys. "<R>"
.

Exe- (Exe-Name):

.
: "[ ] <, exe->".
, Windows .
.
: "C:\program\notapad.exe", "345.pdf"


(DefaultName):

.
$(INSTANCE NUMBER) (.
(Parameter Template)).

, :

(Parameter Tem$(PROJECT_NAME) ( plate):
*.pro").
$(PROJECT_PATH) ( ).
$(PROJECT_DRIVE) .
$(COMPILE_DIR) ( ).
$(TOOL_EXE_NAME) exe- .
$(DISPLAY_NAME) , (Tools).
$(INSTANCE_NUMBER) ( "1")

CoDeSys V2.3

6-87

$(CODESYS_EXE_DIR) , Codesys
exe- ( ).
(Shortcut Properties) (. )
:
"$(PROJECT_NAME)_$(INSTANCE_NUMBER).cfg"
cfg-, <
CoDeSys>_< >.cfg.


(DownloadFile
Templates):

, , . (Editable),
. , ,
codesys-exe .
:
"a.up;$(PROJECT_NAME).zaw;$(INSTANCE_NUMBER).upp"
: a.up, <current CoDeSys Projekt>.pro <shortcut number>.upp
.

2. (Shortcut Properties):
(Tools)
' ' (Object Properties) ''
'' ('Project' 'Object'). (Shortcut Properties) :
;
( ) (
(Com (Parameter Template), . )
mandline)
..: C:\programs\notepad.exe D:\listings\textfile.txt

(Parameter)

(Files to be
downloaded)

(, ). , (Editable).
, (target)
DownloadFileTemplate (. ). (Editable), (. ) . New. 'Filename'.
, , codesys-exe . Delete .

(Defaults) , .. , .
(Apply) , .
(Advanced) '. ' (Advanced Properties), :

CoDeSys V2.3

6-88

'. ' (Advanced Properties):

, 1.
. ,
(Shortcut Number):
. : $(INSTANCE_NUMBER) (. (Parameter
Template)).
,
ID
.
(Tool ID):
.
.
"FixedCount" (. ' ' (Tool Proper(Default Number of
ties)).
Shortcuts):

(Editable):

, .

OK .



(Tools)
' ' (Add Object)
'' '' ('Project' 'Object'). ' ' (Create Shortcut), .
, . : ID ,
(Name of the shortcut) - , (Name of the executable file).

CoDeSys V2.3

6-89

, (ID). , ( (Name of the shortcut)). .


'Create Shortcut'

OK. . , , .
, .

'' (Delete)
'' '' ('Project' 'Object'). . .

( ) ' - ' (Open Object) ( ).
, . , exe- .
exe- ,
. OK CoDeSys
.

CoDeSys (Tools)
.
: ' ' (Save as) ,
, $(PROJECT_NAME) .
.


(Tools) ?

CoDeSys V2.3

6-90

, .
,
CoDeSys?
(Tools) '' (Resources) .
"". ,
. , , .
. , ' ' (Add Object). , , .
?
(Tools) '
' (Object Properties) ( ).
, '' (Advanced).
. (ID), , , (shortcuts) ( (FixedCount))
. . (.
).
?

(Tools) ' ' (Object Properties) ( ).


'' (Advanced).
.
( ), , .
?

(Tools) '
' (Add Object) ( ). , , .
OK.
'Tools' . ,
. , Toolxy "Toolxy_1",
"Toolxy_2" ..
?

( )
' ' (Object
Properties) .
. 'Standard' .
?

( ) 'Open Object' .

CoDeSys V2.3

6-91

7 ENI
7.1 ENI?
ENI (Engineering Interface) CoDeSys . , .
, , . ,
CoDeSys, :

: CoDeSys ( ). , ()
, () .
.
. .

: , POU
, . ,
, " "
. , .

: CoDeSys,
, ENI, .
, ECAD , ( . ENI Server).

ENI : . ,
, .
CoDeSys , .
ENI 'Visual SourceSafe 6.0', 'MKS Source Intergrity',
'PVCS Version Manager' V7.5 ,
. ( )
. . ,
, , .

7.2 ENI
: ENI , 3S Smart Software Solutions GmbH, .
. , ENI Explorer, .

ENI CoDeSys , , :
CoDeSys ENI TCP/IP, ENI
HTTP.

ENI

ENI (ENI Server Suite) .


. .
ENI (ENI Control) (Data base).
, ENI Control.
( ) . , ENI .
. .
ENI . 'Visual SourceSafe' . .
CoDeSys ENI (
'' '' ' ' - 'Project' 'Options' 'Database-connection').
, ENI, ,
. , , , .
CoDeSys
. ( '' '' ' ' - 'Project' 'Options'
'Database-connection').
(log in to the ENI Server) . Login
'' ' ' '' ('Project' 'Project Data Base' 'Login')
.

7.3 ENI CoDeSys


(. ENI ), : (Get Latest Version), (Check Out), (Check In),
(Show Version History), (Label Version) ..
'Data Base Link' , .
(Object Properties) .
( , ) ('' '' ' ' 'Project' 'Options' 'Database-connection').

7.4
4 CoDeSys :
ENI (" ENI"):
(Project objects), (Shared objects),
(Compile files).

CoDeSys V2.3

7-2

ENI

, '' (Local), .
, , .
, CoDeSys : '' (Project objects), ' ' (Shared objects) '' (Local). , 'Compile files' .
, , ' ' - 'Project' 'Options' 'Database-connection', '' ' ' '' ('Project' 'Project Data Base' 'Define')
' ' (Multiple Define).
(Object Properties).
ENI ' ' (Databaseconnection) ('Project' 'Options'). , (, , .)
.
. ( ) . - , .
ENI :
(Project
Objects):

, () , POU,
. 'Get all latest versions' , , .

- , , (Shared Ob- POU, .


: ' ' (Get all Latest Versions)
jects):

.
Compile files:

(.. ) CoDeSys
, .
:
, , .

CoDeSys '' (Local). ,


, , ENI.

CoDeSys V2.3

7-3

8 DDE
CoDeSys DDE
CoDeSys Windows ,
(DDE).
GatewayDDEServer, CoDeSys .
: DDE . , .
DDE Word 97 Excel 97 Windows NT 4.0. DDE , 3S- Smart Software Solutions
.

8.1 DDE CoDeSys


DDE
DDE , .

DDE 3 :
1. (CoDeSys).
2. .
3. .
: CoDeSys.
: (c:\example\example.pro).
: , , .
?
. :
%IX1.4.1
PLC_PRG.TEST
.GlobVar1

(* 1.4.1*)
(* TEST PLC_PRG*)
(* GlobVar1 *)

WORD
TEST POU PLC_PRG DDE Microsoft WORD,
("", ",,,").
:
{DDEAUTO CODESYS "C:\\CODESYS\\PROJECT\\IFMBSP.PRO" "PLC_PRG.TEST"}
. , Word
" ".

DDE

: Word , 6,0 DDEAUTO. , DDE . (, DATE). (


"/ "). {} , . .

EXCEL
EXCEL, ,
=CODESYS|'C:\CODESYS\PROJECT\IFMBSP.PRO'!PLC_PRG.TEST'
"", "" :
: C:\CODESYS\PROJECT\IFMBSP.PRO:
:

PLC_PRG.TEST

CODESYS

.
Intouch
DDE Access Name <AccessName>, CoDeSys DDE
(topic name) C:\CODESYS\PROJECT\IFMBSP.PRO
DDE <AccessName>.
Item Name (, PLC_PRG.TEST).

8.2 DDE GatewayDDE Server


GatewayDDE
GatewayDDE , CoDeSys
(. '' '' ' ' - 'Project' 'Options' 'Symbol
configuration').
GatewayDDE , .
.
GatewayDDE Server

'File' 'Open' .
.cfg. .

CoDeSys V2.3

8-2

DDE

'File' 'Autoload' , , .
, .
'File' 'Settings' 'Server settings',
:
GatewayDDE Server

Motorola byteorder: Motorola


Check identity: (ID) .
Updaterate [ms]: .
Timeout [ms]: .
Tries: ( !)
'Communication Parameters'
'' 'Parameters'. , CoDeSys.
'File' 'Save'
'' 'Login'. , DDE .
CoDeSys..
'' 'Login' .
DDE
DDE CoDeSys.
: GATEWAYDDESERVER
Word , , :
{DDEAUTO GATEWAYDDESERVER "BSP.PRO" "PLC_PRG.TEST"}
EXCEL TEST :
=GATEWAYDDESERVER|'bsp.pro'!'PLC_PRG.TEST'

CoDeSys V2.3

8-3

DDE

GatewayDDE Server
GatewayDDE :
/n
/s

/c
/o



/s=h
/s=i
/s=m
/s=n
/c=<config-file>
( 1)

:
GATEWAYDDE /s=i /c="D:\DDE\conf_1.cfg"
, conf_1.cfg.

CoDeSys V2.3

8-4

CoDeSys

9.1
3S 3S, ,
. CoDeSys . 3S,
.
. : 3S Licensing Manager
.

9.2 CoDeSys
CoDeSys . ,
, (license
information). '' ' ' ('File' 'Save as...'), ' ' (Internal Library) ' ' (External Library)
'' (Edit license info...). ' ' (Edit Licensing Information) , . (Project Info).
CoDeSys, .
: ' ' (Edit Licensing Information)

(General information):

(Name): , . .

CoDeSys

ID (Vendor-ID): , .
(License free mode): , , . (days),
. (10, 20, 30 ...). ,
unlimited, .
(Targets): (ID) , . .

(Contact):

(Licensing via phone): / (Licensing per


via mail): e-mail . .

(Optional information):

,
: (Description), (Manufacturer), (Vendor),
(Pricing information).
: ,
.
3S , . XML . . 3S License
Manager.

CoDeSys V2.3

9-2

10
A:
CoDeSys . (.
D, ) .
CoDeSys , : INDEXOF SIZEOF (. ), ADR BITADR (. ).
, .
(ADD) ST +.
: .

10.1
ADD
: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT,
REAL LREAL.
TIME (. t#45s + t#50s = t#1m35s).
TIME.
IL:
LD

ADD 2,4,7
ST

Var 1

ST:
var1 := 7+2+4+7;
FBD:

MUL
: BYTE, WORD, DWORD, SINT, USINT, INT, UINT,
DINT, UDINT, REAL LREAL.
IL:

A:

LD

MUL 2,4,7
ST

Var 1

ST:
var1 := 7*2*4*7;
FBD:

SUB
: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL LREAL.
TIME TIME. .
IL:
LD

SUB

ST

Var 1

ST:
var1 := 7-2;
FBD:

DIV
: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL LREAL.
IL:
LD

DIV

ST

Var 1

(* 4 *)

ST:
var1 := 7-2;
FBD:

: CheckDivByte, CheckDivWord, CheckDivDWord


CheckDivReal , , 0.
: 0 .

CoDeSys V2.3

10-2

A:

CheckDivReal.
CheckDivReal:
FUNCTION CheckDivReal : REAL
VAR_INPUT
divisor:REAL;
END_VAR

IF divisor = 0 THEN
CheckDivReal := 1;
ELSE
CheckDivReal:=divisor;
END_IF;

DIV CheckDivReal .
0, (d) 0 1. 799.
PROGRAM PLC_PRG
VAR
erg:REAL;
v1:REAL := 799;
d:REAL;
END_VAR

erg:= v1 / d;
: CheckDiv-, Check.Lib, . , , ,
, .

MOD
: BYTE, WORD, DWORD, SINT, USINT, INT,
UINT, DINT, UDINT. .
IL:
LD

MOD 2
ST

Var 1 (* 1 *)

ST:
var1 := 9 MOD 2;
FBD:

CoDeSys V2.3

10-3

A:

MOVE
.
CFC LD ( ) EN/EN0. FBD .
EN/EN0 CFC:
en_i TRUE, var1 var2.

IL:
LD ivar1
MOVE ivar2
ST ivar2
(! :
LD ivar1
ST ivar2 )
ST:
ivar2 := MOVE(ivar1);
( ! : ivar2 := ivar1; )

10.2
AND
. BOOL, BYTE, WORD DWORD.
IL:
Var1 BYTE
LD

2#1001_0011

AND 2#1000_1010
ST

Var 1

(* 2#1000_0010 *)

ST:
var1 := 2#1001_0011 AND 2#1000_1010
FBD:

: . , SFS :

CoDeSys V2.3

10-4

A:

, z .
. x y FALSE,
.

OR
. BOOL, BYTE, WORD DWORD.
IL:
var1 :BYTE;
LD

2#1001_0011

OR

2#1000_1010

ST

var1

(* 2#1001_1011 *)

ST:
Var1 := 2#1001_0011 OR 2#1000_1010
FBD:

: . AND.

XOR
. BOOL, BYTE, WORD DWORD.
IL:
Var1 :BYTE;
LD

2#1001_0011

XOR 2#1000_1010
ST

Var1

(* 2#0001_1001 *)

ST:
Var1 := 2#1001_0011 XOR 2#1000_1010
FBD:

: , .. XOR . , XOR.
.

NOT
. BOOL, BYTE, WORD DWORD.
IL:
Var1 :BYTE;
LD

2#1001_0011

NOT
ST

CoDeSys V2.3

Var1

(* 2#0110_1100 *)

10-5

A:

ST:
Var1 := NOT 2#1001_0011
FBD:

10.3
: , , !
. (. ST ). ,
.

SHL
res:=SHL(in,n) in n .
BYTE, WORD DWORD.
res_byte res_word
(BYTE WORD), .
ST:
PROGRAM shl_st
VAR
in_byte:BYTE:=16#45;
in_word:WORD:=16#45;
res_byte:BYTE;
res_word:WORD;
n:BYTE:=2;
END_VAR

res_byte:=SHL(in_byte,n);

(* 16#14 *)

res_word:=SHL(in_word,n);

(* 16#0114 *)

FBD:

IL:
LD

16#45

SHL

ST

res_byte

SHR
res:= SHR(in,n) in n .
BYTE, WORD DWORD.

CoDeSys V2.3

10-6

A:

(. ):
ST:
PROGRAM shr_st
VAR
in_byte:BYTE:=16#45;
in_word:WORD:=16#45;
res_byte:BYTE;
res_word:WORD;
n:BYTE:=2;
END_VAR
res_byte:=SHR(in_byte,n);

(* 16#11 *)

res_word:=SHR(in_word,n);

(* 16#0011 *)

FBD:

IL:
LD

16#45

SHR

ST

res_byte

ROL
res:=ROL(in,n) in n , . BYTE, WORD
DWORD.
res_byte res_word
(BYTE WORD), .
ST:
PROGRAM rol_st
VAR
in_byte:BYTE:=16#45;
in_word:WORD:=16#45;
res_byte:BYTE;
res_word:WORD;
n:BYTE:=2;
END_VAR
res_byte:=ROL(in_byte,n);

(* 16#15 *)

res_word:=ROL(in_word,n);

(* 16#0114 *)

FBD:

CoDeSys V2.3

10-7

A:

IL:
LD

16#45

ROL

ST

res_byte

ROR
res:=ROR(in,n) in n ,
. BYTE, WORD
DWORD.
(.
):
ST:
PROGRAM ror_st
VAR
in_byte:BYTE:=16#45;
in_word:WORD:=16#45;
res_byte:BYTE;
res_word:WORD;
n:BYTE:=2;
END_VAR

res_byte:=ROR(in_byte,n);

(* 16#51 *)

res_word:=ROR(in_word,n);

(* 16#4011 *)

FBD:

IL:
LD

16#45

ROR

ST

res_byte

10.4
. .

SEL
.
OUT:= SEL(G, IN0, IN1)
OUT:= IN0 G=FALSE;
OUT:= IN1 G=TRUE.
IN0, IN1 OUT , G BOOL.
: IN0, G , IN1, G .

CoDeSys V2.3

10-8

A:

IL:
LD

FALSE

SEL

3,4

ST

Var1

(* - 3 *)

FBD:

: , IN0 IN1 , , G.

MAX
.
OUT := MAX(IN0, IN1)
IN0, IN1 OUT .
IL:
LD

90

MAX 30
MAX 40
MAX 77
ST

Var1

(* - 90 *)

FBD:

MIN
.
OUT := MIN(IN0, IN1)
IN0, IN1 OUT .
IL:
LD

90

MIN

30

MIN

40

MIN

77

ST

Var1

(* 30 *)

FBD:

CoDeSys V2.3

10-9

A:

LIMIT

OUT := LIMIT(Min, IN, Max) :


OUT := MIN (MAX (IN, Min), Max)
Max Min . IN
, Max Min.
IN OUT .
IL:
LD

90

LIMIT 30,80
ST

Var 1

(* - 80 *)

MUX
. K- .
OUT := MUX(K, IN0,...,INn) :
OUT := INK.
IN0, ...,INn OUT . K BYTE, WORD, DWORD,
SINT, USINT, INT, UINT, DINT UDINT.
IL:
LD

MUX 30,40,50,60,70,80
ST

Var 1

(* - 30 *)

: , , , . .

10.5
GT

TRUE, .
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME STRING.
IL:
LD

20

GT

30

ST

Var 1

(* - *)

ST:
VAR1 := 20 > 30 > 40 > 50 > 60 > 70;
FBD:

CoDeSys V2.3

10-10

A:

LT

TRUE, .
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME STRING.
IL:
LD

20

LT

30

ST

Var 1

(* - *)

ST:
VAR1 := 20 < 30;
FBD:

LE

TRUE,
.
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME STRING.
IL:
LD

20

LE

30

ST

Var 1

(* - *)

ST:
VAR1 := 20 <= 30;
FBD:

GE

TRUE,
.
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME STRING.

CoDeSys V2.3

10-11

A:

IL:
LD

60

GE

40

ST

Var 1

(* - *)

ST:
VAR1 := 60 >= 40;
FBD:

EQ

TRUE, .
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME STRING.
IL:
LD

40

EQ

40

ST

Var 1

(* - *)

ST:
VAR1 := 40 = 40;
FBD:

NE

TRUE, .
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT,
UDINT, REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME STRING.
IL:
LD

40

NE

40

ST

Var 1

(* - FALSE*)

ST:
VAR1 := 40 <> 40;
FBD:

CoDeSys V2.3

10-12

A:

10.6
: , . , .
.

ADR

ADR DWORD.
.
IL:
LD

Var 1

ADR
ST

Var 2

man_fun1
ADRINST
ADRINST
DWORD. ,
.
ST ( ):
dvar:=ADRINST(); (* dvar *)
fun(a:=ADRINST()); (* *)
IL:
ADRINST
ST dvar
ADRINST
fun
BITADR
BITADR DWORD .
, .
VAR
var1 AT %IX2.3:BOOL;
bitoffset: DWORD;
END_VAR
ST:
Bitoffset := BITADR(var1); (* 19, byte addressing=TRUE, 35,
byte addressing=FALSE*)
IL:
LD Var1
BITADR

CoDeSys V2.3

10-13

A:

ST Var2

(content)
"^"
.
ST:
pt:POINTER TO INT;
var_int1:INT;
var_int2:INT;
pt := ADR(var_int1);
var_int2:=pt^;

10.7
INDEXOF
POU.
ST:
var1 := INDEXOF(POU2);
SIZEOF
.
IL:
arr1:ARRAY[0..4] OF INT;
Var1 INT
LD

arr1

SIZEOF
ST

Var 1

(* 10 *)

ST:
var1 := SIZEOF(arr1);

TIME
TIME TIME.
IL:
TIME
ST systime (*, .: T#35m11s342ms *)
ST:
systime:=TIME();

CoDeSys V2.3

10-14

A:

FBD:

INI
INI retain , .
: <bool-Variable> := INI(<FB-instance, TRUE|FALSE)
TRUE, , FB, .
ST: fbinst fb, retain
retvar.
:
fbinst:fb;
b:bool;
:
b := INI(fbinst, TRUE);
ivar:=fbinst.retvar (* => retvar *)
IL:
LD fbinst
INI TRUE
ST b
FBD:

10.8
CAL
.
IL ,
.
: Inst, Par1 Par2
0 TRUE .
CAL INST(PAR1 := 0, PAR2 := TRUE)

10.9
(,
INT BYTE DINT WORD). ,
.
.

CoDeSys V2.3

10-15

A:

:
<.1>_TO_<..2>
_TO_STRING .
, .
BOOL_TO
BOOL :
1, TRUE, 0, FALSE.
STRING - TRUE FALSE.
IL:
LD

TRUE

BOOL_TO_INT
ST

LD

TRUE

(*: 1 *)

BOOL_TO_STRING
ST

str

LD

TRUE

(*: 'TRUE' *)

BOOL_TO_TIME
ST

LD

TRUE

(*: T#1ms *)

BOOL_TO_TOD
ST

LD

(*: TOD#00:00:00.001 *)

FALSE

BOOL_TO_DATE
ST

dat

LD

TRUE

(*: D#1970-01-01 *)

BOOL_TO_DT
ST

dandt

(*:DT#1970-01-01-00:00:01 *)

ST:
i:=BOOL_TO_INT(TRUE);

(* :1 *)

str:=BOOL_TO_STRING(TRUE);

(* :"TRUE" *)

t:=BOOL_TO_TIME(TRUE);

(* :T#1ms *)

tof:=BOOL_TO_TOD(TRUE);

(* :TOD#00:00:00.001 *)

dat:=BOOL_TO_DATE(FALSE);

(* :D#1970 *)

dandt:=BOOL_TO_DT(TRUE);

(* :DT#1970-01-01-00:00:01 *)

FBD:

CoDeSys V2.3

10-16

A:

(*: 1 *)

(*: 'TRUE' *)

(*: T#1ms *)

(*: TOD#00:00:00.001 *)

(*: D#1970-01-01 *)

(*: DT#1970-01-01-00:00:01 *)
TO_BOOL
BOOL:
TRUE, , FALSE.
STRING, "TRUE", TRUE, FALSE.
IL:
LD

213

BYTE_TO_BOOL
ST

LD

(*: TRUE *)

INT_TO_BOOL
ST

LD

T#5ms

(*: FALSE *)

TIME_TO_BOOL
ST

LD

'TRUE'

(*: TRUE *)

STRING_TO_BOOL
ST

(*: TRUE *)

ST:

b := BYTE_TO_BOOL(2#11010101);

(* : TRUE *)

b := INT_TO_BOOL(0);

(* : FALSE *)

b := TIME_TO_BOOL(T#5ms);

(* : TRUE *)

b := STRING_TO_BOOL('TRUE');

(* : TRUE *)

FBD:

CoDeSys V2.3

10-17

A:

(*: TRUE *)

(*: FALSE *)

(*: TRUE *)

(*: TRUE *)

:
, .
, .
ST:
si := INT_TO_SINT(4223);

(* : 127 *)

4223 (16#107F ) SINT,


, 127 (16#7F ).
IL:
LD

INT_TO_REAL
MUL 3.5
FBD:

REAL_TO-/ LREAL_TO
REAL LREAL :
.
STRING, BOOL, REAL LREAL. ,
.
STRING 16 .
, .
ST:
i := REAL_TO_INT(1.5);

(* : 2 *)

j := REAL_TO_INT(1.4);

(* : 1 *)

i := REAL_TO_INT(-1.5);

(* : -2 *)

j := REAL_TO_INT(-1.4);

(* : -1 *)

IL:
LD

2.7

REAL_TO_INT
GE

%MW8

FBD:

CoDeSys V2.3

10-18

A:

TIME_TO/TIME_OF_DAY
TIME TIME_OF_DAY :
DWORD,
( 0 TIME_OF_DAY).
. , .
STRING .
IL:
LD

T#12ms

TIME_TO_STRING
ST

str

LD

T#300000ms

(*: 'T#12ms' *)

TIME_TO_DWORD
ST

dw

LD

TOD#00:00:00.012

(*: 300000 *)

TOD_TO_SINT
ST

si

(*: 12 *)

ST:
str :=TIME_TO_STRING(T#12ms);

(* : T#12ms *)

dw:=TIME_TO_DWORD(T#5m);

(* : 300000 *)

si:=TOD_TO_SINT(TOD#00:00:00.012); (* : 12 *)
FBD:

DATE_TO/DT_TO
DATE DATE_AND_TIME :
DWORD,
1 1970 . .
.
STRING .
IL:

CoDeSys V2.3

10-19

A:

LD D#1970-01-01

(* FALSE *)

DATE_TO_BOOL
ST b

LD D#1970-01-15

(* 29952 *)

DATE_TO_INT
ST i

LD DT#1970-01-15-05:05:05

(* 129 *)

DT_TO_BYTE
ST byt

LD DT#1998-02-13-14:20

(* 'DT#1998-02-13-14:20' *)

DT_TO STRING
ST str

ST:
b :=DATE_TO_BOOL(D#1970-01-01);

(* : FALSE *)

i :=DATE_TO_INT(D#1970-01-15);

(* : 29952 *)

byt :=DT_TO_BYTE(DT#1970-01-15-05:05:05);

(* : 129 *)

str:=DT_TO_STRING(DT#1998-02-13-14:20);

(*:'DT#1998-02-13-14:20'

*)
FBD:

STRING_TO
STRING :
,
0.

CoDeSys V2.3

10-20

A:

IL:
LD 'TRUE'

(*: TRUE *)

STRING_TO_BOOL
ST b

LD 'abc34'

(*: 0 *)

STRING_TO_WORD
ST w
LD 't#127ms'

(*: T#127ms *)

STRING_TO_TIME
ST t
ST:
b :=STRING_TO_BOOL('TRUE');

(* : TRUE *)

w :=STRING_TO_WORD('abc34');

(* : 0 *)

t :=STRING_TO_TIME('T#127ms');

(* : T#127ms *)

FBD:

TRUNC
REAL INT. .
.
ST:
i:=TRUNC(1.9);

(* : 1 *)

i:=TRUNC(-1.4);

(* : 1 *)

LD

2.7

TRUNC
GE

CoDeSys V2.3

%MW8

10-21

A:

10.10
ABS
. , ABS(-2) 2.
:

INT

INT, REAL, WORD, DWORD, DINT

REAL

REAL

BYTE

INT, REAL, BYTE, WORD, DWORD, DINT

WORD

INT, REAL, WORD, DWORD, DINT

DWORD

REAL, DWORD, DINT

SINT

REAL

USINT

REAL

UINT

INT, REAL, WORD, DWORD, DINT, UDINT, UINT

DINT

REAL, DWORD, DINT

UDINT

REAL, DWORD, DINT, UDINT

IL:
LD

ABS
ST

(*: 2 *)

ST:
i:=ABS(-2);
FBD:

SQRT
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL.
IL:
LD

16

SQRT
ST

(*: 4 *)

ST:
q:=SQRT(16);
FBD:

LN
.

CoDeSys V2.3

10-22

A:

BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,


UDINT, REAL.
IL:
LD

45

LN
ST

(*: 3.80666 *)

ST:
q:=LN(45);
FBD:

LOG
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL.
IL:
LD

314.5

LOG
ST

(*: 2.49762 *)

ST:
q:=LOG(314.5);
FBD:

EXP
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL.
IL:
LD

EXP
ST

(*: 9.7448e+009 *)

ST:
q:=EXP(2);
FBD:

SIN
.

CoDeSys V2.3

10-23

A:

BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,


UDINT, REAL. .
IL:
LD

0.5

SIN
ST

(*: 0.479426 *)

ST:
q:=SIN(0.5);
FBD:

COS
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL. .
IL:
LD

0.5

COS
ST

(*: 0.877583 *)

ST:
q:=COS(0.5);
FBD:

TAN
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL. .
IL:
LD

0.5

TAN
ST

(*: 0.546302 *)

ST:
q:=TAN(0.5);
FBD:

ASIN
.

CoDeSys V2.3

10-24

A:

BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,


UDINT, REAL.
IL:
LD

0.5

ASIN
ST

(*: 0.523599 *)

ST:
q:=ASIN(0.5);
FBD:

ACOS
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL.
IL:
LD

0.5

ABS
ST

q (*: 1.0472 *)

ST:
q:=ACOS(0.5);
FBD:

ATAN
.
BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, REAL.
IL:
LD

0.5

ABS
ST

q (*: 0.463648 *)

ST:
q := ATAN(0.5);
FBD:

EXPT
:
OUT = IN1IN2.

CoDeSys V2.3

10-25

A:

IN1 IN2 BYTE, WORD, DWORD, INT, DINT, REAL, SINT, USINT, UINT,
UDINT, OUT REAL.
IL:
LD

EXPT 2
ST

var1 (*: 49 *)

ST:
var1 := EXPT(7,2);
FBD:

CoDeSys V2.3

10-26

: CoDeSys

: CoDeSys
, .

BOOL
BOOL TRUE FALSE.
TIME
TIME CoDeSys "t" "T" ( "time"
"TIME") "#". , "d",
"h", "m", "s" "ms". , (d, h, m, s, m, ms).
TIME ST:
TIME1 := T#14ms;
TIME1 := T#100S12ms; (* *)
TIME1 := t#12h34m15s;
:
TIME1 := t#5m68s;

(* *)

TIME1 := 15ms;

(*T# *)

TIME1 := t#4ms13d;

(* *)

DATE
DATE "d", "D", "DATE" "date" "#".
--.
:
DATE#1996-05-06
d#1972-03-29
. 10.14 DATE
TIME_OF_DAY
A TIME_OF_DAY "tod#", "TOD#", "TIME_OF_DAY#"
"time_of_day#" : ::.
.
:
TIME_OF_DAY#15:36:30.123
tod#00:00:00
DATE_AND_TIME
DATE_AND_TIME "dt#", "DT#", "DATE_AND_TIME#"
"date_and_time#". .
:
DATE_AND_TIME#1996-05-06-15:36:30
dt#1972-03-29-00:00:00

CoDeSys V2.3

10-27

: CoDeSys

, , .
, # .
10-15 A-F.
.
:
14

(* *)

2#1001_0011

(* *)

8#67

(* *)

16#A

(* *)

BYTE, WORD, DWORD, SINT, USINT, INT,


UINT, DINT, UDINT, REAL LREAL. "" ""
. , DINT INT , (. ).
REAL/LREAL
REAL LREAL . .
:
7.4 7,4
1.64e+009 1,64e+009
STRING
STRING , . (, ). ,
, ,
($). ,
, :
$$

$'

$L $l

Line feed

$N or $n

New line

$P or $p

Page feed

$R or $r

Line break

$T or $t

Tab

:
' '
' Abby and Craig '
':-)'


. , : <Type>#<Literal>

CoDeSys V2.3

10-28

: CoDeSys
<Type> . : BOOL, SINT, USINT, BYTE, INT, UINT,
WORD, DINT, UDINT, DWORD, REAL, LREAL. .
<Literal> .
:
var1:=DINT#34;
, CoDeSys
.

POU,
- .
: . POU,
, . (, ).

() , .
, , VAR1, Var1 var1 - .
, .. "A_BCD" "AB_CD" - .
. .
.
CoDeSys (Input Assistant).

- , PLC.
"" ""
("Insert" "Operand"). " " (Input Assistant)
System Variable.
, POU
:
<>[1, 2]
:
<>.<>
:
<>.<>

.
, 0 .
a : INT;
b : BOOL;
...
a.2 := b;

CoDeSys V2.3

10-29

: CoDeSys
a b.
, : Index
'<n>' outside the valid range for variable '<var>'
:SINT, INT, DINT, USINT, UINT, UDINT, BYTE, WORD,
DWORD.
, CoDeSys :
Invalid data type '<type>' for direct indexing
VAR_IN_OUT!

,
. , :

VAR_CONSTANT GLOBAL
enable:int := 1;
END_VAR
1, :
POU:
VAR
xxx:int;
END_VAR
:
xxx.enable := true; (* xxx *)
2, :
stru1:
TYPE stru1 :
STRUCT
bvar: BOOL;
rvar: REAL;
wvar: WORD;
{bitaccess: 'enable' 42 'Start drive'}
END_STRUCT
END_TYPE
POU:
VAR
x:stru1;
END_VAR
:
x.enable := true;
42 x. bvar 8 , rvar 32
, wvar,
4.
CoDeSys V2.3

10-30

: CoDeSys
: ,
, pragma {bitaccess}.
, , :

.
"%", , , .
:
I

:
X

(8 )

(16 )

(32 )

:
%QX7.5 %Q7.5

7.5

%IW215

215

%QB7

%MD48

48

%IW2.5.7.1

PLC

, PLC.
: , . . A.

CoDeSys V2.3

10-31

: CoDeSys

.
, , %MD48 48 192, 193, 194
195 (48 * 4 = 192). 0.
%MX5.0 ( ) .


ST .
:
Result := Fct(7) + 3;

CoDeSys V2.3

10-32

: CoDeSys

: CoDeSys
, . () () .


(BOOL)
BOOL . 2 (TRUE)
(FALSE). 8 , (. 10.12 ).

BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT - .


, ,
. :

BYTE

255

WORD

65535

16

DWORD

4294967295

32

-128

127

255

-32768

32767

16

UINT

65535

16

DINT

-2147483648

2147483647

32

4294967295

32

SINT
USINT
INT

UDINT

, .

REAL LREAL ,
. REAL 32 64 LREAL.
REAL : 1.175494351e-38 3.402823466e+38
LREAL : 2.2250738585072014e-308 1.7976931348623158e+308

STRING . .
. , 80 .
CoDeSys, 1
255 !
35 :
str:STRING(35):=' ';

CoDeSys V2.3

10-33

: CoDeSys

CoDeSys , 1
255 .

TIME .
TIME : 49d17h2m47s295ms (4194967295 ms).
TIME, TIME_OF_DAY (. TOD) , 0 ( ). TOD : 00:00:00 23:59:59.999.
DATE , 1 1970 . : 1970-00-00
2106-02-06.
DATE_AND_TIME (. DT) , 0 1 1970 .
: 1970-00-00-00:00:00 2106-02-06-06:28:15.
, TOD, DATE DT DWORD.
.

-, -, .
POU . , 9 ( "ARRAY[0..2] OF ARRAY[0..3]
OF " ).
:
<_>:ARRAY [<ll1>..<ul1>,<ll2>..<ul2>,<ll3>..<ul3>] OF < >
ll1, ll2, ll3 ; ul1, ul2 ul3 .
. .
:
Card_game: ARRAY [1..13, 1..4] OF INT;
:
arr1 : ARRAY [1..5] OF INT := 1,2,3,4,5;
arr2 : ARRAY [1..2,3..4] OF INT := 1,3(7);

(* 3 7: 1,7,7,7 *)

arr3 : ARRAY [1..2,2..3,3..4] OF INT := 2(0),4(4),2,3; (* 0,0,4,4,4,4,2,3 *)


:
TYPE STRUCT1
STRUCT
p1:int;
p2:int;
p3:dword;
END_STRUCT

ARRAY[1..3] OF STRUCT1:= (p1:=1,p2:=10,p3:=4723),(p1:=2,p2:=0,p3:=299),


(p1:=14,p2:=5,p3:=112);

CoDeSys V2.3

10-34

: CoDeSys

:
arr1 : ARRAY [1..10] OF INT := 1,2;
. ,
0.

:
:
<_>[1,2]
:
Card_game [9,2]
: CheckBounds,
.

CheckBounds
CheckBounds, . , .
CheckBounds:
FUNCTION CheckBounds : DINT
VAR_INPUT
index, lower, upper: DINT;
END_VAR

IF index < lower THEN


CheckBounds := lower;
ELSIF index > upper THEN
CheckBounds := upper;
ELSE CheckBounds := index;
END_IF
CheckBounds .
, , CheckBounds .
CheckBounds:
PROGRAM PLC_PRG
VAR
a: ARRAY[0..7] OF BOOL;
b: INT:=10;
END_VAR
a[b] := TRUE;

CoDeSys V2.3

10-35

: CoDeSys

: CheckBounds, Check.Lib, .
, , ,
, .

.
:
<_>: POINTER TO < / >;
, .

ADR. "^" (content)
.
: ! , C, p=p+SIZEOF(p^);.

:
pt:POINTER TO INT;
var_int1:INT := 5;
var_int2:INT;
pt := ADR(var_int1);
var_int2 := pt^;

(* var_int2 5 *)

CheckPointer:
.
CheckPointer,
. ( ).
(CheckPointer) . :

CoDeSys V2.3

10-36

: CoDeSys

32- :
FUNCTION CheckPointer : DWORD
VAR_INPUT
dwAddress : DWORD;
iSize : INT;
bWrite: BOOL;
END_VAR

16- :
FUNCTION CheckPointer : WORD
VAR_INPUT
dwAddress : WORD;
iSize : INT;
bWrite: BOOL;
END_VAR

CoDeSys V2.3

10-37

: CoDeSys
, . ,
dwAddress.

- ,
. ,
POU.
(Data types)
(Object Organizer).
TYPE END_TYPE.
:
TYPE <_>:(<_0> ,< _1>, ...< _n>);
END_TYPE
<_> .
. , , 0. - INT
. .
:
TYPE TRAFFIC_SIGNAL: (Red, Yellow, Green:=10);

(*

, red - 0, yellow - 1 green - 10


*)
END_TYPE
TRAFFIC_SIGNAL1 : TRAFFIC_SIGNAL;
TRAFFIC_SIGNAL1:=0;

(* red*)

FOR i:= Red TO Green DO


i := i + 1;
END_FOR
, , .
:
TRAFFIC_SIGNAL: (red, yellow, green);
COLOR: (blue, white, red);
: TRAFFIC_SIGNAL red COLOR.

(Data types)
(Object
Organizer). TYPE STRUCT
END_STRUCT END_TYPE.
:
TYPE < _>:
STRUCT
< 1>
.
.
< n>
END_STRUCT
CoDeSys V2.3

10-38

: CoDeSys
END_TYPE
< _> ,
.
. (AT !).
Polyg:
TYPE Polyg:
STRUCT
Start:ARRAY [1..2] OF INT;
Point1:ARRAY [1..2] OF INT;
Point2:ARRAY [1..2] OF INT;
Point3:ARRAY [1..2] OF INT;
Point4:ARRAY [1..2] OF INT;
End:ARRAY [1..2] OF INT;
END_STRUCT
END_TYPE
:
Poly_1:polyg := ( Start:=3,3, Point1 =5,2, Point2:=7,3, Point3:=8,5,
Point4:=5,7, End := 3,5);
:
<_>.<_>
, "Week" "Monday", :
Week.Monday


. , .
(Data types)
(Object Organizer). TYPE
END_TYPE.
:
TYPE < >: < >;
END_TYPE
:
TYPE message: STRING[50];
END_TYPE;

, .
.

CoDeSys V2.3

10-39

: CoDeSys
:
TYPE < > : < > (<>..<>) END_TYPE;
< > ,
< > SINT, USINT, INT, UINT, DINT, UDINT, BYTE, WORD,
DWORD (LINT, ULINT, LWORD).
< > , .
< > , .
:
TYPE
SubInt : INT (-4095..4095);
END_TYPE
:
VAR
i : INT (-4095..4095);
ui : UINT (0..10000);
END_VAR
, ( i := 5000;), CoDeSys .
CheckRangeSigned CheckRangeUnsigned. . , . ,
(unsigned). .
:
CheckRangeSigned, (, , i). .
FUNCTION CheckRangeSigned : DINT
VAR_INPUT
value, lower, upper: DINT;
END_VAR

IF (value < lower) THEN


CheckRangeSigned := lower;
ELSIF(value > upper) THEN
CheckRangeSigned := upper;
ELSE
CheckRangeSigned := value;
END_IF

CoDeSys V2.3

10-40

: CoDeSys
.
: (value) (lower, upper).
CheckRangeSigned .
, i:=10*y :
i := CheckRangeSigned(10*y, -4095, 4095);
, y > 1000, i 4095.
CheckRangeUnsigned:
FUNCTION CheckRangeUnsigned : UDINT
VAR_INPUT
value, lower, upper: UDINT;
END_VAR
: CheckRangeSigned CheckRangeUnsigned ,
.
: ,
. ,
- !
. ui 10000, FOR :
VAR
ui : UINT (0..10000);
END_VAR
FOR ui:=0 TO 10000 DO
...
END_FOR

: CheckRange, Check.Lib,
. , ,
, ,
.

CoDeSys V2.3

10-41

D: CoDeSys

D: CoDeSys
Standard.lib

: .

( ).

LEN
.
STR STRING, INT.
IL:
LD

'SUSI'

LEN
ST

VarINT1 (* : 4 *)

FBD:

ST:
VarSTRING1 := LEN (SUSI);
LEFT
.
STR STRING, SIZE INT, STRING.
LEFT (STR, SIZE) : SIZE STR.
IL:
LD

'SUSI'

LEFT

ST

VarSTRING1

(* SUS *)

FBD:

ST:
VarSTRING1 := LEFT (SUSI,3);
RIGHT
.
STR STRING, SIZE INT, STRING.
CoDeSys V2.3

10-42

D: CoDeSys
RIGHT (STR, SIZE) : SIZE STR
IL:
LD

'SUSI'

RIGHT

ST

VarSTRING1

(*: USI *)

FBD:

ST:
VarSTRING1 := RIGHT (SUSI,3);
MID
.
STR STRING, LEN POS INT, STRING.
MID (STR, LEN, POS) : LEN STR , POS.
IL:
LD

'SUSI'

RIGHT

2,2

ST

VarSTRING1

(* : US *)

FBD:

ST:
VarSTRING1 := MID (SUSI,2,2);
CONCAT
() .
STR1 STR2 STRING.
IL:
LD

'SUSI'

CONCAT

WILLI

ST

VarSTRING1

(* : SUSIWILLI *)

FBD:

ST:
VarSTRING1 := CONCAT (SUSI,WILLI);

CoDeSys V2.3

10-43

D: CoDeSys
: CONCAT 5 .

INSERT
INSERT .
STR1 STR2 - STRING, POS - INT, STRING.
INSERT(STR1, STR2, POS) : STR2 STR1 POS.
IL:
LD

'SUSI'

INSERT

XY,2

ST

VarSTRING1

(* : SUXYSI *)

FBD:

ST:
VarSTRING1 := INSERT (SUSI,XY,2);

DELETE
DELETE .
STR STRING, LEN POS INT,
STRING.
DELETE(STR, L, P) : L STR, P.
IL:
LD

'SUXYSI'

DELETE

2,23

ST

Var1

(* : SUSI *)

FBD:

ST:
Var1 := DELETE (SUXYSI,2,3);
REPLACE
REPLACE .
STR1 STR2 STRING, LEN POS INT,
STRING.
CoDeSys V2.3

10-44

D: CoDeSys
REPLACE(STR1, STR2, L, P) : L STR1 STR2 P.
IL:
LD

'SUXYSI'

REPLACE

'K', 2,2

ST

VarSTRING1

(* : SKYSI *)

FBD:

ST:
VarSTRING1 := REPLACE (SUXYSI,K,2,2);
FIND
FIND .
STR1 STR2 STRING, INT.
FIND(STR1, STR2) : STR1,
STR2.
1. STR2 , STR1 0.
IL:
LD

'SUXYSI'

FIND 'XY'
ST

VarINT1

(* : 3 *)

FBD:

ST:
VarINT1 := FIND (SUXYSI,XY);

SR
:
Q1 = SR (SET1, RESET) :
Q1 = (NOT RESET AND Q1) OR SET1
SET1 RESET - Q1 BOOL.
:
SRInst : SR ;
IL:
CoDeSys V2.3

10-45

D: CoDeSys
CAL

SRInst(SET1 := VarBOOL1, RESET := VarBOOL2)

LD

SRInst.Q1

ST

VarBOOL3

FBD:

ST:
SRInst(SET1:= VarBOOL1 , RESET:=VarBOOL2 );
VarBOOL3 := SRInst.Q1 ;

RS
:
Q1 = RS (SET, RESET1) :
Q1 = NOT RESET1 AND (Q1 OR SET)
SET RESET1 - Q1 BOOL.
:
RSInst : RS ;
IL:
CAL

RSInst(SET := VarBOOL1, RESET1 := VarBOOL2)

LD

RSInst.Q1

ST

VarBOOL3

FBD:

ST:
RSInst(SET:= VarBOOL1 , RESET1:=VarBOOL2 );
VarBOOL3 := RSInst.Q1 ;
SEMA
.
BUSY = SEMA(CLAIM, RELEASE) :
BUSY := X;
IF CLAIM THEN X:=TRUE;
ELSE IF RELEASE THEN BUSY := FALSE; X:= FALSE;
END_IF
X - BOOL , FALSE.

CoDeSys V2.3

10-46

D: CoDeSys
CLAIM RELEASE - BUSY BOOL.
(CLAIM , RELEASE - )
.
CLAIM = TRUE BUSY = FALSE,
( RELEASE = TRUE). BUSY = FALSE, , .
:
SEMAInst : SEMA ;
IL:
CAL

SEMAInst(CLAIM := VarBOOL1, RELEASE := VarBOOL2)

LD

SEMAInst.BUSY

ST

VarBOOL3

FBD:

ST:
SEMAInst(CLAIM:= VarBOOL1 , RELEASE:=VarBOOL2 );
VarBOOL3 := SEMAInst.BUSY;


R_TRIG
R_TRIG .
FUNCTION_BLOCK R_TRIG
VAR_INPUT
CLK : BOOL;
END_VAR
VAR_OUTPUT
Q : BOOL;
END_VAR
VAR
M : BOOL := FALSE;
END_VAR
Q := CLK AND NOT M;
M := CLK;
END_FUNCTION_BLOCK
Q FALSE , CLK FALSE. CLK TRUE, Q TRUE.
FALSE. ,
CLK FALSE TRUE.
:
RTRIGInst : R_TRIG ;
CoDeSys V2.3

10-47

D: CoDeSys
IL:
CAL

RTRIGInst(CLK := VarBOOL1)

LD

RTRIGInst.Q

ST

VarBOOL2

FBD:

ST:
RTRIGInst(CLK:= VarBOOL1);
VarBOOL2 := RTRIGInst.Q;
F_TRIG
F_TRIG .
FUNCTION_BLOCK F_TRIG
VAR_INPUT
CLK: BOOL;
END_VAR
VAR_OUTPUT
Q: BOOL;
END_VAR
VAR
M: BOOL := FALSE;
END_VAR
Q := NOT CLK AND NOT M;
M := NOT CLK;
END_FUNCTION_BLOCK

Q FALSE , CLK TRUE. CLK FALSE, Q TRUE.


FALSE. ,
CLK TRUE FALSE.
:
FTRIGInst : F_TRIG ;
IL:
CAL

FTRIGInst(CLK := VarBOOL1)

LD

FTRIGInst.Q

ST

VarBOOL2

FBD:

ST:
FTRIGInst(CLK:= VarBOOL1);
CoDeSys V2.3

10-48

D: CoDeSys
VarBOOL2 := FTRIGInst.Q;

CTU
.
CU, RESET Q BOOL, PV CV WORD.
CU ( FALSE TRUE) CV 1. Q TRUE, PV. CV
0 RESET = TRUE.
:
CTUInst : CTU ;
IL:
CAL

CTUInst(CU := VarBOOL1, RESET := VarBOOL2, PV := VarINT1)

LD

CTUInst.Q

ST

VarBOOL3

LD

CTUInst.CV

ST

VarINT2

FBD:

ST:
CTUInst(CU:= VarBOOL1, RESET:=VarBOOL2 , PV:= VarINT1);
VarBOOL3 := CTUInst.Q ;
VarINT2 := CTUInst.CV;
CTD
.
CD, LOAD Q BOOL, PV CV WORD.
CD ( FALSE TRUE) CV 1.
0, , Q TRUE. CV , PV LOAD = TRUE.
:
CTDInst : CTD ;
IL:

CoDeSys V2.3

CAL

CTDInst(CD := VarBOOL1, LOAD := VarBOOL2, PV := VarINT1)

LD

CTDInst.Q

ST

VarBOOL3

LD

CTDInst.CV

ST

VarINT2
10-49

D: CoDeSys
FBD:

ST:
CTDInst(CD:= VarBOOL1, LOAD:=VarBOOL2 , PV:= VarINT1);
VarBOOL3 := CTDInst.Q ;
VarINT2 := CTDInst.CV;
CTUD
/ .
CU, CD, RESET, LOAD QU QD BOOL, PV CV WORD.
RESET CV 0, LOAD PV.
CU 1. CD
1 ( 0).
QU TRUE, CV PV.
QD TRUE, CV 0.
:
CTUDInst : CUTD ;
IL:
CAL

CTUDInst(CU := VarBOOL2, RESET := VarBOOL3, LOAD :=


VarBOOL4, PV := VarINT1)

LD

CTUDInst.QU

ST

VarBOOL5

LD

CTUDInst.QD

ST

VarBOOL6

LD

CTUDInst.CV

ST

VarINT2

FBD:

ST:
CTUDInst(CU := VarBOOL1, CU:= VarBOOL2, RESET := VarBOOL3,
LOAD:=VarBOOL4 , PV:= VarINT1);
VarBOOL5 := CTUDInst.QU ;
VarBOOL6 := CTUDInst.QD ;

CoDeSys V2.3

10-50

D: CoDeSys
VarINT2 := CTUDInst.CV;

TP
.
TP(IN, PT, Q, ET) IN PT BOOL TIME . Q ET BOOL TIME.
IN FALSE, Q = FALSE, ET = 0. IN TRUE Q TRUE ( ) ET , PT. . , Q PT IN.
TP:

:
TPInst : TP;
IL:
CAL

TPInst(IN := VarBOOL1, PT := T#5s)

LD

TPInst.Q

ST

VarBOOL2

FBD:

ST:
TPInst(IN := VarBOOL1, PT:= T#5s);
VarBOOL2 :=TPInst.Q;

TON
.
TON(IN, PT, Q, ET) IN PT BOOL TIME . Q ET BOOL TIME.
IN FALSE, Q = FALSE, ET = 0. IN TRUE, ( ) ET , PT.
. Q TRUE, IN TRUE ET PT, FALSE. ,
Q PT IN.

CoDeSys V2.3

10-51

D: CoDeSys
TON:

:
TONInst : TON ;
IL:
CAL TONInst(IN := VarBOOL1, PT := T#5s)
LD TONInst.Q
ST VarBOOL2
FBD:

ST:
TONInst(IN := VarBOOL1, PT:= T#5s);
TOF
.
TOF(IN, PT, Q, ET) IN PT BOOL TIME . Q ET BOOL TIME.
IN TRUE, Q = TRUE ET = 0. IN FALSE, ( ) ET. . Q FALSE, IN FALSE ET PT, TRUE.
, Q PT IN.
TOF:

:
TOFInst : TOF ;
IL:

CoDeSys V2.3

CAL

TOFInst(IN := VarBOOL1, PT := T#5s)

LD

TOFInst.Q

ST

VarBOOL2
10-52

D: CoDeSys
FBD:

ST:
TOFInst(IN := VarBOOL1, PT:= T#5s);
VarBOOL2 :=TOFInst.Q;
RTC
. , RTC .

RTC(EN, PDT, Q, CDT) EN PDT, Q CDT BOOL DATE_AND_TIME .


EN FALSE, Q FALSE CDT DT#1970-01-01-00-00:00:00.
EN = TRUE PD .
CDT. EN FALSE, CDT DT#1970-01-01-0000:00:00. , PDT .

UTIL.LIB
, BCD / , , , .
UTIL_NO_REAL
, REAL.

BCD
, BCD, 0 99. 4 . 4-7 . BCD 0..99 0.. FF.
: 51 BCD . 5 - 0101, 1 - 0001.
0101_0001.

BCD_TO_INT
BCD INT.
BYTE INT. BCD, -1.
ST:
i:=BCD_TO_INT(73);

(* 49 *)

k:=BCD_TO_INT(151); (* 97 *)

CoDeSys V2.3

10-53

D: CoDeSys
l:=BCD_TO_INT(15);

(* -1, F0 BCD *)

INT_TO_BCD
INTEGER BCD.
INT BYTE.
INTEGER BCD , 255.
ST:
i:= INT_TO_BCD(49); (* 73 *)
k:=INT_TO_BCD (97); (* 151 *)
l:= INT_TO_BCD (100); (* ! : 255 *)

/
EXTRACT
: DWORD X BYTE N. BOOL, N
X. 0.
ST:
FLAG:=EXTRACT(X:=81,N:=4); (* : TRUE, 81 1010001, 4 1 *)
FLAG:=EXTRACT(X:=33, N:=0); (* : TRUE, 33 100001, 0 1
*)
PACK
B0, B1, ..., B7 BOOL BYTE.
UNPACK .
PUTBIT
: DWORD X, BYTE N BOOL B.
PUTBIT N- X , B. 0.
ST:
A:=38;

(* 100110 *)

B:=PUTBIT(A,4,TRUE);

(* : 54 = 2#110110 *)

C:=PUTBIT(A,1,FALSE);

(* : 36 = 2#100100 *)

UNPACK
UNPACK B BYTE 8 B0,...,B7 BOOL.
PACK.
FBD:

CoDeSys V2.3

10-54

D: CoDeSys


DERIVATIVE
.
IN OUT REAL. TM (
, ) DWORD. (RESET = TRUE) OUT
.
DERIVATIVE ,
.
FBD:

INTEGRAL
.
IN REAL. TM DWORD
( , ). RESET BOOL TRUE. OUT REAL.
.
FBD: :

CoDeSys V2.3

10-55

D: CoDeSys
LIN_TRAFO
(util.lib) REAL,
, .
.
:
(IN - IN_MIN) : (IN_MAX - IN) = (OUT - OUT_MIN) : (OUT_MAX - OUT)

IN

REAL

IN_MIN

REAL

IN_MAX

REAL

OUT_MIN

REAL

OUT_MAX

REAL

OUT

REAL

ERROR

BOOL

: TRUE, IN_MIN =
IN_MAX IN

:
, ( IN). ( OUT). (
) IN_MIN=0 IN_MAX=10. (
) OUT_MIN=-20 OUT_MAX=40.
, 5 , 10 .

STATISTICS_INT
, .

CoDeSys V2.3

10-56

D: CoDeSys
IN INT. RESET BOOL
. MN , MX AVG
IN. INT.
FBD:

STATISTICS_REAL
, STATISTICS_INT. IN MN, MX, AVG
REAL.
VARIANCE
.
IN REAL, RESET BOOL OUT REAL. RESET=TRUE.
VARIANCE.

PD
:

de(t )

Y = Y _ OFFSET + KP e (t ) + TV

dt

Y_OFFSET , KP , TV , e(t) - (SET_POINT-ACTUAL).


:

ACTUAL

REAL

SET_POINT

REAL

KP

REAL

TV

REAL

,
(.. "0.5" 500 ).

Y_MANUAL

REAL

Y, MANUAL = TRUE.

Y_OFFSET

REAL

Y.

Y_MIN,
Y_MAX

REAL

Y Y_MIN Y_MAX.
Y , LIMITS_ACTVE,
(BOOL) TRUE.
Y_MIN < Y_MAX.

MANUAL

BOOL

TRUE,
Y_MANUAL.

CoDeSys V2.3

10-57

D: CoDeSys
RESET

BOOL

TRUE ; Y = Y_OFFSET

REAL

LIMITS_ACTIVE

BOOL

TRUE Y (Y_MIN,
Y_MAX).

Y_OFFSET, Y_MIN Y_MAX . , Y_MIN Y_MAX


0.
P- PD TV 0.
FBD:

PID
:

1 TN
de(t )

Y = Y _ OFFSET + KP e(t ) +
e
(
t
)
+
TV

TN
dt

Y_OFFSET , KP , TN , TV , e(t) - (SET_POINT-ACTUAL).


:

ACTUAL

REAL

SET_POINT

REAL

KP

REAL

TN

REAL

,
(.. "0.5" 500 ).

TV

REAL

,
(.. "0.5" 500 ).

Y_MANUAL

REAL

Y, MANUAL = TRUE.

Y_OFFSET

REAL

Y.

Y_MIN,
Y_MAX

REAL

Y Y_MIN Y_MAX.
Y , LIMITS_ACTVE,

CoDeSys V2.3

10-58

D: CoDeSys
(BOOL) TRUE.
Y_MIN < Y_MAX.

Y_MAX
MANUAL

BOOL

TRUE,
Y_MANUAL.

RESET

BOOL

TRUE ; Y = Y_OFFSET

REAL

LIMITS_ACTIVE

BOOL

TRUE Y (Y_MIN,
Y_MAX).

OVERFLOW

BOOL

TRUE .

PID PD .
. OVERFLOW.
TRUE, . .
FBD:

PID_FIXCYCLE
PID_FIXCYCLE.

PID , , CYCLE, .
CoDeSys V2.3

10-59

D: CoDeSys

BLINK

: ENABLE BOOL, TIMELOW TIMEHIGH TIME. OUT BOOL.
ENABLE = TRUE. TIMEHIGH,
TIMELOW.
ENABLE FALSE, OUT ,
. FALSE ENABLE
FALSE, "OUT AND ENABLE" (..
AND ENABLE).
CFC:

FREQ_MEASURE
() ( )
BOOL. .
.

IN

BOOL

PERIODS

INT

. 1
10.

RESET

BOOL

OUT

REAL

CoDeSys V2.3

10-60

D: CoDeSys
VALID

BOOL

FALSE , >
3*OUT ( )

GEN

: MODE GEN_MODE, BASE BOOL, PERIOD
TIME, CYCLES AMPLITUDE INT RESET BOOL. OUT INT.
MODE . :
TRIANGLE TRIANGLE_POS - , SAWTOOTH_RISE SAWTOOTH_FALL ,
RECTANGLE , SINE COSINE :

TRIANGLE:

TRIANGLE_POS:

SAWTOOTH_RISE:

SAWTOOTH_FALL:

RECTANGLE:

SINUS:

COSINUS:

BASE (BASE=TRUE) ,
.. (BASE=FALSE).
PERIOD CYCLES . AMPLITUDE
.
RESET=TRUE.
FBD:

CoDeSys V2.3

10-61

D: CoDeSys


CHARCURVE
- .

IN INT . N BYTE
. ARRAY
P[0..10], P - , POINT,
INT X Y.
OUT INT, . ERR BYTE, .
P[0]..P[N-1] ARRAY X ,
ERR 1. IN P[0].X P[N1].X, ERR=2 OUT
P[0].X P[N-1].X.
N 2 11, ERR=4.
ST:
ARRAY P:
VAR
...
CHARACTERISTIC_LINE:CHARCURVE;
KL:ARRAY[0..10]

OF

POINT:=

(X:=0,Y:=0),

(X:=250,Y:=50),

(X:=500,Y:=150), (X:=750,Y:=400), 7((X:=1000,Y:=1000));


COUNTER:INT;
...
END_VAR
CHARCURVE :
COUNTER:=COUNTER+10;
CHARACTERISTIC_LINE(IN:=COUNTER,N:=5,P:=KL);
:

RAMP_INT
RAMP_INT .

CoDeSys V2.3

10-62

D: CoDeSys
INT: IN, , ASCEND DESCEND,
, TIMEBASE TIME. RESET TRUE
RAMP_INT .
OUT INT, .
TIMEBASE t#0s, ASCEND DESCEND
( ) .
FBD:

RAMP_REAL
RAMP_REAL RAMP_INT, , IN, ASCEND, DESCEND
OUT REAL.


HYSTERESIS
.
IN, HIGH LOW INT. OUT BOOL.

IN , LOW, OUT TRUE.


IN , HIGH, FALSE. LOW HIGH .
:

LIMITALARM
, IN .
LOW HIGH ..
CoDeSys V2.3

10-63

D: CoDeSys
IN, HIGH LOW INT, O, U IL BOOL.
IN:
HIGH

O = TRUE

LOW

U = TRUE

LOW HIGH ()

IL = TRUE

FBD:

AnalyzationNew.lib
SFC. FALSE, ,
. SFCErrorAnalyzationTable,
.
:
b OR NOT(y < x) OR NOT (NOT d AND e)
:
InputExpr: BOOL,
DoAnalyze: BOOL, TRUE
ExpResult: BOOL,
:
AnalyzeExpression , , FALSE. AppendErrorString , "|".
OutString ( STRING) (: y < x | d).
AnalyseExpressionTable ,
FALSE, . ExpressionResult,
, , .
OutTable: ARRAY [0..15] OF ExpressionResult;
:

AnalyseExpressionCombined AnalyzeExpression AnalyseExpressionTable.

CoDeSys V2.3

10-64

D: CoDeSys

CoDeSys
. . SysLibs_Overview_RU.pdf.
: SysLib_RU.pdf.

CoDeSys V2.3

10-65

E:

E:

CoDeSys
Standard.lib Util.lib. ST IL. IL .
, IL (, LD). IL ( ) .
. IL :
C
N
N
(

, TRUE.
JMPC, CALC, RETC: ,
FALSE.
: ( )
: , , ,
.

CoDeSys:
ST
'
.. [ ]
:

IL

;
^
:=

LD var1
ST var1
S boolvar
R boolvar

<Program name>
<Instance name>
<Fctname>(vx, vy,..)

AND
OR
XOR
NOT
+
*
/
>
>=
CoDeSys V2.3

JMP label
CAL prog1
CAL inst1
<Fctname> vx, vy
(
)
AND
OR
XOR
NOT
ADD
SUB
MUL
DIV
GT
GE

.
(.. 'string1')
(.. ARRAY[0..3] OF INT)
(.. var1 :
INT;)
(.. a:=var1;)
(.. pointer1^)
N
var1
N
var1
boolvar TRUE,
TRUE
boolvar FALSE,
TRUE
CN label
CN prog1
CN inst1
CN fctname vx, vy
.
.
N,(
AND
N,(
OR
N,(
OR
NOT
(

(
,
(

10-66

E:
=
<>
<=
<
MOD(in)
INDEXOF(in)
SIZEOF(in)
SHL(K,in)
SHR(K,in)
ROL(K,in)
ROR(K,in)
SEL(G,in0,in1)

EQ
NE
LE
LT
MOD
INDEXOF
SIZEOF
SHL
SHR
ROL
ROR
SEL

MAX(in0,in1)
MIN(in0,in1)
LIMIT(MIN,in,Max)
MUX(K,in0,...in_n)

MAX
MIN
LIMIT
MUX

ADR(in)
ADRINST()

ADR
ADRINST

BITADR(in)
BOOL_TO_<type>(in)
<type>_TO_BOOL(in)
INT_TO_<type>(in)

BITADR
BOOL_TO_<type>
<type>_TO_BOOL
INT_TO_<type>

REAL_TO_<type>(in)

REAL_TO_<type>

LREAL_TO_<type>(in)

LREAL_TO_<type>

TIME_TO_<type>(in)

TIME_TO_<type>

TOD_TO_<type>(in)

TOD_TO__<type>

DATE_TO_<type>(in)

DATE_TO_<type>

DT_TO_<type>(in)

DT_TO_<type>

STRING_TO_<type>(in)

STRING_TO_<type>

TRUNC(in)
ABS(in)
SQRT(in)
LN(in)
LOG(in)
EXP(in)
SIN(in)
COS(in)
TAN(in)
ASIN(in)
ACOS(in)

TRUNC
ABS
SQRT
LN
LOG
EXP
SIN
COS
TAN
ASIN
ACOS

CoDeSys V2.3

(
(
(
(


,

POU in; [INT]
, in
K
K
K
K
2 in0 ( G FALSE) in1
( G TRUE)
2 in0 in1
2 in0 in1
in MIN MAX
K- (
in0 In_n)
[DWORD]
,
ADRINST.
[DWORD]


INT

REAL
LREAL
TIME

TOD

DATE
DT

.

REAL INT
in
in
in
in
E in
in
in
in
in
in
10-67

E:
ATAN(in)
EXPT(in,expt)

ATAN
EXPT expt

in
expt

Standard.lib:
ST
LEN(in)
LEFT(str,size)
RIGHT(str,size)
MID(str,size,pos)
CONCAT('str1','str2')
INSERT('str1','str2',pos)
DELETE('str1',len,pos)
REPLACE('str1','str2',len,pos)
FIND('str1','str2')
SR
RS
SEMA
R_TRIG
F_TRIG
CTU
CTD
CTUD
TP
TON
TOF
RTC

IL
LEN
LEFT
RIGHT
MID
CONCAT 'str2'
INSERT 'str2',p
DELETE len,pos
REPLACE
'str2',len,pos
FIND 'str2'
SR
RS
SEMA
R_TRIG
F_TRIG
CTU
CTD
CTUD
TP
TON
TOF
RTC

in
str size
str size
str pos size
() 2
str1 str2 pos
, len , pos
str1 pos len
str2
str2 str1
FB:
FB:
FB: (interruptable)
FB:
FB:
FB:
FB:
FB:
FB:
FB:
FB:
FB:

Util.lib:

BCD_TO_INT
INT_TO_BCD
EXTRACT(in,n)
PACK
PUTBIT
UNPACK
DERIVATIVE
INTEGRAL
LIN_TRAFO
STATISTICS_INT
STATISTICS_REAL
VARIANCE
PD
PID
BLINK
FREQ_MEASURE
GEN
CoDeSys V2.3

BCD INT
INT BCD
n- DWORD, BOOL
8
DWORD
8

REAL
., ., INT
., ., REAL


10-68

E:
CHARCURVE
RAMP_INT
RAMP_REAL
HYSTERESIS
LIMITALARM

CoDeSys V2.3

(INT)
(REAL)

10-69

F: /

F: /

, CoDeSys,
. /. . .

CoDeSys .

/batch

CoDeSys , ,
HRESULT. ,
. .
, S_OK.

/run

.
/

/show ...

CoDeSys

/show hide

/show icon

/show max

/show normal

, .

/out <outfile>


<outfile>.

/noinfo

/userlevel
<group>

(, "/userlevel 0"

/password
<password>

(, "/password

0)

abc")

/openfromplc

/visudownload

CoDeSys HMI , ,
.

/notargetchange


(. "target...").

/cmd <cmdfile>

<cmdfile>

:
"< CoDeSys-exe>" "< >" /<1> /<c 2> ....

"D:\dir1\codesys" "C:\projects\ampel.pro" /show hide /cmd command.cmd

CoDeSys V2.3

10-70

F: /
ampel.pro, . ,
command.cmd. !

(cmdfile)
,
(. ). .
( , @). (;) .
:
onerror continue

,
.

onerror break

, .

:
login

('' '' - 'Online'


'Login')

logout

('' '' - 'Online' 'Logout')

run

('' '' - 'Online' 'Run')

stop

('' '' - 'Online' 'Stop')

bootproject

'' ' ' - 'Online' 'Create boot project'

sourcecodedownload

'' '' - 'Online' 'Sourcecode download'

sim

('' ' ' - 'Online'


'Simulation')

sim off

('' ' ' - 'Online'


'Simulation')

File:
file new

('' '' - 'File' 'New')

file open <projectfile>

<projectfile> ('' '' - 'File' 'Open')

/readpwd:<readpassword>

, .

/writepwd:<writepassword>

, .

file close

('' '' - 'File' 'Close')

file save

('' '' - 'File' 'Save')

file saveas <projectfile>


: <type><version>

<projectfile> ('' ' ' 'File' 'Save as')


: CoDeSys
<projectfile>. , :
"internallib" :
"externallib" :
"pro" :
<Version>: 15, 20, 21, 22 ( 1.5, 2.0, 2.1, 2.2)

CoDeSys V2.3

10-71

F: /
: "file save as lib_xy internallib22" -> "project xy.pro", "lib_xy.lib" V2.2.
file printersetup <filename>.dfr dfr ('' ' ' - 'File'
'Printer setup') ' :
' (New page per object) '
pageperobject
' (New page per subobject) (. )
pagepersubject
file archive <filename>.zip

zip- (''
'/ ' - 'File' 'Save/Mail Archive')

file quit

CoDeSys ('' '' - 'File' 'Exit')

Project:
project build

(''
'' - 'Project' 'Build')

project rebuild or
project compile

('' ' ' 'Project' 'Rebuild all')

project clean

(''
' ' - 'Project' 'Clean All')

project check

('' '' - 'Project' 'Check')

project import <file1> ...


<fileN>

<file1> ... <fileN> (''


'' - 'Project' 'Import'). : ,
, "project import C:\projects\*.exp.

project export <expfile>

<expfile> ('' '' - 'Project' 'Export')

project expmul

,
.

project documentation

(. )

:
out open <msgfile>

<msgfile>. .

out close

out clear

:
echo on

echo off

echo <text>

<text>.

( , ,
- import, export, copy):
replace yesall

( , )

replace noall

( , )

replace query

'replace yesall' 'replace


noall'

, CoDeSys :
query on
CoDeSys V2.3


10-72

F: /
query off ok

'OK'

query off no

'No'

query off cancel

'Cancel'

:
call <parameter1> ... <parame- . 10 :$0 - $9.
ter10>
CoDeSys:
( , '' - 'Directories', '' - 'General'):
,
. .
:
dir lib "D:\codesys\Libraries\Standard; D:\codesys\Libraries\NetVar"

dir lib <libdir>

<libdir>

dir compile <compiledir>

<compiledir>

dir config <configdir>

<configdir>

dir upload <uploaddir>

<uploaddir>

CMDFILE:
delay 5000

(Watch and Recipe Manager):


watchlist load <file>

(Watchlist) <file> ('' ' ' - 'Extras' 'Load


Watchlist')

watchlist save <file>

<file> ('' '


' - 'Extras' 'Save Watchlist')

watchlist set <text>

<text> (''
' ' - 'Extras' 'Rename Watchlist')

watchlist read

('' ' ' - 'Extras' 'Read Recipe')

watchlist write


('' ' ' - 'Extras' 'Write Recipe')

:
library add <library file1> <li- . , brary file2> .. <library fileN> , .
library delete [<library1> <library2> .. <libraryN>]

( ) .

:
object copy <source project
file> <source path> <target
path>

(source path) (target path) .


(source path) - . , . .
(target path) , .

CoDeSys V2.3

10-73

F: /
:
.
object setreadonly
<TRUE|FALSE> <object type> ,
.
| <object name>
: pou, dut (data type), gvl (global variables list), vis
(visualization), cnc (CNC object), liblist (Libraries), targetsettings, toolinstanceobject (particular Tools instance), toolmanagerobject (all instances in
the Tools tree), customplconfig (PLC configuration), projectinfo (Project
information), taskconfig (task configuration), trace, watchentrylist (Watchand Recipe Manager), alarmconfig (Alarm configuration)
: "object setreadonly TRUE pou plc_prg" PLC_PRG
.
(gateway, device):
gateway local

Gateway .

gateway tcpip <Address>


<Port>

Gateway .
<Address>: TCP/IP .
<Port>: TCP/IP .
: , !

device guid <guid>

GUID.
GUID (): {01234567-0123-0123-0123-0123456789ABC}
.

device instance <Instance


name>

device parameter <Id> <Value> ( ID)


.
:
system <command>

:
target <Id>

. CoDeSys
( . ) "/notargetchange",
.

:
state offline

"S_OK" (
offline), "HRESULT[0x800441f0)" ( ).

state

"S_OK" (
), "HRESULT[0x800441f0)" ( offline).

:
, ,
.
. "file open..."!

CoDeSys V2.3

10-74

F: /
:
user level 0
user password aaa
file open "D:\codesys\projects\xxxx.pro"
query off ok
user level

user password

:
visual settings...

,
'' '' ('Extras' 'Settings') .

... language file on || off

' ' (Language file) (on


(off).
'. ' (Dynamic texts).

... set languagefile <Dateipfad


Sprachdatei>

(.tlt .vis).

... dynamictexts on || off

'. ' (Dynamic texts) (on)


(off).
' ' (Language file).

... dynamictextfiles <Dateipfad> |


<Dateipfad> | ...

: "visual settings set languagefile proj1.tlt.

: "visual settings D:\dynfiles\p1.xml


D:\dynfiles\p2.xml"

... dynamictexthideelements on || off

'
' (Suppress elements if no text
replacement has taken place).

... language <Sprache>

.
: "visual settings language German

... tablekeyboardusage_web on || off

' ' (Keyboard usage for tables) Web


."

... tablekeyboardusage_codesys on || off ' -

' (Keyboard usage for tables)


CoDeSys-HMI.

visual webvisuactivation on || off

Web
(Target Settings).

ENI:
:
<category>: "project" "shared" "compile"
: Project Objects, Shared Objects, Compile Files
<POUname>: , CoDeSys.

CoDeSys V2.3

10-75

F: /
<Objecttype>: POU , ( , . ENI ).
: "GLOBAL_1.GVL" -> POU "GLOBAL_1", "GVL" (global variables list)
<comment>: ( ),
.
ENI :
eni on
eni off

' (ENI)' (Use source control (ENI))


, . ('' '' '
' - 'Project' 'Options' 'Database-connection')

eni project readonly on


eni project readonly off

' ' (Read only access) '' (Project)


, . ('' '' '' 'Project' 'Options' 'Project objects')

eni shared readonly on


eni shared readonly off

' ' (Read only access)


' ' (Shared objects) ,
. ('' '' ' ' - 'Project' 'Options' 'Shared objects')

eni set local <POUname>

'' (Local), ..
('' '' '' ' ' - 'Project' 'Object'
'Properties' 'Data base-connection')

eni set shared <POUname> ' ' (Shared objects)


('' '' '' ' ' - 'Project' 'Object'
'Properties' 'Data base-connection')
eni set project <POUname> '' (Project)
('' '' '' ' ' - 'Project' 'Object'
'Properties' 'Data base-connection')
eni <category> server
ENI Server '' (Project)
<TCP/IP_Address> <Port> ('Project' 'Options' 'Project data base');
<Projectname> <Username>
:
<Password>
eni project server localhost 80 batchtest\project EniBatch Batch
(TCP/IP-Address = localhost, Port = 80, Project name = batchtest\project, User
name = EniBatch, Password = Batch)
eni compile sym on
eni compile sym off

(Create ASCII symbol information


(.sym)) /
('' '' ' ' ' ENI' - 'Project' 'Options' 'Database-connection' 'ENI settings' 'Compile files')

eni compile sdb on


eni compile sdb off

' ' (Create binary symbol information (.sym)) 'Compile files' , /


('' '' ' ' ' ENI' - 'Project' 'Options' 'Database-connection' 'ENI settings' 'Compile files')

eni compile prg on


eni compile prg off

' ' (Create boot project) 'Compile files' , /


('' '' ' ' ' ENI' - 'Project' 'Options' 'Database-connection' 'ENI settings' 'Compile files')

'' ' ' ('Project' 'Project Data Base'):


eni set <category>

('' 'Define')

'eni set <category>set <Ob- CoDeSys V2.3

10-76

F: /
jecttype>:<POUname>
. (' ' - 'Multiple Define')
<Objecttype>:<POUname>
:
"eni set project pou:as_fub pou:st_prg"
-> (pou) as_fub st_prg get 'Project objects'
eni <category> getall

. ('
' - 'Get All Latest Versions')

'eni <category>get <Ob .


jecttype>:<POUname>
(' ' - 'Multiple Define'). (' ' <Objecttype>:<POUname> 'Get latest version')
:
"eni project get pou:as_fub gvl:global_1"
-> (POU) as_fub.pou
global_1.gvl .
eni <category> checkoutall
"<comment>"

. .

eni <category> checkout


(Objecttype:POUname), , "<comment>" <Ob . jecttype>:<POUname>
.
<Objecttype>:<POUname>
:
"eni project checkout "for working on xy" pou:as_fub gvl:global_1"
-> (POU) as_fub global_1 , "for working on xy" .
eni <category>checkinall
"<comment>"

, , .
.

eni <category> checkin


(Objecttype:POUname), , "<comment>" <Ob . jecttype>:<POUname>
.
<Objecttype>:<POUname>

CoDeSys V2.3

10-77

F: /
:
, "$":
$PROJECT_NAME$ CoDeSys ( ".pro")
$PROJECT_PATH$

CoDeSys (
, .. "projects\sub1").

$PROJECT_DRIVE$ ( , ..
"D:")
$COMPILE_DIR$

( , ..
"D:\codesys\compile")

$EXE_DIR$

codesys.exe ( ,
..D:\codesys)

:
file open C:\projects\CoDeSys_test\ampel.pro
query off ok
watchlist load c:\work\w.wtc
login
run
delay 1000
watchlist read
watchlist save $PROJECT_DRIVE$\$PROJECT_PATH$\w_update.wtc
logout
file close
file ampel.pro, (watch list) w.wtc, . 1
watch.wtc (
"C:\projects\CoDeSys_test"). .
, , :
"<path of codesys.exe>" /cmd "<path of cmd file>"

CoDeSys V2.3

10-78

G: .

G: .
"" " " ("Project" "Siemens Import") , (POU) Siemens STEP5/7. " SEQ " (Import an SEQ symbol file)
STEP5. "
S5" (Import an S5 project file) .
STEP5 CoDeSys. STEP5 IL .
CoDeSys.
standard.lib, .

SEQ
SEQ - STEP5.
*. seq. S5 (,
, , ..), , .
, .
. .
SEQ 61131-3,
, ( ).
61131-3 ( ..). S5 , , . . ,
(, "0"). , . SEQ
. .
64 .
SEQ Siemens STEP5-PG Siemens STEP7300/400 ACCON-PG DELTALOGIC. STEP7-SEQ 3.x
. STEP7 2.x . .
SEQ Windows
. . , STEP5/7 .
, STEP5 A! A? A_.
: A_".
.
.
, Siemens , , , . .
, ,
x (, "%MX4.0"), , SEQ . 61131-3, , , . , . ,
, .
SEQ
STEP5/7. - ,
, .

CoDeSys V2.3

10-79

G: .

S5
(POU) Siemens S5 (*.s5d). MC5
, S5 SPS. MC5 STEP5 IL ( ). , S5D
STEP5. S5D , CoDeSys , . , . SEQ
S5 .
S5D Windows.
POU .
. STEP5 IL
IL, LD FBD.
, , CoDeSys . ,
"U M12.0" , M12.0.
. ,
"U-Name" "U M12.0".
. , R_TRIG .

S5 C 61131-3
STEP5 ,
. ,
61131-3, , STEP5 IL POU. .
, CPU. STEP5 , .
, 61131-3, , LD FBD STEP5, ,
STEP5-PB. , S5 CPU
(, , , ..).
STEP5,
61131-3.
:
U, UN, O, ON, S, R, = : I (), O (), M (), S (S ), D (
)
U, UN, O, ON : T (), C ()
S, R : C
SU, RU, P, PN : E, A, M, D
O, O(, U(, )
L, T : E, A, M, D, T, C, P (Periphery)
: B (byte), W (word), D (double word), L (left byte), R (right byte)
L : DH, KB, KF, KH, KM, KT, KZ, KY, KG, KC
SI, SE, SA : T
ZV, ZR : C
+, -, X, : : F (. ), G (. )

CoDeSys V2.3

10-80

G: .
+, - : D (32 . )
!=, ><, >, <, >=, <= : F, D, G
ADD : BF, KF, DH
SPA, SPB : PB, FB ( ), SB
A, AX : DB, DX
BE, BEA, BEB
BLD, NOP, ***
UW, OW, XOW
KEW, KZW, KZD
SLW, SRW, SLD, RRD, RLD
SPA=, SPB=
SPZ=, SPN=, SPP=, SPM=
TAK
D, I

:
U, UN, O, ON, S, R, = : T0.0, C0.0 ( )
L, T : Q ( )
LC : T, C
SV, SS, R, FR : T
FR : C

BA, BB, BS, BT ( ).
SPA, SPB : OB
BA, BAB : FX
E, EX : DB, DX
STP, STS, STW
DEF, DED, DUF, DUD
SVW, SVD
SPO=, SPS=, SPR
AS, AF, AFS, AFF, BAS, BAF
ENT
SES, SEF
B : DW, MW, BS
LIR, TIR, LDI, TDI, TNW, TXB, TXW
MAS, MAB, MSA, MSB, MBA, MBS
MBR, ABR
LRW, LRD, TRW, TRD
TSG
LB, TB, LW, TW : GB, GW, GD, CB, CW, CD
ACR, TSC
BI
CoDeSys V2.3

10-81

G: .
SIM, LIM
, , , CPU. : BCD (LC T, LC C), SV SS .
:
STEP5 POU, , .

STEP5, :
1. word
STEP5 (word) .
61131-3, TIME WORD .

. "Incompatible Types: Cannot convert WORD to TIME." "Incompatible Types: Cannot convert
TIME to WORD." WORD TIME.
2.
61131-3 (DB) . STEP5
DB ( , ), (B DW), (B MW100 A DB 0) ( ,
). STEP5 DB ,
. , , ( A DB , = ). , POU A DB . A DB ,
,
POU . "No open data block (insert an A DB)".
,
"ErrorDW0". DB (
"ErrorDW0" "DB10.DW0"). , STEP5 POU A DB.
A BD ,
DB.
3.
STEP5 (
) :
L KF +5
T MW 44
B MW 44
A DB 0
DB5 ( DB,
%MW44). .
:
DB ( DB5, DB6 .) IL, LD FBD ( ) POU. POU
. ( DBType)
POU. :
CoDeSys V2.3

10-82

G: .
VAR_GLOBAL
DB5, DB6 : DBType;
END_VAR
POU ( DBs).
DB
VAR_INPUT DBType. .
4. S5 . , STEP5 ( MC5) . POU,
.
5. , (OB)
(805xx ). (OB251), .
, .
.
6. (, DB1 [S5-95U], DX0, DX2), S5
CPU, . ,
CPU. S5.
, , .. , Siemens SPS.
.
:
(*Warning! Unconvertible STEP5/7 code shown as comment:*)
.
. Siemens , :
: -.-
: -
. %MW32 %MW33
%MB33 ( Siemens SPS). CoDeSys %MW32 %MW33 .

, "%MW10.0.0. .
! Siemens , - .
CoDeSys WORD . . . (M) . %MX33.3, %MB33, %MW32 %MD30,
.
, , .
, .

CoDeSys V2.3

10-83

H:

H:
(Target Platform)
Intel 386

(Platform)

(Floating point
processor)

: FPU
.

: ,
(Debugging in multitasking .
environment)

(Optimized jumps)

: ;
+ ( 386/486); ,
,
.

(A = A + 1, A < 500 etc.); + ( 386/486);


(Optimized
.
operations with constants)

(Optimized
Loadoperations)

CoDeSys V2.3


/; +

10-84

H:

Motorola 68K

(Platform)

(CPU)

68k CPU: 68000 CPU32 .

(Floating point
processor)
16 (Use 16 bit jump
offsets)

: FPU
.
:
16 ( , ).
: 8 .

(Allow bytealigned structures)


. 1
(Reserved Register 1)

: .
: .
A2,A4,A5,A6:
:

. 2
(Reserved Register 2)
.
(Base register
for library data)


C (
, ).
"None", A5.

(Output-Mode)

Nothing =
Assembler = "code68k.hex" (.
"//" - "Project/Options/Directories").
Disassembler =

CoDeSys V2.3

10-85

H:

Infineon C16x

(Platform)

/ (Code /
Compiler)

, RTS ( C )

/ (Code / ()
Stack size)
/ (Code / Data)
/ (Code /

Functions)
. (Init. Func- : tions)

(Optimize)

: ,

/ Hex (Output / HEXFile)


/ BIN (Output / BINFile)
/ MAP (Output /
MAP)
/ LST (Output / LST)

: HEX

/ LST
(Output / LST with addresses)
DPPs /
DPP0..DPP2
(In Instances)

CoDeSys V2.3

:
: map-
:
:
DPP
DPP0, DPP1, DPP2
DPP

10-86

H:

/ (Libraries
/Code)
(Tables)
(Data)
(Data length)
POUs
(References)

ARM Power PC
.

(Platform)

- : FPU

(Floating point
processor)
,
.
(First parame- C-
ter Register (integer))
. , (Last parame- C-
ter Register (Integer))
.
, C-
(Register for return values
(Integer))
. , (. .) (First parame- C-
ter Register (Float))
. .
,
(. .) (Last parame- C-
ter Register (Float))
. (.
, C.) (Register for return
value (Float))
Intel (Intel , Intel
byte order)

CoDeSys V2.3

10-87

H:

( ( )
) (Maximum argument size on stack (Byte))

MIPS

(Platform)

.
(First parameter Register (integer))
.
(Last parameter Register (Integer))
.
(Register for return values
(Integer))
(
) (Maximum argument size on stack (Byte))

,
C-

CoDeSys V2.3

, C-
, C-
: . ( ) ,

10-88

H:

'Hitachi SH'

(Platform)

- : FPU

(Floating point
processor)
,
.
(First parame- C-
ter Register (integer))
. , (Last parame- C-
ter Register (Integer))
.
, C-
(Register for return values
(Integer))
( : ( ),
) (Maximum argu- .
ment size on stack (Byte))
. , (. .) (First parame- C-
ter Register (Float))
. .
,
(. .) (Last parame- C-
ter Register (Float))
. (.
, C.) (Register for return
value (Float))
Intel (Intel : Intel
byte order)

CoDeSys V2.3

10-89

H:

8051

(Platform)

( )
(Maximum argument size on stack
(Byte))

( )

Infineon 'TriCore
TriCore . , , 3S-Smart Software Solutions GmbH.
: TriCore REAL, LREAL
.

(Platform)=Tricore

.
, C(First parameter Register (integer)) = 4 ( )
, C.
(Last parameter Register (Integer))= 7 ( )
. (Register for
return values (Integer)) = 2
:

, C-
-
- Motorola ByteOrder
- : 4 ( )

CoDeSys V2.3

10-90

H:

(Memory Layout).
.

/ (Base / Code)

Automatic:
:

/ (Base / Automatic: (global data)


Global)
:
/ (Base /
Memory)

Automatic: (M)
:

/ (Base / Input) Automatic: (I)


:
/ (Base /
Output)
/ . (Base /
Retain)

Automatic: (O)
:
Automatic: Retain
:

/ (Area / Code)
/ (Area (global data)
/ Global)
/ (Area /

Memory)
/ (Area / In-
put)
/ (Area /

Output)
/ . (Area / Retain
Retain)

CoDeSys V2.3

10-91

H:

/ (Size / Code)

/
(Size pro Segment /
Global)
/ (Size /

Memory)
/ (Size / Input)
/ (Size /

Output)
/ . (Size / Retain
Retain)
(To-
tal size of data memory)
. - : Retain
(Retain in own
segment)
. (global data)
.
(Maximum number of global data
segments)
. POU (Maximum . POU
number of POUs)

(General)
.

(Configurable)

: I/O

Support CANopen configura- : CANopen


tion

Support Profibus configuration

CoDeSys V2.3

: Profibus

10-92

H:

(Support
preemptive multitasking)

(Download as file)
(No
address check)
(Online
Change)

I/O (Update unused I/Os)

:
: I/O
:
:
: CoDeSys ,
, . , /


(Singletask
in multitasking)
- :
(Byte-addressing mode)
(.. var1 AT %QD4 %QB4)
(Initialize zero)

: ,
(Download Symbol File)
- INI- : (
(Symbol config from ) codesys.ini ,
INI file)
codesys.ini
- (PLCBrowser)
(Trace)

: -
:

VAR_IN_OUT : VAR_IN_OUT (VAR_IN_OUT as reference) . /


.
(Ini- : (
tialize Inputs)
AT %IX !)
: (Automatic boot project load) .
Softmotion

: SoftMotion
(CNC CAM)

. . (Retain
forcing)

: , .
,
( CoDeSys SP
32F V2.4).

(Save)

: . , . .


(Cycle independent forcing)

: , .

CoDeSys V2.3

10-93

H:

- : ' ' (Parameter-Manager)


(Support parameter . Object Dictionary ,
manager)
(Support network
variables)

, ...: CAN; UDP; DP



(Names of supported networkinterfaces)

'Parameters'
(Index ranges for
parameters)

'Variables'
(Index-ranges
for variables)
'Mappings'
(Index-ranges for Mappings)
: , CanDevice
; (. ) !

(Subindex range)

CoDeSys V2.3

-
Object Dictionar

10-94

H:

-
(Display width in pixel) . , , .
(Display height in pixel)
8.3
(Use 8.3 file format)

8.3 .

ALARM_TASK
(Alarmhandling in the PLC) . ST-, ( ). ST- SysLibAlarmTrend.lib. . (
SysLibSockets.lib, SysLibMem.lib,SysLibTime.lib, SysLibFile.lib.
!)
: (Alarm handling in the PLC)
Target- Web-.

CoDeSys V2.3

10-95

H:

.
(Store trend data in the
TREND_TASK, ST- PLC)
.
ST- SysLibAlarmTrend.lib. ( SysLibSockets.lib,
SysLibMem.lib,SysLibTime.lib, SysLibFile.lib.
!)
: (Store trend data in the PLC)
Target- Web-.

(Activate system variable) 'CurrentVisu'

(Supported fonts
in the target)

(Simplified input handling)

CurrentVisu .
, .
: :
<Tab> <>
. <Return>.
<Tab> .
: <Tab> <>
.

Web- (Web
visualisation)

Web .

(Compression) : Web- CoDeSys Web-/ (zip-):


- XML
- *.bmp
- (*.xml , *.tlt, *.vis)
.zip.
(: PLC_VISU.xml
PLC_VISU_xml.zip).
Java (minml.jar, webvisu.jar) webvisu.htm.

(Prevent
download of visualization
files)

(Keyboard usage
for tables)

(Target visualisation)

CoDeSys V2.3

: . Web- , XML .
: (CoDeSys HMI, Web-, ).
, , Target-.
:
Target .

10-96

H:

VISU_INPUT_TASK (Use
VISU_INPUT_TASK)

( (Target visualisation))
: (Target) (VISU_INPUT_TASK, VISU_TASK),
VISU_TASK,
VISU_INPUT_TASK.

( (Target visu (Deacti- alisation))


vate task generation)
: VISU_INPUT_TASK VISU_TASK (. )
. POU MAINTARGETVISU_PAINT_CODE
. . - CoDeSys .
( , . )
(Keyboard usage
, VK_TAB ()
for tables)
VK_SPACE () , . ,
.

CoDeSys V2.3

10-97

I:

I:
CoDeSys .

<F6>

<Alt>+<F6>

(Message window). <Alt>+<F6>


Object Organizer .

<Control>+<F6> <Con-

trol>+<Shift>+<F6> .

<Tab> .

(Object Or-

ganizer) (Library Manager).


. , ,
<Shift>+<F10>
.


<F6>


<Shift>+<F10>

<Ctrl>+<Enter>
- <Enter>


<Control>+<F6>

<Control>+<Shift>+<F6>

<Enter>

<Enter>
(Object <>
Organizer) (Library Manager)

<Tab>
-
<F1>

'' '' ('File' 'Save')
'' '' ('File' 'Print')
'' '' ('File' 'Exit')
'' '' ('Project' 'Build')
'' ' ' ('Project' 'Delete Object')
'' ' ' ('Project' 'Add Object')
'' ' ' ('Project' 'Rename Object')
'' ' ' ('Project' 'Open Object')
'' '' ('Edit' 'Undo')
'' '' ('Edit' 'Redo')
'' '' ('Edit' 'Cut')
'' '' ('Edit' 'Copy')
CoDeSys V2.3

<Ctrl>+<S>
<Ctrl>+<P>
<Alt>+<F4>
<F11>
<Del>
<Ins>
<Spacebar>
<Enter>
<Ctrl>+<Z>
<Ctrl>+<Y>
<Ctrl>+<X>
<Shift>+<Del>
<Ctrl>+<C>
10-98

I:
'' '' ('Edit' 'Paste')
'' '' ('Edit' 'Delete')
'' ' ' ('Edit' 'Find next')
'' ' ' ('Edit' 'Input Assistant')
'' ' ' ('Edit' 'Auto Declare')
'' ' ' ('Edit' 'Next Error')
'' ' ' ('Edit' 'Previous Error')
'' '' ('Online' 'Log-in')
'' '' ('Online' 'Logout')
'' '' ('Online' 'Run')
'' ' ' ('Online' 'Toggle
Breakpoint')
'' ' ' ('Online' 'Step over')
'' ' ' ('Online' 'Step in')
'' ' ' ('Online' 'Single Cycle')
'' ' ' ('Online' 'Write Values')
'' ' ' ('Online' 'Force Values')
'' ' ' ('Online' 'Release Force')
'' ' /' ('Online' 'Write/Force
dialog')
'' '' ('Window' 'Messages')
FBD
'' ' ()' ('Insert' 'Network (after)')
'' '' ('Insert' 'Assign')
'' '' ('Insert' 'Jump')
'' '' ('Insert' 'Return')
'' '' ('Insert' 'Box')
'' '' ('Insert' 'Input')
'' '' ('Extras' 'Negate')
'' ' POU' ('Extras' 'Zoom')
CFC
'' (Insert) 'POU'
'' '' ('Insert' 'Input')
'' '' ('Insert' 'Output')
'' '' ('Insert' 'Jump')
'' '' ('Insert' 'Label')
'' '' ('Insert' 'Return')
'' '' ('Insert' 'Comment')
'' ' ' ('Insert' 'POU input')
'' '' ('Extras' 'Negate')
'' (Extras) 'Set/Reset'
'' ' ' ('Extras' 'Connection
mark')
'' (Extras) 'EN/ENO'
'' ' POU' ('Extras' 'Zoom')
LD
'' ' ()' ('Insert' 'Network (after)')
'' '' ('Insert' 'Contact')
'' ' ' ('Insert' 'Contact (negated)')
'' ' ' ('Insert' 'Parallel Contact')
CoDeSys V2.3

<Ctrl>+<V>
<Del>
<F3>
<F2>
<Shift>+<F2>
<F4>
<Shift>+<F4>
<Alt><F8>
<Ctrl>+<F8>
<F5>
<F9>
<F10>
<F8>
<Ctrl>+<F5>
<Ctrl>+<F7>
<F7>
<Shift>+<F7>
<Ctrl><Shift>+<F7>
<Shift>+<Esc>

<Ctrl>+<T>
<Ctrl>+<A>
<Ctrl>+<L>
<Ctrl>+<R>
<Ctrl>+<B>
<Ctrl>+<U>
<Ctrl>+<N>
<Alt>+<Enter>

<Ctrl>+<B>
<Ctrl>+<E>
<Ctrl>+<A>
<Ctrl>+<J>
<Ctrl>+<L>
<Ctrl>+<R>
<Ctrl>+<K>
<Ctrl>+<U>
<Ctrl>+<N>
<Ctrl>+<T>
<Ctrl>+<M>
<Ctrl>+<I>
<Alt>+<Enter>

<Ctrl>+<T>
<Ctrl>+<K>
<Ctrl>+<G>
<Ctrl>+<R>

10-99

I:
'' ' ()' ('Insert'
'Parallel contact (negated)')
'' ' ' ('Insert' 'Function
Block')
'' '' ('Insert' 'Coil')
'' 'Set ' ('Insert' 'Set coil')
' ' '' ('Insert at blocks' 'Input')
' ' '' ('Insert at blocks' 'Assign')
'' '' ('Extras' 'Negate')
'' ' POU' ('Extras' 'Zoom')
SFC
'' '- ()' ('Insert' 'Step-Transition
(before)')
'' '- ()' ('Insert' 'Step-Transition
(after)')
'' ' ()' ('Insert' 'Alternative Branch (right)')
'' ' ()' ('Insert' 'Parallel
Branch (right)')
'' '' ('Insert' 'Jump')
'' ' /' ('Extras' 'Zoom
Action/Transition')

'Extras' 'Edit Entry'


.


CoDeSys V2.3

<Ctrl>+<D>
<Ctrl>+<B>
<Ctrl>+<L>
<Ctrl>+<I>
<Ctrl>+<U>
<Ctrl>+<A>
<Ctrl>+<N>
<Alt>+<Enter>

<Ctrl>+<T>
<Ctrl>+<E>
<Ctrl>+<A>
<Ctrl>+<L>
<Ctrl>+<U>
<Alt>+<Enter>

<Enter>
<Spacebar>
<Enter>

<F6>
<Ctrl>+<Del>
<Shift>+<Del>
<Del>

10-100

J:

J:

, ,
POU . , , .


:
, . , ,
(: FileSize).
, ,
.

BOOL

FALSE

-
()

TRUE

x*
b

BYTE

by

WORD

16

DWORD

32

dw

LWORD

64

lw

SINT

-128

127

si

USINT

255

usi

INT

-32.768

32.767

16

UINT

65.535

16

ui

DINT

-2.147.483.648

2.147.483.647

32

di

UDINT

4.294.967.295

LINT
ULINT

REAL

CoDeSys V2.3

-2
0

63

32

udi

63

64

li

64

64

uli

32

2 -1
2 -1

10-101

J:
LREAL

64

lr

STRING

TIME

tim

TIME_OF_DAY

tod

DATETIME

dt

DATE

date

ENUM

16

POINTER

ARRAY

* x BOOL,
, ( %IX0.0). , , ( ).
:

bySubIndex: BYTE;
sFileName: STRING;
udiCounter: UDINT;
, :
:

pabyTelegramData: POINTER TO ARRAY [0..7] OF BYTE;


(:
sdo).
:

cansdoReceivedTelegram: CAN_SDOTelegram;
TYPE CAN_SDOTelegram :

(* : sdo *)

STRUCT
wIndex:WORD;
bySubIndex:BYTE;
byLen:BYTE;
aby: ARRAY [0..3] OF BYTE;
END_STRUCT
END_TYPE

c. ,
.
:

VAR CONSTANT
c_uiSyncID: UINT := 16#80;
END_VAR

(g) (gc) . :
CoDeSys V2.3

10-102

J:
:

VAR_GLOBAL
CAN_g_iTest: INT;
END_VAR
VAR_GLOBAL CONSTANT
CAN_gc_dwExample: DWORD;
END_VAR

(DUT)
(: CAN),
(: SDOTelegram).
, .
:

TYPE CAN_SDOTelegram :

(*: sdo *)

STRUCT
wIndex:WORD;
bySubIndex:BYTE;
byLen:BYTE;
abyData: ARRAY [0..3] OF BYTE;
END_STRUCT
END_TYPE

(: CAL) .
:

TYPE CAL_Day :(
CAL_MONDAY,
CAL_TUESDAY,
CAL_WEDNESDAY,
CAL_THIRSDAY,
CAL_FRIDAY,
CAL_SATURDAY,
CAL_SUNDAY);
:
eToday: CAL_Day;

,
(POU)
, (: CAN), (:
SendTelegram). , . POU .
CoDeSys V2.3

10-103

J:
:

FUNCTION_BLOCK CAN_SendTelegram (* : canst *)

POU .
.
, .
. ,
(), prv_.
, CoDeSys. .


: POU . , .

CoDeSys V2.3

10-104

K:

K:

CoDeSys V2.3

10-105

K:

,
. <F4> . POU.
. <F1> .

1100
" '<>' ."
. , , .hex file, .lib file.
1101
" '<>'."
POU <>, .
/ .
1102
" '<>'."
<> , <> .
1103
" '<>' '<>' 16K !"
16K- . .
.
1200
" '<>', '<>':
"
, ,
.
1300
" '<>' "
, , . .
1301
"Analyze- ! "
, analyzation.lib .
.

CoDeSys V2.3

10-106

K:
1302
" , . !"
, , . .
1400
" (pragma) '<>' !"
pragma . . " ".
1401
" '<>' "
, 1 .
1410
"'RETAIN' 'PERSISTENT' "
RETAIN PERSISTENT-
.
1411
" '<>' "
,
.
:
Variable Configuration:
VAR_CONFIG
plc_prg.aprg.ainst.in AT %IB0 : INT;
END_VAR
plc_prg:
index := INDEXOF(aprg);
aprg , . plc_prg.aprg.ainst. %IB0.
1412
" '<>' {}"
, 'pragma'.
1413
"'<>' '<>'. "
.
.
1414
" '<>'"
Pragma ( ), , .
CoDeSys V2.3

10-107

K:
1415
"<> (<>): '<>' "
<> (: TYPE aenum (a:=1, b:=1); END_TYPE).
1500
" . ."
. .
1501
" , 'VAR_IN_OUT' '<>' !"
POU, .
1502
" '<>' , POU. POU !"
POU .
:
PROGRAM a
...
VAR_GLOBAL
a: INT;
END_VAR
...
a; (* POU . *)
1503
"The POU <> . 'TRUE'"
POU, , FBD.
TRUE.
1504
"<> (<>): "
, .
:
IF a AND funct(TRUE) THEN ....
FALSE, funct .
1505
" '<>'! !"
POU FALSE, .
CoDeSys V2.3

10-108

K:
1506
" '<>' , . !"
, . .
.
1507
" '<>' , . ."
ST , . . .
1509
"'<>' ('<>'): 'Callback'"
callback, callback. RISC Motorola 68K!
1550
" POU '<>' "
POU .
1600
", DB ( )"
Siemens- DB.
1700
" "
CFC . .
1750
" '<>': !"
'Step attributes' . . .
1800
"<>( #< >): '<>'"
, .
.
1801
"'<> (): '<>' "
.
.

CoDeSys V2.3

10-109

K:
1802
"< >( ): '<>' "
, .
1803
"'<>'('<>'): web-"
. Web- Target.
1804
"'<>'('<>'): '<>' "
, . .
.
1805
"'<>'('<>'): '
'"
, .
1806
"'<>'('<>'): ' '"
"" , .
1807
"<> (<>): "
, "" !
1808
"'<>'('<>'): .
"
.
512 . .
1809
"'<> ('<>'): "
, .
1850
" %IB<> '<>'
"

CoDeSys V2.3

10-110

K:
, , ,
. , .
1851
" %IQ<> '<>'
"
, , ,
. , .
1852
"CanOpenMaster '<>' !
UpdateTask!"
CanOpen Master , . ,
UpdateTask dialog 'Module parameters' .
1853
"PDO (: '<>') '<>' ."
PDO , .
, PDO ,
-.
1900
"POU '<>' "
POU (.. PLC_PRG) , .
1901
"
!"
.
1902
"'<>': !"
.obj .
1903
"<>: "
.
1904
" '<>' "
, , .
!

CoDeSys V2.3

10-111

K:
1970
" : '<>', '<>', '<>' !"
*.prm, .
1980
" '<>' '<>':
!"
('Global variables list' 'Properties')
'Read' and 'Write'. .
1990
" 'VAR_CONFIG' '<>'"
Variable_Configuration (VAR_CONFIG).
Variable_Configuration (Resources) ( 'Insert 'All instance paths').
2500
" '<task name>': "
Task configuration , .
'Taskattributes' "Interval".

3100
" . : '<>' (<>K)"
. .
3101
" . : '<>' (<>K)"
. .
3110
" '<>'."
.hex INTEL Hex.
3111
" '<>' . : 64K"
.hex .
3112
" "

CoDeSys V2.3

10-112

K:
.hex . .
3113
" ."
.
3114
" "
.hex .
3115
" VAR_IN_OUT. ."

VAR_IN_OUT, "near", " huge" "far". , .
3116
" "
166x: . .
3117
"<> (<Zahl>): . "
. , .
3120
" 64K"
, 64K. , .
3121
"POU "
POU 64K.
3122
" . . : 64K"
64K.
3123
" : '<>%s', <> (.
<> )"
.

CoDeSys V2.3

10-113

K:
3124
" : <> (. 253)"
.
3130
" : '<>' DWORD, :
'<>' DWORD."
. Debug (Project Options Build).
3131
" : '<>' DWORD, :
'<>' DWORD."
.
3132
" : '<>' WORD , '<>' WORD ."
.
3150
" <> '<>': -,
C-"
, -.
3160
" '<>' ."
<> , .
3161
" '<>' "
.obj C-. .obj,
.lib .
3162
" '<>' ( '<>', '<>', '<>')"
.obj (symbol). -.
3163
" '<>' ( '<>', '<>' ,
'<>')"
.obj , . .

CoDeSys V2.3

10-114

K:
3200
"<>: "
.
.
3201
"<> (<>): 512 "
. "Use 16 bit jump offsets"
68k.
3202
" , //"
CONCAT(x, f(i)). .
3203
" ( )"
.
3204
" ( 32)"
, 32767 .
3205
" : "
POU 3000 .
3206
" "
32767 .
3207
" "
, .
3208
" "
, .
3209
" "
, .
CoDeSys V2.3

10-115

K:
3210
" '<>' "
, .
3211
" "
10 .
3212
" POU < POU>"
POU cslib.hex . (
r 68K).
3250
" Real 8- "
Real.
3251
" 8- "
.
3252
" <> "
.
3253
" hex-: '<>' "
hex .
3254
" "
.
3255
" 8- "
8- .

3260
" <> : ."
CoDeSys V2.3

10-116

K:
. , Target Platform, Target Settings. , .
3400
" "
.exp Access variables.
3401
" "
.exp variables configuration.
3402
" "
.exp global variables.
3403
" <>"
.exp <>.
3404
" "
.exp .
3405
" "
.exp .
3406
" '<name'. "
SFC exp . .
3407
" '<>' "
<> .exp .
3408
" '<>' "
<> .exp .
3409
" '<name>' "
CoDeSys V2.3

10-117

K:
<>. .exp .
3410
" '<>'"
<>. .exp .
3411
" '<>' "
.exp <> .
3412
" '<>' "
.
3413
" CAM"
(*.exp) CAM. .exp .
3414
" CNC "
(*.exp) CNC-.
3415
" "
(*.exp),
(Alarm Configuration). .
3450
"PDO '< PDO>': COB-Id!"
Properties COB ID <PDO Name>.
3451
" : EDS- '<>', ,
!"
, EDS . (Project''Options'
'Directories').
3452
" '<>'!"
<> . , CoDeSys .

CoDeSys V2.3

10-118

K:
3453
" '<>'!"
. ,
CoDeSys .
3454
" '<>' !"
'Check for overlapping addresses' . , , 'size' .
3455
" : GSD- '<>', ,
!"
, Profibus .
(Project' 'Options' 'Directories').
3456
" - '<>'!"
<> . ,
CoDeSys .
3457
" !"
.
3458
" ! "
, . .
3459
" "
CAN ,
GSD .
3460
3S_CanDrv.lib
, 3S_CanDrv.lib, , .
3461
" 3S_CanOpenMaster.lib"
, 3S_CanOpenMaster.lib, , .

CoDeSys V2.3

10-119

K:
3462
" 3S_CanOpenDevice.lib"
, 3S_CanOpenDevice.lib, , .
3463
" 3S_CanOpenManager.lib"
, 3S_ CanOpenManager.lib, , .
3464
" 3S_CanNetVar.lib"
, 3S_ CanNetVar.lib, , .
3465
"CanDevice: "
CanDevice
. .
3466
" CAN: - CAN- "
CAN (Resources, Global Variables),
CAN .
3468
"CanDevice: "
, (Base Settings) CANdevice, (Task Configuration).
3469
" CanOpenMaster. "
, Master UpdateTask PLC Configuration.
3470
" UpdateTask"
CanMasters Module PLC Configuration.
UpdateTask. .
, UpdateTask .
3500
" 'VAR_CONFIG' '<>'"
'Variable_Configuration'.

CoDeSys V2.3

10-120

K:
3501
" 'VAR_CONFIG' '<>'"
'Variable_Configuration'.
3502
" '<>' 'VAR_CONFIG"
Variable_Configuration POU.
3503
" '<>' 'VAR_CONFIG'"
Variable_Configuration POU .
3504
" 'VAR_CONFIG' "
Variable_Configuration .
.
3505
"<> "
Variable_Configuration .
3506
" "

Access
Variables
:<Identifier>:'<Access path>':<Type> <Access mode>.

3507
" 'VAR_ACCESS' "
Access Variables .
. : <Identifier>:'<Access path>':<Type> <Access mode>
3550
" '<>'"
, .
3551
" '<>' , , "
.
3552
" '<>' '<>'"
CoDeSys V2.3

10-121

K:
- Single ,
. .
3553
" '<>' '<>' 'BOOL'"
BOOL - Single .
3554
" '<>' "
Program call POU. .
3555
" '<>' "
Append program call , POU.
3556
" "
.
.
3557
" ('<>')"
. .
: XML- .
3558
" '<>' '<lower limit>'
'<upper limit>'"
. .
3559
" '<>': "
, . .
3560
" '<>': - (freewheeling)
"
(free wheeling) ,
. .

CoDeSys V2.3

10-122

K:
3561
" '<>': "
- ,
. .
3562
" '<>': , ,
"
, . .
3563
" '<>' '<lower limit>' '<upper
limit>'"
.
3564
" '<>' "
. .
3565
" ('<>')"
, .
.
3566
" ('<>')"
,
. .
3567
" - ('<>')"
(free wheeling) , . .
3568
" - ('<>')"
, . .
3569
"POU '<>' '<>' "
POU, '<>', .
CoDeSys V2.3

10-123

K:
3570
" '<>' '<>' "
, .
3571
" 'SysLibCallback' !
."
SysLibCallback.lib. .
3575
" <'name>': <> s."
Taskattributes.
.
3600
" !"
Rebuild all. ,
3601
"<> - "
, .
3610
" '<>' "
.
3611
" '<>'"
Project Options Directories .
3612
" POU (<>)! ."
POU. POU Target Settings / Memory
Layout.
3613
" "
.
3614
" POU '<>' ( ) "
CoDeSys V2.3

10-124

K:
POU (.. PLC_PRG) .
3615
"<> ( ) program"
POU (.. PLC_PRG) .
3616
" "
, , , .
.
3617
" "
.
3618
" !"
.
3619
" '<>' '<>'!"
, *.lib *.obj *.hex .
.
3620
"POU '<> "
2.1. PLC_PRG, .
3621
" '<>'"
, , ,
, " ". .
3622
" '<>'"
, , ( ), , " ".
.
3623
" '<>'"

CoDeSys V2.3

10-125

K:
, , (
), , " ". .
3624
" <1>=<> <2>=<>"
Targetsettings dialogs ( Resources).
, .
3700
"POU <>' '<>'"
POU , .
3701
", , POU"
Project Rename object POU POU. POU :
PROGRAM, FUNCTION FUNCTIONBLOCK.
3702
" "
100 .
3703
" '<>'"
, '<>' POU.
3704
" : "<POU 0> -> <POU 1> -> .. -> <POU 0>""
.
3705
"<>: VAR_IN_OUT POU , "
, VAR_IN_OUT
PLC_PRG.
3720
" 'AT' "
AT .
3721
" 'VAR' 'VAR_GLOBAL' "

CoDeSys V2.3

10-126

K:
VAR VAR_GLOBAL.
3722
" 'BOOL'"
BOOL . .
3726
" "
.
3727
" "
. .
3728
" : '<>'"
. .
3729
" '<>' : '<>' "
. : AT
%IB1:WORD; , . .
3740
" : '<>' "
.
3741
" "

3742
" "
.
3743
" "
(INT).
3744
" '<>' "
CoDeSys V2.3

10-127

K:
:

3745
" Integers!"
.
3746
" '<>' '<>'"
.
3747
" : '<>'"
.
3748
" 3"
. ARRAY OF ARRAY
.
3749
" '<>' "
, .
3750
" '<>' "
, .
3751
" '< >'"
.
3752
" 9"
1- 2- 3-. (, "arr: ARRAY [0..2,0..2,0..2] OF ARRAY [0..2,0..2,0..2] OF ARRAY [0..2,0..2,0..2,
0..2] OF DINT". 9.
. .

CoDeSys V2.3

10-128

K:
3760
" "
, . , (Shift/F2 'Edit''Autodeclare').
3761
" 'VAR_IN_OUT' ."
VAR_IN_OUT.
3780
" : 'VAR', 'VAR_INPUT', 'VAR_OUTPUT' 'VAR_IN_OUT'"
POU
.
3781
" 'END_VAR' "
END_VAR .
3782
" "
: END_VAR .
: , (, END_IF).
3783
" 'END_STRUCT' "
.
3784
" < >"
(, RETAIN, PERSISTENT)
3800
" .
."
Project Options Build.
3801
" '<>' (<> )"
,
. , .
CoDeSys V2.3

10-129

K:
3802
" . '<>', <> ."
Retain . . ,
( :
Retain, Retain !)
3803
" . '<>', <> ."
.
. ,
3820
"'VAR_OUTPUT' 'VAR_IN_OUT' "
-.
3821
" , , "
.
3840
" '<>'!"
POU VAR_EXTERNAL, .
3841
" '<>' !"
VAR_EXTERNAL .
3850
" '<>' '<>' !"
. .
3900
" "
.
3901
" - 4"
, 4- (,
%QB0.1.1.0.1).
CoDeSys V2.3

10-130

K:
3902
" "
Autoformat in Project
Options.
3903
" "
61131-3.
3904
" "
.
: t#49d17h2m47s295ms.
3905
" "
61131-3.
3906
" "
61131-3.
3907
" "
61131-3.
3908
" "
.
4000
" "

4001
" '<>' "
.
4010
" : '<>' '<>'."
, ,
.
CoDeSys V2.3

10-131

K:
4011
" '<>' '<>': '<>' '<>'."
. .
4012
" '<>' '<>': '<>'
'<>'."
'<>.
.
4013
" '<>' '<>': '<>' '<>'."
'<>.
.
4014
" : '<>' '<>'"
.
: SINT#255
4015
" <>' "
,
. , REAL/LREAL
<var1>.<bit>, .
4016
" '<>' '<>'"
, .
4017
"'MOD' 'REAL'"
MOD .
4020
" 'ST', 'STN', 'S', 'R'
"
, .
4021
" '<>' "
, .
CoDeSys V2.3

10-132

K:
4022
" "
.
4023
" '+' '-' "
.
4024
" <Operator 0> <Operator 1> ... '<>'"
.
4025
" ':=' '=>' '<>'"
.
4026
" 'BITADR' "
(.. %IX0.1).
4027
" "
.
4028
"'INI'- "
, 1.
4029
" ."
.
.
4030
" 'ADR'"
.
4031
"'ADR' ! 'BITADR'."
BITADR. , BITADR .
CoDeSys V2.3

10-133

K:
4032
" '<>' <> . , , <>"
.
4033
"<> '<>'. <>"
.
4034
" 0"
0 .
, .
4035
" ADR 'VAR CONSTANT', '
'"
. ,
Replace Constants in Project Options Build.
4040
" '<>' "
<LabelName> .
4041
" '<>'"
'<>' . .
4042
" <>"
. .
4043
" . , "
.
4050
"POU '<>' "
POU '<>' Project Add Object '<>' POU.
4051
"'<>' "
CoDeSys V2.3

10-134

K:
<> , .
4052
"'<>' '<>'"
.
4053
"'<>' "
'<>' POU , .
4054
" 'INDEXOF' POU"
POU.
4060
" 'VAR_IN_OUT' '<>' '<>' "
VAR_IN_OUT ,
POU.
4061
"'VAR_IN_OUT' '<>' '<>'."
VAR_IN_OUT , POU.
4062
" 'VAR_IN_OUT' '<>' '<>'."
VAR_IN_OUT POU,
.
4063
" 'VAR_IN_OUT' '<>' '<>'
."
. .
4064
"'VAR_IN_OUT' !"
VAR_IN_OUT .
4070
"POU "
, . .

CoDeSys V2.3

10-135

K:
4071
" "
.
4072
" FB ('<>')
('<>')."
fb, a1 a2,
, .
: fb.a1 inst.a1.
4100
"'^' "
, .
4110
" '[<>]' "
, .
4111
" 'INT'"
.
4112
" "
(1, 2 3) .
4113
" "
(1, 2 3) .
4114
" "
, , .
4120
"'.' "
, ,
.
4121
" '<>' <object name>"
CoDeSys V2.3

10-136

K:
'<>' <object name>.
4122
"'<>' "

.
4200
" 'LD'"
LD jump IL.
4201
" IL "
IL .
4202
" "
.
4203
"<> "
<> IL.
( 'JMP', 'RET', 'CAL', 'LDN', 'LD', 'TIME')
4204
" "
.
4205
" ')' "
.
4206
" "
, .
4207
" 'N' 'BOOL','BYTE','WORD' 'DWORD'"
N .
4208
" 'BOOL'"
CoDeSys V2.3

10-137

K:
,
BOOL.
4209
" "
.
4210
" 'CAL', 'CALC' 'CALN'
"
, .
4211
" IL "
.
4212
" "
. ,
( 'CAL').
4213
" 'S' 'R' 'BOOL'"
.
4250
" 'ST'- POU"
ST .
4251
" '<>'"
, .
4252
" '<>'"
, .
4253
" 'IF' 'ELSIF' "
IF ELSIF .
4254
" 'WHILE' "
CoDeSys V2.3

10-138

K:
WHILE .
4255
" 'UNTIL' "
UNTIL .
4256
" 'NOT' 'BOOL'-"
, NOT .
4257
" 'FOR' 'INT'"
,
DWORD).

'FOR' (.. DINT,

4258
" 'FOR' "
.
4259
" 'FOR' 'INT'"
'FOR' .
4260
" 'FOR' 'INT'"
'FOR' .
4261
" 'FOR' 'INT'"
'FOR' .
4262
"'EXIT' "
'EXIT' 'FOR', 'WHILE' 'UNTIL'.
4263
" , 'ELSE' 'END_CASE'"
CASE' .
4264
" 'CASE' "
, (.. DINT, DWORD).
CoDeSys V2.3

10-139

K:
4265
" ',' "
CASE .
4266
" "
.
4267
" "
.
4268
" "
.
4269
" 'ELSE'- 'END_CASE'"
'CASE' 'ELSE' 'END_CASE'.
4270
" 'CASE' '<>' "
CASE' CASE' .
4271
" , ."
, .
4272
" '<>' <position> '<>'!"
,
.
4273
"'CASE'- '<>' '<>',
"
, CASE .
4274
" 'ELSE'- 'CASE'"
CASE 'ELSE'.
CoDeSys V2.3

10-140

K:
4300
" Jump 'BOOL'"
, jump - .
4301
"POU '<>' <> "
VAR_INPUT VAR_IN_OUT.
4302
"POU '<>' %d "
VAR_ OUTPUT.
4303
"'<>' "
'<>' .
4320
" '<>'"
.
4321
" '<>'"
.
4330
" 'EN' POU '<>'"
EN..
4331
" '<>' POU '<>'"
<> .
4332
" '<>' POU '<>'"
VAR_IN_OUT.
4333
" "
.

CoDeSys V2.3

10-141

K:
4334
" jump"
jump. TRUE.
4335
" return"
RETURN. TRUE.
4336
" "
.
4337
" "
.
4338
" '<>' "
POU '<>' .
4339
" : '<>' '<>'.
.
4340
" Jump 'BOOL'"
, jump - .
4341
" Return 'BOOL'"
, RETURN - .
4342
" 'EN' POU '<>'"
EN.
4343
" : <>"
VAR_INPUT CONSTANT. POU 'Edit Parameters' .

CoDeSys V2.3

10-142

K:
4344
" 'S' 'R' 'BOOL'"
Set Reset.
4345
" '<>' '<>': '<>' '<>'."
'<>' .
4346
" , "
.
4347
" 'VAR_IN_OUT' "
VAR_IN_OUT .
4348
" '<>'. ."
CFC, , ,
. .
4349
POU <> : . CFC
POU. POU CFC.
4350
" SFC- !"
SFC POU, . SFC POU, , iecsfc.lib .
.
4351
" : '<>'"
.
4352
" : '<>'"
.
4353
" : '<>'"
CoDeSys V2.3

10-143

K:
.
4354
" : '<>'"
.
4355
" (, ..)"
.
4356
" : '<>' "
.
4357
"IEC- "
iecsfc.lib , Project Options, .
4358
" : '<>'"
, SFC POU
SFC.
4359
" : '<>'"
.
4360
" '<>'"
.
4361
"'<>' "

4362
" : '<>'"
.
4363
" IEC- : '<>'"
CoDeSys V2.3

10-144

K:
.
4364
" "
BOOL.
4365
" '<>'"
step attributes '<>'
.
4366
" : '<>'"
(jump).
4367
" '<>' "
. .
4368
" '<>' ,
!"
'<>' POU .
4369
" "
FBD LD . .
4370
" IL-"
IL .
4371
" : '<>"
.
4372
" '<>': 'TIME'"
TIME
(, "t#200ms").
4373
"- SFC-POU"
CoDeSys V2.3

10-145

K:
-SFC-POU (. ), . .
4374
" '<>' "
SFC POU , , -.
4375
" '<>' "
SFC POU , , -.
4376
" '<>' "
SFC POU , , -.
4377
" '<>'"
SFC POU , , -.
4400
" / POU '<>' ."
POU 61131-3.
4401
" S5, <>, (. 9990)."
BCD .
4402
" /"
, , .
4403
" STEP5/7 61131-3"
STEP5/7 61131-3, , , , MAS.
4404
" STEP5/7 61131-3"
STEP5/7 61131-3.
4405
" STEP5/7 61131-3"
CoDeSys V2.3

10-146

K:
.
4406
" STEP5/7 (. 999)"
BCD .
4407
" STEP5/7 61131-3"
STEP5/7 61131-3, , DUF.
4408
"
61131-3"
/ 61131-3.
4409
" ACCU1 ACCU2 611313"
, .
4410
" POU ."
POU.
4411
" ."
SEQ .
4412
" 11"
.
4413
" "
.
4414
"FB/FX "
S5D POU .
4415
" "
CoDeSys V2.3

10-147

K:
POU .
4416
" "
S5/S7
4417
" "
"*)".
4418
"FB/FX- (. 8 )"
POU .
4419
" ""(* : <FB/FX-> *)"" "
.
4420
" FB/FX"
POU.
4421
" FB/FX"
POU.
4422
" FB/FX"
POU.
4423
" FB/FX"
POU.
4424
": FB/FX , "
POU , (
).
4425
" "
CoDeSys V2.3

10-148

K:
.
4426
"POU STEP 5, . PB10"
POU.
4427
" "
..
4428
" STEP5/7"
.
4429
" "
.
4430
" 61131-3"
61131-3 , POU .
4431
" 'VAR_OUTPUT' STEP5/7-IL"
POU .
4432
" "
61131-3 .
4434
" "
POU 100 .
4435
" "
LD Load .
4436
" IEC 61131-3"
, VKE, , VKE
.
CoDeSys V2.3

10-149

K:
4437
" "
..
4438
" ( C DB)"
.
4500
" "
. <F2> .
4501
" "
.
4520
" : '<>' !"
. <>'
4521
" : '<>'!"
, .
4522
" 'flag off'!"
, .
4523
" {<>} '<>'"
.
.
4550
" : OD <>, < >."
, (. Target settings/networkfunctionality).
4551
" : OD <>, < >."
, (. Target settings /networkfunctionality).
CoDeSys V2.3

10-150

K:
4552
" : OD <>, < >."
, (. Target settings/networkfunctionality).
4553
" : OD <>, < >."
, (. Target settings/networkfunctionality).
4554
" : OD <>, < >."
'variable'. <POU name>.<variable
name> .<variable name> .
4555
" , : OD <>, < >
.
4556
" , : OD <>, <>"
.
4557
" "
, (Parameters). . .
4558
" "
, (Variables). . .
4560
" : '<>', '<>', '< >'"
. , - XML , .
4561
" : '<>'"
, .
XML . XML ,
.

CoDeSys V2.3

10-151

K:
4562
"/ : '<>', '< >'"
/ .
.
4563
" '<>' : '<>', '< >'"
, .
4564
" '<>' : '<>', '< >'
"
,
(Variables, Parameters, Mappings).
4565
" '<>' : '<>', '<
>'"
, 'SubIndex range'.
4566
" "
, . *.exp-.
4600
" : '<>' bool!"
, , 'Transmit on event' , BOOL.
4601
" '<>': - "
free-wheeling , CAN
UDP , PLC_PRG ( !).
PLC_PRG.
, , .
4602
"'< >': UDP- '< >'
'< >'"
, , . !
CoDeSys V2.3

10-152

K:
4604
" '<>': ."
COB-ID (Object Properties)
. ID.
4605
" '<>': CAN COB id."
(Object Properties) COB-ID,
CAN PLC Configuration. ID.
4620
. . 'Project' 'Check' (Unused Variables).
4621
AT"-. . 'Project'
'Check' ('Overlapping memory areas').
4622
, , . .
'Project' 'Check' ('Concurrent Access').
4623
. . 'Project' 'Check' ('Multiple writes to output').
4650
"AxisGroup '<>': '<>' ."
PLC Configuration ( 'Module parameters', 'Value') , , .
4651
"AxisGroup '<>': (dwCycle) ."
'Module parameters' (dwCycle).
4670
"CNC- '<>': '<>'."
CNC (, $glob_var$),
. .
4671
"CNC- '<>': '<>'."
CNC .
.

CoDeSys V2.3

10-153

K:
4685
"CAM '<>': CAM-."
, ''Compile options.."
4686
"CAM '<>': , CAM, ."
CAM , . . 'Compile options..' CAM-..
4700
"'<>' ('<>'): '<>' ."
, , (, XOffset Angle ..).
4701
"'<>' ('<>'): '<>' BOOL."
BOOL ,
4702
"'<>' ('<>'): '<>' STRING."
STRING ,
4703
"'<>' ('<>'): '<>'"
.
4704
"'<>'('<>'): '<>'."
, ( INTERN, Input),
. .
4705
"'<>' ('<>'): ."
( Alarm table).
4706
"'<>' ('<>'):
' '."
'Alarmhandling in the PLC'.
CoDeSys V2.3

10-154

K:
4707
"'<>' ('<>'): .
."
( 'Alarmhandling in the PLC'
). .
4708
"'<>' ('<>'): '
'."
'Store trend data in the PLC'
'Resources' 'Visualization'. , .
4709
"'<>' ('<>'): .
."
( 'Store trend data in the PLC'
). .
4900
" "
, .
4901
" : !"
32- . .
5100
"<> (<Zahl>): . "
. , .

CoDeSys V2.3

10-155

10-1