Preface, Contents
Bit Logic Instructions 1
Comparison Instructions 2
Conversion Instructions 3
Counter Instructions 4
Data Block Instructions 5
Logic Control Instructions 6
Integer Math Instructions 7
Floating-point Math Instructions 8
Load and Transfer Instructions 9
Program Control Instructions 10
Shift and Rotate Instructions 11
Timer Instructions 12
Word Logic Instructions 13
Accumulator Instructions 14
Appendix
Overview of All STL Instructions A
SIMATIC
Statement List (STL)for S7-300 and S7-400Programming
Reference Manual
This manual is part of the documentation
package with the order number:6ES7810-4CA06-8BR0
Programming Examples B
Index
Edition 12/2002A5E00171232-01
Copyright © Siemens AG 2002 All rights reserved
The reproduction, transmission or use of this document or itscontents is not permitted without express written authority.Offenders will be liable for damages. All rights, including rightscreated by patent grant or registration of a utility model or design,are reserved.
Siemens AGBereich Automation and DrivesGeschaeftsgebiet Industrial Automation SystemsPostfach 4848, D- 90327 Nuernberg
Disclaimer of Liability
We have checked the contents of this manual for agreement withthe hardware and software described. Since deviations cannot beprecluded entirely, we cannot guarantee full agreement. However,the data in this manual are reviewed regularly and any necessarycorrections included in subsequent editions. Suggestions forimprovement are welcomed.
©Siemens AG 2002Technical data subject to change.
Siemens Aktiengesellschaft A5E00171232-01
Safety Guidelines
This manual contains notices intended to ensure personal safety, as well as to protect the products and
connected equipment against damage. These notices are highlighted by the symbols shown below and
graded according to severity by the following texts:
!Dangerindicates that death, severe personal injury or substantial property damage will result if properprecautions are not taken.
!Warningindicates that death, severe personal injury or substantial property damage can result if properprecautions are not taken.
!Cautionindicates that minor personal injury can result if proper precautions are not taken.
Cautionindicates that property damage can result if proper precautions are not taken.
Noticedraws your attention to particularly important information on the product, handling the product, or to aparticular part of the documentation.
Qualified Personnel
Only qualified personnel should be allowed to install and work on this equipment. Qualified persons are
defined as persons who are authorized to commission, to ground and to tag circuits, equipment, and
systems in accordance with established safety practices and standards.
Correct Usage
Note the following:
!Warning
This device and its components may only be used for the applications described in the catalog or the
technical description, and only in connection with devices or components from other manufacturers
which have been approved or recommended by Siemens.
This product can only function correctly and safely if it is transported, stored, set up, and installedcorrectly, and operated and maintained as recommended.
Trademarks
SIMATIC®, SIMATIC HMI® and SIMATIC NET® are registered trademarks of SIEMENS AG.
Third parties using for their own purposes any other names in this document which refer to trademarks might
infringe upon the rights of the trademark owners.
Statement List (STL) for S7-300 and S7-400 Programming
A5E00171232-01 iii
Preface
Purpose
This manual is your guide to creating user programs in the Statement List
programming language STL.
The manual also includes a reference section that describes the syntax and
functions of the language elements of STL.
Basic Knowledge Required
The manual is intended for S7 programmers, operators, and maintenance/service
personnel.
In order to understand this manual, general knowledge of automation technology is
required.
In addition to, computer literacy and the knowledge of other working equipment
similar to the PC (e.g. programming devices) under the operating systems
MS Windows 95, MS Windows 98, MS Windows Millenium, MS Windows NT 4.0
Workstation, MS Windows 2000 Professional or MS Windows XP Professional are
required.
Scope of the Manual
This manual is valid for release 5.2 of the STEP 7 programming software package.
Compliance with Standards
STL corresponds to the "Instruction List" language defined in the International
Electrotechnical Commission's standard IEC 1131-3, although there are substantial
differences with regard to the operations. For further details, refer to the table of
standards in the STEP 7 file NORM_TBL.WRI.
Preface
Statement List (STL) for S7-300 and S7-400 Programming
iv A5E00171232-01
Requirements
To use the Statement List manual effectively, you should already be familiar with
the theory behind S7 programs which is documented in the online help for STEP 7.
The language packages also use the STEP 7 standard software, so you should be
familiar with handling this software and have read the accompanying
documentation.
This manual is part of the documentation package "STEP 7 Reference".
The following table displays an overview of the STEP 7 documentation:
Documentation Purpose Order Number
STEP 7 Basic Information with
• Working with STEP 7 V5.2,
Getting Started Manual
• Programming with STEP 7 V5.2
• Configuring Hardware and
Communication Connections,
STEP 7 V5.2
• From S5 to S7, Converter Manual
Basic information for technical
personnel describing the methods
of implementing control tasks with
STEP 7 and the S7-300/400
programmable controllers.
6ES7810-4CA06-8BA0
STEP 7 Reference with
• Ladder Logic (LAD)/Function Block
Diagram (FBD)/Statement List (STL)
for S7-300/400 manuals
• Standard and System Functions
for S7-300/400
Provides reference information
and describes the programming
languages LAD, FBD, and STL,
and standard and system
functions extending the scope of
the STEP 7 basic information.
6ES7810-4CA06-8BR0
Online Helps Purpose Order Number
Help on STEP 7 Basic information on
programming and configuring
hardware with STEP 7 in the form
of an online help.
Part of the STEP 7
Standard software.
Reference helps on STL/LAD/FBD
Reference help on SFBs/SFCs
Reference help on Organization Blocks
Context-sensitive reference
information.
Part of the STEP 7
Standard software.
Preface
Statement List (STL) for S7-300 and S7-400 Programming
A5E00171232-01 v
Online Help
The manual is complemented by an online help which is integrated in the software.
This online help is intended to provide you with detailed support when using the
software.
The help system is integrated in the software via a number of interfaces:
• The context-sensitive help offers information on the current context, for
example, an open dialog box or an active window. You can open the context-sensitive help via the menu command Help > Context-Sensitive Help, by
pressing F1 or by using the question mark symbol in the toolbar.
• You can call the general Help on STEP 7 using the menu command Help >
Contents or the "Help on STEP 7" button in the context-sensitive help window.
• You can call the glossary for all STEP 7 applications via the "Glossary" button.
This manual is an extract from the "Help on Statement List". As the manual and the
online help share an identical structure, it is easy to switch between the manual
and the online help.
Further Support
If you have any technical questions, please get in touch with your Siemens
representative or agent responsible.
http://www.siemens.com/automation/partner
Training Centers
Siemens offers a number of training courses to familiarize you with the SIMATIC
S7 automation system. Please contact your regional training center or our central
training center in D 90327 Nuremberg, Germany for details:
Telephone: +49 (911) 895-3200.
Internet: http://www.sitrain.com
Preface
Statement List (STL) for S7-300 and S7-400 Programming
vi A5E00171232-01
A&D Technical Support
Worldwide, available 24 hours a day:
Beijing
Nuremberg
Johnson City
Worldwide (Nuremberg)
Technical Support
24 hours a day, 365 days a year
Phone: +49 (0) 180 5050-222
Fax: +49 (0) 180 5050-223
E-Mail: adsupport@
siemens.com
GMT: +1:00
Europe / Africa (Nuremberg)
Authorization
Local time: Mon.-Fri. 8:00 to 17:00
Phone: +49 (0) 180 5050-222
Fax: +49 (0) 180 5050-223
E-Mail: adsupport@
siemens.com
GMT: +1:00
United States (Johnson City)
Technical Support and
Authorization
Local time: Mon.-Fri. 8:00 to 17:00
Phone: +1 (0) 770 740 3505
Fax: +1 (0) 770 740 3699
E-Mail: isd-callcenter@
sea.siemens.com
GMT: -5:00
Asia / Australia (Beijing)
Technical Support and
Authorization
Local time: Mon.-Fri. 8:30 to 17:30
Phone: +86 10 64 75 75 75
Fax: +86 10 64 74 74 74
E-Mail: adsupport.asia@
siemens.com
GMT: +8:00
The languages of the SIMATIC Hotlines and the authorization hotline are generally German and English.
Preface
Statement List (STL) for S7-300 and S7-400 Programming
A5E00171232-01 vii
Service & Support on the Internet
In addition to our documentation, we offer our Know-how online on the internet at:
http://www.siemens.com/automation/service&support
where you will find the following:
• The newsletter, which constantly provides you with up-to-date information on
your products.
• The right documents via our Search function in Service & Support.
• A forum, where users and experts from all over the world exchange their
experiences.
• Your local representative for Automation & Drives via our representatives
database.
• Information on field service, repairs, spare parts and more under "Services".
Statement List (STL) for S7-300 and S7-400 Programming
A5E00171232-01 vii
Contents
1 Bit Logic Instructions 1-1
1.1 Overview of Bit Logic Instructions.....................................................................1-11.2 A And..............................................................................................................1-31.3 AN And Not ....................................................................................................1-41.4 O Or................................................................................................................1-51.5 ON Or Not ......................................................................................................1-61.6 X Exclusive Or................................................................................................1-71.7 XN Exclusive Or Not ......................................................................................1-81.8 O And before Or.............................................................................................1-91.9 A( And with Nesting Open............................................................................1-101.10 AN( And Not with Nesting Open...................................................................1-111.11 O( Or with Nesting Open..............................................................................1-111.12 ON( Or Not with Nesting Open.....................................................................1-121.13 X( Exclusive Or with Nesting Open..............................................................1-121.14 XN( Exclusive Or Not with Nesting Open.....................................................1-131.15 ) Nesting Closed...........................................................................................1-141.16 = Assign .......................................................................................................1-151.17 R Reset ........................................................................................................1-161.18 S Set.............................................................................................................1-171.19 NOT Negate RLO.........................................................................................1-181.20 SET Set RLO (=1) ........................................................................................1-181.21 CLR Clear RLO (=0).....................................................................................1-191.22 SAVE Save RLO in BR Register..................................................................1-201.23 FN Edge Negative........................................................................................1-211.24 FP Edge Positive............................................................................................1-23
2 Comparison Instructions 2-1
2.1 Overview of Comparison Instructions ...............................................................2-12.2 ? I Compare Integer (16-bit)...........................................................................2-22.3 ? D Compare Double Integer (32-bit).............................................................2-32.4 ? R Compare Floating-point Number (32-bit).................................................2-4
3 Conversion Instructions 3-1
3.1 Overview of Conversion Instructions ................................................................3-13.2 BTI BCD to Integer (16-bit) ............................................................................3-23.3 ITB Integer (16-bit) to BCD ............................................................................3-33.4 BTD BCD to Integer (32-bit)...........................................................................3-43.5 ITD Integer (16 Bit) to Double Integer (32-bit) ...............................................3-53.6 DTB Double Integer (32-bit) to BCD ..............................................................3-63.7 DTR Double Integer (32-bit) to Floating-point (32-bit IEEE-FP) ....................3-73.8 INVI Ones Complement Integer (16-bit) ........................................................3-83.9 INVD Ones Complement Double Integer (32-bit) ..........................................3-9
Contents
Statement List (STL) for S7-300 and S7-400 Programming
viii A5E00171232-01
3.10 NEGI Twos Complement Integer (16-bit).....................................................3-103.11 NEGD Twos Complement Double Integer (32-bit).......................................3-113.12 NEGR Negate Floating-point Number (32-bit, IEEE-FP) .............................3-123.13 CAW Change Byte Sequence in ACCU 1-L (16-bit) ....................................3-133.14 CAD Change Byte Sequence in ACCU 1 (32-bit) ........................................3-143.15 RND Round..................................................................................................3-153.16 TRUNC Truncate .........................................................................................3-163.17 RND+ Round to Upper Double Integer ........................................................3-173.18 RND- Round to Lower Double Integer .........................................................3-18
4 Counter Instructions 4-1
4.1 Overview of Counter Instructions ......................................................................4-14.2 FR Enable Counter (Free)..............................................................................4-24.3 L Load Current Counter Value into ACCU 1 ..................................................4-34.4 LC Load Current Counter Value into ACCU 1 as BCD..................................4-44.5 R Reset Counter.............................................................................................4-54.6 S Set Counter Preset Value ...........................................................................4-64.7 CU Counter Up...............................................................................................4-74.8 CD Counter Down ..........................................................................................4-8
5 Data Block Instructions 5-1
5.1 Overview of Data Block Instructions .................................................................5-15.2 OPN Open a Data Block ................................................................................5-25.3 CDB Exchange Shared DB and Instance DB ................................................5-35.4 L DBLG Load Length of Shared DB in ACCU 1.............................................5-35.5 L DBNO Load Number of Shared DB in ACCU 1 ..........................................5-45.6 L DILG Load Length of Instance DB in ACCU 1 ............................................5-45.7 L DINO Load Number of Instance DB in ACCU 1..........................................5-5
6 Logic Control Instructions 6-1
6.1 Overview of Logic Control Instructions .............................................................6-16.2 JU Jump Unconditional ..................................................................................6-36.3 JL Jump to Labels ..........................................................................................6-46.4 JC Jump if RLO = 1........................................................................................6-56.5 JCN Jump if RLO = 0 .....................................................................................6-66.6 JCB Jump if RLO = 1 with BR........................................................................6-76.7 JNB Jump if RLO = 0 with BR........................................................................6-86.8 JBI Jump if BR = 1 .........................................................................................6-96.9 JNBI Jump if BR = 0.....................................................................................6-106.10 JO Jump if OV = 1........................................................................................6-116.11 JOS Jump if OS = 1 .....................................................................................6-126.12 JZ Jump if Zero ............................................................................................6-136.13 JN Jump if Not Zero .....................................................................................6-146.14 JP Jump if Plus.............................................................................................6-156.15 JM Jump if Minus .........................................................................................6-166.16 JPZ Jump if Plus or Zero..............................................................................6-176.17 JMZ Jump if Minus or Zero ..........................................................................6-186.18 JUO Jump if Unordered ...............................................................................6-196.19 LOOP Loop ..................................................................................................6-20