Specifications
Basic Concepts for Programming an S7-200 CPU
4-7
S7-200 Programmable Controller System Manual
C79000-G7076-C233-01
As you can see from Figure 4-3, this text-based concept is very similar to
assembly language programming. The CPU executes each instruction in the order
dictated by the program, from top to bottom, and then restarts at the top. STL and
assembly language are also similar in another sense. S7-200 CPUs use a logic
stack to resolve the control logic (see Figure 4-4). The LAD and FBD editors
automatically insert the instructions that are necessary to handle the stack
operation. In STL, you have to insert these instructions to handle the stack.
S0
S1
S2
S3
S4
S5
S6
S7
Stack 0 - First stack level, or top of the stack
Stack 1 - Second stack level
Stack 2 - Third stack level
Stack 3 - Fourth stack level
Stack 4 - Fifth stack level
Stack 5 - Sixth stack level
Stack 6 - Seventh stack level
Stack 7 - Eighth stack level
Bits of the Logic Stack
Load (LD)
Loads a new value (nv) onto the
stack.
Before Load After Load
And (A)
ANDs a new value (nv) with the
initial value (iv) at the top of the
stack.
S0 = iv0 * nv
Or (O)
ORs a new value (nv) with the initial
value (iv) at the top of the stack.
S0 = iv0 + nv
iv0
iv1
iv2
iv3
iv4
iv5
iv6
iv7
nv
iv0
iv1
iv2
iv3
iv4
iv5
iv6
Before And After And
iv0
iv1
iv2
iv3
iv4
iv5
iv6
iv7
S0
iv1
iv2
iv3
iv4
iv5
iv6
iv7
Before Or After Or
iv0
iv1
iv2
iv3
iv4
iv5
iv6
iv7
S0
iv1
iv2
iv3
iv4
iv5
iv6
iv7
In these examples, “iv0” to “iv7” identify the initial values of the logic stack, “nv” identifies a new value provided by the instruction, and
“S0” identifies the calculated value that is stored in the logic stack.
S8 Stack 8 - Ninth stack level
iv8 is lost.
iv8
iv7
iv8 iv8 iv8 iv8
Figure 4-4 Logic Stack of the S7-200 CPU
The main points to consider when you select the STL editor are:
STL is most appropriate for experienced programmers.
STL sometimes allows you to solve problems that you cannot solve very easily
with the LAD or FBD editor.
You can only use the STL editor with the SIMATIC instruction set.
While you can always use the STL editor to view or edit a program that was
created with the SIMATIC LAD or FBD editors, the reverse is not always true.
You cannot always use the SIMATIC LAD or FBD editors to display a program
that was written with the STL editor.