TIA PRO3 09 IntroductionToSTL en
TIA PRO3 09 IntroductionToSTL en
Contents 7
7. Introduction to STL ................................................................................................ 7-2
7.1. Goal of this Chapter: Displaying the Running Light when the Operation is Switched Off .... 7-3
7.2. What is STL?......................................................................................................................... 7-4
7.3. First Steps with STL .............................................................................................................. 7-5
7.3.1. Creating an STL Block .......................................................................................................... 7-5
7.3.2. STL Network in a LAD/FBD Block ........................................................................................ 7-6
7.3.3. Structure of an STL Block and Editing It ............................................................................... 7-7
7.3.4. Execution of Logic Strings (Instructions for Binary Logic Operations).................................. 7-8
7.3.5. Execution of Instructions with 1 or 2 Operands (Math Functions, Compare...) .................... 7-9
7.3.6. Compiling the Block and Downloading It ............................................................................ 7-10
7.3.7. Calling an STL Block ........................................................................................................... 7-11
7.4. Testing / Monitoring an STL Block ...................................................................................... 7-12
7.5. Frequently Used Instructions .............................................................................................. 7-13
7.5.1. Overview ............................................................................................................................. 7-13
7.5.2. L, T, TAK, POP Instructions ................................................................................................ 7-14
7.5.3. Math Function Instructions .................................................................................................. 7-15
7.5.4. Word Logic Operations ....................................................................................................... 7-16
7.5.5. Shift / Rotate Instructions .................................................................................................... 7-17
7.7. Processing 64-Bit Variables ................................................................................................ 7-18
7.8. Exercise 1 (Theory): First Check, Signal State, Result of Check and Result of Logic
Operation ............................................................................................................................ 7-19
7.9. Exercise 2: Commissioning the Running Light when the Operation is Switched Off ......... 7-20
7. Introduction to STL
In this chapter, an introduction to the programming language STL is given and the commissioning
of an STL block is practiced.
The participant becomes familiar with STL. He gets an overview of the structure and handling of
STL blocks.
Objectives:
The participant can then commission a simple STL block.
Task Description
As long as the operation is not switched on ("P_operation" Q0.1 =0), the output byte
"byteRunningLight“ (QB3) of the central DO module of the S7-1500 is to show a running light
which is pulsed with a 2 Hz "Clock_2Hz" (M10.3).
Just as with all other LAD/FBD/STL blocks, STL blocks are also created and managed in the
"Program blocks" section of the opened project.
• Possible block types: FC, FB or OB
• Selected language: STL
This cannot be changed later on since a switch-over to other programming languages (for
example, LAD/FBD/SCL) generally is not possible.
Block name and block number can be chosen (as is also generally the case for other languages).
Caution!
The registers (accumulators, address/DB registers...) do not really exist in S7-1500. They
are emulated and are only available within the STL networks of a block.
A data transfer between LAD/FBD networks and STL networks can only be done using PLC tags.
Even the result of logic operation (RLO) of a binary logic chain is set to undefined for network
transfers with language change (LAD/FBD ↔ STL).
The block structure (interface and instruction section) is identical to that of LAD/FBD/SCL blocks.
When programming instructions, the following points must be taken into consideration:
• Each instruction requires its own line.
• All identifiers (names) used in the instruction section must be defined as a global PLC tag, DB
variable or as an interface variable.
Bit logic operations use the RLO from the previous line and, with the result of check of the
operand, form a new RLO.
If the status ‘first check’ is fulfilled, there is no gating, but only the result of check of the operand is
adopted in the RLO.
ACCU1, ACCU2
Size: 4 bytes or 32 bits
These are two CPU-internal memories for storing operand values for the execution of a byte,
word or double-word instruction with 1 or 2 operands.
In the S7-300/400, these were very quick CPU-internal registers (memories). In the
S7-1500, they are emulated and so have no performance advantage vis-à-vis
LAD/FBD or SCL.
Load
Loading influences both ACCU1 and ACCU2 data registers
1. Value from ACCU1 is written in ACCU2
2. New load value is written in ACCU1
Transfer
The value from ACCU1 is always stored
STL blocks can be created as an FC or an FB depending on the task. These can be called by any
block. It doesn’t matter in which STEP 7 language (SCL, GRAPH, STL, LAD or FBD) these
blocks were created.
In accordance with the principle of structured programming, other blocks (FB, FC) can also be
called by an STL block. These blocks could have been created in STL or in another STEP 7
language (SCL, LAD, etc.).
Correctly compiled STL blocks which have been downloaded into the controller can be tested
using the monitoring function “Monitor”.
Address
Global operands → Operand address
Constants as operand → Value of the constant
RLO
The entry of the current RLO is additionally highlighted in color depending on the status.
• RLO = 1 → Table entry Column "RLO" highlighted in green
• RLO = 0 → Table entry Column "RLO" highlighted in blue
Extra
This column is used for further information depending on the need. For example,
- for mathematical instructions → relevant status bits
- for timer and counter instructions → time or count values
- for indirect addressing → memory address
- for ACCU manipulation → ACCU2
Word logic operations gate the operands ACCU1 with ACCU2 bit-by-bit and make the result
available in ACCU1.
This is used, for example, to check whether a certain bit of a variable is set.
0000_0000_0000_0000_0000_0000_0001_0000 checks bit 4 of the value from ACCU2
0000_0001_0000_0400_1010_1111_0001_0011 16#0104AF13
AD
0000_0000_0000_0000_0000_0000_0001_0000 ACCU1<>0, when bit is set
ACCU1 = 0, when bit is not set
Since math function instructions and comparators expect the values in ACCU1/2 and these only
have a size of 32 bits, 64-bit variables cannot be processed by these.
STEP 7 supplies the required global library.
Task
An instruction sequence with 3 different signal statuses of the checked (queried) binary signals is
given.
Analyze the logic string with regards to the result of check and result of logic operation and enter
your results in the table.
Task
As long as the operation is not switched on ("P_operation" Q0.1 =0), the output byte
"byteRunningLight" (QB3) of the central DO module of the S7-1500 is to show a running light
which is pulsed with a 2 Hz "Clock_2Hz" (M10.3).
The running light is to fulfill the following conditions:
• Switch on “P_operation”
(Input parameter #StatusOperation = ′0′ →'1'), the running light always starts from Bit No.0
(Q3.0).
• Switch off “P_operation”
(Input parameter #StatusOperation = '0') all bits are set to 0.
For this, an STL block is prepared in the course library.
Copy the FB from the course library, integrate the call in your FB "Signal", download the program
expansion and test the running light display at QB3.
What to Do