Efficiently Inserting Case Instruction; No Manipulation Of Loop Counters For For Loop - Siemens S7-1200 Programming Manualline

Step 7 tia portal, background and system description
Hide thumbs Also See for S7-1200:
Table of Contents

Advertisement

3 General Programming
3.10 SCL programming language: Tips and tricks
3.10.4

Efficiently inserting CASE instruction

With the CASE instruction in SCL, it will be exactly jumped to the selected CASE
block condition. After executing the CASE block the instruction is finished. This
allows you, for example, to check frequently required value ranges more
specifically and easily.
Example
CASE #myVar OF
// FCGlobal is never called for the values 5, 10, 12 or 15!
END_CASE;
3.10.5

No manipulation of loop counters for FOR loop

FOR loops in SCL are pure counter loops, i.e. the number of iterations is fixed
when the loop is entered. In a FOR loop, the loop counter cannot be changed.
With the EXIT instruction a loop can be interrupted at any time.
Advantages
The compiler can optimize the program better, since it does not know the
number of iterations.
Example
FOR #var := #lower TO #upper DO
#var := #var + 1;
END_FOR;
Programming Guideline for S7-1200/1500
V1.2, Entry ID: 81318674
5:
FC5(#myParam);
10,12:
FC10(#myParam);
15:
FC15(#myParam);
0..20:
FCGlobal(#myParam);
ELSE
// no effect, Compiler -> Warning
66

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

S7-1500

Table of Contents