DriveLab
Account

Statement list (STL) and the .awl export

The syntax of S7-200 statement list: networks and comments, the logic stack (LD, A, O, ALD, OLD, LPS, LRD, LPP), boxes, operands and constants, symbols, and the layout of a Micro/WIN .awl export. Paste your own program and run it.

35 min

Show me

STL (statement list; IEC name: instruction list) is the text form of an S7-200 program. Every LAD network has an STL equivalent, and File → Export writes a whole program as STL in an .awl file. Reading STL tells you exactly what the CPU executes.

Lines, networks, comments

Network 1 // Start/stop station
// RUN is set by START, held by its own contact, released by STOP_NC
LD     START      // START pressed
O      RUN
A      STOP_NC
=      RUN
  • A program is a list of networks; Network n // title starts one.
  • // starts a comment: on its own line after the network line (network comment) or after an instruction.
  • One instruction per line: a mnemonic (LD, A, =, TON…) then its operands separated by commas.
  • Operands are addresses (I0.0, VW100, T37), constants (+50, 16#DB, 2#1010, 9.81) or symbols from the symbol table (START). The export may also quote symbols ("START").

The logic stack

Bit instructions work on a stack of bits. The top of the stack (TOS) is the current "power flow".

InstructionEffect on the stackLAD equivalent
LD bit / LDN bitpush bit / NOT bitfirst contact of a rung or branch
A bit / AN bitTOS := TOS AND bit / AND NOT bitcontact in series
O bit / ON bitTOS := TOS OR bit / OR NOT bitcontact in parallel
ALDpop two, push their ANDtwo blocks in series
OLDpop two, push their ORtwo blocks in parallel
LPS / LRD / LPPpush a copy / read the copy / pop ita branch point feeding several outputs
NOT, EU, EDinvert TOS / rising / falling edge of TOSNOT, P, N contacts
= bit, S bit, n, R bit, nwrite TOS / set / reset n bits if TOScoils

Boxes (TON, MOVW, +I, CTU…) execute when TOS is 1. A counter takes two or three stack levels (CU, then R; or CU, CD, R). The stack is 9 levels deep on the S7-200.

Statement list (STL) on a virtual PLC-200

No errors: the program compiles.

SIMATIC S7-200 · CPU 224SFRUNSTOP
I0.0
I0.1
I0.2
I0.3
I0.4
I0.5
Q0.0 0
Q0.1 0
Q0.2 0
Timet = 0.00 s · 0 scans

Open Program status: the first column is the TOS after each instruction, live. Change the inputs on the panel and watch ALD and LPS/LPP do their work.

Predict first

How do you write (I0.0 OR I0.1) AND (I0.2 OR I0.3) → Q0.0 in STL?

The layout of an .awl export

ORGANIZATION_BLOCK MAIN:OB1
TITLE=Program comment
BEGIN
Network 1 // Network title
// Network comment
LD     START
…
END_ORGANIZATION_BLOCK
SUBROUTINE_BLOCK SBR_0:SBR0
TITLE=Subroutine comment
VAR_INPUT
Speed:INT;   // local variables of the subroutine
END_VAR
BEGIN
Network 1
…
END_SUBROUTINE_BLOCK

The main program is ORGANIZATION_BLOCK MAIN:OB1; subroutines and interrupt routines follow. The symbol table is not in the .awl: copy it from Micro/WIN (select the table, Ctrl+C) into the symbol box of the runner, or save it as a text file.

SIMATIC and International mnemonics

Micro/WIN can show STL with two mnemonic sets (Tools → Options → General). The booklet, the manual and this site use the SIMATIC set (LD, A, O, =). If an export looks unfamiliar, check that option before anything else.