Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
159
Добавлен:
11.10.2020
Размер:
2.81 Mб
Скачать

Appendix E: - Operators and Library Modules Overview

Appendix E: Operators and Library Modules Overview

The table shown below shows an overview on the operators, which are available in CoDeSys resp. in the libraries Standard.lib and Util.lib. You find there the notation for ST and IL. For IL also the supported modificators are listed.

Take note that for the 'IL operator' column: Only the line in which the operator is used will be displayed. A prerequisite is that the (first) required operand have been successfully loaded in the preceding line (e.g. LD in).

The 'Mod. IL' column shows the possible modifiers in IL:

C The command is only executed if the result of the preceding expression is TRUE.

Nfor JMPC, CALC, RETC: The command is only executed if the result of the preceding expression is FALSE.

N otherwise: negation of the operand (not of the accumulator)

( Operator enclosed in brackets: only after the closing bracket is reached will the operation preceding the brackets be carried out.

Please obtain a detailed description of usage from the appropriate Appendices concerning IEC operators integrated into CoDeSys resp. the libraries.

10.20 Operators in CoDeSys:

in ST

in AWL

Mod. Description

 

 

AWL

 

'

 

 

String delimiters (e.g. 'string1')

..

 

 

Size of Array range (e.g. ARRAY[0..3] OF

[ ]

 

 

INT)

:

 

 

Delimiter between Operand and Type in a

 

 

 

declaration (e.g. var1 : INT;)

;

 

 

Termination of instruction (e.g. a:=var1;)

^

 

 

Dereferenced Pointer (e.g. pointer1^)

 

LD var1

N

Load value of var1 in buffer

:=

ST var1

N

Store actual result to var1

 

S boolvar

 

Set boolean operand boolvar exactly then to

 

 

 

TRUE, when the actual result is TRUE

 

R boolvar

 

Set boolean operand boolvar exactly then to

 

 

 

FALSE, when the actual result is TRUE

 

JMP label

CN

Jump to label

<Program name>

CAL prog1

CN

Call program prog1

<Instance name>

CAL inst1

CN

Call function block instance inst1

<Fctname>(vx, vy,..)

<Fctname> vx, vy

CN

Call function fctname and transmit variables

 

 

 

vx, vy

CoDeSys V2.3

10-61

 

Appendix E: - Operators and Library Modules Overview

in ST

in AWL

Mod. Description

 

 

AWL

 

 

(

 

The value following the bracket is handled as

 

 

 

operand, the operation before the bracket is

 

 

 

not executed before the expression in the

 

 

 

brackets.

 

)

 

Now execute the operation which has been

 

 

 

set back

AND

AND

N,(

Bitwise AND

OR

OR

N,(

Bitwise OR

XOR

XOR

N,(

Bitwise exclusive OR

NOT

NOT

 

Bitweise NOT

+

ADD

(

Addition

-

SUB

(

Subtraction

*

MUL

(

Multiplication

/

DIV

(

Division

>

GT

(

Greater than

>=

GE

(

Greater or equal

=

EQ

(

Equal

<>

NE

(

Not equal

<=

LE

(

Less or equal

<

LT

(

Less than

MOD(in)

MOD

 

Modulo Division

INDEXOF(in)

INDEXOF

 

Internal index of POU in1; [INT]

SIZEOF(in)

SIZEOF

 

Number of bytes required for the given data

 

 

 

type of in

SHL(K,in)

SHL

 

Bitwise left-shift of operator in by K

SHR(K,in)

SHR

 

Bitwise right-shift of operator in by K

ROL(K,in)

ROL

 

Bitwise rotation to the left of operator in by K

ROR(K,in)

ROR

 

Bitwise rotation to the right of operator in by

 

 

 

K

SEL(G,in0,in1)

SEL

 

Binary selection between 2 operands in0 (G

 

 

 

is FALSE) and in1 (G is TRUE)

MAX(in0,in1)

MAX

 

Returns the greater of 2 values

MIN(in0,in1)

MIN

 

Returns the lesser of 2 values in0 and in1

LIMIT(MIN,in,Max)

LIMIT

 

Limits the value range (in is set back to MIN

 

 

 

or MAX in case of exceeding the range)

10-62

CoDeSys V2.3

Appendix E: - Operators and Library Modules Overview

in ST

in AWL

Mod. Description

 

 

AWL

MUX(K,in0,...in_n)

MUX

Selectsi the Kth value out of a group of

 

 

values (in0 to In_n)

ADR(in)

ADR

Address of the operand in [DWORD]

BOOL_TO_<type>(in)

BOOL_TO_<type>

Type conversion of the boolean operand

<type>_TO_BOOL(in)

<type>_TO_BOOL

Type conversion to BOOL

INT_TO_<type>(in)

INT_TO_<type>

Type conversion of an INT Operand to

 

 

anotner elementary type

REAL_TO_<type>(in)

REAL_TO_<type>

Type conversion of an REAL operand to

 

 

anotner elementary type

LREAL_TO_<type>(in)

LREAL_TO_<type>

Type conversion of a LREAL operand to

 

 

anotner elementary type

TIME_TO_<type>(in)

TIME_TO_<type>

Type conversion of a TIME operand to

 

 

anotner elementary type

TOD_TO_<type>(in)

TOD_TO__<type>

Type conversion of a TOD operand to

 

 

anotner elementary type

DATE_TO_<type>(in)

DATE_TO_<type>

Type conversion of a DATE operand to

 

 

anotner elementary type

DT_TO_<type>(in)

DT_TO_<type>

Type conversion of a DT operand to anotner

 

 

elementary type

STRING_TO_<type>(in)

STRING_TO_<type>

Type conversion of a string operand des

 

 

Operanden to anotner elementary type, in

 

 

must contain valid value of desired type

TRUNC(in)

TRUNC

Conversion from REAL to INT

ABS(in)

ABS

Absolut value of operand in

SQRT(in)

SQRT

Square root of operand in

LN(in)

LN

Natural logarithm of operand in

LOG(in)

LOG

Logarithm of operand in, base 10

EXP(in)

EXP

Exponential function of operand in

SIN(in)

SIN

Sine of operand in

COS(in)

COS

Cosine of operand in

TAN(in)

TAN

Tangent of operand in

ASIN(in)

ASIN

Arc sine of operand in

ACOS(in)

ACOS

Arc cosine of operand in

ATAN(in)

ATAN

Arc tangent of operand in

EXPT(in,expt)

EXPT expt

Exponentation of operand in with expt

CoDeSys V2.3

10-63

Appendix E: - Operators and Library Modules Overview

10.21 Elements of the Standard.lib:

in ST

in AWL

Description

LEN(in)

LEN

String length of operand in

LEFT(str,size)

LEFT

Left inital string of given size of string str

RIGHT(str,size)

RIGHT

Right initial string of given size of string str

MID(str,size)

MID

Partial string of str of given size

CONCAT('str1','str2')

CONCAT 'str2'

Concatenation of two subsequent strings

INSERT('str1','str2',pos)

INSERT 'str2',p

Insert string str1 in String str2 at position pos

DELETE('str1',len,pos)

DELETE len,pos

Delete partial string (length len), start at position pos of

 

 

str1

REPLACE('str1','str2',len,pos)

REPLACE

Replace partial string of lenght len by str2, start at

 

'str2',len,pos

position pos of str1

FIND('str1','str2')

FIND 'str2'

Search for partial string str2 in str1

SR

SR

Bistable FB is set dominant

RS

RS

Bistable FB is set back

SEMA

SEMA

FB: Software Semaphor (interruptable)

R_TRIG

R_TRIG

FB: rising edge is detected

F_TRIG

F_TRIG

FB: falling edge is detected

CTU

CTU

FB: Counts upv

CTD

CTD

FB: Counts down

CTUD

CTUD

FB: Counts up and down

TP

TP

FB: trigger

TON

TON

FB: Einschaltverzögerung

TOF

TOF

FB: Ausschaltverzögerung

RTC

RTC

FB: Laufzeit-Uhr

10.22 Elements of the Util.lib:

BCD_TO_INT

Conversion of a Byte: BCD to INT format

INT_TO_BCD

Converstion of a Byte: INT to BCD format

EXTRACT(in,n)

The n-th bit of DWORD in is returned in BOOl

PACK

Up to 8 bits are packed into a byte

PUTBIT

A bit of a DWORD is set to a certain value

UNPACK

A Byte is returned as single bits

10-64

CoDeSys V2.3

 

Appendix E: - Operators and Library Modules Overview

DERIVATIVE

Local derivation

INTEGRAL

Integral

STATISTICS_INT

Min.,Max, Average values in INT format

STATISTICS_REAL

Min.,Max, Average in REAL format

VARIANCE

Variance

PD

PD controller

PID

PID controller

BLINK

Pulsating signal

GEN

Periodic functions

CHARCURVE

linear functions

RAMP_INT

Limiting ascendance of descendance of the function beeing fed (INT)

RAMP_REAL

Limiting ascendance of descendance of the function beeing fed (REAL)

HYSTERESIS

Hysteresis

LIMITALARM

Watches whether input value exceeds limits of a defined range

CoDeSys V2.3

10-65

Appendix E: - Operators and Library Modules Overview

10-66

CoDeSys V2.3

Соседние файлы в папке 759-333