0% found this document useful (0 votes)
76 views558 pages

Programming

Prima pero favore

Uploaded by

Res Peto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views558 pages

Programming

Prima pero favore

Uploaded by

Res Peto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 558



Important Notes, Contents


What’s New? 1
Installing and Authorization 2
Working Out the Automation
Concept 3

Basics of Designing a Program


Structure 4
SIMATIC Startup and Operation 5
Setting Up and Editing a Project 6
Defining Symbols 7
Creating Blocks and Libraries 8
Programming with STEP 7 V5.1 Creating Logic Blocks 9
Creating Data Blocks 10
Manual
Creating STL Source Files 11
Displaying Reference Data 12
This manual is part of the documentation
package with the order number: Checking Block Consistency and
Time Stamps as Block Property 13
6ES7 810-4CA05-8BA0
Configuring Messages 14
Controlling and Monitoring
Variables 15

Establishing Online
Connections and Making CPU 16
Settings
Downloading 17
Testing with Variable Tables 18
Testing using Program Status 19
Testing using the Simulation
Program S7-PLCSIM 20
(Optional Package)
Diagnostics 21
Printing and Archiving 22
When Several Users are Editing
the Same Project 23

Working with M7 24
Programmable Control Systems
Tips and Tricks 25

Appendix A
Edition 08/2000 Index
A5E00069873-03
Safety Guidelines

This manual contains notices which you should observe to ensure your own personal safety, as well as to
protect the product and connected equipment. These notices are highlighted in the manual by a warning
triangle and are marked as follows according to the level of danger:

Danger
! Indicates that death, severe personal injury or substantial property damage will result if proper
precautions are not taken.

! Warning
Indicates that death, severe personal injury or substantial property damage can result if proper
precautions are not taken.

! Caution
Indicates that minor personal injury or property damage can result if proper precautions are not taken.

Note
Draws your attention to particularly important information on the product, handling the product, or to a
particular 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 sys-
tems 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 descriptions, 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 installed
correctly, and operated and maintained as recommended.

Trademarks

SIMATIC®, SIMATIC HMI® and SIMATIC NET® are registered trademarks of SIEMENS AG.

Some of other designations used in these documents are also registered trademarks; the owner's rights may
be violated if they are used by third parties for their own purposes.

Copyright © Siemens AG 1998 All rights reserved Disclaimer of Liability

The reproduction, transmission or use of this document or its We have checked the contents of this manual for agreement with
contents is not permitted without express written authority. Offen- the hardware and software described. Since deviations cannot be
ders will be liable for damages. All rights, including rights created precluded entirely, we cannot guarantee full agreement. However,
by patent grant or registration of a utility model or design, are the data in this manual are reviewed regularly and any necessary
reserved. corrections included in subsequent editions. Suggestions for
improvement are welcomed.
Siemens AG
Bereich Automatisierungs- und Antriebstechnik
Geschaeftsgebiet Industrie-Automatisierungssysteme ©Siemens AG 1998
Postfach 4848, D- 90327 Nuernberg Technical data subject to change.

Siemens Aktiengesellschaft A5E00069873


Important Notes

Purpose
This manual provides a complete overview of programming with STEP 7. It is
designed to support you when installing and commissioning the software. It
explains how to proceed when creating programs and describes the components of
user programs.
The manual is intended for people who are involved in carrying out control tasks
using STEP 7 and SIMATIC S7 automation systems.
We recommend that you familiarize yourself with the examples in the manual
"Working with STEP 7 V5.1, Getting Started." These examples provide an easy
introduction to the topic "Programming with STEP 7."

Basic Knowledge Required


In order to understand this manual, general knowledge of automation technology is
required.
In addition, you must be familiar with using computers or PC-similar tools (for
example, programming devices) with the Windows 95/98/2000 or Windows NT
operating system.

Scope of the Manual


This manual is valid for release 5.1 of the STEP 7 programming software package.

Programming with STEP 7 V5.1


A5E00069873-03 iii
Important Notes

STEP 7 Documentation Packages


This manual is part of the documentation package "STEP 7 Basic Information.“
The following table displays an overview of the STEP 7 documentation:

Documentation Purpose Order Number


STEP 7 Basic Information with Basic information for technical 6ES7810-4CA05-8BA0
• Working with STEP 7 V5.1, personnel describing the methods
Getting Started Manual of implementing control tasks with
STEP 7 and the S7-300/400
• Programming with STEP 7 V5.1
programmable controllers.
• Configuring Hardware and
Communication Connections,
STEP 7 V5.1
• From S5 to S7, Converter Manual
STEP 7 Reference with Provides reference information 6ES7810-4CA05-8BR0
• Ladder Logic (LAD)/Function Block and describes the programming
Diagram (FBD)/Statement List (STL) languages LAD, FBD, and STL,
for S7-300/400 manuals and standard and system
functions extending the scope of
• Standard and System Functions for
the STEP 7 basic information.
S7-300/400

Online Helps Purpose Order Number


Help on STEP 7 Basic information on Part of the STEP 7
programming and configuring Standard software.
hardware with STEP 7 in the form
of an online help.
Reference helps on STL/LAD/FBD Context-sensitive reference Part of the STEP 7
Reference help on SFBs/SFCs information. Standard software.
Reference help on Organization Blocks

Programming with STEP 7 V5.1


iv A5E00069873-03
Important Notes

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:
• There are several menu commands which you can select in the Help menu:
The Contents command opens the index for the Help on Step 7.
• Using Help provides detailed instructions on using the online help.
• 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 by clicking the "Help" button or by pressing F1.
• The status bar offers another form of context-sensitive help. It displays a short
explanation for each menu command when the mouse pointer is positioned on
the menu command.
• A brief explanation is also displayed for each icon in the toolbar when the
mouse pointer is positioned on the icon for a short time.
If you prefer to read the information from the online help in printed format, you can
print out individual help topics, books, or the entire online help.
This manual is an extract from the HTML-based Help on STEP 7. For detailed
procedures please refer to the STEP 7 help. As the manual and the online help
share an almost identical structure, it is easy to switch between the manual and the
online help.

Feedback on Documentation
To help us to provide the best possible documentation for you and future STEP 7
users, we need your support. If you have any comments or suggestions relating to
this manual or the online help, please complete the questionnaire at the end of the
manual and send it to the address shown. Please include your own personal rating
of the documentation.

SIMATIC Training Centers


Siemens offers a number of training courses to introduce you to the SIMATIC S7
automation system. Please contact your regional training center or the central
training center in D-90327 Nuremberg, Germany for details:
Telephone: +49 (911) 895-3200.

Programming with STEP 7 V5.1


A5E00069873-03 v
Important Notes

SIMATIC Customer Support Hotline


Open round the clock, world-wide:

Nuremberg

Johnson City

Singapur

SIMATIC Hotline

Worldwide (Nuremberg) Worldwide (Nuremberg)


Technical Support Technical Support
(FreeContact) (fee based, only with
SIMATIC Card)
Local time: Mo.-Fr. 7:00 to 17:00 Local time: Mo.-Fr. 0:00 to 24:00
Phone: +49 (180) 5050 222 Phone: +49 (911) 895-7777
Fax: +49 (180) 5050 223 Fax: +49 (911) 895-7001
E-Mail: techsupport@ GMT: +01:00
ad.siemens.de
GMT: +1:00
Europe / Africa (Nuremberg) America (Johnson City) Asia / Australia (Singapore)
Authorization Technical Support and Technical Support and
Authorization Authorization
Local time: Mo.-Fr. 7:00 to 17:00 Local time: Mo.-Fr. 8:00 to 19:00 Local time: Mo.-Fr. 8:30 to 17:30
Phone: +49 (911) 895-7200 Phone: +1 423 461-2522 Phone: +65 740-7000
Fax: +49 (911) 895-7201 Fax: +1 423 461-2289 Fax: +65 740-7001
E-Mail: authorization@ E-Mail: simatic.hotline@ E-Mail: simatic.hotline@
nbgm.siemens.de sea.siemens.com sae.siemens.com.sg
GMT: +1:00 GMT: -5:00 GMT: +8:00
The languages of the SIMATIC Hotlines are generally German and English, in addition, French, Italian and Spanish are
spoken on the authorization hotline.

Programming with STEP 7 V5.1


vi A5E00069873-03
Important Notes

SIMATIC Customer Support Online Services


The SIMATIC Customer Support team offers you sunstantial additional information
about SIMATIC products via its online services:
• General current information can be obtain from:
- the Internet under http://www.ad.siemens.de/simatic
• Current product Information leaflets and downloads which you may find useful
are available:
- the Internet under http://www.ad.siemens.de/simatic-cs
- via the Bulletin Board System (BBS) in Nuremberg (SIMATIC Customer
Support Mailbox) under the number +49 (911) 895-7100.
To access mailbox, use a modem with up to V.34(28.8Kbps) with the following
parameter set as follows: 8, N, 1, ANSI, or dial via ISDN (x.75, 64 Kbps).
• You can find your local customer service representative for
Automation & Drives in our customer service representative data bank:
- In the Internet under
http://www3.ad.siemens.de/partner/search.asp?lang=en

Programming with STEP 7 V5.1


A5E00069873-03 vii
Important Notes

Programming with STEP 7 V5.1


viii A5E00069873-03
Contents

1 What’s New? 1-1


1.1 Overview of STEP 7...................................................................................... 1-1
1.2 The STEP 7 Standard Package..................................................................... 1-6
1.3 What’s New in STEP 7, Version 5.1?........................................................... 1-10
1.4 Extended Uses of the STEP 7 Standard Package........................................ 1-14
1.4.1 Extended Uses of the STEP 7 Standard Package........................................ 1-14
1.4.2 Engineering Tools ....................................................................................... 1-15
1.4.3 Run-Time Software ..................................................................................... 1-17
1.4.4 Human Machine Interface ........................................................................... 1-18
2 Installing and Authorization 2-1
2.1 Authorization................................................................................................. 2-1
2.1.1 Authorization.................................................................................................2-1
2.1.2 Installing and Removing the Authorization .....................................................2-1
2.1.3 Guidelines for Handling Authorizations ..........................................................2-4
2.2 Installing STEP 7........................................................................................... 2-7
2.2.1 Installing STEP 7...........................................................................................2-7
2.2.2 Installation Procedure....................................................................................2-9
2.2.3 Setting the PG/PC Interface ........................................................................ 2-11
2.3 Uninstalling STEP 7 .................................................................................... 2-14
2.3.1 Uninstalling STEP 7 .................................................................................... 2-14
3 Working Out the Automation Concept 3-1
3.1 Basic Procedure for Planning an Automation Project ..................................... 3-1
3.2 Dividing the Process into Tasks and Areas .................................................... 3-2
3.3 Describing the Individual Functional Areas .................................................... 3-4
3.4 Listing Inputs, Outputs, and In/Outs............................................................... 3-6
3.5 Creating an I/O Diagram for the Motors ......................................................... 3-6
3.6 Creating an I/O Diagram for the Valves ......................................................... 3-7
3.7 Establishing the Safety Requirements ........................................................... 3-8
3.8 Describing the Required Operator Displays and Controls............................... 3-9
3.9 Creating a Configuration Diagram ............................................................... 3-10
4 Basics of Designing a Program Structure 4-1
4.1 Programs in a CPU ....................................................................................... 4-1
4.2 Blocks in the User Program ........................................................................... 4-2
4.2.1 Blocks in the User Program ...........................................................................4-2
4.2.2 Organization Blocks and Program Structure ..................................................4-3
4.2.3 Call Hierarchy in the User Program ...............................................................4-8
4.2.4 Block Types and Cyclic Program Processing ............................................... 4-10
4.2.4.1 Organization Block for Cyclic Program Processing (OB1) ............................ 4-10
4.2.4.2 Functions (FC) ............................................................................................ 4-16
4.2.4.3 Function Blocks (FB)................................................................................... 4-16
4.2.4.4 Instance Data Blocks................................................................................... 4-19

Programming with STEP 7 V5.1


A5E00069873-03 ix
Contents

4.2.4.5 Shared Data Blocks (DB) ............................................................................ 4-21


4.2.4.6 System Function Blocks (SFB) and System Functions (SFC) ...................... 4-22
4.2.5 Organization Blocks for Interrupt-Driven Program Processing...................... 4-24
4.2.5.1 Organization Blocks for Interrupt-Driven Program Processing...................... 4-24
4.2.5.2 Time-of-Day Interrupt Organization Blocks (OB10 to OB17) ........................ 4-24
4.2.5.3 Time-Delay Interrupt Organization Blocks (OB20 to OB23).......................... 4-26
4.2.5.4 Cyclic Interrupt Organization Blocks (OB30 to OB38) .................................. 4-27
4.2.5.5 Hardware Interrupt Organization Blocks (OB40 to OB47) ............................ 4-28
4.2.5.6 Startup Organization Blocks (OB100 / OB101 / OB102) .............................. 4-29
4.2.5.7 Background Organization Block (OB90) ...................................................... 4-31
4.2.5.8 Error Handling Organization Blocks (OB70 to OB87 / OB121 to OB122) ..... 4-33
5 Startup and Operation 5-1
5.1 Starting STEP 7 ............................................................................................ 5-1
5.1.1 Starting STEP 7 ............................................................................................ 5-1
5.1.2 Starting STEP 7 with Default Start Parameters.............................................. 5-2
5.1.3 Calling the Help Functions............................................................................. 5-3
5.2 Objects and Object Hierarchy........................................................................ 5-5
5.2.1 Objects and Object Hierarchy........................................................................ 5-5
5.2.2 Project Object ............................................................................................... 5-6
5.2.3 Library Object ............................................................................................... 5-7
5.2.4 Station Object ............................................................................................... 5-8
5.2.5 Programmable Module Object....................................................................... 5-9
5.2.6 S7/M7 Program Object................................................................................ 5-11
5.2.7 Block Folder Object..................................................................................... 5-12
5.2.8 Source File Folder Object............................................................................ 5-15
5.2.9 S7/M7 Program without a Station or CPU.................................................... 5-16
5.3 User Interface and Operation ...................................................................... 5-17
5.3.1 Operating Philosophy.................................................................................. 5-17
5.3.2 Window Arrangement.................................................................................. 5-18
5.3.3 Elements in Dialog Boxes ........................................................................... 5-19
5.3.4 Creating and Managing Objects .................................................................. 5-20
5.3.5 Selecting Objects in a Dialog Box................................................................ 5-24
5.3.6 Session Memory ......................................................................................... 5-26
5.3.7 Changing the Window Arrangement of Symbol Tables ................................ 5-26
5.3.8 Saving and Restoring the Window Arrangement.......................................... 5-27
5.4 Keyboard Control ........................................................................................ 5-28
5.4.1 Keyboard Control ........................................................................................ 5-28
5.4.2 Key Combinations for Menu Commands...................................................... 5-28
5.4.3 Key Combinations for Moving the Cursor..................................................... 5-30
5.4.4 Key Combinations for Selecting Text........................................................... 5-31
5.4.5 Key Combinations for Access to Online Help............................................... 5-32
5.4.6 Key Combinations for Toggling between Windows....................................... 5-32
6 Setting Up and Editing the Project 6-1
6.1 Project Structure ........................................................................................... 6-1
6.2 Setting Up a Project ...................................................................................... 6-3
6.2.1 Creating a Project ......................................................................................... 6-3
6.2.2 Inserting Stations .......................................................................................... 6-4
6.2.3 Inserting an S7/M7 Program.......................................................................... 6-5
6.3 Editing a Project............................................................................................ 6-8
6.3.1 Editing a Project............................................................................................ 6-8
6.3.2 Managing Multilingual Text............................................................................ 6-9

Programming with STEP 7 V5.1


x A5E00069873-03
Contents

7 Defining Symbols 7-1


7.1 Absolute and Symbolic Addressing................................................................ 7-1
7.2 Shared and Local Symbols............................................................................ 7-3
7.3 Displaying Shared or Local Symbols ............................................................. 7-4
7.4 Setting the Address Priority ........................................................................... 7-5
7.5 Symbol Table for Shared Symbols................................................................. 7-6
7.5.1 Symbol Table for Shared Symbols.................................................................7-6
7.5.2 Structure and Components of the Symbol Table............................................7-6
7.5.3 Addresses and Data Types Permitted in the Symbol Table............................7-7
7.5.4 Incomplete and Non-Unique Symbols in the Symbol Table ............................7-9
7.6 Entering Shared Symbols............................................................................ 7-10
7.6.1 Entering Shared Symbols............................................................................ 7-10
7.6.2 General Tips on Entering Symbols .............................................................. 7-10
7.6.3 Entering Single Shared Symbols in a Dialog Box......................................... 7-11
7.6.4 Entering Multiple Shared Symbols in the Symbol Table ............................... 7-12
7.6.5 Using Upper and Lower Case for Symbols .................................................. 7-13
7.6.6 Exporting and Importing Symbol Tables ...................................................... 7-15
7.6.7 File Formats for Importing/Exporting a Symbol Table................................... 7-15
8 Creating Blocks and Libraries 8-1
8.1 Selecting an Editing Method .......................................................................... 8-1
8.2 Selecting the Programming Language ........................................................... 8-2
8.2.1 Selecting the Programming Language ...........................................................8-2
8.2.2 Ladder Logic Programming Language (LAD).................................................8-4
8.2.3 Function Block Diagram Programming Language (FBD)................................8-4
8.2.4 Statement List Programming Language (STL) ...............................................8-5
8.2.5 S7 SCL Programming Language ...................................................................8-6
8.2.6 S7-GRAPH Programming Language (Sequential Control) .............................8-7
8.2.7 S7 HiGraph Programming Language (State Graph).......................................8-8
8.2.8 S7 CFC Programming Language...................................................................8-9
8.3 Creating Blocks........................................................................................... 8-10
8.3.1 Blocks Folder .............................................................................................. 8-10
8.3.2 User-Defined Data Types (UDT).................................................................. 8-11
8.3.3 Block Properties.......................................................................................... 8-11
8.3.4 Displaying Block Lengths ............................................................................ 8-13
8.3.5 Rewiring...................................................................................................... 8-14
8.3.6 Attributes for Blocks and Parameters........................................................... 8-14
8.4 Working with Libraries ................................................................................. 8-15
8.4.1 Working with Libraries ................................................................................. 8-15
8.4.2 Hierarchical Structure of Libraries................................................................ 8-16
8.4.3 Overview of the Standard Libraries.............................................................. 8-17
9 Creating Logic Blocks 9-1
9.1 Basic Procedure for Creating Logic Blocks .................................................... 9-1
9.1.1 Basic Procedure for Creating Logic Blocks ....................................................9-1
9.1.2 Default Settings for the LAD/STL/FBD Program Editor...................................9-2
9.1.3 Access Rights to Blocks and Source Files .....................................................9-3
9.1.4 Instructions from the Program Element Catalog.............................................9-3
9.2 Editing the Variable Declaration Table........................................................... 9-5
9.2.1 Using the Variable Declaration in Logic Blocks ..............................................9-5
9.2.2 Relationship between the Variable Declaration Table and the Code Section..9-6
9.2.3 Structure of the Variable Declaration Table....................................................9-6
9.2.4 General Notes on Variable Declaration Tables ..............................................9-8
9.3 Multiple Instances in the Variable Declaration Table ...................................... 9-9

Programming with STEP 7 V5.1


A5E00069873-03 xi
Contents

9.3.1 Using Multiple Instances ............................................................................... 9-9


9.3.2 Rules for Declaring Multiple Instances......................................................... 9-10
9.3.3 Entering a Multiple Instance in the Variable Declaration Table..................... 9-10
9.4 General Notes on Entering Statements and Comments............................... 9-11
9.4.1 Structure of the Code Section ..................................................................... 9-11
9.4.2 Procedure for Entering Statements.............................................................. 9-12
9.4.3 Entering Shared Symbols in a Program....................................................... 9-13
9.4.4 Title and Comments for Blocks and Networks.............................................. 9-13
9.4.5 Search Function for Errors in the Code Section ........................................... 9-14
9.5 Editing LAD Elements in the Code Section .................................................. 9-15
9.5.1 Settings for Ladder Logic Programming....................................................... 9-15
9.5.2 Rules for Entering Ladder Logic Elements................................................... 9-16
9.5.3 Illegal Logic Operations in Ladder ............................................................... 9-18
9.6 Editing FBD Elements in the Code Section.................................................. 9-19
9.6.1 Settings for Function Block Diagram Programming...................................... 9-19
9.6.2 Rules for Entering FBD Elements................................................................ 9-20
9.7 Editing STL Statements in the Code Section ............................................... 9-22
9.7.1 Settings for Statement List Programming .................................................... 9-22
9.7.2 Rules for Entering STL Statements ............................................................. 9-22
9.8 Updating Block Calls................................................................................... 9-23
9.8.1 Updating Block Calls................................................................................... 9-23
9.9 Saving Logic Blocks.................................................................................... 9-24
9.9.1 Saving Logic Blocks.................................................................................... 9-24
9.9.2 Correcting the Interfaces in a Function, Function Block, or UDT .................. 9-24
9.9.3 Avoiding Errors when Calling Blocks ........................................................... 9-25
10 Creating Data Blocks 10-1
10.1 Basic Information on Creating Data Blocks.................................................. 10-1
10.2 Declaration View of Data Blocks.................................................................. 10-2
10.3 Data View of Data Blocks............................................................................ 10-3
10.4 Editing and Saving Data Blocks................................................................... 10-4
10.4.1 Entering the Data Structure of Shared Data Blocks ..................................... 10-4
10.4.2 Entering and Displaying the Data Structure of Data Blocks Referencing
an FB (Instance DBs).................................................................................. 10-4
10.4.3 Entering the Data Structure of User-Defined Data Types (UDT) .................. 10-6
10.4.4 Entering and Displaying the Structure of Data Blocks Referencing a UDT ... 10-6
10.4.5 Editing Data Values in the Data View .......................................................... 10-7
10.4.6 Resetting Data Values to their Initial Values ................................................ 10-8
10.4.7 Saving Data Blocks..................................................................................... 10-8
11 Creating STL Source Files 11-1
11.1 Basic Information on Programming in STL Source Files .............................. 11-1
11.2 Rules for Programming in STL Source Files ................................................ 11-2
11.2.1 Rules for Entering Statements in STL Source Files ..................................... 11-2
11.2.2 Rules for Declaring Variables in STL Source Files....................................... 11-3
11.2.3 Rules for Block Order in STL Source Files................................................... 11-4
11.2.4 Rules for Setting System Attributes in STL Source Files.............................. 11-4
11.2.5 Rules for Setting Block Properties in STL Source Files................................ 11-5
11.2.6 Permitted Block Properties for Each Block Type.......................................... 11-6
11.3 Structure of Blocks in STL Source Files....................................................... 11-7
11.3.1 Structure of Blocks in STL Source Files....................................................... 11-7
11.3.2 Structure of Logic Blocks in STL Source Files ............................................. 11-7
11.3.3 Structure of Data Blocks in STL Source Files .............................................. 11-8
11.3.4 Structure of User-Defined Data Types in STL Source Files.......................... 11-8
11.4 Syntax and Formats for Blocks in STL Source Files..................................... 11-9

Programming with STEP 7 V5.1


xii A5E00069873-03
Contents

11.4.1 Syntax and Formats for Blocks in STL Source Files..................................... 11-9
11.4.2 Format Table of Organization Blocks........................................................... 11-9
11.4.3 Format Table of Function Blocks ............................................................... 11-10
11.4.4 Format Table of Functions......................................................................... 11-11
11.4.5 Format Table of Data Blocks ..................................................................... 11-12
11.5 Creating STL Source Files ........................................................................ 11-13
11.5.1 Creating STL Source Files ........................................................................ 11-13
11.5.2 Editing S7 Source Files ............................................................................. 11-13
11.5.3 Inserting Block Templates in STL Source Files .......................................... 11-14
11.5.4 Inserting External Source Files.................................................................. 11-14
11.5.5 Generating STL Source Files from Blocks ................................................. 11-15
11.6 Saving and Compiling STL Source Files and Executing a
Consistency Check.................................................................................... 11-16
11.6.1 Saving STL Source Files ........................................................................... 11-16
11.6.2 Checking Consistency in STL Source Files................................................ 11-16
11.6.3 Troubleshooting in STL Source Files ......................................................... 11-16
11.6.4 Compiling STL Source Files ...................................................................... 11-17
11.7 Examples of STL Source Files................................................................... 11-18
11.7.1 Examples of Declaring Variables in STL Source Files................................ 11-18
11.7.2 Example of Organization Blocks in STL Source Files................................. 11-19
11.7.3 Example of Functions in STL Source Files................................................. 11-20
11.7.4 Example of Function Blocks in STL Source Files ....................................... 11-22
11.7.5 Example of Data Blocks in STL Source Files ............................................. 11-24
11.7.6 Example of User-Defined Data Types in STL Source Files ........................ 11-25
12 Displaying Reference Data 12-1
12.1 Overview of the Available Reference Data................................................... 12-1
12.1.1 Overview of the Available Reference Data................................................... 12-1
12.1.2 Cross-Reference List................................................................................... 12-2
12.1.3 Program Structure....................................................................................... 12-3
12.1.4 Assignment List for Inputs, Outputs, and Bit Memory (I/Q/M) ....................... 12-5
12.1.5 Assignment List for Timers and Counters (T/C) ........................................... 12-7
12.1.6 Unused Symbols......................................................................................... 12-8
12.1.7 Addresses Without Symbols........................................................................ 12-8
12.1.8 Displaying Block Information for LAD, FBD, and STL................................... 12-9
12.2 Working with Reference Data .................................................................... 12-10
12.2.1 Ways of Displaying Reference Data .......................................................... 12-10
12.2.2 Displaying Lists in Additional Working Windows......................................... 12-11
12.2.3 Generating and Displaying Reference Data ............................................... 12-11
12.2.4 Finding Address Locations in the Program Quickly .................................... 12-12
12.2.5 Example of Working with Address Locations.............................................. 12-13
13 Checking Block Consistency and Time Stamps as Block Property 13-1
13.1 Checking Block Consistency ....................................................................... 13-1
13.2 Time Stamps as a Block Property and Time Stamp Conflicts....................... 13-3
13.3 Time Stamps in Logic Blocks....................................................................... 13-4
13.4 Time Stamps in Shared Data Blocks ........................................................... 13-5
13.5 Time Stamps in Instance Data Blocks.......................................................... 13-6
13.6 Time Stamps in UDTs and Data Blocks Derived from UDTs ........................ 13-7

Programming with STEP 7 V5.1


A5E00069873-03 xiii
Contents

14 Configuring Messages 14-1


14.1 The Message Concept ................................................................................ 14-1
14.1.1 The Message Concept ................................................................................ 14-1
14.1.2 What Are the Different Messaging Methods?............................................... 14-1
14.1.3 Choosing a Messaging Method ................................................................... 14-3
14.1.4 SIMATIC Components ................................................................................ 14-4
14.1.5 Parts of a Message ..................................................................................... 14-5
14.1.6 Assigning Message Numbers...................................................................... 14-6
14.2 Assigning and Editing Block-Related Messages .......................................... 14-7
14.2.1 Assigning and Editing Block-Related Messages .......................................... 14-7
14.2.2 Which Message Blocks Are Available?........................................................ 14-7
14.2.3 Formal Parameters, System Attributes, and Message Blocks ...................... 14-9
14.2.4 Message Templates and Messages .......................................................... 14-10
14.2.5 Creating Block-Related Messages............................................................. 14-11
14.2.6 PCS7 Message Configuration ................................................................... 14-14
14.3 Assigning and Editing Symbol-Related Messages ..................................... 14-16
14.3.1 Assigning and Editing Symbol-Related Messages ..................................... 14-16
14.4 Creating and Editing User-Defined Diagnostic Messages .......................... 14-17
14.4.1 Creating and Editing User-defined Diagnostic Messages........................... 14-17
14.5 Translating and Editing User Texts............................................................ 14-18
14.5.1 Translating and Editing Operator Related Texts ........................................ 14-18
14.5.2 Translating and Editing User Texts............................................................ 14-18
14.5.3 Translating Text Libraries.......................................................................... 14-19
14.6 Transferring Message Configuration Data to the Programmable Controller 14-21
14.6.1 Transferring Configuration Data to the Programmable Controller............... 14-21
14.7 Displaying CPU Messages and User-Defined Diagnostic Messages.......... 14-22
14.7.1 Displaying CPU Messages and User-Defined Diagnostic Messages.......... 14-22
14.7.2 Configuring CPU Messages ...................................................................... 14-24
14.7.3 Displaying Stored CPU Messages............................................................. 14-25
14.8 Configuring the 'Reporting of System Errors' ............................................. 14-25
14.8.1 Configuring the 'Reporting of System Errors' ............................................. 14-25
14.8.2 Supported Components and Functional Scope.......................................... 14-26
14.8.3 Settings for Reporting System Errors ........................................................ 14-28
14.8.4 Generating Blocks for Reporting System Errors......................................... 14-29
14.8.5 Generated Error OBs ................................................................................ 14-30
14.8.6 Generated FB, DB .................................................................................... 14-31
15 Controlling and Monitoring Variables 15-1
15.1 Configuring Variables for Operator Control and Monitoring .......................... 15-1
15.2 Configuring Operator Control and Monitoring Attributes with
Statement List, Ladder Logic, a ................................................................... 15-2
15.2.1 Configuring Operator Control and Monitoring Attributes with
Statement List, Ladder Logic, and Function Block Diagram ......................... 15-2
15.3 Configuring Operator Control and Monitoring Attributes via
the Symbol Table ........................................................................................ 15-3
15.3.1 Configuring Operator Control and Monitoring Attributes via
the Symbol Table ........................................................................................ 15-3
15.4 Changing Operator Control and Monitoring Attributes with CFC .................. 15-4
15.4.1 Changing Operator Control and Monitoring Attributes with CFC .................. 15-4
15.5 Transferring Configuration Data to the Operator Interface
Programmable Controller ............................................................................ 15-5
15.5.1 Transferring Configuration Data to the Operator Interface
Programmable Controller ............................................................................ 15-5

Programming with STEP 7 V5.1


xiv A5E00069873-03
Contents

16 Establishing an Online Connection and Making CPU Settings 16-1


16.1 Establishing Online Connections ................................................................. 16-1
16.1.1 Establishing Online Connections ................................................................. 16-1
16.1.2 Establishing an Online Connection via the "Accessible Nodes" Window....... 16-1
16.1.3 Establishing an Online Connection via the Online Window of the Project ..... 16-2
16.1.4 Password Protection for Access to Programmable Controllers..................... 16-3
16.1.5 Updating the Window Contents ................................................................... 16-4
16.2 Displaying and Changing the Operating Mode ............................................. 16-5
16.2.1 Displaying and Changing the Operating Mode ............................................. 16-5
16.3 Displaying and Setting the Time and Date ................................................... 16-6
16.3.1 Displaying and Setting the Time and Date ................................................... 16-6
17 Downloading 17-1
17.1 Downloading from the PG/PC to the Programmable Controller .................... 17-1
17.1.1 Requirements for Downloading.................................................................... 17-1
17.1.2 Differences Between Saving and Downloading Blocks................................. 17-2
17.1.3 Load Memory and Work Memory in the CPU............................................... 17-3
17.1.4 Download Methods Dependent on the Load Memory................................... 17-4
17.1.5 Reloading Blocks in the Programmable Controller ....................................... 17-5
17.1.6 Downloading via EPROM Memory Cards .................................................... 17-6
17.1.7 Downloading the Hardware Configuration and Connection Configuration
Separately................................................................................................... 17-7
17.1.7.1 Downloading a Configuration to a Programmable Controller ........................ 17-7
17.1.7.2 Downloading the Network Configuration for the First Time........................... 17-8
17.1.7.3 Downloading the Network Configuration to a Programmable Controller ....... 17-9
17.1.7.4 Downloading Changes to the Network Configuration ................................. 17-10
17.1.7.5 Downloading the Global Data Configuration .............................................. 17-11
17.2 Uploading from the Programmable Controller to the PG/PC....................... 17-12
17.2.1 Uploading from the Programmable Controller to the PG/PC....................... 17-12
17.2.2 Uploading a Station................................................................................... 17-13
17.2.3 Uploading Blocks from an S7 CPU ............................................................ 17-14
17.2.4 Editing Uploaded Blocks in the PG/PC ...................................................... 17-15
17.2.5 Reloading the Hardware Configuration and Connection Configuration ....... 17-16
17.2.5.1 Uploading a Configuration from a Station .................................................. 17-16
17.2.5.2 Uploading a Network Configuration ........................................................... 17-17
17.2.6 Deleting on the Programmable Controller .................................................. 17-18
17.2.6.1 Erasing the Load/Work Memory and Resetting the CPU............................ 17-18
17.2.6.2 Deleting S7 Blocks on the Programmable Controller.................................. 17-19
17.2.7 Compressing the User Memory (RAM) ...................................................... 17-20
17.2.7.1 Gaps in the User Memory (RAM)............................................................... 17-20
17.2.7.2 Compressing the Memory Contents of an S7 CPU .................................... 17-21
18 Testing with Variable Tables 18-1
18.1 Introduction to Testing with Variable Tables................................................. 18-1
18.2 Basic Procedure when Monitoring and Modifying with the Variable Table .... 18-2
18.3 Editing and Saving Variable Tables ............................................................. 18-2
18.3.1 Creating and Opening a Variable Table ....................................................... 18-2
18.3.2 Copying/Moving Variable Tables ................................................................. 18-3
18.3.3 Saving a Variable Table .............................................................................. 18-3
18.4 Entering Variables in Variable Table............................................................ 18-4
18.4.1 Inserting Addresses or Symbols in a Variable Table .................................... 18-4
18.4.2 Inserting Modify Values ............................................................................... 18-5
18.4.3 Upper Limits for Entering Timers ................................................................. 18-6
18.4.4 Upper Limits for Entering Counters.............................................................. 18-7

Programming with STEP 7 V5.1


A5E00069873-03 xv
Contents

18.4.5 Inserting Comment Lines ............................................................................ 18-7


18.5 Examples.................................................................................................... 18-8
18.5.1 Example of Entering Addresses in Variable Tables...................................... 18-8
18.5.2 Example of Entering a Contiguous Address Range...................................... 18-8
18.5.3 Examples of Entering Modify and Force Values........................................... 18-9
18.6 Establishing a Connection to the CPU....................................................... 18-12
18.6.1 Establishing a Connection to the CPU....................................................... 18-12
18.7 Monitoring Variables ................................................................................. 18-13
18.7.1 Introduction to Monitoring Variables .......................................................... 18-13
18.7.2 Defining the Trigger for Monitoring Variables............................................. 18-13
18.8 Modifying Variables................................................................................... 18-15
18.8.1 Introduction to Modifying Variables............................................................ 18-15
18.8.2 Defining the Trigger for Modifying Variables .............................................. 18-16
18.9 Forcing Variables ...................................................................................... 18-18
18.9.1 Introduction to Forcing Variables ............................................................... 18-18
18.9.2 Safety Measures When Forcing Variables................................................. 18-20
18.9.3 Differences Between Forcing and Modifying Variables .............................. 18-21
19 Testing Using Program Status 19-1
19.1 Testing Using Program Status..................................................................... 19-1
19.2 Program Status Display............................................................................... 19-3
19.3 What You Should Know About Testing in Single-Step Mode/Breakpoints .... 19-4
19.4 What You Should Know About the HOLD Mode .......................................... 19-6
19.5 Program Status of Data Blocks.................................................................... 19-7
19.6 Setting the Call Environment for a Block...................................................... 19-8
20 Testing using the Simulation Program S7-PLCSIM (Optional Package) 20-1
20.1 Testing using the Simulation Program (Optional Package) .......................... 20-1
21 Diagnostics 21-1
21.1 Diagnosing Hardware and Troubleshooting ................................................. 21-1
21.2 Diagnostics Symbols in the Online View...................................................... 21-3
21.3 Diagnosing Hardware: Quick View .............................................................. 21-5
21.3.1 Calling the Quick View ................................................................................ 21-5
21.3.2 Information Functions in the Quick View...................................................... 21-5
21.4 Diagnosing Hardware: Diagnostic View ....................................................... 21-6
21.4.1 Calling the Diagnostic View......................................................................... 21-6
21.4.2 Information Functions in the Diagnostic View............................................... 21-8
21.5 Module Information ..................................................................................... 21-9
21.5.1.1 Options for Displaying the Module Information............................................. 21-9
21.5.2 Module Information Functions ................................................................... 21-10
21.5.3 Scope of the Module Type-Dependent Information.................................... 21-11
21.6 Diagnosing in STOP Mode........................................................................ 21-13
21.6.1 Basic Procedure for Determining the Cause of a STOP............................. 21-13
21.6.2 Stack Contents in STOP Mode.................................................................. 21-13
21.7 Checking Scan Cycle Times to Avoid Time Errors ..................................... 21-15
21.7.1 Checking Scan Cycle Times to Avoid Time Errors ..................................... 21-15
21.8 Flow of Diagnostic Information .................................................................. 21-16
21.8.1 Flow of Diagnostic Information .................................................................. 21-16
21.8.2 System Status List SSL............................................................................. 21-17
21.8.3 Sending Your Own Diagnostic Messages .................................................. 21-20
21.8.4 Diagnostic Functions................................................................................. 21-21
21.9 Program Measures for Handling Errors ..................................................... 21-22
21.9.1 Program Measures for Handling Errors ..................................................... 21-22
21.9.2 Evaluating the Output Parameter RET_VAL .............................................. 21-23

Programming with STEP 7 V5.1


xvi A5E00069873-03
Contents

21.9.3 Error OBs as a Reaction to Detected Errors .............................................. 21-24


21.9.4 Inserting Substitute Values for Error Detection........................................... 21-29
21.9.5 I/O Redundancy Error (OB70) ................................................................... 21-31
21.9.6 CPU Redundancy Error (OB72)................................................................. 21-31
21.9.7 Communication Redundancy Error (OB73)................................................ 21-32
21.9.8 Time Error (OB80)..................................................................................... 21-33
21.9.9 Power Supply Error (OB81)....................................................................... 21-34
21.9.10 Diagnostic Interrupt (OB82)....................................................................... 21-34
21.9.11 Insert/Remove Module Interrupt (OB83) .................................................... 21-35
21.9.12 CPU Hardware Fault (OB84) ..................................................................... 21-36
21.9.13 Program Sequence Error (OB85) .............................................................. 21-37
21.9.14 Rack Failure (OB86).................................................................................. 21-37
21.9.15 Communication Error (OB87) .................................................................... 21-38
21.9.16 Programming Error (OB121)...................................................................... 21-39
21.9.17 I/O Access Error (OB122).......................................................................... 21-39
22 Printing and Archiving 22-1
22.1 Printing Project Documentation ................................................................... 22-1
22.1.1 Printing Project Documentation ................................................................... 22-1
22.1.2 Basic Procedure when Printing.................................................................... 22-2
22.1.3 Print Functions ............................................................................................ 22-2
22.1.4 Special Note on Printing the Object Tree ..................................................... 22-4
22.2 Archiving Projects and Libraries .................................................................. 22-5
22.2.1 Archiving Projects and Libraries .................................................................. 22-5
22.2.2 Uses for Saving/Archiving ........................................................................... 22-5
22.2.3 Requirements for Archiving ......................................................................... 22-6
22.2.4 Procedure for Archiving/Retrieving .............................................................. 22-6
23 When Several Users are Editing the Same Project 23-1
23.1 Multi-User Configuration in a Network.......................................................... 23-1
24 Working with M7 Programmable Control Systems 24-1
24.1 Procedure for M7 Systems .......................................................................... 24-1
24.2 Optional Software for M7 Programming ....................................................... 24-3
24.3 M7-300/M7-400 Operating Systems ............................................................ 24-6
25 Tips and Tricks 25-1
25.1 Exchanging Modules in the Configuration Table .......................................... 25-1
25.2 Projects with a Large Number of Networked Stations................................... 25-2
25.3 Rearranging ................................................................................................ 25-3
25.4 Testing with the Variable Table ................................................................... 25-4
25.5 Virtual Work Memory................................................................................... 25-5

Programming with STEP 7 V5.1


A5E00069873-03 xvii
Contents

A Appendix A-1
A.1 Operating Modes ..........................................................................................A-1
A.1.1 Operating Modes and Mode Transitions ........................................................A-1
A.1.2 STOP Mode..................................................................................................A-4
A.1.3 STARTUP Mode ...........................................................................................A-5
A.1.4 RUN Mode..................................................................................................A-12
A.1.5 HOLD Mode................................................................................................A-13
A.2 Memory Areas of S7 CPUs .........................................................................A-14
A.2.1 Distribution of the Memory Areas.................................................................A-14
A.2.2 Load Memory and Work Memory ................................................................A-15
A.2.3 System Memory..........................................................................................A-17
A.2.3.1 Using the System Memory Areas ................................................................A-17
A.2.3.2 Process-Image Input/Output Tables ............................................................A-19
A.2.3.3 Local Data Stack.........................................................................................A-22
A.2.3.4 Interrupt Stack ............................................................................................A-24
A.2.3.5 Block Stack.................................................................................................A-24
A.2.3.6 Diagnostic Buffer.........................................................................................A-25
A.2.3.7 Evaluating the Diagnostic Buffer..................................................................A-25
A.2.3.8 Retentive Memory Areas on S7-300 CPUs..................................................A-27
A.2.3.9 Retentive Memory Areas on S7-400 CPUs..................................................A-29
A.2.3.10 Configurable Memory Objects in the Work Memory .....................................A-30
A.3 Data Types and Parameter Types...............................................................A-31
A.3.1 Introduction to Data Types and Parameter Types........................................A-31
A.3.2 E