Материал: m912201e

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

WAGO-I/O-PRO 32 V2.2 Overview

29

Languages

 

 

 

END_IF;

Here the heating is turned on when the temperature sinks below 17 degrees. Otherwise it remains off.

2.4.2.7 CASE instruction

With the CASE instructions one can combine several conditioned instructions with the same condition variable in one construct.

Syntax:

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;

A CASE instruction is processed according to the following model:

If the variable in <Var1> has the value <Value i>, then the instruction <Instruction i> is executed.

If <Var 1> has none of the indicated values, then the <ELSE Instruction> is executed.

If the same instruction is to be executed for several values of the variables, then one can write these values one after the other separated by commas, and thus condition the common execution.

If the same instruction is to be executed for a value range of a variable, one can write the initial value and the end value separated by two dots one

after the other. So you can condition the common condition. Example:

CASE INT1 OF

1, 5: BOOL1 := TRUE; BOOL3 := FALSE;

2:BOOL2 := FALSE; BOOL3 := TRUE;

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

30WAGO-I/O-PRO 32 V2.2 Overview

Languages

10..20: BOOL1 := TRUE;

BOOL3:= TRUE;

ELSE

BOOL1 := NOT BOOL1;

BOOL2 := BOOL1 OR BOOL2;

END_CASE;

2.4.2.8 FOR loop

With the FOR loop one can program repeated processes.

Syntax:

INT_Var :INT;

FOR <INT_Var> := <INIT_VALUE> TO <END_VALUE> {BY <Step

size>} DO

<Instructions>

END_FOR;

The part in braces {} is optional.

The <Instructions> are executed as long as the counter <INT_Var> is not greater than the <END_VALUE>. This is checked before executing the <Instructions> so that the <instructions> are never executed if <INIT_VALUE> is greater than <END_VALUE>.

When <Instructions> are executed, <INT_Var> is always increased by <Step size>. The step size can have any integer value. If it is missing, then it is set to 1. The loop must also end since <INT_Var> only becomes greater.

Example:

FOR Counter:=1 TO 5 BY 1 DO

Var1:=Var1*2;

END_FOR;

Erg:=Var1;

Let us assume that the default setting for Var1 is the value 1. Then it will have the value 32 after the FOR loop.

Note:

<END_VALUE> must not be equal to the limit value of the counter <INT_VAR>. For example: If the variable Counter is of type SINT and if

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

WAGO-I/O-PRO 32 V2.2 Overview

31

Languages

 

 

 

<END_VALUE> is 127, you will get an endless loop.

2.4.2.9 WHILE loop

The WHILE loop can be used like the FOR loop with the difference that the break-off condition can be any Boolean expression. This means you indicate a condition which, when it is fulfilled, the loop will be executed.

Syntax:

WHILE <Boolean expression>

<Instructions>

END_WHILE;

The <Instructions> are repeatedly executed as long as the <Boolean_expression> returns TRUE. If the <Boolean_expression> is already FALSE at the first evaluation, then the <Instructions> are never executed. If <Boolean_expression> never assumes the value FALSE, then the <Instructions> are repeated endlessly which causes a relative time delay.

Note:

The programmer must make sure that no endless loop is caused. He does this by changing the condition in the instruction part of the loop, for example, by counting up or down one counter.

Example:

WHILE counter<>0 DO

Var1 := Var1*2;

Counter := Counter-1;

END_WHILE

The WHILE and REPEAT loops are, in a certain sense, more powerful than the FOR loop since one doesn't need to know the number of cycles before executing the loop. In some cases one will, therefore, only be able to work with these two loop types. If, however, the number of the loop cycles is clear, then a FOR loop is preferable since it allows no endless loops.

2.4.2.10REPEAT loop

The REPEAT loop is different from the WHILE loop because the break-off condition is checked only after the loop has been executed. This means that the loop will run through at least once, regardless of the wording of the breakoff condition.

Syntax:

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

32WAGO-I/O-PRO 32 V2.2 Overview

Languages

REPEAT

<Instructions>

UNTIL <Boolean expression>

END_REPEAT;

The <Instructions> are carried out until the <Boolean expression> returns TRUE.

If <Boolean expression> is produced already at the first TRUE evaluation, then <Instructions> are executed only once. If <Boolean_expression> never assumes the value TRUE, then the <Instructions> are repeated endlessly which causes a relative time delay.

Note:

The programmer must make sure that no endless loop is caused. He does this by changing the condition in the instruction part of the loop, for example by counting up or down one counter.

Example:

REPEAT

Var1 := Var1*2;

Counter := Counter-1;

UNTIL

Counter=0

END_REPEAT;

2.4.2.11EXIT instruction

If the EXIT instruction appears in a FOR, WHILE, or REPEAT loop, then the innermost loop is ended, regardless of the break-off condition.

2.4.3 Sequential Function Chart (SFC)

The Sequential Function Chart is a graphically oriented language which makes it possible to describe the chronological order of different actions within a program.

x Example for a network in the Sequential Function Chart

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

WAGO-I/O-PRO 32 V2.2 Overview

33

Languages

 

 

 

2.4.3.1 Step

A POU written in a Sequential Function Chart consists of a series of steps which are connected with each other through directed connections (transitions).

There are two types of steps.

The simplified type consists of an action and a flag which shows if the step is active. If the action of a step is implemented, then a small triangle appears in upper right corner of the step.

An IEC step consists of a flag and one or more assigned actions or boolean variables. The associated actions appear to the right of the step..

2.4.3.2 Action

An action can contain a series of instructions in IL or in ST, a lot of networks in FBD or in LD, or again in Sequential Function Chart (SFC).

With the simplified steps an action is always connected to a step. In order to edit an action, click twice with the mouse on the step to which the action belongs. Or select the step and select the menu command 'Extras' 'Zoom Action/Transition'. In addition, one input or output action per step is possible.

Actions of IEC steps hang in the Object Organizer directly under their SFCPOU and are loaded with a doubleclick or by pressing <Enter> in their editor. New actions can be created with 'Project' 'Add Action'.

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