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

The IEC Operators

287

The IEC Operators

 

 

 

12The IEC Operators

12.1 The IEC Operators

WAGO-I/O-PRO 32 supports all IEC operators. In contrast with the standard library functions (see appendix D, Standard library), these operators are recognized implicitly throughout the project. Operators are used like functions in POU. The following categories of operators are supported:

12.2 Arithmetic Operators

12.2.1ADD

Addition of variables of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT and REAL.

Two TIME variables can also be added together resulting in another time (e.g., t#45s + t#50s = t#1m35s)

Example in IL:

LD 7

ADD 2,4,7

ST Var 1

Example in ST:

var1 := 7+2+4+7;

Example in FBD:

12.2.2MUL

Multiplication of variables of the types: BYTE, WORD, DWORD, SINT,

USINT, INT, UINT, DINT, UDINT and REAL.

Example in IL:

LD 7

MUL 2,4,7

ST Var 1

Example in ST:

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

288 The IEC Operators

Arithmetic Operators

var1 := 7*2*4*7;

Example in FBD:

12.2.3SUB

Subtraction of one variable from another of the types: BYTE, WORD,

DWORD, SINT, USINT, INT, UINT, DINT, UDINT and REAL.

A TIME variable may also be subtracted from another TIME variable resulting in third TIME type variable. Note that negative TIME values are undefined.

Example in IL:

LD 7

SUB 8

ST Var 1

Example in ST:

var1 := 7-2;

Example in FBD:

12.2.4DIV

Division of one variable by another of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT and REAL.

Example in IL:

LD 8

DIV 2

ST

Var1 (* Result is 4 *)

Example in ST:

var1 := 8/2;

Example in FBD:

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

The IEC Operators 289

Arithmetic Operators

Note:

If you define functions in your project with the names CheckDivByte,

CheckDivWord, CheckDivDWord and CheckDivReal, you can use them to check the value of the divisor if you use the operator DIV, for example to avoid a division by 0. The functions must have the above listed names. See in the following an example for the implementation of function CheckDivReal:

Operator DIV uses the output of function CheckDivReal as divisor. In a program like shown in the following example this avoids a division by 0, the divisor (d) is set from 0 to 1. So the result of the division is 799.

12.2.5MOD

Modulo Division of one variable by another of the types: BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT. The result of this function will be the remainder of the division. This result will be a whole number.

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

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