Introduction

Operators are used for operands.

An operand can be:

  • an address

  • a literal

  • a variable

  • a multi-element variable

  • an element of a multi-element variable

  • an EFB/DFB output or

  • an EFB/DFB call

Data Types

The operand and the current accumulator content must be of the same type. Should operands of various types be processed, a type conversion must be performed beforehand.

In the example the integer variable i1 is converted into a real variable before being added to the real variable r4.

LD  i1
INT_TO_REAL
ADD r4
ST  r3

As an exception to this rule, variables with data type TIME can be multiplied or divided by variables with data type INT, DINT, UINT or UDINT.

Permitted operations:

  • LD timeVar1

    DIV dintVar1

    ST timeVar2

  • LD timeVar1

    MUL intVar1

    ST timeVar2

  • LD timeVar1

    MUL 10

    ST timeVar2

This function is listed by IEC 61131-3 as "undesired" service.

Direct Use of Addresses

Addresses can be used directly (without a previous declaration). In this case the data type is assigned to the address directly. The assignment is made using the "Large prefix".

The different large prefixes are given in the following table.

Large prefix / Symbol

Example

Data type

no prefix

%I10, %CH203.MOD, %CH203.MOD.ERR

BOOL

X

%MX20

BOOL

B

%QB102.3

BYTE

W

%KW43

INT

D

%QD100

DINT

F

%MF100

REAL

Using Other Data Types

Should other data types be assigned as the default data types of an address, this must be done through an explicit declaration. This variable declaration takes place comfortably using the variable editor. The data type of an address can not be declared directly in an ST section (e.g. declaration AT %MW1: UINT; not permitted).

The following variables are declared in the variable editor:

UnlocV1: ARRAY [1..10] OF INT;
LocV1:   ARRAY [1..10] OF INT AT %MW100;
LocV2:   TIME AT %MW100;

The following calls then have the correct syntax:

%MW200 := 5;
LD LocV1[%MW200]
ST UnlocV1[2]

LD t#3s
ST LocV2

Accessing Field Variables

When accessing field variables (ARRAY), only literals and variables of INT, DINT, UINT and UDINT types are permitted in the index entry.

The index of an ARRAY element can be negative if the lower threshold of the range is negative.

Example: Saving a field variable

LD var1[i]
ST var2.otto[4]