Introduction

An operand can be:

  • an address

  • a literal

  • a variable

  • a multi-element variable

  • an element of a multi-element variable

  • a function call

  • an FFB output

Data Types

Data types, which are in an instruction of processing operands, must be identical. 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.

r3 := r4 + SIN(INT_TO_REAL(i1)) ;

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:

  • timeVar1 := timeVar2 / dintVar1;

  • timeVar1 := timeVar2 * intVar1;

  • timeVar := 10 * time#10s;

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 addresses data type is assigned 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).

For example, 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;
UnlocV1[2] := LocV1[%MW200];
LocV2      := t#3s;

Accessing Field Variables

When accessing field variables (ARRAY), only literals and variables of the INT, UINT, DINT and UDINT data 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: Using field variables

var1[i] := 8 ;
var2.otto[4] := var3 ;
var4[1+i+j*5] := 4 ;